Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.message/src')
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java208
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationService.java136
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java31
-rw-r--r--plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TableDataTranslator.java64
4 files changed, 0 insertions, 439 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java
deleted file mode 100644
index ab93c73816c..00000000000
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/TranslationUtil.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.message;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
-import org.eclipse.osee.framework.jdk.core.type.Triplet;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class TranslationUtil {
-
- private TranslationUtil() {
- //Utility Class
- }
-
- public static void loadArrayMap(Map<Long, String[]> map, PropertyStore store, Enum<?> key) {
- storeToArrayMap(map, store.getPropertyStore(key.name()));
- }
-
- public static void loadMap(Map<Long, Integer> map, PropertyStore store, Enum<?> key) {
- storeToMap(map, store.getPropertyStore(key.name()));
- }
-
- public static void loadMapLong(Map<Long, Long> map, PropertyStore store, Enum<?> key) {
- storeToMapLong(map, store.getPropertyStore(key.name()));
- }
-
- public static void putMap(PropertyStore store, Enum<?> key, Map<Long, Integer> map) {
- store.put(key.name(), mapToStore(map));
- }
-
- public static void putMapLong(PropertyStore store, Enum<?> key, Map<Long, Long> map) {
- store.put(key.name(), mapToStoreLong(map));
- }
-
- public static void putArrayMap(PropertyStore store, Enum<?> key, Map<Long, String[]> map) {
- store.put(key.name(), arrayMapToStore(map));
- }
-
- public static void loadTripletList(List<Triplet<Long, Long, Long>> data, PropertyStore store, Enum<?> key) {
- storeToStringTripletList(data, store.getPropertyStore(key.name()));
- }
-
- public static void loadTripletListForMergeBranches(List<Triplet<Long, Long, Long>> data, PropertyStore store, Enum<?> key) {
- storeToStringTripletListForMergeBranches(data, store.getPropertyStore(key.name()));
- }
-
- public static void loadTripletLongList(List<Triplet<Long, Long, Long>> data, PropertyStore store, Enum<?> key) {
- storeToTripletList(data, store.getPropertyStore(key.name()));
- }
-
- public static void putTripletList(PropertyStore store, Enum<?> key, List<Triplet<Long, Long, Long>> list) {
- store.put(key.name(), tripletListToStore(list));
- }
-
- public static void putTripletLongList(PropertyStore store, Enum<?> key, List<Triplet<Long, Long, Long>> list) {
- store.put(key.name(), tripletLongListToStore(list));
- }
-
- private static PropertyStore arrayMapToStore(Map<Long, String[]> map) {
- PropertyStore innerStore = new PropertyStore();
- for (Entry<Long, String[]> entry : map.entrySet()) {
- innerStore.put(String.valueOf(entry.getKey()), entry.getValue());
- }
- return innerStore;
- }
-
- private static PropertyStore longArrayMapToStore(Map<Long, Long[]> map) {
- PropertyStore innerStore = new PropertyStore();
- for (Entry<Long, Long[]> entry : map.entrySet()) {
- Long[] values = entry.getValue();
- String[] data = new String[values.length];
- for (int index = 0; index < values.length; index++) {
- data[index] = String.valueOf(values[index]);
- }
- innerStore.put(String.valueOf(entry.getKey()), data);
- }
- return innerStore;
- }
-
- private static PropertyStore mapToStore(Map<Long, Integer> map) {
- PropertyStore innerStore = new PropertyStore();
- for (Entry<Long, Integer> entry : map.entrySet()) {
- innerStore.put(String.valueOf(entry.getKey()), entry.getValue());
- }
- return innerStore;
- }
-
- private static PropertyStore mapToStoreLong(Map<Long, Long> map) {
- PropertyStore innerStore = new PropertyStore();
- for (Entry<Long, Long> entry : map.entrySet()) {
- innerStore.put(String.valueOf(entry.getKey()), entry.getValue());
- }
- return innerStore;
- }
-
- private static void storeToMap(Map<Long, Integer> map, PropertyStore innerStore) {
- for (String strkey : innerStore.keySet()) {
- Long key = Long.valueOf(strkey);
- Integer value = innerStore.getInt(strkey);
- map.put(key, value);
- }
- }
-
- private static void storeToMapLong(Map<Long, Long> map, PropertyStore innerStore) {
- for (String strkey : innerStore.keySet()) {
- Long key = Long.valueOf(strkey);
- Long value = innerStore.getLong(strkey);
- map.put(key, value);
- }
- }
-
- private static void storeToArrayMap(Map<Long, String[]> map, PropertyStore innerStore) {
- for (String strkey : innerStore.arrayKeySet()) {
- Long key = Long.valueOf(strkey);
- String[] value = innerStore.getArray(strkey);
- map.put(key, value);
- }
- }
-
- private static void storeToLongArrayMap(Map<Long, Long[]> map, PropertyStore innerStore) {
- for (String strkey : innerStore.arrayKeySet()) {
- Long key = Long.valueOf(strkey);
- String[] value = innerStore.getArray(strkey);
- Long[] intValues = new Long[value.length];
- for (int index = 0; index < value.length; index++) {
- intValues[index] = Long.valueOf(value[index]);
- }
- map.put(key, intValues);
- }
- }
-
- private static void storeToTripletList(List<Triplet<Long, Long, Long>> data, PropertyStore innerStore) {
- for (String strKey : innerStore.arrayKeySet()) {
- String[] value = innerStore.getArray(strKey);
- data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), Long.valueOf(value[1]), Long.valueOf(value[2])));
- }
- }
-
- private static void storeToStringTripletList(List<Triplet<Long, Long, Long>> data, PropertyStore innerStore) {
- for (String strKey : innerStore.arrayKeySet()) {
- String[] value = innerStore.getArray(strKey);
- data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), Long.valueOf(value[1]), Long.valueOf(value[2])));
- }
- }
-
- private static void storeToStringTripletListForMergeBranches(List<Triplet<Long, Long, Long>> data, PropertyStore innerStore) {
- for (String strKey : innerStore.arrayKeySet()) {
- String[] value = innerStore.getArray(strKey);
- data.add(new Triplet<Long, Long, Long>(Long.valueOf(value[0]), Long.valueOf(value[1]), Long.valueOf(value[2])));
- }
- }
-
- private static PropertyStore tripletListToStore(List<Triplet<Long, Long, Long>> list) {
- PropertyStore innerStore = new PropertyStore();
- int index = 0;
- for (Triplet<Long, Long, Long> entry : list) {
- innerStore.put(String.valueOf(index), new String[] {
- String.valueOf(entry.getFirst()),
- getStringBranchGuid(entry.getSecond()),
- String.valueOf(entry.getThird())});
- index++;
- }
- return innerStore;
- }
-
- private static String getStringBranchGuid(Long second) {
- return String.valueOf(second);
- }
-
- private static PropertyStore tripletLongListToStore(List<Triplet<Long, Long, Long>> list) {
- PropertyStore innerStore = new PropertyStore();
- int index = 0;
- for (Triplet<Long, Long, Long> entry : list) {
- innerStore.put(String.valueOf(index), new String[] {
- String.valueOf(entry.getFirst()),
- getStringBranchGuid(entry.getSecond()),
- String.valueOf(entry.getThird())});
- index++;
- }
- return innerStore;
- }
-
- public static void loadLongArrayMap(Map<Long, Long[]> map, PropertyStore store, Enum<?> key) {
- storeToLongArrayMap(map, store.getPropertyStore(key.name()));
- }
-
- public static void putLongArrayMap(PropertyStore store, Enum<?> key, Map<Long, Long[]> map) {
- store.put(key.name(), longArrayMapToStore(map));
- }
-
- public static String createKey(Enum<?> prefix, int index) {
- return prefix.name() + "_" + index;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationService.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationService.java
deleted file mode 100644
index c4c15fec930..00000000000
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationService.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.message.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.core.translation.IDataTranslationService;
-import org.eclipse.osee.framework.core.translation.ITranslator;
-import org.eclipse.osee.framework.core.translation.ITranslatorId;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
-import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DataTranslationService implements IDataTranslationService {
-
- private final DataTranslationServiceFactory factoryConfigurator = new DataTranslationServiceFactory();
- private final Map<ITranslatorId, ITranslator<?>> translators =
- new ConcurrentHashMap<ITranslatorId, ITranslator<?>>();
-
- public void start() throws OseeCoreException {
- translators.clear();
- factoryConfigurator.configureService(this);
- }
-
- public void stop() {
- translators.clear();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> T convert(PropertyStore propertyStore, ITranslatorId txId) throws OseeCoreException {
- Conditions.checkNotNull(txId, "translator Id");
-
- T object = null;
- if (propertyStore != null && !propertyStore.isEmpty()) {
- ITranslator<?> translator = getTranslator(txId);
- object = (T) translator.convert(propertyStore);
- }
- return object;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> PropertyStore convert(T object, ITranslatorId txId) throws OseeCoreException {
- PropertyStore propertyStore = null;
- if (object == null) {
- propertyStore = new PropertyStore();
- } else {
- ITranslator<T> translator = (ITranslator<T>) getTranslator(txId);
- propertyStore = translator.convert(object);
- }
- return propertyStore;
- }
-
- @Override
- public ITranslator<?> getTranslator(ITranslatorId txId) throws OseeCoreException {
- Conditions.checkNotNull(txId, "translator Id");
- ITranslator<?> toReturn = translators.get(txId);
- if (toReturn == null) {
- throw new OseeStateException("Unable to find a match for translator id [%s]", txId);
- }
- return toReturn;
-
- }
-
- @Override
- public boolean addTranslator(ITranslator<?> translator, ITranslatorId txId) throws OseeCoreException {
- Conditions.checkNotNull(txId, "translator Id");
- Conditions.checkNotNull(translator, "translator");
- boolean wasAdded = false;
- if (!translators.containsKey(txId)) {
- translators.put(txId, translator);
- wasAdded = true;
- }
- return wasAdded;
- }
-
- @Override
- public boolean removeTranslator(ITranslatorId txId) throws OseeCoreException {
- Conditions.checkNotNull(txId, "translator Id");
- return translators.remove(txId) != null;
- }
-
- @Override
- public Collection<ITranslatorId> getSupportedClasses() {
- return new HashSet<ITranslatorId>(translators.keySet());
- }
-
- @Override
- public <T> T convert(InputStream inputStream, ITranslatorId txId) throws OseeCoreException {
- Conditions.checkNotNull(inputStream, "inputStream");
- Conditions.checkNotNull(txId, "translator Id");
-
- T toReturn = null;
- PropertyStore propertyStore = new PropertyStore();
- try {
- propertyStore.load(inputStream);
- toReturn = convert(propertyStore, txId);
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- return toReturn;
- }
-
- @Override
- public <T> InputStream convertToStream(T object, ITranslatorId txId) throws OseeCoreException {
- PropertyStore propertyStore = convert(object, txId);
- InputStream inputStream = null;
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- try {
- propertyStore.save(buffer);
- inputStream = new ByteArrayInputStream(buffer.toByteArray());
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- return inputStream;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java
deleted file mode 100644
index 133c06f166b..00000000000
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/DataTranslationServiceFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.message.internal;
-
-import org.eclipse.osee.framework.core.enums.CoreTranslatorId;
-import org.eclipse.osee.framework.core.message.internal.translation.TableDataTranslator;
-import org.eclipse.osee.framework.core.translation.IDataTranslationService;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- * @author Jeff C. Phillips
- */
-public class DataTranslationServiceFactory {
-
- public DataTranslationServiceFactory() {
- //
- }
-
- public void configureService(IDataTranslationService service) throws OseeCoreException {
- service.addTranslator(new TableDataTranslator(), CoreTranslatorId.TABLE_DATA);
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TableDataTranslator.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TableDataTranslator.java
deleted file mode 100644
index 93c3ce285c5..00000000000
--- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/internal/translation/TableDataTranslator.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.message.internal.translation;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.framework.core.message.TranslationUtil;
-import org.eclipse.osee.framework.core.model.TableData;
-import org.eclipse.osee.framework.core.translation.ITranslator;
-import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TableDataTranslator implements ITranslator<TableData> {
-
- private static enum Entry {
- TABLE,
- TITLE,
- HEADERS,
- ROW,
- ROW_COUNT;
- }
-
- public TableDataTranslator() {
- super();
- }
-
- @Override
- public TableData convert(PropertyStore store) {
- String title = store.get(Entry.TITLE.name());
- String[] columns = store.getArray(Entry.HEADERS.name());
-
- List<String[]> rows = new ArrayList<String[]>();
- int numberOfRows = store.getInt(Entry.ROW_COUNT.name());
- for (int rowIndex = 0; rowIndex < numberOfRows; rowIndex++) {
- rows.add(store.getArray(TranslationUtil.createKey(Entry.ROW, rowIndex)));
- }
- return new TableData(title, columns, rows);
- }
-
- @Override
- public PropertyStore convert(TableData data) {
- PropertyStore store = new PropertyStore();
- store.put(Entry.TITLE.name(), data.getTitle());
- store.put(Entry.HEADERS.name(), data.getColumns());
-
- List<String[]> rows = data.getRows();
- for (int index = 0; index < rows.size(); index++) {
- store.put(TranslationUtil.createKey(Entry.ROW, index), rows.get(index));
- }
- store.put(Entry.ROW_COUNT.name(), rows.size());
- return store;
- }
-
-}

Back to the top