Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/LazyObject.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesTest.java1031
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/TypesTestSuite.java23
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/testTypeModel.osee139
-rw-r--r--plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF14
-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
-rw-r--r--plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java33
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/OrcsTypeLoaderCallable.java152
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsTypes.java6
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactTypes.java40
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java50
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/EnumEntry.java24
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/EnumType.java32
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/IdentityCollection.java32
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/RelationTypes.java46
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/ObjectProvider.java22
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/Providers.java32
48 files changed, 3673 insertions, 19 deletions
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/LazyObject.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/LazyObject.java
index 8b1d315f618..7143670c2dc 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/LazyObject.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/LazyObject.java
@@ -57,4 +57,7 @@ public abstract class LazyObject<T> {
protected abstract FutureTask<T> createLoaderTask();
+ protected Object getLock() {
+ return lock;
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF
index f578e9bb4dd..d09731dd7c0 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.core.test/META-INF/MANIFEST.MF
@@ -9,7 +9,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.core.runtime,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.model.cache,
- org.eclipse.osee.framework.core.model.mocks
+ org.eclipse.osee.framework.core.model.mocks,
+ org.eclipse.osee.framework.resource.management.util
Require-Bundle: org.junit,
org.mockito;bundle-version="1.9.0",
org.hamcrest.core,
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java
index 18ee8b9dd12..b0ce0a4137e 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/InternalTestSuite.java
@@ -16,6 +16,8 @@ import org.eclipse.osee.orcs.core.internal.branch.BranchTestSuite;
import org.eclipse.osee.orcs.core.internal.proxy.ProxyTestSuite;
import org.eclipse.osee.orcs.core.internal.relation.RelationTestSuite;
import org.eclipse.osee.orcs.core.internal.search.QueryTestSuite;
+import org.eclipse.osee.orcs.core.internal.transaction.TransactionTestSuite;
+import org.eclipse.osee.orcs.core.internal.types.TypesTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -28,8 +30,10 @@ import org.junit.runners.Suite;
AttributeTestSuite.class,
BranchTestSuite.class,
ProxyTestSuite.class,
+ RelationTestSuite.class,
QueryTestSuite.class,
- RelationTestSuite.class})
+ TransactionTestSuite.class,
+ TypesTestSuite.class})
public class InternalTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesTest.java
new file mode 100644
index 00000000000..b9dd0ff46ee
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/OrcsTypesTest.java
@@ -0,0 +1,1031 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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 static org.eclipse.osee.framework.core.enums.RelationSide.SIDE_A;
+import static org.eclipse.osee.framework.core.enums.RelationSide.SIDE_B;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+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.Identity;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
+import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+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.impl.OrcsTypesImpl;
+import org.eclipse.osee.orcs.data.ArtifactTypes;
+import org.eclipse.osee.orcs.data.AttributeTypes;
+import org.eclipse.osee.orcs.data.EnumEntry;
+import org.eclipse.osee.orcs.data.EnumType;
+import org.eclipse.osee.orcs.data.RelationTypes;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.InputSupplier;
+import com.google.common.io.Resources;
+import com.google.common.util.concurrent.Callables;
+
+/**
+ * Test Case for {@link OrcsTypesImpl}
+ *
+ * @author Roberto E. Escobar
+ */
+public class OrcsTypesTest {
+
+ //@formatter:off
+ private static final String SESSION_ID = "Test Session";
+
+ private static final String TEST_TYPE_MODEL = "testTypeModel.osee";
+
+ private static final IArtifactType ARTIFACT = TokenFactory.createArtifactType(0x0000000000000001L, "Artifact");
+ private static final IArtifactType REQUIREMENT = TokenFactory.createArtifactType(0x0000000000000015L, "Requirement");
+ private static final IArtifactType SOFTWARE_REQUIREMENT = TokenFactory.createArtifactType(0x0000000000000018L, "Software Requirement");
+ private static final IArtifactType SYSTEM_REQUIREMENT = TokenFactory.createArtifactType(0x000000000000001EL, "System Requirement");
+ private static final IArtifactType SUBSYSTEM_REQUIREMENT = TokenFactory.createArtifactType(0x000000000000001DL, "SubSystem Requirement");
+ private static final IArtifactType OTHER_ARTIFACT = TokenFactory.createArtifactType(0x0000000000000020L, "Other Artifact");
+ private static final IArtifactType LAST_ARTIFACT = TokenFactory.createArtifactType(0x0000000000000021L, "Last Artifact");
+
+ private static final IAttributeType NAME = TokenFactory.createAttributeType(0x1000000000000070L, "Name");
+ private static final IAttributeType ANNOTATION = TokenFactory.createAttributeType(0x1000000000000076L, "Annotation");
+ private static final IAttributeType WORDML = TokenFactory.createAttributeType(0x100000000000007AL, "WordML");
+ private static final IAttributeType FIELD_1 = TokenFactory.createAttributeType(0x1000000000000080L, "Field 1");
+ private static final IAttributeType FIELD_2 = TokenFactory.createAttributeType(0x1000000000000081L, "Field 2");
+
+ private static final IRelationType REQUIREMENT_REL = TokenFactory.createRelationType(0x2000000000000157L, "Requirement Relation");
+ private static final IRelationType ANOTHER_REL = TokenFactory.createRelationType(0x2000000000000158L, "Another Relation");
+
+ private static final IOseeBranch BRANCH_A = TokenFactory.createBranch("AU2FErW1QwSXWPiP4cwA", "Branch A");
+ private static final IOseeBranch BRANCH_B = TokenFactory.createBranch("AU2JKsKQAQAvzkTkk+gA", "Branch B");
+ private static final IOseeBranch BRANCH_C = TokenFactory.createBranch(GUID.create(), "Branch C");
+ private static final IOseeBranch BRANCH_D = TokenFactory.createBranch(GUID.create(), "Branch D");
+ private static final IOseeBranch BRANCH_E = TokenFactory.createBranch(GUID.create(), "Branch E");
+
+ @Mock private Log logger;
+ @Mock private OrcsTypesDataStore dataStore;
+ @Mock private BranchHierarchyProvider hierarchyProvider;
+ @Mock private SessionContext session;
+ //@formatter:on
+
+ private OrcsTypes orcsTypes;
+ private List<InputSupplier<? extends InputStream>> resources;
+ private Multimap<IOseeBranch, IOseeBranch> branchHierachies;
+ private OrcsTypesModule module;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ module = new OrcsTypesModule(logger, dataStore, hierarchyProvider);
+ module.start(session);
+
+ orcsTypes = module.createOrcsTypes(session);
+ resources = new ArrayList<InputSupplier<? extends InputStream>>();
+
+ URI uri = new URI("osee:/types.test.data.osee");
+
+ IResource resource = new MultiResource(uri, resources);
+ when(dataStore.getOrcsTypesLoader(SESSION_ID)).thenReturn(Callables.returning(resource));
+
+ when(session.getSessionId()).thenReturn(SESSION_ID);
+
+ resources.add(getResource(TEST_TYPE_MODEL));
+
+ branchHierachies = ArrayListMultimap.create();
+
+ // Field 1 will only be visible on branch A and its descendants
+ // Field 2 will only be visible on branch B and its descendants
+ branchHierachies.put(CoreBranches.SYSTEM_ROOT, CoreBranches.SYSTEM_ROOT);
+ branchHierachies.putAll(BRANCH_A, Arrays.asList(BRANCH_A, CoreBranches.SYSTEM_ROOT));
+ branchHierachies.putAll(BRANCH_B, Arrays.asList(BRANCH_B, CoreBranches.SYSTEM_ROOT));
+ branchHierachies.putAll(BRANCH_C, Arrays.asList(BRANCH_C, CoreBranches.SYSTEM_ROOT));
+ branchHierachies.putAll(BRANCH_D, Arrays.asList(BRANCH_D, BRANCH_A, CoreBranches.SYSTEM_ROOT));
+ branchHierachies.putAll(BRANCH_E, Arrays.asList(BRANCH_E, BRANCH_B, CoreBranches.SYSTEM_ROOT));
+
+ when(hierarchyProvider.getParentHierarchy(any(IOseeBranch.class))).thenAnswer(
+ new Answer<Iterable<? extends IOseeBranch>>() {
+
+ @Override
+ public Iterable<? extends IOseeBranch> answer(InvocationOnMock invocation) throws Throwable {
+ IOseeBranch branchToGet = (IOseeBranch) invocation.getArguments()[0];
+ return branchHierachies.get(branchToGet);
+ }
+ });
+
+ }
+
+ @After
+ public void tearDown() {
+ if (module != null) {
+ module.stop();
+ }
+ }
+
+ @Test
+ public void testGetAllArtifactTypes() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(7, artTypes.size());
+ assertEquals(false, artTypes.isEmpty());
+
+ //@formatter:off
+ assertContains(artTypes.getAll(), ARTIFACT, REQUIREMENT, SOFTWARE_REQUIREMENT, SYSTEM_REQUIREMENT, SUBSYSTEM_REQUIREMENT, OTHER_ARTIFACT, LAST_ARTIFACT);
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetArtifactTypesByUuid() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(ARTIFACT, artTypes.getByUuid(ARTIFACT.getGuid()));
+ assertEquals(REQUIREMENT, artTypes.getByUuid(REQUIREMENT.getGuid()));
+ assertEquals(SOFTWARE_REQUIREMENT, artTypes.getByUuid(SOFTWARE_REQUIREMENT.getGuid()));
+ assertEquals(SYSTEM_REQUIREMENT, artTypes.getByUuid(SYSTEM_REQUIREMENT.getGuid()));
+ assertEquals(SUBSYSTEM_REQUIREMENT, artTypes.getByUuid(SUBSYSTEM_REQUIREMENT.getGuid()));
+ assertEquals(OTHER_ARTIFACT, artTypes.getByUuid(OTHER_ARTIFACT.getGuid()));
+ assertEquals(LAST_ARTIFACT, artTypes.getByUuid(LAST_ARTIFACT.getGuid()));
+ }
+
+ @Test
+ public void testExistsArtifactType() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(true, artTypes.exists(ARTIFACT));
+ assertEquals(true, artTypes.exists(REQUIREMENT));
+ assertEquals(true, artTypes.exists(SOFTWARE_REQUIREMENT));
+ assertEquals(true, artTypes.exists(SYSTEM_REQUIREMENT));
+ assertEquals(true, artTypes.exists(SUBSYSTEM_REQUIREMENT));
+ assertEquals(true, artTypes.exists(OTHER_ARTIFACT));
+ assertEquals(true, artTypes.exists(LAST_ARTIFACT));
+ }
+
+ @Test
+ public void testIsAbstract() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(false, artTypes.isAbstract(ARTIFACT));
+ assertEquals(true, artTypes.isAbstract(REQUIREMENT));
+ assertEquals(false, artTypes.isAbstract(SOFTWARE_REQUIREMENT));
+ assertEquals(false, artTypes.isAbstract(SYSTEM_REQUIREMENT));
+ assertEquals(false, artTypes.isAbstract(SUBSYSTEM_REQUIREMENT));
+ assertEquals(false, artTypes.isAbstract(OTHER_ARTIFACT));
+ assertEquals(true, artTypes.isAbstract(LAST_ARTIFACT));
+ }
+
+ @Test
+ public void testHasSuperArtifactTypes() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(false, artTypes.hasSuperArtifactTypes(ARTIFACT));
+ assertEquals(true, artTypes.hasSuperArtifactTypes(REQUIREMENT));
+ assertEquals(true, artTypes.hasSuperArtifactTypes(SOFTWARE_REQUIREMENT));
+ assertEquals(true, artTypes.hasSuperArtifactTypes(SYSTEM_REQUIREMENT));
+ assertEquals(true, artTypes.hasSuperArtifactTypes(SUBSYSTEM_REQUIREMENT));
+ assertEquals(true, artTypes.hasSuperArtifactTypes(OTHER_ARTIFACT));
+ assertEquals(true, artTypes.hasSuperArtifactTypes(LAST_ARTIFACT));
+ }
+
+ @Test
+ public void testGetSuperTypes() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(true, artTypes.getSuperArtifactTypes(ARTIFACT).isEmpty());
+
+ assertContains(artTypes.getSuperArtifactTypes(REQUIREMENT), ARTIFACT);
+ assertContains(artTypes.getSuperArtifactTypes(SOFTWARE_REQUIREMENT), REQUIREMENT);
+ assertContains(artTypes.getSuperArtifactTypes(SYSTEM_REQUIREMENT), REQUIREMENT);
+ assertContains(artTypes.getSuperArtifactTypes(SUBSYSTEM_REQUIREMENT), REQUIREMENT, OTHER_ARTIFACT);
+ assertContains(artTypes.getSuperArtifactTypes(OTHER_ARTIFACT), ARTIFACT);
+ assertContains(artTypes.getSuperArtifactTypes(LAST_ARTIFACT), SUBSYSTEM_REQUIREMENT);
+ }
+
+ @Test
+ public void testInheritsFrom() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(false, artTypes.inheritsFrom(ARTIFACT, REQUIREMENT));
+ assertEquals(true, artTypes.inheritsFrom(REQUIREMENT, ARTIFACT));
+
+ assertEquals(false, artTypes.inheritsFrom(ARTIFACT, OTHER_ARTIFACT));
+ assertEquals(false, artTypes.inheritsFrom(OTHER_ARTIFACT, REQUIREMENT));
+ assertEquals(true, artTypes.inheritsFrom(OTHER_ARTIFACT, ARTIFACT));
+
+ assertEquals(false, artTypes.inheritsFrom(ARTIFACT, SOFTWARE_REQUIREMENT));
+ assertEquals(false, artTypes.inheritsFrom(REQUIREMENT, SOFTWARE_REQUIREMENT));
+ assertEquals(true, artTypes.inheritsFrom(SOFTWARE_REQUIREMENT, ARTIFACT));
+ assertEquals(true, artTypes.inheritsFrom(SOFTWARE_REQUIREMENT, REQUIREMENT));
+ assertEquals(false, artTypes.inheritsFrom(SOFTWARE_REQUIREMENT, OTHER_ARTIFACT));
+
+ assertEquals(false, artTypes.inheritsFrom(ARTIFACT, SYSTEM_REQUIREMENT));
+ assertEquals(false, artTypes.inheritsFrom(REQUIREMENT, SYSTEM_REQUIREMENT));
+ assertEquals(true, artTypes.inheritsFrom(SYSTEM_REQUIREMENT, ARTIFACT));
+ assertEquals(true, artTypes.inheritsFrom(SYSTEM_REQUIREMENT, REQUIREMENT));
+ assertEquals(false, artTypes.inheritsFrom(SYSTEM_REQUIREMENT, OTHER_ARTIFACT));
+
+ assertEquals(false, artTypes.inheritsFrom(ARTIFACT, SUBSYSTEM_REQUIREMENT));
+ assertEquals(false, artTypes.inheritsFrom(REQUIREMENT, SUBSYSTEM_REQUIREMENT));
+ assertEquals(true, artTypes.inheritsFrom(SUBSYSTEM_REQUIREMENT, ARTIFACT));
+ assertEquals(true, artTypes.inheritsFrom(SUBSYSTEM_REQUIREMENT, REQUIREMENT));
+ assertEquals(true, artTypes.inheritsFrom(SUBSYSTEM_REQUIREMENT, OTHER_ARTIFACT));
+
+ assertEquals(false, artTypes.inheritsFrom(ARTIFACT, LAST_ARTIFACT));
+ assertEquals(false, artTypes.inheritsFrom(REQUIREMENT, LAST_ARTIFACT));
+ assertEquals(false, artTypes.inheritsFrom(SUBSYSTEM_REQUIREMENT, LAST_ARTIFACT));
+ assertEquals(true, artTypes.inheritsFrom(LAST_ARTIFACT, ARTIFACT));
+ assertEquals(true, artTypes.inheritsFrom(LAST_ARTIFACT, REQUIREMENT));
+ assertEquals(true, artTypes.inheritsFrom(LAST_ARTIFACT, OTHER_ARTIFACT));
+ assertEquals(true, artTypes.inheritsFrom(LAST_ARTIFACT, SUBSYSTEM_REQUIREMENT));
+ }
+
+ @Test
+ public void testGetAllDescendants() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ //@formatter:off
+ assertContains(artTypes.getAllDescendantTypes(ARTIFACT), REQUIREMENT, SOFTWARE_REQUIREMENT, SYSTEM_REQUIREMENT, SUBSYSTEM_REQUIREMENT, OTHER_ARTIFACT, LAST_ARTIFACT);
+ assertContains(artTypes.getAllDescendantTypes(REQUIREMENT), SOFTWARE_REQUIREMENT, SYSTEM_REQUIREMENT, SUBSYSTEM_REQUIREMENT, LAST_ARTIFACT);
+ assertEquals(true, artTypes.getAllDescendantTypes(SOFTWARE_REQUIREMENT).isEmpty());
+ assertEquals(true, artTypes.getAllDescendantTypes(SYSTEM_REQUIREMENT).isEmpty());
+ assertEquals(true, artTypes.getAllDescendantTypes(SYSTEM_REQUIREMENT).isEmpty());
+ assertEquals(true, artTypes.getAllDescendantTypes(LAST_ARTIFACT).isEmpty());
+ assertContains(artTypes.getAllDescendantTypes(SUBSYSTEM_REQUIREMENT), LAST_ARTIFACT);
+ assertContains(artTypes.getAllDescendantTypes(OTHER_ARTIFACT), SUBSYSTEM_REQUIREMENT, LAST_ARTIFACT);
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetAllDescendantsWithDepth() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ //@formatter:off
+ assertEquals(true, artTypes.getDescendantTypes(ARTIFACT, 0).isEmpty());
+ assertContains(artTypes.getDescendantTypes(ARTIFACT, 1), REQUIREMENT, OTHER_ARTIFACT);
+ assertContains(artTypes.getDescendantTypes(ARTIFACT, 2), REQUIREMENT, OTHER_ARTIFACT, SOFTWARE_REQUIREMENT, SYSTEM_REQUIREMENT, SUBSYSTEM_REQUIREMENT);
+ assertContains(artTypes.getDescendantTypes(ARTIFACT, 3), REQUIREMENT, OTHER_ARTIFACT, SOFTWARE_REQUIREMENT, SYSTEM_REQUIREMENT, SUBSYSTEM_REQUIREMENT, LAST_ARTIFACT);
+
+ assertContains(artTypes.getDescendantTypes(ARTIFACT, 10), REQUIREMENT, OTHER_ARTIFACT, SOFTWARE_REQUIREMENT, SYSTEM_REQUIREMENT, SUBSYSTEM_REQUIREMENT, LAST_ARTIFACT);
+ assertContains(artTypes.getDescendantTypes(ARTIFACT, -1), REQUIREMENT, OTHER_ARTIFACT, SOFTWARE_REQUIREMENT, SYSTEM_REQUIREMENT, SUBSYSTEM_REQUIREMENT, LAST_ARTIFACT);
+ //@formatter:on
+ }
+
+ @Test
+ public void testIsValidAttributeType() throws OseeCoreException {
+ // Field 1 will only be visible on branch A and Branch D
+ // Field 2 will only be visible on branch B and Branch E
+
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(true, artTypes.isValidAttributeType(OTHER_ARTIFACT, CoreBranches.SYSTEM_ROOT, NAME));
+ assertEquals(true, artTypes.isValidAttributeType(OTHER_ARTIFACT, CoreBranches.SYSTEM_ROOT, ANNOTATION));
+ assertEquals(false, artTypes.isValidAttributeType(OTHER_ARTIFACT, CoreBranches.SYSTEM_ROOT, WORDML));
+
+ assertEquals(true, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, CoreBranches.SYSTEM_ROOT, NAME));
+ assertEquals(true, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, CoreBranches.SYSTEM_ROOT, ANNOTATION));
+ assertEquals(true, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, CoreBranches.SYSTEM_ROOT, WORDML));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, CoreBranches.SYSTEM_ROOT, FIELD_1));
+ assertEquals(true, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_A, FIELD_1));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_B, FIELD_1));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_C, FIELD_1));
+ assertEquals(true, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_D, FIELD_1));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_E, FIELD_1));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, CoreBranches.SYSTEM_ROOT, FIELD_2));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_A, FIELD_2));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_B, FIELD_2));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_C, FIELD_2));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_D, FIELD_2));
+ assertEquals(false, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_E, FIELD_2));
+
+ assertEquals(true, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_E, NAME));
+ assertEquals(true, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_E, ANNOTATION));
+ assertEquals(true, artTypes.isValidAttributeType(SUBSYSTEM_REQUIREMENT, BRANCH_E, WORDML));
+
+ assertEquals(true, artTypes.isValidAttributeType(LAST_ARTIFACT, CoreBranches.SYSTEM_ROOT, NAME));
+ assertEquals(true, artTypes.isValidAttributeType(LAST_ARTIFACT, CoreBranches.SYSTEM_ROOT, ANNOTATION));
+ assertEquals(true, artTypes.isValidAttributeType(LAST_ARTIFACT, CoreBranches.SYSTEM_ROOT, WORDML));
+ assertEquals(false, artTypes.isValidAttributeType(LAST_ARTIFACT, CoreBranches.SYSTEM_ROOT, FIELD_1));
+ assertEquals(true, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_A, FIELD_1));
+ assertEquals(false, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_B, FIELD_1));
+ assertEquals(false, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_C, FIELD_1));
+ assertEquals(true, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_D, FIELD_1));
+ assertEquals(false, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_E, FIELD_1));
+
+ assertEquals(false, artTypes.isValidAttributeType(LAST_ARTIFACT, CoreBranches.SYSTEM_ROOT, FIELD_2));
+ assertEquals(false, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_A, FIELD_2));
+ assertEquals(true, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_B, FIELD_2));
+ assertEquals(false, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_C, FIELD_2));
+ assertEquals(false, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_D, FIELD_2));
+ assertEquals(true, artTypes.isValidAttributeType(LAST_ARTIFACT, BRANCH_E, FIELD_2));
+ }
+
+ @Test
+ public void testGetAttributeTypes() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertContains(artTypes.getAttributeTypes(OTHER_ARTIFACT, CoreBranches.SYSTEM_ROOT), NAME, ANNOTATION);
+ assertContains(artTypes.getAttributeTypes(LAST_ARTIFACT, CoreBranches.SYSTEM_ROOT), NAME, ANNOTATION, WORDML);
+
+ //@formatter:off
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, CoreBranches.SYSTEM_ROOT), NAME, ANNOTATION, WORDML);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_A), NAME, ANNOTATION, WORDML, FIELD_1);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_B), NAME, ANNOTATION, WORDML);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_C), NAME, ANNOTATION, WORDML);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_D), NAME, ANNOTATION, WORDML, FIELD_1);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_E), NAME, ANNOTATION, WORDML);
+
+ assertContains(artTypes.getAttributeTypes(LAST_ARTIFACT, CoreBranches.SYSTEM_ROOT), NAME, ANNOTATION, WORDML);
+ assertContains(artTypes.getAttributeTypes(LAST_ARTIFACT, BRANCH_A), NAME, ANNOTATION, WORDML, FIELD_1);
+ assertContains(artTypes.getAttributeTypes(LAST_ARTIFACT, BRANCH_B), NAME, ANNOTATION, WORDML, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(LAST_ARTIFACT, BRANCH_C), NAME, ANNOTATION, WORDML);
+ assertContains(artTypes.getAttributeTypes(LAST_ARTIFACT, BRANCH_D), NAME, ANNOTATION, WORDML, FIELD_1);
+ assertContains(artTypes.getAttributeTypes(LAST_ARTIFACT, BRANCH_E), NAME, ANNOTATION, WORDML, FIELD_2);
+ //@formatter:on
+ }
+
+ @Test
+ public void testReloadAddArtifactType() throws OseeCoreException {
+ String addTypeDef = "artifactType \"Added Artifact Type\" extends \"Other Artifact\" {\n" + //
+ "guid \"AUsuRi68hVhYLH76ENgA\" \n" + //
+ "uuid 0x0000000000000023 \n" + //
+ "}";
+
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(7, artTypes.size());
+
+ orcsTypes.invalidateAll();
+
+ resources.add(asInput(addTypeDef));
+
+ assertEquals(8, artTypes.size());
+ IArtifactType artifactType = artTypes.getByUuid(0x0000000000000023L);
+
+ assertEquals("Added Artifact Type", artifactType.getName());
+ assertEquals(Long.valueOf(0x0000000000000023L), artifactType.getGuid());
+
+ assertEquals(false, artTypes.isAbstract(artifactType));
+ assertEquals(true, artTypes.inheritsFrom(artifactType, OTHER_ARTIFACT));
+ assertEquals(true, artTypes.inheritsFrom(artifactType, ARTIFACT));
+ assertEquals(false, artTypes.inheritsFrom(artifactType, REQUIREMENT));
+
+ assertEquals(true, artTypes.exists(artifactType));
+ }
+
+ @Test
+ public void testArtifactTypeOverride() throws OseeCoreException {
+ ArtifactTypes artTypes = orcsTypes.getArtifactTypes();
+
+ assertEquals(7, artTypes.size());
+
+ assertContains(artTypes.getAttributeTypes(OTHER_ARTIFACT, CoreBranches.SYSTEM_ROOT), NAME, ANNOTATION);
+
+ //@formatter:off
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, CoreBranches.SYSTEM_ROOT), NAME, ANNOTATION, WORDML);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_A), NAME, ANNOTATION, WORDML, FIELD_1);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_B), NAME, ANNOTATION, WORDML);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_C), NAME, ANNOTATION, WORDML);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_D), NAME, ANNOTATION, WORDML, FIELD_1);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_E), NAME, ANNOTATION, WORDML);
+ //@formatter:on
+
+ //@formatter:off
+ String overrideArtTypes =
+ "\n overrides artifactType \"Artifact\" {\n" +
+ " inheritAll \n" +
+ " update attribute \"Annotation\" branchGuid \"AU2FErW1QwSXWPiP4cwA\"\n" +
+ "}\n" +
+ "\n overrides artifactType \"Other Artifact\" {\n" +
+ " inheritAll \n" +
+ " add attribute \"Field 2\" \n" +
+ "}\n" +
+ "\n overrides artifactType \"SubSystem Requirement\" {\n" +
+ " inheritAll \n" +
+ " remove attribute \"Field 1\" \n" +
+ "}\n"
+ ;
+ //@formatter:on
+
+ resources.add(asInput(overrideArtTypes));
+ orcsTypes.invalidateAll();
+
+ assertEquals(7, artTypes.size());
+
+ assertContains(artTypes.getAttributeTypes(OTHER_ARTIFACT, CoreBranches.SYSTEM_ROOT), NAME, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(OTHER_ARTIFACT, BRANCH_A), NAME, ANNOTATION, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(OTHER_ARTIFACT, BRANCH_B), NAME, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(OTHER_ARTIFACT, BRANCH_C), NAME, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(OTHER_ARTIFACT, BRANCH_D), NAME, ANNOTATION, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(OTHER_ARTIFACT, BRANCH_E), NAME, FIELD_2);
+
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, CoreBranches.SYSTEM_ROOT), NAME, WORDML, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_A), NAME, ANNOTATION, WORDML, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_B), NAME, WORDML, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_C), NAME, WORDML, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_D), NAME, ANNOTATION, WORDML, FIELD_2);
+ assertContains(artTypes.getAttributeTypes(SUBSYSTEM_REQUIREMENT, BRANCH_E), NAME, WORDML, FIELD_2);
+ }
+
+ @Test
+ public void testGetAllAttributeTypes() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ assertEquals(5, attrTypes.size());
+ assertEquals(false, attrTypes.isEmpty());
+
+ //@formatter:off
+ assertContains(attrTypes.getAll(), NAME, ANNOTATION, WORDML, FIELD_1, FIELD_2);
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetAttributeTypesByUuid() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ assertEquals(NAME, attrTypes.getByUuid(NAME.getGuid()));
+ assertEquals(ANNOTATION, attrTypes.getByUuid(ANNOTATION.getGuid()));
+ assertEquals(WORDML, attrTypes.getByUuid(WORDML.getGuid()));
+ assertEquals(FIELD_1, attrTypes.getByUuid(FIELD_1.getGuid()));
+ assertEquals(FIELD_2, attrTypes.getByUuid(FIELD_2.getGuid()));
+ }
+
+ @Test
+ public void testExistsAttributeTypes() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ assertEquals(true, attrTypes.exists(NAME));
+ assertEquals(true, attrTypes.exists(ANNOTATION));
+ assertEquals(true, attrTypes.exists(WORDML));
+ assertEquals(true, attrTypes.exists(FIELD_1));
+ assertEquals(true, attrTypes.exists(FIELD_2));
+ }
+
+ @Test
+ public void testGetAttributeProviderId() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals("org.eclipse.osee.framework.skynet.core.DefaultAttributeDataProvider", attrTypes.getAttributeProviderId(NAME));
+ assertEquals("org.eclipse.osee.framework.skynet.core.UriAttributeDataProvider", attrTypes.getAttributeProviderId(ANNOTATION));
+ assertEquals("org.eclipse.osee.framework.skynet.core.UriAttributeDataProvider", attrTypes.getAttributeProviderId(WORDML));
+ assertEquals("org.eclipse.osee.framework.skynet.core.DefaultAttributeDataProvider", attrTypes.getAttributeProviderId(FIELD_1));
+ assertEquals("org.eclipse.osee.framework.skynet.core.UriAttributeDataProvider", attrTypes.getAttributeProviderId(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetBaseAttributeTypeId() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals("org.eclipse.osee.framework.skynet.core.StringAttribute", attrTypes.getBaseAttributeTypeId(NAME));
+ assertEquals("org.eclipse.osee.framework.skynet.core.CompressedContentAttribute", attrTypes.getBaseAttributeTypeId(ANNOTATION));
+ assertEquals("org.eclipse.osee.framework.skynet.core.WordAttribute", attrTypes.getBaseAttributeTypeId(WORDML));
+ assertEquals("org.eclipse.osee.framework.skynet.core.EnumeratedAttribute", attrTypes.getBaseAttributeTypeId(FIELD_1));
+ assertEquals("org.eclipse.osee.framework.skynet.core.DateAttribute", attrTypes.getBaseAttributeTypeId(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetDefaultValue() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals("unnamed", attrTypes.getDefaultValue(NAME));
+ assertEquals(null, attrTypes.getDefaultValue(ANNOTATION));
+ assertEquals("<w:p xmlns:w=\"http://schemas.microsoft.com/office/word/2003/wordml\"><w:r><w:t></w:t></w:r></w:p>", attrTypes.getDefaultValue(WORDML));
+ assertEquals("this is a field", attrTypes.getDefaultValue(FIELD_1));
+ assertEquals(null, attrTypes.getDefaultValue(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetDescription() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals("Descriptive Name", attrTypes.getDescription(NAME));
+ assertEquals("the version \'1.0\' is this \"1.2.0\"", attrTypes.getDescription(ANNOTATION));
+ assertEquals("value must comply with WordML xml schema", attrTypes.getDescription(WORDML));
+ assertEquals("", attrTypes.getDescription(FIELD_1));
+ assertEquals("field 2 description", attrTypes.getDescription(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetFileExtension() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals("", attrTypes.getFileTypeExtension(NAME));
+ assertEquals("", attrTypes.getFileTypeExtension(ANNOTATION));
+ assertEquals("xml", attrTypes.getFileTypeExtension(WORDML));
+ assertEquals("", attrTypes.getFileTypeExtension(FIELD_1));
+ assertEquals("hello", attrTypes.getFileTypeExtension(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetMinOccurrence() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals(1, attrTypes.getMinOccurrences(NAME));
+ assertEquals(0, attrTypes.getMinOccurrences(ANNOTATION));
+ assertEquals(0, attrTypes.getMinOccurrences(WORDML));
+ assertEquals(2, attrTypes.getMinOccurrences(FIELD_1));
+ assertEquals(1, attrTypes.getMinOccurrences(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetMaxOccurrences() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals(1, attrTypes.getMaxOccurrences(NAME));
+ assertEquals(Integer.MAX_VALUE, attrTypes.getMaxOccurrences(ANNOTATION));
+ assertEquals(1, attrTypes.getMaxOccurrences(WORDML));
+ assertEquals(3, attrTypes.getMaxOccurrences(FIELD_1));
+ assertEquals(1, attrTypes.getMaxOccurrences(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetTaggerId() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals("DefaultAttributeTaggerProvider", attrTypes.getTaggerId(NAME));
+ assertEquals("DefaultAttributeTaggerProvider", attrTypes.getTaggerId(ANNOTATION));
+ assertEquals("XmlAttributeTaggerProvider", attrTypes.getTaggerId(WORDML));
+ assertEquals("", attrTypes.getTaggerId(FIELD_1));
+ assertEquals("SomeOtherTagger", attrTypes.getTaggerId(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetMediaType() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ //@formatter:off
+ assertEquals("plan/text", attrTypes.getMediaType(NAME));
+ assertEquals("plan/text", attrTypes.getMediaType(ANNOTATION));
+ assertEquals("application/xml", attrTypes.getMediaType(WORDML));
+ assertEquals("application/custom", attrTypes.getMediaType(FIELD_1));
+ assertEquals("**", attrTypes.getMediaType(FIELD_2));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetAllTaggable() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ Collection<? extends IAttributeType> allTaggable = attrTypes.getAllTaggable();
+ assertContains(allTaggable, NAME, ANNOTATION, WORDML, FIELD_2);
+ }
+
+ @Test
+ public void testGetOseeEnum() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ EnumType enumType = attrTypes.getEnumType(FIELD_1);
+
+ assertEquals("enum.test.proc.status", enumType.getName());
+ assertEquals(Long.valueOf(0x3000000000000178L), enumType.getGuid());
+
+ EnumEntry[] values = enumType.values();
+
+ assertEnumEntry(values[0], "Completed -- Analysis in Work", "APt7j0WUEAIFUyyzVZgA", 1, "");
+ assertEnumEntry(values[1], "Completed -- Passed", "APt7j0YZq1AjCER1qzAA", 2, "");
+ assertEnumEntry(values[2], "Completed -- With Issues", "APt7j0aZWF2BJc_BqnQA", 3, "");
+ assertEnumEntry(values[3], "Completed -- With Issues Resolved", "APt7j0cv9B1ImjckeTAA", 4, "");
+ assertEnumEntry(values[4], "Not Performed", "APt7jzRPv2HBlrjQZXAA", 0, "it was not performed");
+ assertEnumEntry(values[5], "Partially Complete", "AAvULbOIbxhPUO_oDFQA", 5, "is a partial");
+
+ assertEnumEntry(enumType.valueOf(0), "Not Performed", "APt7jzRPv2HBlrjQZXAA", 0, "it was not performed");
+ assertEnumEntry(enumType.valueOf(1), "Completed -- Analysis in Work", "APt7j0WUEAIFUyyzVZgA", 1, "");
+ assertEnumEntry(enumType.valueOf(2), "Completed -- Passed", "APt7j0YZq1AjCER1qzAA", 2, "");
+ assertEnumEntry(enumType.valueOf(3), "Completed -- With Issues", "APt7j0aZWF2BJc_BqnQA", 3, "");
+ assertEnumEntry(enumType.valueOf(4), "Completed -- With Issues Resolved", "APt7j0cv9B1ImjckeTAA", 4, "");
+ assertEnumEntry(enumType.valueOf(5), "Partially Complete", "AAvULbOIbxhPUO_oDFQA", 5, "is a partial");
+
+ //@formatter:off
+ assertEnumEntry(enumType.valueOf("Not Performed"), "Not Performed", "APt7jzRPv2HBlrjQZXAA", 0, "it was not performed");
+ assertEnumEntry(enumType.valueOf("Completed -- Analysis in Work"), "Completed -- Analysis in Work", "APt7j0WUEAIFUyyzVZgA", 1, "");
+ assertEnumEntry(enumType.valueOf("Completed -- Passed"), "Completed -- Passed", "APt7j0YZq1AjCER1qzAA", 2, "");
+ assertEnumEntry(enumType.valueOf("Completed -- With Issues"), "Completed -- With Issues", "APt7j0aZWF2BJc_BqnQA", 3, "");
+ assertEnumEntry(enumType.valueOf("Completed -- With Issues Resolved"), "Completed -- With Issues Resolved", "APt7j0cv9B1ImjckeTAA", 4, "");
+ assertEnumEntry(enumType.valueOf("Partially Complete"), "Partially Complete", "AAvULbOIbxhPUO_oDFQA", 5, "is a partial");
+
+ assertEnumEntry(enumType.getEntryByGuid("APt7jzRPv2HBlrjQZXAA"), "Not Performed", "APt7jzRPv2HBlrjQZXAA", 0, "it was not performed");
+ assertEnumEntry(enumType.getEntryByGuid("APt7j0WUEAIFUyyzVZgA"), "Completed -- Analysis in Work", "APt7j0WUEAIFUyyzVZgA", 1, "");
+ assertEnumEntry(enumType.getEntryByGuid("APt7j0YZq1AjCER1qzAA"), "Completed -- Passed", "APt7j0YZq1AjCER1qzAA", 2, "");
+ assertEnumEntry(enumType.getEntryByGuid("APt7j0aZWF2BJc_BqnQA"), "Completed -- With Issues", "APt7j0aZWF2BJc_BqnQA", 3, "");
+ assertEnumEntry(enumType.getEntryByGuid("APt7j0cv9B1ImjckeTAA"), "Completed -- With Issues Resolved", "APt7j0cv9B1ImjckeTAA", 4, "");
+ assertEnumEntry(enumType.getEntryByGuid("AAvULbOIbxhPUO_oDFQA"), "Partially Complete", "AAvULbOIbxhPUO_oDFQA", 5, "is a partial");
+ //@formatter:on
+
+ Iterator<String> iterator = enumType.valuesAsOrderedStringSet().iterator();
+ assertEquals("Completed -- Analysis in Work", iterator.next());
+ assertEquals("Completed -- Passed", iterator.next());
+ assertEquals("Completed -- With Issues", iterator.next());
+ assertEquals("Completed -- With Issues Resolved", iterator.next());
+ assertEquals("Not Performed", iterator.next());
+ assertEquals("Partially Complete", iterator.next());
+ }
+
+ private void assertEnumEntry(EnumEntry actual, String name, String uuid, int ordinal, String description) {
+ assertEquals(name, actual.getName());
+ assertEquals(uuid, actual.getGuid());
+ assertEquals(ordinal, actual.ordinal());
+ assertEquals(description, actual.getDescription());
+ }
+
+ @Test
+ public void testEnumOverride() throws OseeCoreException {
+ //@formatter:off
+ String enumOverride = "overrides enum \"enum.test.proc.status\" { \n" +
+ "inheritAll \n" +
+ "add \"In Work\" entryGuid \"CArJmMckZm_uUjBpStQA\" description \"this is in work\"\n" +
+ "remove \"enum.test.proc.status.Completed -- With Issues\" \n" +
+ "}\n";
+ //@formatter:on
+
+ orcsTypes.invalidateAll();
+ resources.add(asInput(enumOverride));
+
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ EnumType enumType = attrTypes.getEnumType(FIELD_1);
+
+ assertEquals("enum.test.proc.status", enumType.getName());
+ assertEquals(Long.valueOf(0x3000000000000178L), enumType.getGuid());
+
+ Iterator<String> iterator = enumType.valuesAsOrderedStringSet().iterator();
+ assertEquals("Completed -- Analysis in Work", iterator.next());
+ assertEquals("Completed -- Passed", iterator.next());
+ assertEquals("Completed -- With Issues Resolved", iterator.next());
+ assertEquals("In Work", iterator.next());
+ assertEquals("Not Performed", iterator.next());
+ assertEquals("Partially Complete", iterator.next());
+
+ EnumEntry[] values = enumType.values();
+
+ assertEnumEntry(values[0], "Completed -- Analysis in Work", "APt7j0WUEAIFUyyzVZgA", 1, "");
+ assertEnumEntry(values[1], "Completed -- Passed", "APt7j0YZq1AjCER1qzAA", 2, "");
+ assertEnumEntry(values[2], "Completed -- With Issues Resolved", "APt7j0cv9B1ImjckeTAA", 3, "");
+
+ assertEnumEntry(values[3], "In Work", "CArJmMckZm_uUjBpStQA", 5, "this is in work");
+
+ assertEnumEntry(values[4], "Not Performed", "APt7jzRPv2HBlrjQZXAA", 0, "it was not performed");
+ assertEnumEntry(values[5], "Partially Complete", "AAvULbOIbxhPUO_oDFQA", 4, "is a partial");
+ }
+
+ @Test
+ public void testReloadAddAttributeType() throws OseeCoreException {
+ AttributeTypes attrTypes = orcsTypes.getAttributeTypes();
+
+ assertEquals(5, attrTypes.size());
+
+ orcsTypes.invalidateAll();
+
+ //@formatter:off
+ String addAttributeType = "attributeType \"Field 3\" extends DateAttribute {" +
+ "guid \"AizLp7tWSgr9HNzdmUAA\" \n" +
+ "uuid 0x1000000000000082 \n" +
+ "dataProvider DefaultAttributeDataProvider \n" +
+ "min 1 \n" +
+ "max 1 \n" +
+ "taggerId AnotherTagger \n" +
+ "description \"Added dynamically\" \n" +
+ "}\n";
+ //@formatter:on
+
+ resources.add(asInput(addAttributeType));
+
+ assertEquals(6, attrTypes.size());
+
+ IAttributeType attrType = attrTypes.getByUuid(0x1000000000000082L);
+
+ //@formatter:off
+ assertEquals("Field 3", attrType.getName());
+ assertEquals(Long.valueOf(0x1000000000000082L), attrType.getGuid());
+ assertEquals("org.eclipse.osee.framework.skynet.core.DefaultAttributeDataProvider", attrTypes.getAttributeProviderId(attrType));
+ assertEquals("org.eclipse.osee.framework.skynet.core.DateAttribute", attrTypes.getBaseAttributeTypeId(attrType));
+ assertEquals(null, attrTypes.getDefaultValue(attrType));
+ assertEquals("Added dynamically", attrTypes.getDescription(attrType));
+ assertEquals("", attrTypes.getFileTypeExtension(attrType));
+ assertEquals(1, attrTypes.getMinOccurrences(attrType));
+ assertEquals(1, attrTypes.getMaxOccurrences(attrType));
+ assertEquals("AnotherTagger", attrTypes.getTaggerId(attrType));
+ assertEquals(null, attrTypes.getEnumType(attrType));
+ assertEquals(false, attrTypes.isEnumerated(attrType));
+ assertEquals(true, attrTypes.isTaggable(attrType));
+
+ assertEquals(true, attrTypes.exists(attrType));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetAllRelationTypes() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(2, relTypes.size());
+ assertEquals(false, relTypes.isEmpty());
+
+ //@formatter:off
+ assertContains(relTypes.getAll(), REQUIREMENT_REL, ANOTHER_REL);
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetRelationTypesByUuid() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(REQUIREMENT_REL, relTypes.getByUuid(REQUIREMENT_REL.getGuid()));
+ assertEquals(ANOTHER_REL, relTypes.getByUuid(ANOTHER_REL.getGuid()));
+ }
+
+ @Test
+ public void testExistsRelationTypes() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(true, relTypes.exists(REQUIREMENT_REL));
+ assertEquals(true, relTypes.exists(ANOTHER_REL));
+ }
+
+ @Test
+ public void testGetArtifactType() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(REQUIREMENT, relTypes.getArtifactType(REQUIREMENT_REL, SIDE_A));
+ assertEquals(SUBSYSTEM_REQUIREMENT, relTypes.getArtifactType(REQUIREMENT_REL, SIDE_B));
+
+ assertEquals(OTHER_ARTIFACT, relTypes.getArtifactType(ANOTHER_REL, SIDE_A));
+ assertEquals(LAST_ARTIFACT, relTypes.getArtifactType(ANOTHER_REL, SIDE_B));
+ }
+
+ @Test
+ public void testGetArtifactTypeSideA() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(REQUIREMENT, relTypes.getArtifactTypeSideA(REQUIREMENT_REL));
+ assertEquals(OTHER_ARTIFACT, relTypes.getArtifactTypeSideA(ANOTHER_REL));
+ }
+
+ @Test
+ public void testGetArtifactTypeSideB() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(SUBSYSTEM_REQUIREMENT, relTypes.getArtifactTypeSideB(REQUIREMENT_REL));
+ assertEquals(LAST_ARTIFACT, relTypes.getArtifactTypeSideB(ANOTHER_REL));
+ }
+
+ @Test
+ public void testGetDefaultOrderTypeGuid() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ //@formatter:off
+ assertEquals(RelationOrderBaseTypes.LEXICOGRAPHICAL_ASC.getGuid(), relTypes.getDefaultOrderTypeGuid(REQUIREMENT_REL));
+ assertEquals(RelationOrderBaseTypes.UNORDERED.getGuid(), relTypes.getDefaultOrderTypeGuid(ANOTHER_REL));
+ //@formatter:on
+ }
+
+ @Test
+ public void testGetMultiplicity() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(RelationTypeMultiplicity.ONE_TO_MANY, relTypes.getMultiplicity(REQUIREMENT_REL));
+ assertEquals(RelationTypeMultiplicity.MANY_TO_MANY, relTypes.getMultiplicity(ANOTHER_REL));
+ }
+
+ @Test
+ public void testGetSideNameA() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals("requirement-sideA", relTypes.getSideAName(REQUIREMENT_REL));
+ assertEquals("other-sideA", relTypes.getSideAName(ANOTHER_REL));
+ }
+
+ @Test
+ public void testGetSideNameB() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals("subsystem-sideB", relTypes.getSideBName(REQUIREMENT_REL));
+ assertEquals("last-sideB", relTypes.getSideBName(ANOTHER_REL));
+ }
+
+ @Test
+ public void testGetSideName() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals("requirement-sideA", relTypes.getSideName(REQUIREMENT_REL, SIDE_A));
+ assertEquals("subsystem-sideB", relTypes.getSideName(REQUIREMENT_REL, SIDE_B));
+
+ assertEquals("other-sideA", relTypes.getSideName(ANOTHER_REL, SIDE_A));
+ assertEquals("last-sideB", relTypes.getSideName(ANOTHER_REL, SIDE_B));
+ }
+
+ @Test
+ public void testIsSideName() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(true, relTypes.isSideAName(REQUIREMENT_REL, "requirement-sideA"));
+ assertEquals(false, relTypes.isSideAName(REQUIREMENT_REL, "subsystem-sideB"));
+
+ assertEquals(true, relTypes.isSideAName(ANOTHER_REL, "other-sideA"));
+ assertEquals(false, relTypes.isSideAName(ANOTHER_REL, "last-sideB"));
+ }
+
+ @Test
+ public void testIsOrdered() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(true, relTypes.isOrdered(REQUIREMENT_REL));
+ assertEquals(false, relTypes.isOrdered(ANOTHER_REL));
+ }
+
+ @Test
+ public void testIsArtifactTypeAllowed() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(false, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_A, ARTIFACT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_A, REQUIREMENT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_A, SOFTWARE_REQUIREMENT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_A, SYSTEM_REQUIREMENT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_A, SUBSYSTEM_REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_A, OTHER_ARTIFACT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_A, LAST_ARTIFACT));
+
+ assertEquals(false, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_B, ARTIFACT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_B, REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_B, SOFTWARE_REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_B, SYSTEM_REQUIREMENT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_B, SUBSYSTEM_REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_B, OTHER_ARTIFACT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(REQUIREMENT_REL, SIDE_B, LAST_ARTIFACT));
+
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_A, ARTIFACT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_A, REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_A, SOFTWARE_REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_A, SYSTEM_REQUIREMENT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_A, SUBSYSTEM_REQUIREMENT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_A, OTHER_ARTIFACT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_A, LAST_ARTIFACT));
+
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_B, ARTIFACT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_B, REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_B, SOFTWARE_REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_B, SYSTEM_REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_B, SUBSYSTEM_REQUIREMENT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_B, OTHER_ARTIFACT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(ANOTHER_REL, SIDE_B, LAST_ARTIFACT));
+ }
+
+ @Test
+ public void testReloadAddRelationType() throws OseeCoreException {
+ RelationTypes relTypes = orcsTypes.getRelationTypes();
+
+ assertEquals(2, relTypes.size());
+ orcsTypes.invalidateAll();
+
+ //@formatter:off
+ String addType = "relationType \"Dynamic Relation\" {\n"+
+ "guid \"Ai1n5tou4mr0pqXEPgQA\" \n"+
+ "uuid 0x2000000000000159 \n"+
+ "sideAName \"dynamic-sideA\" \n"+
+ "sideAArtifactType \"Artifact\" \n"+
+ "sideBName \"dynamic-sideB\" \n"+
+ "sideBArtifactType \"Other Artifact\" \n"+
+ "defaultOrderType Lexicographical_Descending \n"+
+ "multiplicity MANY_TO_ONE \n" +
+ "}\n";
+ //@formatter:on
+
+ resources.add(asInput(addType));
+
+ assertEquals(3, relTypes.size());
+
+ IRelationType relation = relTypes.getByUuid(0x2000000000000159L);
+
+ assertEquals("Dynamic Relation", relation.getName());
+ assertEquals(Long.valueOf(0x2000000000000159L), relation.getGuid());
+
+ assertEquals(ARTIFACT, relTypes.getArtifactType(relation, SIDE_A));
+ assertEquals(OTHER_ARTIFACT, relTypes.getArtifactType(relation, SIDE_B));
+ assertEquals(ARTIFACT, relTypes.getArtifactTypeSideA(relation));
+ assertEquals(OTHER_ARTIFACT, relTypes.getArtifactTypeSideB(relation));
+ assertEquals(RelationOrderBaseTypes.LEXICOGRAPHICAL_DESC.getGuid(), relTypes.getDefaultOrderTypeGuid(relation));
+ assertEquals(RelationTypeMultiplicity.MANY_TO_ONE, relTypes.getMultiplicity(relation));
+ assertEquals("dynamic-sideA", relTypes.getSideName(relation, SIDE_A));
+ assertEquals("dynamic-sideB", relTypes.getSideName(relation, SIDE_B));
+ assertEquals("dynamic-sideA", relTypes.getSideAName(relation));
+ assertEquals("dynamic-sideB", relTypes.getSideBName(relation));
+ assertEquals(true, relTypes.isOrdered(relation));
+ assertEquals(true, relTypes.isSideAName(relation, "dynamic-sideA"));
+ assertEquals(false, relTypes.isSideAName(relation, "dynamic-sideB"));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(relation, SIDE_A, LAST_ARTIFACT));
+ assertEquals(false, relTypes.isArtifactTypeAllowed(relation, SIDE_B, REQUIREMENT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(relation, SIDE_B, OTHER_ARTIFACT));
+ assertEquals(true, relTypes.isArtifactTypeAllowed(relation, SIDE_B, LAST_ARTIFACT));
+
+ assertEquals(true, relTypes.exists(relation));
+ }
+
+ private static void assertContains(Collection<?> actual, Identity<?>... expected) {
+ List<?> asList = Arrays.asList(expected);
+
+ String message = String.format("Actual: [%s] Expected: [%s]", actual, Arrays.deepToString(expected));
+
+ assertEquals(message, asList.size(), actual.size());
+ assertEquals(message, true, actual.containsAll(asList));
+ }
+
+ private static InputSupplier<? extends InputStream> getResource(String resourcePath) {
+ URL resource = Resources.getResource(OrcsTypesTest.class, resourcePath);
+ return Resources.newInputStreamSupplier(resource);
+ }
+
+ private static InputSupplier<? extends InputStream> asInput(final String data) {
+ return new InputSupplier<InputStream>() {
+ @Override
+ public InputStream getInput() throws java.io.IOException {
+ return new ByteArrayInputStream(data.getBytes("UTF-8"));
+ }
+ };
+ }
+ private static final class MultiResource implements IResource {
+ private final Iterable<? extends InputSupplier<? extends InputStream>> suppliers;
+ private final URI resourceUri;
+
+ public MultiResource(URI resourceUri, Iterable<? extends InputSupplier<? extends InputStream>> suppliers) {
+ super();
+ this.suppliers = suppliers;
+ this.resourceUri = resourceUri;
+ }
+
+ @Override
+ public InputStream getContent() throws OseeCoreException {
+ InputStream stream = null;
+ InputSupplier<InputStream> join = ByteStreams.join(suppliers);
+ try {
+ stream = join.getInput();
+ } catch (IOException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ }
+ return stream;
+ }
+
+ @Override
+ public URI getLocation() {
+ return resourceUri;
+ }
+
+ @Override
+ public String getName() {
+ String value = resourceUri.toASCIIString();
+ return value.substring(value.lastIndexOf("/") + 1, value.length());
+ }
+
+ @Override
+ public boolean isCompressed() {
+ return false;
+ }
+
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/TypesTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/TypesTestSuite.java
new file mode 100644
index 00000000000..e8d811b432c
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/TypesTestSuite.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.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({OrcsTypesTest.class})
+public class TypesTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/testTypeModel.osee b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/testTypeModel.osee
new file mode 100644
index 00000000000..4ef968c528e
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/types/testTypeModel.osee
@@ -0,0 +1,139 @@
+attributeType "Name" extends StringAttribute {
+ guid "AAMFEcF1AzV7PKuHmxwA"
+ uuid 0x1000000000000070
+ dataProvider DefaultAttributeDataProvider
+ min 1
+ max 1
+ taggerId DefaultAttributeTaggerProvider
+ description "Descriptive Name"
+ defaultValue "unnamed"
+ mediaType "plan/text"
+}
+
+attributeType "Annotation" extends CompressedContentAttribute {
+ guid "AAMFEcWy0xc4e3tcemQA"
+ uuid 0x1000000000000076
+ dataProvider UriAttributeDataProvider
+ min 0
+ max unlimited
+ taggerId DefaultAttributeTaggerProvider
+ description "the version \'1.0\' is this \"1.2.0\""
+ mediaType "plan/text"
+}
+
+attributeType "WordML" extends WordAttribute {
+ guid "AAMFEcfcGS2V3SqQN2wA"
+ uuid 0x100000000000007A
+ dataProvider UriAttributeDataProvider
+ min 0
+ max 1
+ taggerId XmlAttributeTaggerProvider
+ description "value must comply with WordML xml schema"
+ defaultValue "<w:p xmlns:w=\"http://schemas.microsoft.com/office/word/2003/wordml\"><w:r><w:t></w:t></w:r></w:p>"
+ fileExtension "xml"
+ mediaType "application/xml"
+}
+
+attributeType "Field 1" extends EnumeratedAttribute {
+ guid "AU1W_RDAbiHjGBUHyNQA"
+ uuid 0x1000000000000080
+ dataProvider DefaultAttributeDataProvider
+ min 2
+ max 3
+ enumType "enum.test.proc.status"
+ defaultValue "this is a field"
+ mediaType "application/custom"
+}
+
+oseeEnumType "enum.test.proc.status" {
+ guid "AKkmjINR11UDdTOE1WAA"
+ uuid 0x3000000000000178
+ entry "Not Performed"
+ entryGuid "APt7jzRPv2HBlrjQZXAA"
+ description "it was not performed"
+ entry "Completed -- Analysis in Work"
+ entryGuid "APt7j0WUEAIFUyyzVZgA"
+ entry "Completed -- Passed"
+ entryGuid "APt7j0YZq1AjCER1qzAA"
+ entry "Completed -- With Issues"
+ entryGuid "APt7j0aZWF2BJc_BqnQA"
+ entry "Completed -- With Issues Resolved"
+ entryGuid "APt7j0cv9B1ImjckeTAA"
+ entry "Partially Complete"
+ entryGuid "AAvULbOIbxhPUO_oDFQA"
+ description "is a partial"
+}
+
+attributeType "Field 2" extends DateAttribute {
+ guid "AU1tcZpvAgWKt9wooVQA"
+ uuid 0x1000000000000081
+ dataProvider UriAttributeDataProvider
+ min 1
+ max 1
+ taggerId SomeOtherTagger
+ description "field 2 description"
+ fileExtension "hello"
+ mediaType "**"
+}
+
+relationType "Requirement Relation" {
+ guid "BOkzi3U9VTe2fcUz_9gA"
+ uuid 0x2000000000000157
+ sideAName "requirement-sideA"
+ sideAArtifactType "Requirement"
+ sideBName "subsystem-sideB"
+ sideBArtifactType "SubSystem Requirement"
+ defaultOrderType Lexicographical_Ascending
+ multiplicity ONE_TO_MANY
+}
+
+relationType "Another Relation" {
+ guid "AVM9fT1Ue2QhFnt30FQA"
+ uuid 0x2000000000000158
+ sideAName "other-sideA"
+ sideAArtifactType "Other Artifact"
+ sideBName "last-sideB"
+ sideBArtifactType "Last Artifact"
+ defaultOrderType Unordered
+ multiplicity MANY_TO_MANY
+}
+
+artifactType "Artifact" {
+ guid "AAMFDh6S7gRLupAMwywA"
+ uuid 0x0000000000000001
+ attribute "Name"
+ attribute "Annotation"
+}
+
+abstract artifactType "Requirement" extends "Artifact" {
+ guid "BOm4NmAq+HC1O2hkMagA"
+ uuid 0x0000000000000015
+ attribute "WordML"
+}
+
+artifactType "Software Requirement" extends "Requirement" {
+ guid "BOm+AIG2snNbAM5FFcwA"
+ uuid 0x0000000000000018
+}
+
+artifactType "System Requirement" extends "Requirement" {
+ guid "BOnAaYTBOG68_Tw5Y_AA"
+ uuid 0x000000000000001E
+}
+
+artifactType "Other Artifact" extends "Artifact" {
+ guid "AUStoi43TWac2EHzNIAA"
+ uuid 0x0000000000000020
+}
+
+artifactType "SubSystem Requirement" extends "Requirement" , "Other Artifact" {
+ guid "BOnBhJ1XAFGKcrku3LgA"
+ uuid 0x000000000000001D
+ attribute "Field 1" branchGuid "AU2FErW1QwSXWPiP4cwA"
+}
+
+abstract artifactType "Last Artifact" extends "SubSystem Requirement" {
+ guid "AUqqRktDXW9r6YXq0WQA"
+ uuid 0x0000000000000021
+ attribute "Field 2" branchGuid "AU2JKsKQAQAvzkTkk+gA"
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
index 70a4fedbb18..8734a2a7625 100644
--- a/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.core/META-INF/MANIFEST.MF
@@ -6,10 +6,16 @@ Bundle-Version: 0.11.1.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/*.xml
-Import-Package: com.google.common.collect,
+Import-Package: org.eclipse.emf.common.notify,
+ org.eclipse.emf.common.util,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.util,
org.eclipse.osee.console.admin,
org.eclipse.osee.executor.admin,
org.eclipse.osee.framework.core.data,
+ org.eclipse.osee.framework.core.dsl,
+ org.eclipse.osee.framework.core.dsl.oseeDsl,
+ org.eclipse.osee.framework.core.dsl.oseeDsl.util,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
org.eclipse.osee.framework.core.model,
@@ -25,10 +31,12 @@ Import-Package: com.google.common.collect,
org.eclipse.osee.orcs.data,
org.eclipse.osee.orcs.search,
org.eclipse.osee.orcs.statistics,
- org.eclipse.osee.orcs.transaction
+ org.eclipse.osee.orcs.transaction,
+ org.eclipse.osee.orcs.utility
Export-Package: org.eclipse.osee.orcs.core,
org.eclipse.osee.orcs.core.ds,
org.eclipse.osee.orcs.core.ds.criteria
Require-Bundle: org.eclipse.core.runtime,
- org.eclipse.osee.framework.jdk.core
+ org.eclipse.osee.framework.jdk.core,
+ com.google.guava;bundle-version="12.0.0"
Bundle-ActivationPolicy: lazy
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
diff --git a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
index 9f12e5744b6..66ac12fb341 100644
--- a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
@@ -6,8 +6,7 @@ Bundle-Version: 0.11.1.qualifier
Bundle-Vendor: Eclipse Open System Engineering Environment
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Service-Component: OSGI-INF/*.xml
-Import-Package: com.google.common.collect,
- org.eclipse.emf.common.notify,
+Import-Package: org.eclipse.emf.common.notify,
org.eclipse.emf.common.util,
org.eclipse.emf.ecore,
org.eclipse.emf.ecore.util,
@@ -51,4 +50,5 @@ Import-Package: com.google.common.collect,
org.eclipse.osee.orcs.search,
org.osgi.framework
Bundle-ActivationPolicy: lazy
-Require-Bundle: org.eclipse.core.runtime
+Require-Bundle: org.eclipse.core.runtime,
+ com.google.guava;bundle-version="12.0.0"
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java
index b08987157a0..5678c97bd77 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/OrcsDataStoreImpl.java
@@ -33,6 +33,7 @@ import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.core.services.IOseeModelFactoryService;
import org.eclipse.osee.framework.core.services.IdentityService;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.framework.resource.management.IResourceManager;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.SystemPreferences;
@@ -44,6 +45,7 @@ import org.eclipse.osee.orcs.core.ds.OrcsDataStore;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
import org.eclipse.osee.orcs.core.ds.QueryEngineIndexer;
import org.eclipse.osee.orcs.db.internal.branch.BranchDataStoreImpl;
+import org.eclipse.osee.orcs.db.internal.callable.OrcsTypeLoaderCallable;
import org.eclipse.osee.orcs.db.internal.callable.PurgeArtifactTypeDatabaseTxCallable;
import org.eclipse.osee.orcs.db.internal.callable.PurgeAttributeTypeDatabaseTxCallable;
import org.eclipse.osee.orcs.db.internal.callable.PurgeRelationTypeDatabaseTxCallable;
@@ -261,18 +263,43 @@ public class OrcsDataStoreImpl implements OrcsDataStore, IOseeCachingService {
}
@Override
- public Callable<?> purgeArtifactType(Collection<? extends IArtifactType> typesToPurge) {
+ public Callable<IResource> getOrcsTypesLoader(String sessionId) {
+ return new OrcsTypeLoaderCallable(dbService, identityService, resourceManager);
+ }
+
+ @Override
+ public Callable<?> purgeArtifactsByArtifactType(String sessionId, Collection<? extends IArtifactType> typesToPurge) {
return new PurgeArtifactTypeDatabaseTxCallable(logger, dbService, identityService, typesToPurge);
}
@Override
- public Callable<?> purgeAttributeType(Collection<? extends IAttributeType> typesToPurge) {
+ public Callable<?> purgeAttributesByAttributeType(String sessionId, Collection<? extends IAttributeType> typesToPurge) {
return new PurgeAttributeTypeDatabaseTxCallable(logger, dbService, identityService, typesToPurge);
}
@Override
- public Callable<?> purgeRelationType(Collection<? extends IRelationType> typesToPurge) {
+ public Callable<?> purgeRelationsByRelationType(String sessionId, Collection<? extends IRelationType> typesToPurge) {
return new PurgeRelationTypeDatabaseTxCallable(logger, dbService, identityService, typesToPurge);
}
+ // TODO - REMOVE OrcsTypes interface from OrcsDataStore interface
+ // TODO - REMOVE the bottom three methods
+ // TODO - REMOVE IOseeCachingService interface from OrcsDataStoreImpl and all cachingService related methods
+ // TODO - REMOVE IOseeModelingService and its implementations
+ // TODO - DELETE types package from org.eclipse.osee.orcs.db.internal
+ @Override
+ public Callable<?> purgeArtifactsByArtifactType(Collection<? extends IArtifactType> artifactTypes) {
+ return purgeArtifactsByArtifactType("", artifactTypes);
+ }
+
+ @Override
+ public Callable<?> purgeAttributesByAttributeType(Collection<? extends IAttributeType> attributeTypes) {
+ return purgeAttributesByAttributeType("", attributeTypes);
+ }
+
+ @Override
+ public Callable<?> purgeRelationsByRelationType(Collection<? extends IRelationType> relationTypes) {
+ return purgeRelationsByRelationType("", relationTypes);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/OrcsTypeLoaderCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/OrcsTypeLoaderCallable.java
new file mode 100644
index 00000000000..41551852899
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/OrcsTypeLoaderCallable.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * 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.db.internal.callable;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
+import org.eclipse.osee.framework.core.enums.TxChange;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeExceptions;
+import org.eclipse.osee.framework.core.services.IdentityService;
+import org.eclipse.osee.framework.core.util.Conditions;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.resource.management.IResource;
+import org.eclipse.osee.framework.resource.management.IResourceLocator;
+import org.eclipse.osee.framework.resource.management.IResourceManager;
+import org.eclipse.osee.framework.resource.management.StandardOptions;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class OrcsTypeLoaderCallable extends CancellableCallable<IResource> {
+
+ private static final String LOAD_OSEE_TYPE_DEF_URIS =
+ "select attr.uri from osee_branch br, osee_txs txs1, osee_artifact art, osee_attribute attr, osee_txs txs2 where br.branch_guid = ? and txs1.branch_id = br.branch_id and txs1.tx_current = ? and txs1.gamma_id = art.gamma_id and txs2.branch_id = br.branch_id and txs2.tx_current = ? and txs2.gamma_id = attr.gamma_id and art.art_type_id = ? and art.art_id = attr.art_id and attr.attr_type_id = ?";
+
+ private final IdentityService identityService;
+ private final IOseeDatabaseService dbService;
+ private final IResourceManager resourceManager;
+
+ public OrcsTypeLoaderCallable(IOseeDatabaseService dbService, IdentityService identityService, IResourceManager resourceManager) {
+ super();
+ this.identityService = identityService;
+ this.dbService = dbService;
+ this.resourceManager = resourceManager;
+ }
+
+ @Override
+ public IResource call() throws Exception {
+ String resourceUri = String.format("osee:/datastore.orcs.types_%s.osee", Lib.getDateTimeString());
+ URI uri = new URI(resourceUri);
+ Collection<String> uriPaths = findOseeTypeData();
+
+ Conditions.checkExpressionFailOnTrue(uriPaths.isEmpty(), "No orcs types found");
+ return new OrcsTypesResource(uri, uriPaths);
+ }
+
+ private Collection<String> findOseeTypeData() throws OseeCoreException {
+ Collection<String> paths = new LinkedHashSet<String>();
+
+ Integer artifactTypeId = identityService.getLocalId(CoreArtifactTypes.OseeTypeDefinition);
+ Integer attributeTypeId = identityService.getLocalId(CoreAttributeTypes.UriGeneralStringData);
+
+ IOseeStatement chStmt = null;
+ try {
+ chStmt = dbService.getStatement();
+
+ chStmt.runPreparedQuery(LOAD_OSEE_TYPE_DEF_URIS, CoreBranches.COMMON.getGuid(), TxChange.CURRENT.getValue(),
+ TxChange.CURRENT.getValue(), artifactTypeId, attributeTypeId);
+ while (chStmt.next()) {
+ String uri = chStmt.getString("uri");
+ paths.add(uri);
+ }
+ } finally {
+ Lib.close(chStmt);
+ }
+ return paths;
+ }
+
+ private final class OrcsTypesResource implements IResource {
+
+ private final URI uri;
+ private final Collection<String> resources;
+
+ public OrcsTypesResource(URI uri, Collection<String> resources) {
+ this.uri = uri;
+ this.resources = resources;
+ }
+
+ @Override
+ public InputStream getContent() throws OseeCoreException {
+ return asInputStream(resources);
+ }
+
+ @Override
+ public URI getLocation() {
+ return uri;
+ }
+
+ @Override
+ public String getName() {
+ String value = uri.toASCIIString();
+ return value.substring(value.lastIndexOf("/") + 1, value.length());
+ }
+
+ @Override
+ public boolean isCompressed() {
+ return false;
+ }
+
+ private InputStream asInputStream(Collection<String> resources) throws OseeCoreException {
+ PropertyStore options = new PropertyStore();
+ options.put(StandardOptions.DecompressOnAquire.name(), "true");
+
+ StringBuilder builder = new StringBuilder();
+ for (String path : resources) {
+ IResourceLocator locator = resourceManager.getResourceLocator(path);
+ IResource resource = resourceManager.acquire(locator, options);
+
+ InputStream inputStream = null;
+ try {
+ inputStream = resource.getContent();
+ String oseeTypeFragment = Lib.inputStreamToString(inputStream);
+ oseeTypeFragment = oseeTypeFragment.replaceAll("import\\s+\"", "// import \"");
+ builder.append("\n////////////// ");
+ builder.append(resource.getName());
+ builder.append("\n\n");
+ builder.append(oseeTypeFragment);
+ } catch (IOException ex) {
+ OseeExceptions.wrapAndThrow(ex);
+ } finally {
+ Lib.close(inputStream);
+ }
+ }
+ char[] chars = new char[builder.length()];
+ builder.getChars(0, builder.length(), chars, 0);
+ byte[] bytes = Charset.forName("UTF-8").encode(CharBuffer.wrap(chars)).array();
+ return new ByteArrayInputStream(bytes);
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsTypes.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsTypes.java
index 589ce7bd75c..69ffe2b9f74 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsTypes.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsTypes.java
@@ -29,10 +29,10 @@ public interface OrcsTypes {
void exportOseeTypes(OutputStream outputStream) throws OseeCoreException;
- Callable<?> purgeArtifactType(Collection<? extends IArtifactType> artifactTypes);
+ Callable<?> purgeArtifactsByArtifactType(Collection<? extends IArtifactType> artifactTypes);
- Callable<?> purgeAttributeType(Collection<? extends IAttributeType> attributeTypes);
+ Callable<?> purgeAttributesByAttributeType(Collection<? extends IAttributeType> attributeTypes);
- Callable<?> purgeRelationType(Collection<? extends IRelationType> relationTypes);
+ Callable<?> purgeRelationsByRelationType(Collection<? extends IRelationType> relationTypes);
}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactTypes.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactTypes.java
new file mode 100644
index 00000000000..f9cc8b52030
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactTypes.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.data;
+
+import java.util.Collection;
+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.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface ArtifactTypes extends IdentityCollection<Long, IArtifactType> {
+
+ boolean hasSuperArtifactTypes(IArtifactType artType) throws OseeCoreException;
+
+ Collection<? extends IArtifactType> getSuperArtifactTypes(IArtifactType artType) throws OseeCoreException;
+
+ Collection<? extends IArtifactType> getDescendantTypes(IArtifactType artType, int depth) throws OseeCoreException;
+
+ Collection<? extends IArtifactType> getAllDescendantTypes(IArtifactType artType) throws OseeCoreException;
+
+ boolean isValidAttributeType(IArtifactType artType, IOseeBranch branch, IAttributeType attributeType) throws OseeCoreException;
+
+ Collection<IAttributeType> getAttributeTypes(IArtifactType artType, IOseeBranch branch) throws OseeCoreException;
+
+ boolean isAbstract(IArtifactType artType) throws OseeCoreException;
+
+ boolean inheritsFrom(IArtifactType artType, IArtifactType... otherTypes) throws OseeCoreException;
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java
new file mode 100644
index 00000000000..26cb8cd46ac
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/AttributeTypes.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * 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.data;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface AttributeTypes extends IdentityCollection<Long, IAttributeType> {
+
+ Collection<? extends IAttributeType> getAllTaggable() throws OseeCoreException;
+
+ String getDescription(IAttributeType attrType) throws OseeCoreException;
+
+ String getBaseAttributeTypeId(IAttributeType attrType) throws OseeCoreException;
+
+ String getAttributeProviderId(IAttributeType attrType) throws OseeCoreException;
+
+ String getDefaultValue(IAttributeType attrType) throws OseeCoreException;
+
+ int getMaxOccurrences(IAttributeType attrType) throws OseeCoreException;
+
+ int getMinOccurrences(IAttributeType attrType) throws OseeCoreException;
+
+ EnumType getEnumType(IAttributeType attrType) throws OseeCoreException;
+
+ String getFileTypeExtension(IAttributeType attrType) throws OseeCoreException;
+
+ String getTaggerId(IAttributeType attrType) throws OseeCoreException;
+
+ boolean isTaggable(IAttributeType attrType) throws OseeCoreException;
+
+ boolean isEnumerated(IAttributeType attrType) throws OseeCoreException;
+
+ String getMediaType(IAttributeType attrType) throws OseeCoreException;
+
+ boolean hasMediaType(IAttributeType attrType) throws OseeCoreException;
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/EnumEntry.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/EnumEntry.java
new file mode 100644
index 00000000000..737b1402a5d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/EnumEntry.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * 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.data;
+
+import org.eclipse.osee.framework.core.data.FullyNamed;
+import org.eclipse.osee.framework.core.data.HasDescription;
+import org.eclipse.osee.framework.core.data.Identity;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface EnumEntry extends Identity<String>, FullyNamed, HasDescription {
+
+ int ordinal();
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/EnumType.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/EnumType.java
new file mode 100644
index 00000000000..3969a29e2a6
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/EnumType.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.data;
+
+import java.util.Set;
+import org.eclipse.osee.framework.core.data.FullyNamed;
+import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface EnumType extends Identity<Long>, FullyNamed {
+
+ EnumEntry[] values();
+
+ EnumEntry getEntryByGuid(String entryGuid);
+
+ Set<String> valuesAsOrderedStringSet();
+
+ EnumEntry valueOf(int ordinal) throws OseeCoreException;
+
+ EnumEntry valueOf(String entryName) throws OseeCoreException;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/IdentityCollection.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/IdentityCollection.java
new file mode 100644
index 00000000000..520f2ef45eb
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/IdentityCollection.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.data;
+
+import java.util.Collection;
+import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface IdentityCollection<K, T extends Identity<K>> {
+
+ Collection<? extends T> getAll() throws OseeCoreException;
+
+ T getByUuid(K typeId) throws OseeCoreException;
+
+ boolean exists(T item) throws OseeCoreException;
+
+ boolean isEmpty() throws OseeCoreException;
+
+ int size() throws OseeCoreException;
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/RelationTypes.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/RelationTypes.java
new file mode 100644
index 00000000000..7625dc3fdfd
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/RelationTypes.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.data;
+
+import org.eclipse.osee.framework.core.data.IArtifactType;
+import org.eclipse.osee.framework.core.data.IRelationType;
+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;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface RelationTypes extends IdentityCollection<Long, IRelationType> {
+
+ RelationTypeMultiplicity getMultiplicity(IRelationType relation) throws OseeCoreException;
+
+ IArtifactType getArtifactTypeSideA(IRelationType relation) throws OseeCoreException;
+
+ IArtifactType getArtifactTypeSideB(IRelationType relation) throws OseeCoreException;
+
+ IArtifactType getArtifactType(IRelationType relation, RelationSide relationSide) throws OseeCoreException;
+
+ String getSideName(IRelationType relation, RelationSide relationSide) throws OseeCoreException;
+
+ boolean isArtifactTypeAllowed(IRelationType relation, RelationSide relationSide, IArtifactType artifactType) throws OseeCoreException;
+
+ String getSideAName(IRelationType relation) throws OseeCoreException;
+
+ String getSideBName(IRelationType relation) throws OseeCoreException;
+
+ boolean isSideAName(IRelationType relation, String sideName) throws OseeArgumentException, OseeCoreException;
+
+ boolean isOrdered(IRelationType relation) throws OseeCoreException;
+
+ String getDefaultOrderTypeGuid(IRelationType relation) throws OseeCoreException;
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/ObjectProvider.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/ObjectProvider.java
new file mode 100644
index 00000000000..3968b8c0d8d
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/ObjectProvider.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.utility;
+
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public interface ObjectProvider<T> {
+
+ T get() throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/Providers.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/Providers.java
new file mode 100644
index 00000000000..3799e1e5e06
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/utility/Providers.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.utility;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class Providers {
+
+ private Providers() {
+ // utility class
+ }
+
+ public static <T> ObjectProvider<T> returning(final T object) {
+ return new ObjectProvider<T>() {
+
+ @Override
+ public T get() {
+ return object;
+ }
+ };
+ }
+
+}

Back to the top