Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs')
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsTypesDataStore.java32
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeArtifactTypeCommand.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeAttributeTypeCommand.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeRelationTypeCommand.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/BranchHierarchyProvider.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypes.java49
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesIndex.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesIndexProvider.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesLoader.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesLoaderFactory.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesModule.java60
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesResourceProvider.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/ArtifactTypeIndex.java171
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/ArtifactTypesImpl.java145
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypeIndex.java39
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java198
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/CreateOrcsTypesIndexCallable.java59
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumEntryImpl.java65
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumTypeImpl.java95
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumTypeIndex.java21
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesImpl.java142
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesIndexProviderImpl.java77
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesIndexer.java379
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesLoaderFactoryImpl.java59
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/RelationTypeIndex.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/RelationTypesImpl.java154
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/TokenTypeIndex.java65
29 files changed, 1993 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java
index c2930d0bb3a..6da1ea394f1 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsDataStore.java
@@ -15,7 +15,7 @@ import org.eclipse.osee.orcs.OrcsTypes;
/**
* @author Roberto E. Escobar
*/
-public interface OrcsDataStore extends OrcsTypes {
+public interface OrcsDataStore extends OrcsTypes, OrcsTypesDataStore {
BranchDataStore getBranchDataStore();
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsTypesDataStore.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsTypesDataStore.java
new file mode 100644
index 00000000000..9546df95ca1
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsTypesDataStore.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.ds;
+
+import java.util.Collection;
+import java.util.concurrent.Callable;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.resource.management.IResource;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsTypesDataStore {
+
+ Callable<IResource> getOrcsTypesLoader(String sessionId);
+
+ Callable<?> purgeArtifactsByArtifactType(String sessionId, Collection<? extends IArtifactType> artifactTypes);
+
+ Callable<?> purgeAttributesByAttributeType(String sessionId, Collection<? extends IAttributeType> attributeTypes);
+
+ Callable<?> purgeRelationsByRelationType(String sessionId, Collection<? extends IRelationType> relationTypes);
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
index 45ccf0e95c4..5f7dee81ba3 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java
@@ -116,7 +116,6 @@ public class OrcsApiImpl implements OrcsApi {
indexerModule = new IndexerModule(logger, preferences, executorAdmin, dataStore.getQueryEngineIndexer());
indexerModule.start();
-
}
public void stop() {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeArtifactTypeCommand.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeArtifactTypeCommand.java
index d547fa9a0fd..39e5adc365b 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeArtifactTypeCommand.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeArtifactTypeCommand.java
@@ -83,7 +83,7 @@ public class PurgeArtifactTypeCommand implements ConsoleCommand {
boolean found = !types.isEmpty();
if (forcePurge && found) {
- orcsTypes.purgeArtifactType(types).call();
+ orcsTypes.purgeArtifactsByArtifactType(types).call();
}
console.writeln((found && !forcePurge) ? "To >DELETE Artifact DATA!< add --force to confirm." : "Operation finished.");
return null;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeAttributeTypeCommand.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeAttributeTypeCommand.java
index 1f7d3a26e15..c5c10164a9a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeAttributeTypeCommand.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeAttributeTypeCommand.java
@@ -83,7 +83,7 @@ public class PurgeAttributeTypeCommand implements ConsoleCommand {
boolean found = !types.isEmpty();
if (forcePurge && found) {
- orcsTypes.purgeAttributeType(types).call();
+ orcsTypes.purgeAttributesByAttributeType(types).call();
}
console.writeln((found && !forcePurge) ? "To >DELETE Attribute DATA!< add --force to confirm." : "Operation finished.");
return null;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeRelationTypeCommand.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeRelationTypeCommand.java
index 8520d154d94..4a61d8f981a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeRelationTypeCommand.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/console/PurgeRelationTypeCommand.java
@@ -83,7 +83,7 @@ public class PurgeRelationTypeCommand implements ConsoleCommand {
boolean found = !types.isEmpty();
if (forcePurge && found) {
- orcsTypes.purgeRelationType(types).call();
+ orcsTypes.purgeRelationsByRelationType(types).call();
}
console.writeln((found && !forcePurge) ? "To >DELETE Relation DATA!< add --force to confirm." : "Operation finished.");
return null;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/BranchHierarchyProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/BranchHierarchyProvider.java
new file mode 100644
index 00000000000..f04062bd0ec
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/BranchHierarchyProvider.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types;
+
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface BranchHierarchyProvider {
+
+ Iterable<? extends IOseeBranch> getParentHierarchy(IOseeBranch branch) throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypes.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypes.java
new file mode 100644
index 00000000000..4b69a40409f
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypes.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types;
+
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.concurrent.Callable;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.orcs.data.ArtifactTypes;
+import org.eclipse.osee.orcs.data.AttributeTypes;
+import org.eclipse.osee.orcs.data.RelationTypes;
+import org.eclipse.osee.orcs.utility.ObjectProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsTypes {
+
+ //TODO: Move this interface to org.eclipse.osee.orcs api
+
+ ArtifactTypes getArtifactTypes();
+
+ AttributeTypes getAttributeTypes();
+
+ RelationTypes getRelationTypes();
+
+ Callable<?> loadTypes(IResource resource, boolean isInitializing);
+
+ Callable<?> writeTypes(ObjectProvider<? extends OutputStream> supplier);
+
+ Callable<?> purgeArtifactsByArtifactType(Collection<? extends IArtifactType> artifactTypes);
+
+ Callable<?> purgeAttributesByAttributeType(Collection<? extends IAttributeType> attributeTypes);
+
+ Callable<?> purgeRelationsByRelationType(Collection<? extends IRelationType> relationTypes);
+
+ void invalidateAll();
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesIndex.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesIndex.java
new file mode 100644
index 00000000000..f6ad8ddfedb
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesIndex.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types;
+
+import org.eclipse.osee.orcs.core.internal.types.impl.ArtifactTypesImpl.ArtifactTypeIndexProvider;
+import org.eclipse.osee.orcs.core.internal.types.impl.AttributeTypesImpl.AttributeTypeIndexProvider;
+import org.eclipse.osee.orcs.core.internal.types.impl.AttributeTypesImpl.EnumTypeIndexProvider;
+import org.eclipse.osee.orcs.core.internal.types.impl.RelationTypesImpl.RelationTypeIndexProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsTypesIndex extends ArtifactTypeIndexProvider, AttributeTypeIndexProvider, EnumTypeIndexProvider, RelationTypeIndexProvider, OrcsTypesResourceProvider {
+ //
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesIndexProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesIndexProvider.java
new file mode 100644
index 00000000000..bc136673cfe
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesIndexProvider.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types;
+
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsTypesIndexProvider extends OrcsTypesIndex {
+
+ void invalidate();
+
+ void setLoader(OrcsTypesLoader loader);
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesLoader.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesLoader.java
new file mode 100644
index 00000000000..3d764818df9
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesLoader.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsTypesLoader {
+
+ Callable<OrcsTypesIndex> createLoader();
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesLoaderFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesLoaderFactory.java
new file mode 100644
index 00000000000..2f60f2e0582
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesLoaderFactory.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types;
+
+import org.eclipse.osee.orcs.core.ds.OrcsTypesDataStore;
+import org.eclipse.osee.orcs.core.internal.SessionContext;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsTypesLoaderFactory {
+
+ OrcsTypesLoader createTypesLoader(SessionContext session, OrcsTypesDataStore ds);
+
+ OrcsTypesLoader createTypesLoader(SessionContext session, OrcsTypesResourceProvider provider);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesModule.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesModule.java
new file mode 100644
index 00000000000..4135856d317
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesModule.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types;
+
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.OrcsTypesDataStore;
+import org.eclipse.osee.orcs.core.internal.SessionContext;
+import org.eclipse.osee.orcs.core.internal.types.impl.OrcsTypesImpl;
+import org.eclipse.osee.orcs.core.internal.types.impl.OrcsTypesIndexProviderImpl;
+import org.eclipse.osee.orcs.core.internal.types.impl.OrcsTypesLoaderFactoryImpl;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OrcsTypesModule {
+
+ private final Log logger;
+ private final OrcsTypesDataStore dataStore;
+ private final BranchHierarchyProvider hierarchy;
+
+ private OrcsTypesLoaderFactory factory;
+ private OrcsTypesIndexProvider indexer;
+
+ public OrcsTypesModule(Log logger, OrcsTypesDataStore dataStore, BranchHierarchyProvider hierarchy) {
+ this.logger = logger;
+ this.dataStore = dataStore;
+ this.hierarchy = hierarchy;
+ }
+
+ public void start(SessionContext session) {
+ factory = createFactory();
+ indexer = createIndexer(factory.createTypesLoader(session, dataStore));
+ }
+
+ public void stop() {
+ factory = null;
+ indexer = null;
+ }
+
+ protected OrcsTypesLoaderFactory createFactory() {
+ return new OrcsTypesLoaderFactoryImpl(logger, hierarchy);
+ }
+
+ protected OrcsTypesIndexProvider createIndexer(OrcsTypesLoader loader) {
+ return new OrcsTypesIndexProviderImpl(loader);
+ }
+
+ public OrcsTypes createOrcsTypes(SessionContext session) {
+ return new OrcsTypesImpl(logger, session, dataStore, factory, indexer);
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesResourceProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesResourceProvider.java
new file mode 100644
index 00000000000..e1741499468
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesResourceProvider.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types;
+
+import org.eclipse.osee.framework.resource.management.IResource;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsTypesResourceProvider {
+
+ IResource getOrcsTypesResource() throws Exception;
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/ArtifactTypeIndex.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/ArtifactTypeIndex.java
new file mode 100644
index 00000000000..0751beeb214
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/ArtifactTypeIndex.java
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.core.internal.types.BranchHierarchyProvider;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactTypeIndex extends TokenTypeIndex<Long, IArtifactType, XArtifactType> {
+
+ private final Map<IArtifactType, ArtifactTypeMetaData> tokenToTypeData;
+ private final BranchHierarchyProvider hierarchyProvider;
+
+ public ArtifactTypeIndex(BranchHierarchyProvider hierarchyProvider) {
+ super();
+ this.tokenToTypeData = Maps.newHashMap();
+ this.hierarchyProvider = hierarchyProvider;
+ }
+
+ public void put(IArtifactType type, Set<IArtifactType> superTypes) {
+ ArtifactTypeMetaData metaData = getOrCreateData(type);
+ metaData.setSuperTypes(superTypes);
+ }
+
+ public void put(IArtifactType type, Map<IOseeBranch, Collection<IAttributeType>> attributes) {
+ ArtifactTypeMetaData metaData = getOrCreateData(type);
+ metaData.setAttributeTypes(attributes);
+ }
+
+ private ArtifactTypeMetaData getOrCreateData(IArtifactType type) {
+ ArtifactTypeMetaData metaData = tokenToTypeData.get(type);
+ if (metaData == null) {
+ metaData = new ArtifactTypeMetaData(type);
+ tokenToTypeData.put(type, metaData);
+ }
+ return metaData;
+ }
+
+ public Collection<IArtifactType> getSuperTypes(IArtifactType artifactType) {
+ ArtifactTypeMetaData metaData = tokenToTypeData.get(artifactType);
+ return metaData != null ? metaData.getSuperTypes() : Collections.<IArtifactType> emptyList();
+ }
+
+ public Collection<IArtifactType> getDescendantTypes(IArtifactType artifactType) {
+ ArtifactTypeMetaData metaData = tokenToTypeData.get(artifactType);
+ return metaData != null ? metaData.getDescendantTypes() : Collections.<IArtifactType> emptyList();
+ }
+
+ public boolean hasSuperArtifactTypes(IArtifactType artType) {
+ return !getSuperTypes(artType).isEmpty();
+ }
+
+ public boolean inheritsFrom(IArtifactType thisType, IArtifactType... otherTypes) {
+ boolean result = false;
+ for (IArtifactType otherType : otherTypes) {
+ if (inheritsFromSingle(thisType, otherType)) {
+ result = true;
+ break;
+ }
+ }
+ return result;
+ }
+
+ private boolean inheritsFromSingle(IArtifactType thisType, IArtifactType otherType) {
+ boolean result = false;
+ if (thisType.equals(otherType)) {
+ result = true;
+ } else {
+ for (IArtifactType superType : getSuperTypes(thisType)) {
+ if (inheritsFrom(superType, otherType)) {
+ result = true;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public Collection<IAttributeType> getAttributeTypes(IArtifactType artType, IOseeBranch branch) throws OseeCoreException {
+ Set<IAttributeType> attributeTypes = Sets.newLinkedHashSet();
+ getAttributeTypes(attributeTypes, artType, branch);
+ return attributeTypes;
+ }
+
+ private void getAttributeTypes(Set<IAttributeType> attributeTypes, IArtifactType artifactType, IOseeBranch branch) throws OseeCoreException {
+ ArtifactTypeMetaData metaData = tokenToTypeData.get(artifactType);
+ if (metaData != null) {
+ Map<IOseeBranch, Collection<IAttributeType>> validityMap = metaData.getAttributeTypes();
+
+ Iterable<? extends IOseeBranch> branches = hierarchyProvider.getParentHierarchy(branch);
+ for (IOseeBranch parent : branches) {
+ Collection<IAttributeType> items = validityMap.get(parent);
+ if (items != null) {
+ attributeTypes.addAll(items);
+ }
+ }
+ }
+ for (IArtifactType superType : getSuperTypes(artifactType)) {
+ getAttributeTypes(attributeTypes, superType, branch);
+ }
+ }
+
+ private final class ArtifactTypeMetaData {
+ private final IArtifactType type;
+ private Set<IArtifactType> superTypes;
+ private final Set<IArtifactType> descendantTypes;
+ private Map<IOseeBranch, Collection<IAttributeType>> attributeTypes;
+
+ public ArtifactTypeMetaData(IArtifactType type) {
+ super();
+ this.type = type;
+ superTypes = Collections.emptySet();
+ descendantTypes = Sets.newLinkedHashSet();
+ attributeTypes = Collections.emptyMap();
+ }
+
+ public void setSuperTypes(Set<IArtifactType> newSuperTypes) {
+ Set<IArtifactType> originals = Sets.newHashSet(superTypes);
+ superTypes = Sets.newHashSet(newSuperTypes);
+ for (IArtifactType superType : superTypes) {
+ ArtifactTypeMetaData metaData = tokenToTypeData.get(superType);
+ if (metaData != null) {
+ metaData.getDescendantTypes().add(type);
+ }
+ }
+ for (IArtifactType oldValue : originals) {
+ ArtifactTypeMetaData metaData = tokenToTypeData.get(oldValue);
+ if (metaData != null) {
+ metaData.getDescendantTypes().remove(type);
+ }
+ }
+ }
+
+ public void setAttributeTypes(Map<IOseeBranch, Collection<IAttributeType>> attributes) {
+ this.attributeTypes = attributes;
+ }
+
+ public Set<IArtifactType> getSuperTypes() {
+ return superTypes;
+ }
+
+ public Set<IArtifactType> getDescendantTypes() {
+ return descendantTypes;
+ }
+
+ public Map<IOseeBranch, Collection<IAttributeType>> getAttributeTypes() {
+ return attributeTypes;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/ArtifactTypesImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/ArtifactTypesImpl.java
new file mode 100644
index 00000000000..f4d3f935ed1
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/ArtifactTypesImpl.java
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.orcs.data.ArtifactTypes;
+import com.google.common.collect.Sets;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class ArtifactTypesImpl implements ArtifactTypes {
+
+ public static interface ArtifactTypeIndexProvider {
+ ArtifactTypeIndex getArtifactTypeIndex() throws OseeCoreException;
+ }
+
+ private static final int INFINITE_DEPTH = -1;
+ private static final int DEPTH_ZERO = 0;
+ private static final int DEPTH_ONE = 1;
+
+ private final ArtifactTypeIndexProvider provider;
+
+ public ArtifactTypesImpl(ArtifactTypeIndexProvider provider) {
+ this.provider = provider;
+ }
+
+ private ArtifactTypeIndex getArtifactTypesIndex() throws OseeCoreException {
+ return provider.getArtifactTypeIndex();
+ }
+
+ private XArtifactType getType(IArtifactType artType) throws OseeCoreException {
+ Conditions.checkNotNull(artType, "artifactType");
+ return getArtifactTypesIndex().getDslTypeByToken(artType);
+ }
+
+ @Override
+ public Collection<? extends IArtifactType> getAll() throws OseeCoreException {
+ return getArtifactTypesIndex().getAllTokens();
+ }
+
+ @Override
+ public IArtifactType getByUuid(Long uuid) throws OseeCoreException {
+ Conditions.checkNotNull(uuid, "uuid");
+ return getArtifactTypesIndex().getTokenByUuid(uuid);
+ }
+
+ @Override
+ public boolean isAbstract(IArtifactType artType) throws OseeCoreException {
+ XArtifactType type = getType(artType);
+ return type.isAbstract();
+ }
+
+ @Override
+ public boolean hasSuperArtifactTypes(IArtifactType artType) throws OseeCoreException {
+ return !getSuperArtifactTypes(artType).isEmpty();
+ }
+
+ @Override
+ public Collection<? extends IArtifactType> getSuperArtifactTypes(IArtifactType artType) throws OseeCoreException {
+ Conditions.checkNotNull(artType, "artifactType");
+ return getArtifactTypesIndex().getSuperTypes(artType);
+ }
+
+ @Override
+ public boolean inheritsFrom(IArtifactType thisType, IArtifactType... otherTypes) throws OseeCoreException {
+ Conditions.checkNotNull(thisType, "thisArtifactType");
+ Conditions.checkNotNull(otherTypes, "otherArtifactTypes");
+ return getArtifactTypesIndex().inheritsFrom(thisType, otherTypes);
+ }
+
+ @Override
+ public Collection<? extends IArtifactType> getDescendantTypes(IArtifactType artType, int depth) throws OseeCoreException {
+ Conditions.checkNotNull(artType, "artifactType");
+ LinkedHashSet<IArtifactType> descendants = Sets.newLinkedHashSet();
+ if (depth != DEPTH_ZERO) {
+ int depthToUse = depth < 0 ? INFINITE_DEPTH : depth;
+ walkDescendants(artType, descendants, depthToUse);
+ }
+ return descendants;
+ }
+
+ @Override
+ public Collection<? extends IArtifactType> getAllDescendantTypes(IArtifactType artType) throws OseeCoreException {
+ return getDescendantTypes(artType, INFINITE_DEPTH);
+ }
+
+ private void walkDescendants(IArtifactType artifactType, Collection<IArtifactType> descendants, int depth) throws OseeCoreException {
+ Collection<IArtifactType> childTypes = getArtifactTypesIndex().getDescendantTypes(artifactType);
+ if (!childTypes.isEmpty()) {
+ boolean isWalkNextLevelAllowed = depth > DEPTH_ONE || depth <= INFINITE_DEPTH;
+ int nextLevel = depth - DEPTH_ONE;
+ for (IArtifactType type : childTypes) {
+ if (isWalkNextLevelAllowed) {
+ walkDescendants(type, descendants, nextLevel);
+ }
+ descendants.add(type);
+ }
+ }
+ }
+
+ @Override
+ public boolean isValidAttributeType(IArtifactType artType, IOseeBranch branch, IAttributeType attributeType) throws OseeCoreException {
+ Collection<IAttributeType> attributes = getAttributeTypes(artType, branch);
+ return attributes.contains(attributeType);
+ }
+
+ @Override
+ public Collection<IAttributeType> getAttributeTypes(IArtifactType artType, IOseeBranch branch) throws OseeCoreException {
+ Conditions.checkNotNull(artType, "artifactType");
+ Conditions.checkNotNull(branch, "branch");
+ return getArtifactTypesIndex().getAttributeTypes(artType, branch);
+ }
+
+ @Override
+ public boolean isEmpty() throws OseeCoreException {
+ return getArtifactTypesIndex().isEmpty();
+ }
+
+ @Override
+ public int size() throws OseeCoreException {
+ return getArtifactTypesIndex().size();
+ }
+
+ @Override
+ public boolean exists(IArtifactType item) throws OseeCoreException {
+ return getArtifactTypesIndex().existsByUuid(item.getGuid());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypeIndex.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypeIndex.java
new file mode 100644
index 00000000000..a5ddf64a013
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypeIndex.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeTypeIndex extends TokenTypeIndex<Long, IAttributeType, XAttributeType> {
+
+ private final Set<IAttributeType> taggables = new HashSet<IAttributeType>();
+
+ @Override
+ public void put(IAttributeType token, XAttributeType dslType) {
+ super.put(token, dslType);
+ if (Strings.isValid(dslType.getTaggerId())) {
+ taggables.add(token);
+ }
+ }
+
+ public Collection<? extends IAttributeType> getAllTaggable() {
+ return taggables;
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java
new file mode 100644
index 00000000000..9358222afad
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/AttributeTypesImpl.java
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.data.AttributeTypes;
+import org.eclipse.osee.orcs.data.EnumType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeTypesImpl implements AttributeTypes {
+
+ public static interface AttributeTypeIndexProvider {
+ AttributeTypeIndex getAttributeTypeIndex() throws OseeCoreException;
+ }
+
+ public static interface EnumTypeIndexProvider {
+ EnumTypeIndex getEnumTypeIndex() throws OseeCoreException;
+ }
+
+ private static final String ATTRIBUTE_OCCURRENCE_UNLIMITED = "unlimited";
+ private static final String BASE_TYPE_NAMESPACE = "org.eclipse.osee.framework.skynet.core.";
+
+ private final AttributeTypeIndexProvider provider;
+ private final EnumTypeIndexProvider enumTypeIndexProvider;
+
+ public AttributeTypesImpl(AttributeTypeIndexProvider provider, EnumTypeIndexProvider enumTypeIndexProvider) {
+ this.provider = provider;
+ this.enumTypeIndexProvider = enumTypeIndexProvider;
+ }
+
+ private XAttributeType getType(IAttributeType attrType) throws OseeCoreException {
+ Conditions.checkNotNull(attrType, "attributeType");
+ return provider.getAttributeTypeIndex().getDslTypeByToken(attrType);
+ }
+
+ @Override
+ public Collection<? extends IAttributeType> getAll() throws OseeCoreException {
+ return provider.getAttributeTypeIndex().getAllTokens();
+ }
+
+ @Override
+ public IAttributeType getByUuid(Long uuid) throws OseeCoreException {
+ Conditions.checkNotNull(uuid, "uuid");
+ return provider.getAttributeTypeIndex().getTokenByUuid(uuid);
+ }
+
+ private String getQualifiedTypeName(String id) {
+ String value = !Strings.isValid(id) ? Strings.emptyString() : id;
+ if (!value.contains(".")) {
+ value = BASE_TYPE_NAMESPACE + id;
+ }
+ return value;
+ }
+
+ @Override
+ public String getBaseAttributeTypeId(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ return getQualifiedTypeName(type.getBaseAttributeType());
+ }
+
+ @Override
+ public String getAttributeProviderId(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ return getQualifiedTypeName(type.getDataProvider());
+ }
+
+ @Override
+ public String getDefaultValue(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ return type.getDefaultValue();
+ }
+
+ @Override
+ public int getMaxOccurrences(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ String maxValue = type.getMax();
+ int max = Integer.MAX_VALUE;
+ if (!ATTRIBUTE_OCCURRENCE_UNLIMITED.equals(maxValue)) {
+ if (Strings.isValid(maxValue)) {
+ max = Integer.parseInt(maxValue);
+ }
+ }
+ return max;
+ }
+
+ @Override
+ public int getMinOccurrences(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ String minValue = type.getMin();
+ int min = 0;
+ if (Strings.isValid(minValue)) {
+ min = Integer.parseInt(minValue);
+ }
+ return min;
+ }
+
+ @Override
+ public String getFileTypeExtension(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ String value = type.getFileExtension();
+ return Strings.isValid(value) ? value : Strings.emptyString();
+ }
+
+ @Override
+ public String getTaggerId(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ String value = type.getTaggerId();
+ return Strings.isValid(value) ? value : Strings.emptyString();
+ }
+
+ @Override
+ public boolean isTaggable(IAttributeType attrType) throws OseeCoreException {
+ boolean toReturn = false;
+ String taggerId = getTaggerId(attrType);
+ if (taggerId != null) {
+ toReturn = Strings.isValid(taggerId.trim());
+ }
+ return toReturn;
+ }
+
+ @Override
+ public boolean isEnumerated(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ XOseeEnumType enumType = type.getEnumType();
+ return enumType != null;
+ }
+
+ @Override
+ public EnumType getEnumType(IAttributeType attrType) throws OseeCoreException {
+ EnumType toReturn = null;
+ XAttributeType type = getType(attrType);
+ XOseeEnumType enumType = type.getEnumType();
+ if (enumType != null) {
+ toReturn = enumTypeIndexProvider.getEnumTypeIndex().getTokenByDslType(enumType);
+ }
+ return toReturn;
+ }
+
+ @Override
+ public String getDescription(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ String value = type.getDescription();
+ return Strings.isValid(value) ? value : Strings.emptyString();
+ }
+
+ @Override
+ public boolean isEmpty() throws OseeCoreException {
+ return provider.getAttributeTypeIndex().isEmpty();
+ }
+
+ @Override
+ public int size() throws OseeCoreException {
+ return provider.getAttributeTypeIndex().size();
+ }
+
+ @Override
+ public Collection<? extends IAttributeType> getAllTaggable() throws OseeCoreException {
+ return provider.getAttributeTypeIndex().getAllTaggable();
+ }
+
+ @Override
+ public boolean exists(IAttributeType item) throws OseeCoreException {
+ return provider.getAttributeTypeIndex().existsByUuid(item.getGuid());
+ }
+
+ @Override
+ public String getMediaType(IAttributeType attrType) throws OseeCoreException {
+ XAttributeType type = getType(attrType);
+ String value = type.getMediaType();
+ return Strings.isValid(value) ? value : Strings.emptyString();
+ }
+
+ @Override
+ public boolean hasMediaType(IAttributeType attrType) throws OseeCoreException {
+ boolean toReturn = false;
+ String mediaType = getMediaType(attrType);
+ if (mediaType != null) {
+ toReturn = Strings.isValid(mediaType.trim());
+ }
+ return toReturn;
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/CreateOrcsTypesIndexCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/CreateOrcsTypesIndexCallable.java
new file mode 100644
index 00000000000..ed350c53e33
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/CreateOrcsTypesIndexCallable.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesIndex;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesResourceProvider;
+import com.google.common.base.Stopwatch;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class CreateOrcsTypesIndexCallable extends CancellableCallable<OrcsTypesIndex> {
+
+ private final Log logger;
+ private final OrcsTypesIndexer indexer;
+ private final OrcsTypesResourceProvider provider;
+
+ public CreateOrcsTypesIndexCallable(Log logger, OrcsTypesIndexer indexer, OrcsTypesResourceProvider provider) {
+ super();
+ this.logger = logger;
+ this.indexer = indexer;
+ this.provider = provider;
+ }
+
+ @Override
+ public OrcsTypesIndex call() throws Exception {
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.start();
+ OrcsTypesIndex index = null;
+ try {
+ index = createIndex();
+ } finally {
+ logger.trace("Created OrcsTypesIndex in [%s]", Lib.getElapseString(stopwatch.elapsedMillis()));
+ stopwatch.stop();
+ }
+ return index;
+ }
+
+ private OrcsTypesIndex createIndex() throws Exception {
+ long startTime = System.currentTimeMillis();
+ IResource source = provider.getOrcsTypesResource();
+ checkForCancelled();
+ logger.trace("Read OrcsTypes from datastore in [%s]", Lib.getElapseString(startTime));
+ OrcsTypesIndex index = indexer.index(source);
+ return index;
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumEntryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumEntryImpl.java
new file mode 100644
index 00000000000..0f9deae83e9
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumEntryImpl.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import org.eclipse.osee.framework.core.data.NamedIdentity;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.data.EnumEntry;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class EnumEntryImpl extends NamedIdentity<String> implements EnumEntry {
+
+ private final int ordinal;
+
+ public EnumEntryImpl(String guid, String name, int ordinal, String description) {
+ super(guid, name, description);
+ this.ordinal = ordinal;
+ }
+
+ @Override
+ public int ordinal() {
+ return ordinal;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object instanceof EnumEntry) {
+ EnumEntry other = (EnumEntry) object;
+ return super.equals(other) && ordinal() == other.ordinal();
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 37;
+ int result = super.hashCode();
+ result = prime * result + ordinal();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(getName());
+ builder.append(":");
+ builder.append(ordinal());
+ String description = getDescription();
+ if (Strings.isValid(description)) {
+ builder.append(" - ");
+ builder.append(description);
+ }
+ return builder.toString();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumTypeImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumTypeImpl.java
new file mode 100644
index 00000000000..98e43ba3460
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumTypeImpl.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.NamedIdentity;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.orcs.data.EnumEntry;
+import org.eclipse.osee.orcs.data.EnumType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class EnumTypeImpl extends NamedIdentity<Long> implements EnumType {
+
+ private final List<EnumEntry> entries;
+
+ public EnumTypeImpl(Long uuid, String name, List<EnumEntry> entries) {
+ super(uuid, name);
+ this.entries = entries;
+ }
+
+ private List<EnumEntry> getValues() {
+ return entries;
+ }
+
+ @Override
+ public String getDescription() {
+ return Strings.emptyString();
+ }
+
+ @Override
+ public EnumEntry[] values() {
+ List<EnumEntry> values = getValues();
+ return values.toArray(new EnumEntry[values.size()]);
+ }
+
+ @Override
+ public EnumEntry getEntryByGuid(String entryGuid) {
+ EnumEntry toReturn = null;
+ for (EnumEntry entry : getValues()) {
+ if (entry.getGuid().equals(entryGuid)) {
+ toReturn = entry;
+ break;
+ }
+ }
+ return toReturn;
+ }
+
+ @Override
+ public Set<String> valuesAsOrderedStringSet() {
+ Set<String> values = new LinkedHashSet<String>();
+ for (EnumEntry oseeEnumEntry : values()) {
+ values.add(oseeEnumEntry.getName());
+ }
+ return values;
+ }
+
+ @Override
+ public EnumEntry valueOf(int ordinal) throws OseeCoreException {
+ EnumEntry toReturn = null;
+ for (EnumEntry entry : values()) {
+ if (entry.ordinal() == ordinal) {
+ toReturn = entry;
+ }
+ }
+ Conditions.checkNotNull(toReturn, "enumEntry", "No enum const [%s].[%s]", getName(), ordinal);
+ return toReturn;
+ }
+
+ @Override
+ public EnumEntry valueOf(String entryName) throws OseeCoreException {
+ EnumEntry toReturn = null;
+ for (EnumEntry entry : values()) {
+ if (entry.getName().equals(entryName)) {
+ toReturn = entry;
+ }
+ }
+ Conditions.checkNotNull(toReturn, "enumEntry", "No enum const [%s].[%s]", getName(), entryName);
+ return toReturn;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumTypeIndex.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumTypeIndex.java
new file mode 100644
index 00000000000..548c829310d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/EnumTypeIndex.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumType;
+import org.eclipse.osee.orcs.data.EnumType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class EnumTypeIndex extends TokenTypeIndex<Long, EnumType, XOseeEnumType> {
+ //
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesImpl.java
new file mode 100644
index 00000000000..4d7a2a5cc36
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesImpl.java
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.concurrent.Callable;
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.OrcsTypesDataStore;
+import org.eclipse.osee.orcs.core.internal.SessionContext;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypes;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesIndexProvider;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesLoaderFactory;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesResourceProvider;
+import org.eclipse.osee.orcs.data.ArtifactTypes;
+import org.eclipse.osee.orcs.data.AttributeTypes;
+import org.eclipse.osee.orcs.data.RelationTypes;
+import org.eclipse.osee.orcs.utility.ObjectProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OrcsTypesImpl implements OrcsTypes {
+
+ private final OrcsTypesIndexProvider indexProvider;
+
+ private final Log logger;
+ private final SessionContext session;
+ private final OrcsTypesDataStore dataStore;
+ private final OrcsTypesLoaderFactory loaderFactory;
+
+ private final ArtifactTypes artifactTypes;
+ private final AttributeTypes attributeTypes;
+ private final RelationTypes relationTypes;
+
+ public OrcsTypesImpl(Log logger, SessionContext session, OrcsTypesDataStore dataStore, OrcsTypesLoaderFactory loaderFactory, OrcsTypesIndexProvider indexProvider) {
+ this.logger = logger;
+ this.session = session;
+ this.dataStore = dataStore;
+ this.loaderFactory = loaderFactory;
+
+ this.indexProvider = indexProvider;
+
+ this.artifactTypes = new ArtifactTypesImpl(indexProvider);
+ this.attributeTypes = new AttributeTypesImpl(indexProvider, indexProvider);
+ this.relationTypes = new RelationTypesImpl(indexProvider);
+ }
+
+ @Override
+ public ArtifactTypes getArtifactTypes() {
+ return artifactTypes;
+ }
+
+ @Override
+ public AttributeTypes getAttributeTypes() {
+ return attributeTypes;
+ }
+
+ @Override
+ public RelationTypes getRelationTypes() {
+ return relationTypes;
+ }
+
+ @Override
+ public void invalidateAll() {
+ indexProvider.invalidate();
+ }
+
+ @Override
+ public Callable<?> loadTypes(final IResource resource, final boolean isInitializing) {
+ return new CancellableCallable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ indexProvider.setLoader(loaderFactory.createTypesLoader(session, new OrcsTypesResourceProvider() {
+
+ @Override
+ public IResource getOrcsTypesResource() {
+ return resource;
+ }
+ }));
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public Callable<?> writeTypes(final ObjectProvider<? extends OutputStream> supplier) {
+ return new CancellableCallable<Void>() {
+ @Override
+ public Void call() throws Exception {
+ logger.trace("Writing OrcsTypes for session [%s]", session);
+ IResource resource = indexProvider.getOrcsTypesResource();
+ InputStream inputStream = null;
+ OutputStream outputStream = null;
+ try {
+ outputStream = supplier.get();
+ inputStream = resource.getContent();
+ checkForCancelled();
+ Lib.inputStreamToOutputStream(inputStream, outputStream);
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ } finally {
+ Lib.close(inputStream);
+ Lib.close(outputStream);
+ }
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public Callable<?> purgeArtifactsByArtifactType(Collection<? extends IArtifactType> artifactTypes) {
+ return dataStore.purgeArtifactsByArtifactType(session.getSessionId(), artifactTypes);
+ }
+
+ @Override
+ public Callable<?> purgeAttributesByAttributeType(Collection<? extends IAttributeType> attributeTypes) {
+ return dataStore.purgeAttributesByAttributeType(session.getSessionId(), attributeTypes);
+ }
+
+ @Override
+ public Callable<?> purgeRelationsByRelationType(Collection<? extends IRelationType> relationTypes) {
+ return dataStore.purgeRelationsByRelationType(session.getSessionId(), relationTypes);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesIndexProviderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesIndexProviderImpl.java
new file mode 100644
index 00000000000..d0d98f4f0bf
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesIndexProviderImpl.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.concurrent.FutureTask;
+import org.eclipse.osee.framework.core.data.LazyObject;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesIndex;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesIndexProvider;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesLoader;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OrcsTypesIndexProviderImpl extends LazyObject<OrcsTypesIndex> implements OrcsTypesIndexProvider {
+
+ private OrcsTypesLoader loader;
+
+ public OrcsTypesIndexProviderImpl(OrcsTypesLoader loader) {
+ super();
+ this.loader = loader;
+ }
+
+ @Override
+ public ArtifactTypeIndex getArtifactTypeIndex() throws OseeCoreException {
+ return get().getArtifactTypeIndex();
+ }
+
+ @Override
+ public AttributeTypeIndex getAttributeTypeIndex() throws OseeCoreException {
+ return get().getAttributeTypeIndex();
+ }
+
+ @Override
+ public EnumTypeIndex getEnumTypeIndex() throws OseeCoreException {
+ return get().getEnumTypeIndex();
+ }
+
+ @Override
+ public RelationTypeIndex getRelationTypeIndex() throws OseeCoreException {
+ return get().getRelationTypeIndex();
+ }
+
+ @Override
+ public IResource getOrcsTypesResource() throws OseeCoreException {
+ IResource resource = null;
+ try {
+ resource = get().getOrcsTypesResource();
+ } catch (Exception ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return resource;
+ }
+
+ @Override
+ protected FutureTask<OrcsTypesIndex> createLoaderTask() {
+ return new FutureTask<OrcsTypesIndex>(loader.createLoader());
+ }
+
+ @Override
+ public void setLoader(OrcsTypesLoader loader) {
+ synchronized (getLock()) {
+ this.loader = loader;
+ invalidate();
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesIndexer.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesIndexer.java
new file mode 100644
index 00000000000..4f98a1202bc
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesIndexer.java
@@ -0,0 +1,379 @@
+/*******************************************************************************
+ * 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.orcs.core.internal.types.impl;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.dsl.OseeDslResource;
+import org.eclipse.osee.framework.core.dsl.OseeDslResourceUtil;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AddAttribute;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AddEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.AttributeOverrideOption;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDsl;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.OseeDslFactory;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.OverrideOption;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.RemoveAttribute;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.RemoveEnum;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.UpdateAttribute;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XAttributeTypeRef;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeArtifactTypeOverride;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumEntry;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumOverride;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XOseeEnumType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.util.OseeDslSwitch;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.core.util.HexUtil;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.internal.types.BranchHierarchyProvider;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesIndex;
+import org.eclipse.osee.orcs.data.EnumEntry;
+import org.eclipse.osee.orcs.data.EnumType;
+import com.google.common.base.Stopwatch;
+import com.google.common.collect.Sets;
+
+/**
+ * @author Ryan D. Brooks
+ * @author Roberto E. Escobar
+ */
+public class OrcsTypesIndexer {
+
+ private final Log logger;
+ private final BranchHierarchyProvider hierarchyProvider;
+
+ public OrcsTypesIndexer(Log logger, BranchHierarchyProvider hierarchyProvider) {
+ super();
+ this.logger = logger;
+ this.hierarchyProvider = hierarchyProvider;
+ }
+
+ public OrcsTypesIndex index(IResource source) throws Exception {
+ Stopwatch stopwatch = new Stopwatch();
+ stopwatch.start();
+
+ OseeDslResource resource = null;
+ InputStream inputStream = null;
+ try {
+ inputStream = source.getContent();
+ resource = OseeDslResourceUtil.loadModel(source.getLocation().toASCIIString(), inputStream);
+ } finally {
+ Lib.close(inputStream);
+ }
+ logger.trace("Converted OrcsTypes to model in [%s]", Lib.getElapseString(stopwatch.elapsedMillis()));
+
+ Conditions.checkNotNull(resource, "osee dsl model", "Error reading osee dsl resource");
+ OseeDsl model = resource.getModel();
+ ArtifactTypeIndex artifactTypeIndex = new ArtifactTypeIndex(hierarchyProvider);
+ AttributeTypeIndex attributeTypeIndex = new AttributeTypeIndex();
+ EnumTypeIndex enumTypeIndex = new EnumTypeIndex();
+ RelationTypeIndex relationTypeIndex = new RelationTypeIndex(artifactTypeIndex);
+ OrcsIndeces index =
+ new OrcsIndeces(source, artifactTypeIndex, attributeTypeIndex, enumTypeIndex, relationTypeIndex);
+
+ try {
+ for (XOseeArtifactTypeOverride xArtifactTypeOverride : model.getArtifactTypeOverrides()) {
+ applyArtifactTypeOverrides(xArtifactTypeOverride);
+ }
+
+ for (XOseeEnumOverride xEnumOverride : model.getEnumOverrides()) {
+ applyEnumOverrides(xEnumOverride);
+ }
+
+ for (XAttributeType dslType : model.getAttributeTypes()) {
+ getOrCreateToken(attributeTypeIndex, dslType);
+ }
+
+ for (XArtifactType dslType : model.getArtifactTypes()) {
+ IArtifactType token = getOrCreateToken(artifactTypeIndex, dslType);
+ indexSuperTypes(artifactTypeIndex, token, dslType);
+ indexAttributes(artifactTypeIndex, attributeTypeIndex, dslType);
+ }
+
+ for (XRelationType dslType : model.getRelationTypes()) {
+ getOrCreateToken(relationTypeIndex, dslType);
+ }
+
+ for (XOseeEnumType dslType : model.getEnumTypes()) {
+ getOrCreateEnumType(enumTypeIndex, dslType);
+ }
+ } finally {
+ logger.trace("Indexed OseeDsl model in [%s]", Lib.getElapseString(stopwatch.elapsedMillis()));
+ stopwatch.stop();
+ }
+ return index;
+ }
+
+ private void indexSuperTypes(ArtifactTypeIndex artifactTypeIndex, IArtifactType token, XArtifactType dslType) throws OseeCoreException {
+ Set<IArtifactType> tokenSuperTypes = Sets.newLinkedHashSet();
+ for (XArtifactType superTypes : dslType.getSuperArtifactTypes()) {
+ IArtifactType superToken = getOrCreateToken(artifactTypeIndex, superTypes);
+ tokenSuperTypes.add(superToken);
+ }
+ if (!tokenSuperTypes.isEmpty()) {
+ artifactTypeIndex.put(token, tokenSuperTypes);
+ }
+ }
+
+ private void indexAttributes(ArtifactTypeIndex artifactTypeIndex, AttributeTypeIndex attributeTypeIndex, XArtifactType dslType) throws OseeCoreException {
+ Map<IOseeBranch, Collection<IAttributeType>> validAttributes =
+ new HashMap<IOseeBranch, Collection<IAttributeType>>();
+ for (XAttributeTypeRef xAttributeTypeRef : dslType.getValidAttributeTypes()) {
+ XAttributeType xAttributeType = xAttributeTypeRef.getValidAttributeType();
+ IOseeBranch branch = getAttributeBranch(xAttributeTypeRef);
+
+ IAttributeType attributeType = attributeTypeIndex.getTokenByDslType(xAttributeType);
+ if (attributeType != null) {
+ Collection<IAttributeType> listOfAllowedAttributes = validAttributes.get(branch);
+ if (listOfAllowedAttributes == null) {
+ listOfAllowedAttributes = Sets.newHashSet();
+ validAttributes.put(branch, listOfAllowedAttributes);
+ }
+ listOfAllowedAttributes.add(attributeType);
+ } else {
+ logger.warn("Type was null for [%s]", dslType.getName());
+ }
+ }
+ IArtifactType token = getOrCreateToken(artifactTypeIndex, dslType);
+ artifactTypeIndex.put(token, validAttributes);
+ }
+
+ private IArtifactType getOrCreateToken(ArtifactTypeIndex index, XArtifactType dslType) throws OseeCoreException {
+ IArtifactType token = index.getTokenByDslType(dslType);
+ if (token == null) {
+ long id = HexUtil.toLong(dslType.getUuid());
+ token = TokenFactory.createArtifactType(id, dslType.getName());
+ index.put(token, dslType);
+ }
+ return token;
+ }
+
+ private IAttributeType getOrCreateToken(AttributeTypeIndex index, XAttributeType dslType) throws OseeCoreException {
+ IAttributeType token = index.getTokenByDslType(dslType);
+ if (token == null) {
+ long id = HexUtil.toLong(dslType.getUuid());
+ token = TokenFactory.createAttributeType(id, dslType.getName());
+ index.put(token, dslType);
+ }
+ return token;
+ }
+
+ private IRelationType getOrCreateToken(RelationTypeIndex index, XRelationType dslType) throws OseeCoreException {
+ IRelationType token = index.getTokenByDslType(dslType);
+ if (token == null) {
+ long id = HexUtil.toLong(dslType.getUuid());
+ token = TokenFactory.createRelationType(id, dslType.getName());
+ index.put(token, dslType);
+ }
+ return token;
+ }
+
+ private EnumType getOrCreateEnumType(EnumTypeIndex index, XOseeEnumType dslType) throws OseeCoreException {
+ EnumType item = index.getTokenByDslType(dslType);
+ if (item == null) {
+ item = createEnumType(dslType);
+ index.put(item, dslType);
+ }
+ return item;
+ }
+
+ private EnumType createEnumType(XOseeEnumType dslType) throws OseeCoreException {
+ int lastOrdinal = 0;
+ List<EnumEntry> entries = new LinkedList<EnumEntry>();
+ for (XOseeEnumEntry entry : dslType.getEnumEntries()) {
+ String ordinal = entry.getOrdinal();
+ if (Strings.isValid(ordinal)) {
+ lastOrdinal = Integer.parseInt(ordinal);
+ }
+
+ String description = entry.getDescription();
+ if (description == null) {
+ description = Strings.emptyString();
+ }
+
+ EnumEntry enumEntry = new EnumEntryImpl(entry.getEntryGuid(), entry.getName(), lastOrdinal, description);
+ entries.add(enumEntry);
+ lastOrdinal++;
+ }
+ Collections.sort(entries);
+ Long uuid = HexUtil.toLong(dslType.getUuid());
+ return new EnumTypeImpl(uuid, dslType.getName(), entries);
+ }
+
+ private IOseeBranch getAttributeBranch(XAttributeTypeRef xAttributeTypeRef) {
+ IOseeBranch branchToken = CoreBranches.SYSTEM_ROOT;
+ String branchGuid = xAttributeTypeRef.getBranchGuid();
+ if (branchGuid != null) {
+ branchToken = TokenFactory.createBranch(branchGuid, branchGuid);
+ }
+ return branchToken;
+ }
+
+ private void applyArtifactTypeOverrides(XOseeArtifactTypeOverride xArtTypeOverride) {
+ XArtifactType xArtifactType = xArtTypeOverride.getOverridenArtifactType();
+ final EList<XAttributeTypeRef> validAttributeTypes = xArtifactType.getValidAttributeTypes();
+ if (!xArtTypeOverride.isInheritAll()) {
+ validAttributeTypes.clear();
+ }
+
+ OseeDslSwitch<Void> overrideVisitor = new OseeDslSwitch<Void>() {
+
+ @Override
+ public Void caseAddAttribute(AddAttribute addOption) {
+ XAttributeTypeRef attributeRef = addOption.getAttribute();
+ validAttributeTypes.add(attributeRef);
+ return super.caseAddAttribute(addOption);
+ }
+
+ @Override
+ public Void caseRemoveAttribute(RemoveAttribute removeOption) {
+ XAttributeType attribute = removeOption.getAttribute();
+ String guidToMatch = attribute.getUuid();
+ List<XAttributeTypeRef> toRemove = new LinkedList<XAttributeTypeRef>();
+ for (XAttributeTypeRef xAttributeTypeRef : validAttributeTypes) {
+ String itemGuid = xAttributeTypeRef.getValidAttributeType().getUuid();
+ if (guidToMatch.equals(itemGuid)) {
+ toRemove.add(xAttributeTypeRef);
+ }
+ }
+ validAttributeTypes.removeAll(toRemove);
+ return super.caseRemoveAttribute(removeOption);
+ }
+
+ @Override
+ public Void caseUpdateAttribute(UpdateAttribute updateAttribute) {
+ XAttributeTypeRef refToUpdate = updateAttribute.getAttribute();
+ String guidToMatch = refToUpdate.getValidAttributeType().getUuid();
+ List<XAttributeTypeRef> toRemove = new LinkedList<XAttributeTypeRef>();
+ for (XAttributeTypeRef xAttributeTypeRef : validAttributeTypes) {
+ String itemGuid = xAttributeTypeRef.getValidAttributeType().getUuid();
+ if (guidToMatch.equals(itemGuid)) {
+ toRemove.add(xAttributeTypeRef);
+ }
+ }
+ validAttributeTypes.removeAll(toRemove);
+ validAttributeTypes.add(refToUpdate);
+ return super.caseUpdateAttribute(updateAttribute);
+ }
+
+ };
+
+ for (AttributeOverrideOption xOverrideOption : xArtTypeOverride.getOverrideOptions()) {
+ overrideVisitor.doSwitch(xOverrideOption);
+ }
+ }
+
+ private void applyEnumOverrides(XOseeEnumOverride xEnumOverride) {
+ XOseeEnumType xEnumType = xEnumOverride.getOverridenEnumType();
+ final EList<XOseeEnumEntry> enumEntries = xEnumType.getEnumEntries();
+ if (!xEnumOverride.isInheritAll()) {
+ enumEntries.clear();
+ }
+
+ OseeDslSwitch<Void> overrideVisitor = new OseeDslSwitch<Void>() {
+
+ @Override
+ public Void caseAddEnum(AddEnum addEnum) {
+ String entryName = addEnum.getEnumEntry();
+ String entryGuid = addEnum.getEntryGuid();
+ String description = addEnum.getDescription();
+ XOseeEnumEntry xEnumEntry = OseeDslFactory.eINSTANCE.createXOseeEnumEntry();
+ xEnumEntry.setName(entryName);
+ xEnumEntry.setEntryGuid(entryGuid);
+ xEnumEntry.setDescription(description);
+ enumEntries.add(xEnumEntry);
+ return super.caseAddEnum(addEnum);
+ }
+
+ @Override
+ public Void caseRemoveEnum(RemoveEnum removeEnum) {
+ XOseeEnumEntry enumEntry = removeEnum.getEnumEntry();
+ String nameToMatch = enumEntry.getName();
+ List<XOseeEnumEntry> toRemove = new LinkedList<XOseeEnumEntry>();
+ for (XOseeEnumEntry item : enumEntries) {
+ String toMatch = item.getName();
+ if (nameToMatch.equals(toMatch)) {
+ toRemove.add(item);
+ }
+ }
+ enumEntries.removeAll(toRemove);
+ return super.caseRemoveEnum(removeEnum);
+ }
+
+ };
+
+ for (OverrideOption xOverrideOption : xEnumOverride.getOverrideOptions()) {
+ overrideVisitor.doSwitch(xOverrideOption);
+ }
+ }
+
+ private static final class OrcsIndeces implements OrcsTypesIndex {
+
+ private final IResource resource;
+ private final ArtifactTypeIndex artifactTypeIndex;
+ private final AttributeTypeIndex attributeTypeIndex;
+ private final EnumTypeIndex enumTypeIndex;
+ private final RelationTypeIndex relationTypeIndex;
+
+ public OrcsIndeces(IResource resource, ArtifactTypeIndex artifactTypeIndex, AttributeTypeIndex attributeTypeIndex, EnumTypeIndex enumTypeIndex, RelationTypeIndex relationTypeIndex) {
+ super();
+ this.resource = resource;
+ this.artifactTypeIndex = artifactTypeIndex;
+ this.attributeTypeIndex = attributeTypeIndex;
+ this.enumTypeIndex = enumTypeIndex;
+ this.relationTypeIndex = relationTypeIndex;
+ }
+
+ @Override
+ public ArtifactTypeIndex getArtifactTypeIndex() {
+ return artifactTypeIndex;
+ }
+
+ @Override
+ public AttributeTypeIndex getAttributeTypeIndex() {
+ return attributeTypeIndex;
+ }
+
+ @Override
+ public RelationTypeIndex getRelationTypeIndex() {
+ return relationTypeIndex;
+ }
+
+ @Override
+ public EnumTypeIndex getEnumTypeIndex() {
+ return enumTypeIndex;
+ }
+
+ @Override
+ public IResource getOrcsTypesResource() {
+ return resource;
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesLoaderFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesLoaderFactoryImpl.java
new file mode 100644
index 00000000000..73138b6cbb6
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/OrcsTypesLoaderFactoryImpl.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.concurrent.Callable;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.core.ds.OrcsTypesDataStore;
+import org.eclipse.osee.orcs.core.internal.SessionContext;
+import org.eclipse.osee.orcs.core.internal.types.BranchHierarchyProvider;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesIndex;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesLoader;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesLoaderFactory;
+import org.eclipse.osee.orcs.core.internal.types.OrcsTypesResourceProvider;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OrcsTypesLoaderFactoryImpl implements OrcsTypesLoaderFactory {
+
+ private final Log logger;
+ private final BranchHierarchyProvider hierarchyProvider;
+
+ public OrcsTypesLoaderFactoryImpl(Log logger, BranchHierarchyProvider hierarchyProvider) {
+ this.logger = logger;
+ this.hierarchyProvider = hierarchyProvider;
+ }
+
+ @Override
+ public OrcsTypesLoader createTypesLoader(final SessionContext session, final OrcsTypesDataStore ds) {
+ return createTypesLoader(session, new OrcsTypesResourceProvider() {
+
+ @Override
+ public IResource getOrcsTypesResource() throws Exception {
+ return ds.getOrcsTypesLoader(session.getSessionId()).call();
+ }
+ });
+ }
+
+ @Override
+ public OrcsTypesLoader createTypesLoader(final SessionContext session, final OrcsTypesResourceProvider provider) {
+ return new OrcsTypesLoader() {
+
+ @Override
+ public Callable<OrcsTypesIndex> createLoader() {
+ OrcsTypesIndexer indexer = new OrcsTypesIndexer(logger, hierarchyProvider);
+ return new CreateOrcsTypesIndexCallable(logger, indexer, provider);
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/RelationTypeIndex.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/RelationTypeIndex.java
new file mode 100644
index 00000000000..67632dcc3e8
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/RelationTypeIndex.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XArtifactType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
+import org.eclipse.osee.framework.core.enums.RelationSide;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class RelationTypeIndex extends TokenTypeIndex<Long, IRelationType, XRelationType> {
+
+ private final ArtifactTypeIndex artifactTypeIndex;
+
+ public RelationTypeIndex(ArtifactTypeIndex artifactTypeIndex) {
+ super();
+ this.artifactTypeIndex = artifactTypeIndex;
+ }
+
+ public IArtifactType getArtifactType(IRelationType relation, RelationSide relationSide) {
+ XRelationType type = getDslTypeByToken(relation);
+ XArtifactType artifactType =
+ relationSide == RelationSide.SIDE_A ? type.getSideAArtifactType() : type.getSideBArtifactType();
+ return artifactTypeIndex.getTokenByDslType(artifactType);
+ }
+
+ public boolean isArtifactTypeAllowed(IRelationType relation, RelationSide relationSide, IArtifactType artifactType) {
+ IArtifactType allowedType = getArtifactType(relation, relationSide);
+ return artifactTypeIndex.inheritsFrom(artifactType, allowedType);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/RelationTypesImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/RelationTypesImpl.java
new file mode 100644
index 00000000000..e2864b1503c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/RelationTypesImpl.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.dsl.oseeDsl.XRelationType;
+import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
+import org.eclipse.osee.framework.core.enums.RelationSide;
+import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
+import org.eclipse.osee.framework.core.exception.OseeArgumentException;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.orcs.data.RelationTypes;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class RelationTypesImpl implements RelationTypes {
+
+ public static interface RelationTypeIndexProvider {
+ RelationTypeIndex getRelationTypeIndex() throws OseeCoreException;
+ }
+
+ private final RelationTypeIndexProvider provider;
+
+ public RelationTypesImpl(RelationTypeIndexProvider provider) {
+ this.provider = provider;
+ }
+
+ private XRelationType getType(IRelationType type) throws OseeCoreException {
+ Conditions.checkNotNull(type, "relationType");
+ return provider.getRelationTypeIndex().getDslTypeByToken(type);
+ }
+
+ @Override
+ public Collection<? extends IRelationType> getAll() throws OseeCoreException {
+ return provider.getRelationTypeIndex().getAllTokens();
+ }
+
+ @Override
+ public IRelationType getByUuid(Long uuid) throws OseeCoreException {
+ Conditions.checkNotNull(uuid, "uuid");
+ return provider.getRelationTypeIndex().getTokenByUuid(uuid);
+ }
+
+ @Override
+ public RelationTypeMultiplicity getMultiplicity(IRelationType relation) throws OseeCoreException {
+ XRelationType type = getType(relation);
+ String multiplicityId = type.getMultiplicity().getName();
+ RelationTypeMultiplicity multiplicity = RelationTypeMultiplicity.getFromString(multiplicityId);
+ return multiplicity;
+ }
+
+ @Override
+ public String getSideName(IRelationType relation, RelationSide relationSide) throws OseeCoreException {
+ Conditions.checkNotNull(relationSide, "relationSide");
+ return relationSide == RelationSide.SIDE_A ? getSideAName(relation) : getSideBName(relation);
+ }
+
+ @Override
+ public String getSideAName(IRelationType relation) throws OseeCoreException {
+ XRelationType type = getType(relation);
+ return type.getSideAName();
+ }
+
+ @Override
+ public String getSideBName(IRelationType relation) throws OseeCoreException {
+ XRelationType type = getType(relation);
+ return type.getSideBName();
+ }
+
+ @Override
+ public boolean isSideAName(IRelationType relation, String sideName) throws OseeCoreException {
+ XRelationType type = getType(relation);
+ boolean isSideA = type.getSideAName().equals(sideName);
+ if (!isSideA && !type.getSideBName().equals(sideName)) {
+ throw new OseeArgumentException("sideName does not match either of the available side names");
+ }
+ return isSideA;
+ }
+
+ @Override
+ public boolean isOrdered(IRelationType relation) {
+ String defaultOrderTypeGuid = null;
+ try {
+ defaultOrderTypeGuid = getDefaultOrderTypeGuid(relation);
+ } catch (OseeCoreException ex) {
+ // Do nothing
+ }
+ return !RelationOrderBaseTypes.UNORDERED.getGuid().equals(defaultOrderTypeGuid);
+ }
+
+ @Override
+ public String getDefaultOrderTypeGuid(IRelationType relation) throws OseeCoreException {
+ XRelationType type = getType(relation);
+ return orderTypeNameToGuid(type.getDefaultOrderType());
+ }
+
+ @Override
+ public IArtifactType getArtifactTypeSideA(IRelationType relation) throws OseeCoreException {
+ return getArtifactType(relation, RelationSide.SIDE_A);
+ }
+
+ @Override
+ public IArtifactType getArtifactTypeSideB(IRelationType relation) throws OseeCoreException {
+ return getArtifactType(relation, RelationSide.SIDE_B);
+ }
+
+ @Override
+ public IArtifactType getArtifactType(IRelationType relation, RelationSide relationSide) throws OseeCoreException {
+ Conditions.checkNotNull(relation, "relationType");
+ Conditions.checkNotNull(relationSide, "relationSide");
+ return provider.getRelationTypeIndex().getArtifactType(relation, relationSide);
+ }
+
+ @Override
+ public boolean isArtifactTypeAllowed(IRelationType relation, RelationSide relationSide, IArtifactType artifactType) throws OseeCoreException {
+ Conditions.checkNotNull(relation, "relationType");
+ Conditions.checkNotNull(relationSide, "relationSide");
+ Conditions.checkNotNull(artifactType, "artifactType");
+ return provider.getRelationTypeIndex().isArtifactTypeAllowed(relation, relationSide, artifactType);
+ }
+
+ private static String orderTypeNameToGuid(String orderTypeName) throws OseeCoreException {
+ Conditions.checkNotNull(orderTypeName, "orderTypeName");
+ String orderType = orderTypeName.replaceAll("_", " ");
+ return RelationOrderBaseTypes.getFromOrderTypeName(orderType).getGuid();
+ }
+
+ @Override
+ public boolean isEmpty() throws OseeCoreException {
+ return provider.getRelationTypeIndex().isEmpty();
+ }
+
+ @Override
+ public int size() throws OseeCoreException {
+ return provider.getRelationTypeIndex().size();
+ }
+
+ @Override
+ public boolean exists(IRelationType item) throws OseeCoreException {
+ return provider.getRelationTypeIndex().existsByUuid(item.getGuid());
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/TokenTypeIndex.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/TokenTypeIndex.java
new file mode 100644
index 00000000000..0dcd974ba1c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/types/impl/TokenTypeIndex.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.orcs.core.internal.types.impl;
+
+import java.util.Collection;
+import java.util.Map;
+import org.eclipse.osee.framework.core.data.Identity;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Maps;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TokenTypeIndex<UUID_TYPE, TOKEN extends Identity<UUID_TYPE>, DSLTYPE> {
+
+ private final Map<UUID_TYPE, TOKEN> uuidToToken;
+ private final BiMap<TOKEN, DSLTYPE> tokenToType;
+
+ public TokenTypeIndex() {
+ uuidToToken = Maps.newHashMap();
+ tokenToType = HashBiMap.create();
+ }
+
+ public Collection<? extends TOKEN> getAllTokens() {
+ return tokenToType.keySet();
+ }
+
+ public TOKEN getTokenByUuid(UUID_TYPE uuid) {
+ return uuidToToken.get(uuid);
+ }
+
+ public DSLTYPE getDslTypeByToken(TOKEN key) {
+ return tokenToType.get(key);
+ }
+
+ public TOKEN getTokenByDslType(DSLTYPE value) {
+ return tokenToType.inverse().get(value);
+ }
+
+ public boolean existsByUuid(UUID_TYPE uuid) {
+ return uuidToToken.containsKey(uuid);
+ }
+
+ public void put(TOKEN token, DSLTYPE dslType) {
+ uuidToToken.put(token.getGuid(), token);
+ tokenToType.put(token, dslType);
+ }
+
+ public boolean isEmpty() {
+ return uuidToToken.isEmpty();
+ }
+
+ public int size() {
+ return uuidToToken.size();
+ }
+} \ No newline at end of file

Back to the top