Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormegumi.telles2013-09-06 03:19:46 +0000
committerRoberto E. Escobar2013-09-17 23:29:02 +0000
commitfd56354a8ee51c2a3d848af2837751fa8e5f1a7f (patch)
tree1c679bba945782fb34c15bab13f0b6189afbf6bd /plugins
parent46b4f19063bd42368afd178eb90436381bc9582b (diff)
downloadorg.eclipse.osee-fd56354a8ee51c2a3d848af2837751fa8e5f1a7f.tar.gz
org.eclipse.osee-fd56354a8ee51c2a3d848af2837751fa8e5f1a7f.tar.xz
org.eclipse.osee-fd56354a8ee51c2a3d848af2837751fa8e5f1a7f.zip
feature[ats_7SNLZ]: Enable relation editing
Remove ArtifactBuilder Remove RelationContainer Remove GraphReadable Add Relation Walking capabilities to ArtifactReadable Add RelationEditing methods to TransactionBuilder Add RelationEditing integration tests Change ArtifactTransactionData to OrcsChangeSet Change-Id: I450352cd10b1ae038dabeef5ec4e727fc4ba8f3b
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsArtifactProviderImpl.java6
-rw-r--r--plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsPresenterFactoryImpl.java7
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/build/report/resources/BuildTraceReportResource.java11
-rw-r--r--plugins/org.eclipse.osee.display.presenter.mocks/src/org/eclipse/osee/display/presenter/mocks/MockArtifact.java55
-rw-r--r--plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java23
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java4
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/Identity.java6
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java6
-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/artifact/ArtifactFactoryTest.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java273
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java176
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ProxyTestSuite.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImplTest.java494
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AttributeReadOnlyImplTest.java147
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerTest.java147
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ProxyImplTestSuite.java (renamed from plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/LoaderTestSuite.java)6
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationManagerTest.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidityTest.java68
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImplTest.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/ChangeSetBuilderTest.java (renamed from plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/CollectDirtyDataTest.java)53
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImplTest.java67
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactoryTest.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java313
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTxDataImpl.java64
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/HasOrcsChangeSet.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/HasRelationContainer.java)12
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsChangeSet.java (renamed from plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTransactionData.java)20
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionResult.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactBuilder.java24
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactBuilderFactory.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactLoader.java67
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactLoaderFactory.java33
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsApiImpl.java65
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java22
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderFactoryImpl.java48
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java156
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImpl.java71
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderInvocationHandler.java96
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ExternalArtifactManager.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AbstractProxied.java59
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java152
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AttributeReadOnlyImpl.java70
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerImpl.java64
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationContainer.java31
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationContainerImpl.java102
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationFactory.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationGraphImpl.java132
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidity.java27
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationUtil.java67
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImpl.java20
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImpl.java1
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java48
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java36
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/ChangeSetBuilder.java118
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/CollectDirtyData.java52
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java56
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionDataImpl.java70
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxData.java15
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java52
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java150
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriterTest.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java19
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionIndexer.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriter.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactsResource.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java30
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java271
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java3
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactReadable.java35
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/GraphReadable.java39
-rw-r--r--plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java25
82 files changed, 2480 insertions, 2010 deletions
diff --git a/plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsArtifactProviderImpl.java b/plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsArtifactProviderImpl.java
index 238d276263..f7111eaf88 100644
--- a/plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsArtifactProviderImpl.java
+++ b/plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsArtifactProviderImpl.java
@@ -26,8 +26,8 @@ import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.OrcsTypes;
import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.search.QueryFactory;
/**
@@ -37,8 +37,8 @@ public class AtsArtifactProviderImpl extends ArtifactProviderImpl implements Ats
private static final String FILTER_KEYWORD = "Apply_Filter";
- public AtsArtifactProviderImpl(Log logger, ExecutorAdmin executorAdmin, QueryFactory queryFactory, GraphReadable graph) {
- super(logger, executorAdmin, queryFactory, graph);
+ public AtsArtifactProviderImpl(Log logger, ExecutorAdmin executorAdmin, QueryFactory queryFactory, OrcsTypes orcsTypes) {
+ super(logger, executorAdmin, queryFactory, orcsTypes);
}
@Override
diff --git a/plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsPresenterFactoryImpl.java b/plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsPresenterFactoryImpl.java
index 9a1ab14ea7..a5ccd203ae 100644
--- a/plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsPresenterFactoryImpl.java
+++ b/plugins/org.eclipse.osee.ats.presenter/src/org/eclipse/osee/ats/presenter/internal/AtsPresenterFactoryImpl.java
@@ -19,7 +19,7 @@ import org.eclipse.osee.executor.admin.ExecutorAdmin;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
-import org.eclipse.osee.orcs.data.GraphReadable;
+import org.eclipse.osee.orcs.OrcsTypes;
import org.eclipse.osee.orcs.search.QueryFactory;
/**
@@ -46,9 +46,8 @@ public class AtsPresenterFactoryImpl<T extends AtsSearchHeaderComponent, K exten
@Override
public AtsSearchPresenter<AtsSearchHeaderComponent, AtsSearchParameters> createInstance(ApplicationContext context) {
QueryFactory queryFactory = orcsApi.getQueryFactory(context);
- GraphReadable graph = orcsApi.getGraph(context);
-
- AtsArtifactProvider provider = new AtsArtifactProviderImpl(logger, executorAdmin, queryFactory, graph);
+ OrcsTypes orcsTypes = orcsApi.getOrcsTypes(context);
+ AtsArtifactProvider provider = new AtsArtifactProviderImpl(logger, executorAdmin, queryFactory, orcsTypes);
AtsSearchPresenterImpl<AtsSearchHeaderComponent, AtsSearchParameters> instance =
new AtsSearchPresenterImpl<AtsSearchHeaderComponent, AtsSearchParameters>(provider, logger);
return instance;
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/build/report/resources/BuildTraceReportResource.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/build/report/resources/BuildTraceReportResource.java
index 58e90c2617..8d0f053b99 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/build/report/resources/BuildTraceReportResource.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/build/report/resources/BuildTraceReportResource.java
@@ -13,7 +13,6 @@ package org.eclipse.osee.ats.rest.internal.build.report.resources;
import java.io.OutputStream;
import java.util.Collection;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
@@ -45,7 +44,6 @@ import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -66,7 +64,6 @@ public class BuildTraceReportResource {
@Produces(MediaType.TEXT_HTML)
public StreamingOutput getBuildReport(@PathParam("programId") String programId, @PathParam("buildId") final String buildId, @DefaultValue("UNKNOWN") @QueryParam("program") final String programName, @DefaultValue("UNKNOWN") @QueryParam("build") final String buildName) throws OseeCoreException {
OrcsApi orcsApi = AtsApplication.getOrcsApi();
- final GraphReadable graph = orcsApi.getGraph(null);
final QueryFactory queryFactory = orcsApi.getQueryFactory(null);
final IOseeBranch branch = getBaselineBranch(buildId, queryFactory);
@@ -95,7 +92,7 @@ public class BuildTraceReportResource {
for (ArtifactReadable requirement : requirements) {
ResultSet<ArtifactReadable> verifiers =
- graph.getRelatedArtifacts(CoreRelationTypes.Verification__Verifier, requirement);
+ requirement.getRelated(CoreRelationTypes.Verification__Verifier);
requirementsToTests.put(requirement, verifiers);
}
@@ -123,10 +120,10 @@ public class BuildTraceReportResource {
private IOseeBranch getBaselineBranch(String buildId, QueryFactory queryFactory) throws OseeCoreException {
QueryBuilder builder = queryFactory.fromBranch(CoreBranches.COMMON);
ArtifactReadable buildArt = builder.andGuidsOrHrids(buildId).getResults().getExactlyOne();
- List<? extends AttributeReadable<String>> branchGuids =
+ ResultSet<? extends AttributeReadable<String>> branchGuids =
buildArt.getAttributes(AtsAttributeTypes.BaselineBranchGuid);
- Conditions.checkNotNullOrEmpty(branchGuids, "branchGuid");
- String baselineBranchGuid = branchGuids.iterator().next().getValue();
+ Conditions.checkNotNull(branchGuids, "branchGuid");
+ String baselineBranchGuid = branchGuids.getExactlyOne().getValue();
IOseeBranch branch = TokenFactory.createBranch(baselineBranchGuid, "TraceReport Branch");
return branch;
}
diff --git a/plugins/org.eclipse.osee.display.presenter.mocks/src/org/eclipse/osee/display/presenter/mocks/MockArtifact.java b/plugins/org.eclipse.osee.display.presenter.mocks/src/org/eclipse/osee/display/presenter/mocks/MockArtifact.java
index 9b6e017f48..8a22d81f15 100644
--- a/plugins/org.eclipse.osee.display.presenter.mocks/src/org/eclipse/osee/display/presenter/mocks/MockArtifact.java
+++ b/plugins/org.eclipse.osee.display.presenter.mocks/src/org/eclipse/osee/display/presenter/mocks/MockArtifact.java
@@ -23,6 +23,7 @@ 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.data.IRelationType;
import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.Identity;
import org.eclipse.osee.framework.core.data.ResultSet;
@@ -75,6 +76,7 @@ public class MockArtifact implements ArtifactReadable {
attributes.put(type, value);
}
+ @Override
public Collection<RelationType> getValidRelationTypes() {
return validRelationTypes;
}
@@ -136,7 +138,7 @@ public class MockArtifact implements ArtifactReadable {
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
- public <T> List<AttributeReadable<T>> getAttributes(IAttributeType attributeType) {
+ public <T> ResultSet<AttributeReadable<T>> getAttributes(IAttributeType attributeType) {
Collection<String> values = attributes.getValues(attributeType);
List<AttributeReadable<T>> toReturn = null;
if (values != null && !values.isEmpty()) {
@@ -148,7 +150,7 @@ public class MockArtifact implements ArtifactReadable {
} else {
toReturn = Collections.emptyList();
}
- return toReturn;
+ return new ResultSetList<AttributeReadable<T>>(toReturn);
}
@Override
@@ -172,14 +174,14 @@ public class MockArtifact implements ArtifactReadable {
}
@Override
- public List<AttributeReadable<Object>> getAttributes() {
+ public ResultSet<AttributeReadable<Object>> getAttributes() {
List<AttributeReadable<Object>> toReturn = new ArrayList<AttributeReadable<Object>>();
for (Entry<IAttributeType, Collection<String>> entry : attributes.entrySet()) {
for (String value : entry.getValue()) {
toReturn.add(new MockAttribute<Object>(entry.getKey(), value));
}
}
- return toReturn;
+ return new ResultSetList<AttributeReadable<Object>>(toReturn);
}
public void clearRelations() {
@@ -233,12 +235,12 @@ public class MockArtifact implements ArtifactReadable {
}
@Override
- public List<AttributeReadable<Object>> getAttributes(DeletionFlag deletionFlag) throws OseeCoreException {
+ public ResultSet<AttributeReadable<Object>> getAttributes(DeletionFlag deletionFlag) throws OseeCoreException {
return null;
}
@Override
- public <T> List<AttributeReadable<T>> getAttributes(IAttributeType attributeType, DeletionFlag deletionFlag) throws OseeCoreException {
+ public <T> ResultSet<AttributeReadable<T>> getAttributes(IAttributeType attributeType, DeletionFlag deletionFlag) throws OseeCoreException {
return null;
}
@@ -246,4 +248,45 @@ public class MockArtifact implements ArtifactReadable {
public AttributeReadable<Object> getAttributeById(AttributeId attributeId) throws OseeCoreException {
return null;
}
+
+ @Override
+ public int getMaximumRelationAllowed(IRelationTypeSide relationTypeSide) throws OseeCoreException {
+ return 0;
+ }
+
+ @Override
+ public Collection<? extends IRelationType> getExistingRelationTypes() throws OseeCoreException {
+ return null;
+ }
+
+ @Override
+ public ArtifactReadable getParent() throws OseeCoreException {
+ return null;
+ }
+
+ @Override
+ public ResultSet<ArtifactReadable> getChildren() throws OseeCoreException {
+ return null;
+ }
+
+ @Override
+ public ResultSet<ArtifactReadable> getRelated(IRelationTypeSide relationTypeSide) throws OseeCoreException {
+ return null;
+ }
+
+ @Override
+ public boolean areRelated(IRelationTypeSide typeAndSide, ArtifactReadable readable) throws OseeCoreException {
+ return false;
+ }
+
+ @Override
+ public int getRelatedCount(IRelationTypeSide typeAndSide) throws OseeCoreException {
+ return 0;
+ }
+
+ @Override
+ public String getRationale(IRelationTypeSide typeAndSide, ArtifactReadable readable) throws OseeCoreException {
+ return null;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java b/plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java
index 555ed9f318..235ac83dd6 100644
--- a/plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java
+++ b/plugins/org.eclipse.osee.display.presenter/src/org/eclipse/osee/display/presenter/ArtifactProviderImpl.java
@@ -42,9 +42,10 @@ import org.eclipse.osee.framework.core.enums.TokenOrderType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.logger.Log;
+import org.eclipse.osee.orcs.OrcsTypes;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.search.Match;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -61,13 +62,13 @@ public class ArtifactProviderImpl implements ArtifactProvider {
private final ArtifactProviderCache cache = new ArtifactProviderCache();
private final ArtifactFilter filter = new ArtifactFilter(this);
- private final GraphReadable graph;
+ private final OrcsTypes orcsTypes;
- public ArtifactProviderImpl(Log logger, ExecutorAdmin executorAdmin, QueryFactory queryFactory, GraphReadable graph) {
+ public ArtifactProviderImpl(Log logger, ExecutorAdmin executorAdmin, QueryFactory queryFactory, OrcsTypes orcsTypes) {
this.logger = logger;
this.executorAdmin = executorAdmin;
this.queryFactory = queryFactory;
- this.graph = graph;
+ this.orcsTypes = orcsTypes;
}
protected void setFilterAllTypesAllowed(boolean allTypesAllowed) {
@@ -134,7 +135,7 @@ public class ArtifactProviderImpl implements ArtifactProvider {
@Override
public ResultSet<ArtifactReadable> getRelatedArtifacts(ArtifactReadable art, IRelationTypeSide relationTypeSide) throws OseeCoreException {
- final ResultSet<ArtifactReadable> artifacts = graph.getRelatedArtifacts(relationTypeSide, art);
+ final ResultSet<ArtifactReadable> artifacts = art.getRelated(relationTypeSide);
List<ArtifactReadable> results = Collections.emptyList();
try {
FilteredArtifactCallable callable = new FilteredArtifactCallable(executorAdmin, filter, artifacts);
@@ -149,7 +150,7 @@ public class ArtifactProviderImpl implements ArtifactProvider {
@Override
public ArtifactReadable getRelatedArtifact(ArtifactReadable art, IRelationTypeSide relationTypeSide) throws OseeCoreException {
- ArtifactReadable item = graph.getRelatedArtifacts(relationTypeSide, art).getOneOrNull();
+ ArtifactReadable item = art.getRelated(relationTypeSide).getOneOrNull();
try {
if (!filter.accept(item)) {
item = null;
@@ -175,10 +176,10 @@ public class ArtifactProviderImpl implements ArtifactProvider {
@Override
public Collection<? extends IRelationType> getValidRelationTypes(ArtifactReadable art) throws OseeCoreException {
- Collection<IRelationTypeSide> existingRelationTypes = graph.getExistingRelationTypes(art);
+ Collection<? extends IRelationType> existingRelationTypes = art.getExistingRelationTypes();
Set<IRelationType> toReturn = new HashSet<IRelationType>();
- for (IRelationTypeSide side : existingRelationTypes) {
- toReturn.add(side);
+ for (IRelationType type : existingRelationTypes) {
+ toReturn.add(type);
}
List<? extends IRelationType> listToReturn = Lists.newLinkedList(toReturn);
java.util.Collections.sort(listToReturn);
@@ -187,12 +188,12 @@ public class ArtifactProviderImpl implements ArtifactProvider {
@Override
public String getSideAName(IRelationType type) throws OseeCoreException {
- return graph.getTypes().getSideAName(type);
+ return orcsTypes.getRelationTypes().getSideAName(type);
}
@Override
public String getSideBName(IRelationType type) throws OseeCoreException {
- return graph.getTypes().getSideBName(type);
+ return orcsTypes.getRelationTypes().getSideBName(type);
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java
index 0a41d37bb6..2a4d087506 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/AbstractIdentity.java
@@ -23,8 +23,8 @@ public abstract class AbstractIdentity<T> implements Identity<T> {
@Override
public boolean equals(Object obj) {
- if (obj instanceof AbstractIdentity) {
- return getGuid().equals(((AbstractIdentity<?>) obj).getGuid());
+ if (obj instanceof Identity) {
+ return getGuid().equals(((Identity<?>) obj).getGuid());
}
return false;
}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/Identity.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/Identity.java
index bce2b3766e..dc6cceb4c4 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/Identity.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/Identity.java
@@ -15,7 +15,9 @@ package org.eclipse.osee.framework.core.data;
* @author Ryan D. Brooks
*/
public interface Identity<T> {
- public abstract T getGuid();
- public abstract boolean matches(Identity<?>... identities);
+ T getGuid();
+
+ boolean matches(Identity<?>... identities);
+
}
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java
index c5f8c7e3c5..2e8e5c6dfe 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java
@@ -190,6 +190,7 @@ public final class TokenFactory {
}
private final static class RelationTypeSideToken extends NamedIdentity<Long> implements IRelationTypeSide {
+
private final RelationSide relationSide;
private RelationTypeSideToken opposite;
@@ -230,6 +231,11 @@ public final class TokenFactory {
}
return opposite;
}
+
+ @Override
+ public String toString() {
+ return String.format("RelationTypeSide - uuid=[%s] type=[%s] side=[%s]", getGuid(), getName(), getSide());
+ }
}
}
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 8ed221c763..128ee58688 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
@@ -14,8 +14,7 @@ import org.eclipse.osee.orcs.core.internal.artifact.ArtifactTestSuite;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeTestSuite;
import org.eclipse.osee.orcs.core.internal.branch.BranchTestSuite;
import org.eclipse.osee.orcs.core.internal.graph.GraphTestSuite;
-import org.eclipse.osee.orcs.core.internal.loader.LoaderTestSuite;
-import org.eclipse.osee.orcs.core.internal.proxy.ProxyTestSuite;
+import org.eclipse.osee.orcs.core.internal.proxy.impl.ProxyImplTestSuite;
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;
@@ -33,9 +32,8 @@ import org.junit.runners.Suite;
AttributeTestSuite.class,
BranchTestSuite.class,
GraphTestSuite.class,
- LoaderTestSuite.class,
- ProxyTestSuite.class,
RelationTestSuite.class,
+ ProxyImplTestSuite.class,
QueryTestSuite.class,
TransactionTestSuite.class,
TypesTestSuite.class,
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java
index 920e1a7441..4f23337181 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactoryTest.java
@@ -36,7 +36,6 @@ import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeManager;
-import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
import org.eclipse.osee.orcs.core.internal.util.ValueProviderFactory;
@@ -66,7 +65,6 @@ public class ArtifactFactoryTest {
@Mock private Branch branch;
@Mock private IArtifactType artifactType;
@Mock private ArtifactData artifactData;
- @Mock private RelationContainer relationContainer;
@Mock private VersionData artifactVersion;
@Mock private ArtifactDataFactory dataFactory;
@@ -91,8 +89,7 @@ public class ArtifactFactoryTest {
public void init() throws OseeCoreException {
MockitoAnnotations.initMocks(this);
- artifactFactory =
- new ArtifactFactory(dataFactory, attributeFactory, relationFactory, artifactTypeCache, providerFactory);
+ artifactFactory = new ArtifactFactory(dataFactory, attributeFactory, artifactTypeCache, providerFactory);
guid = GUID.create();
@@ -116,8 +113,6 @@ public class ArtifactFactoryTest {
when(otherArtifactData.getTypeUuid()).thenReturn(65L);
when(otherArtifactData.getVersion()).thenReturn(artifactVersion);
- when(relationFactory.createRelationContainer(45)).thenReturn(relationContainer);
-
when(providerFactory.createBranchProvider(artifactData)).thenReturn(branchProvider);
when(providerFactory.createBranchProvider(otherArtifactData)).thenReturn(branchProvider);
@@ -139,8 +134,6 @@ public class ArtifactFactoryTest {
@Test
public void testCreateArtifactFromArtifactData() throws OseeCoreException {
- when(relationFactory.createRelationContainer(45)).thenReturn(relationContainer);
-
Artifact artifact = artifactFactory.createArtifact(artifactData);
assertEquals(artifactType, artifact.getArtifactType());
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
index 19c1d658ee..af8b25519e 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/ArtifactTest.java
@@ -34,7 +34,6 @@ import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.VersionData;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl;
-import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.junit.Assert;
@@ -57,7 +56,6 @@ public class ArtifactTest {
@Mock private Artifact artifact;
@Mock private ArtifactData artifactData;
@Mock private AttributeFactory attributeFactory;
- @Mock private RelationContainer relationContainer;
@Mock private ValueProvider<Branch, OrcsData> branchProvider;
@Mock private ArtifactTypes types;
@@ -83,7 +81,7 @@ public class ArtifactTest {
@Before
public void init() throws OseeCoreException {
MockitoAnnotations.initMocks(this);
- artifact = new ArtifactImpl(types, artifactData, attributeFactory, relationContainer, branchProvider);
+ artifact = new ArtifactImpl(types, artifactData, attributeFactory, branchProvider);
when(types.isValidAttributeType(any(IArtifactType.class), any(Branch.class), any(IAttributeType.class))).thenReturn(
true);
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java
deleted file mode 100644
index fc37cb8e2f..0000000000
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImplTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * 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.loader;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.eclipse.osee.framework.core.data.IRelationType;
-import org.eclipse.osee.framework.core.data.TokenFactory;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.enums.RelationSide;
-import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.core.ds.VersionData;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
-import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
-import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
-import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
-import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
-import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
-import org.eclipse.osee.orcs.core.internal.relation.RelationContainerImpl;
-import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
-import org.eclipse.osee.orcs.data.RelationTypes;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-
-/**
- * Test Case for {@link AritfactBuilderImpl}
- *
- * @author Andrew M. Finkbeiner
- * @author Roberto E. Escobar
- */
-public class ArtifactBuilderImplTest {
-
- // @formatter:off
- @Mock private Log logger;
- @Mock private ExternalArtifactManager proxyFactory;
- @Mock private ArtifactFactory artifactFactory;
- @Mock private AttributeFactory attributeFactory;
- @Mock private RelationFactory relationFactory;
-
- @Mock private OrcsSession session;
- @Mock private Artifact artifact;
- @Mock private ArtifactData artifactData;
- @Mock private AttributeData attributeData;
- // @formatter:on
-
- private ArtifactBuilder builder;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- builder =
- new ArtifactBuilderImpl(logger, proxyFactory, artifactFactory, attributeFactory, relationFactory, session);
- }
-
- @Test
- public void testAttributeDataValid() throws OseeCoreException {
- when(artifactFactory.createArtifact(artifactData)).thenReturn(artifact);
- when(artifact.getLocalId()).thenReturn(45);
-
- when(attributeData.getArtifactId()).thenReturn(45);
-
- builder.onData(artifactData);
- builder.onData(attributeData);
-
- verify(attributeFactory).createAttribute(artifact, attributeData);
- verify(logger, times(0)).warn("");
- }
-
- @Test
- public void testAttributeDataNotFound() throws OseeCoreException {
- when(artifactFactory.createArtifact(artifactData)).thenReturn(artifact);
- when(artifact.getLocalId()).thenReturn(45);
-
- when(attributeData.getArtifactId()).thenReturn(45);
-
- builder.onData(attributeData);
-
- verify(attributeFactory, times(0)).createAttribute(artifact, attributeData);
- verify(logger).warn("Orphaned attribute detected - [%s]", attributeData);
- }
-
- @Ignore
- @Test
- public void testRelationCountMatches() throws OseeCoreException {
- RelationTypes cache = createAndPopulate();
- Map<Integer, RelationContainer> containers = getRelationProviderList(cache, 22);
- List<RelationData> datas = getTestData();
- doSetup(datas, containers);
-
- for (RelationData data : datas) {
- builder.onData(data);
- }
-
- checkRelationCount(containers.get(1), RelationSide.SIDE_B, 9);
- checkRelationCount(containers.get(1), RelationSide.SIDE_A, 0);
- checkRelationCount(containers.get(2), RelationSide.SIDE_B, 0);
- checkRelationCount(containers.get(3), RelationSide.SIDE_B, 6);
- checkRelationCount(containers.get(3), RelationSide.SIDE_A, 1);
- checkRelationCount(containers.get(4), RelationSide.SIDE_B, 7);
- }
-
- @Ignore
- @Test
- public void testRelatedArtifactsMatch() throws OseeCoreException {
- RelationTypes cache = createAndPopulate();
- Map<Integer, RelationContainer> containers = getRelationProviderList(cache, 22);
- List<RelationData> datas = getTestData();
- doSetup(datas, containers);
-
- checkRelatedArtifacts(containers.get(1), RelationSide.SIDE_B, 2, 3, 4, 5, 6, 7, 8, 9, 10);
- checkRelatedArtifacts(containers.get(1), RelationSide.SIDE_A);
- checkRelatedArtifacts(containers.get(2), RelationSide.SIDE_B);
- checkRelatedArtifacts(containers.get(3), RelationSide.SIDE_B, 11, 12, 13, 14, 15, 16);
- checkRelatedArtifacts(containers.get(3), RelationSide.SIDE_A, 1);
- checkRelatedArtifacts(containers.get(4), RelationSide.SIDE_B, 17, 18, 19, 20, 21, 22, 2);
- }
-
- private void doSetup(List<RelationData> datas, Map<Integer, RelationContainer> containers) throws OseeCoreException {
- for (RelationData data : datas) {
- createAndDispatchArtifact(containers, data.getArtIdA());
- createAndDispatchArtifact(containers, data.getArtIdB());
- }
- }
-
- private void createAndDispatchArtifact(Map<Integer, RelationContainer> containers, int id) throws OseeCoreException {
- Artifact artifact = Mockito.mock(Artifact.class);
- ArtifactData artData = Mockito.mock(ArtifactData.class);
- when(artifactFactory.createArtifact(artData)).thenReturn(artifact);
- when(artifact.getLocalId()).thenReturn(id);
- when(artData.getLocalId()).thenReturn(id);
-
- RelationContainer container = containers.get(id);
- when(artifact.getRelationContainer()).thenReturn(container);
-
- builder.onData(artData);
- }
-
- private void checkRelatedArtifacts(RelationContainer relationContainer, RelationSide side, int... expected) {
- List<Integer> relatedArtifacts = new ArrayList<Integer>();
- relationContainer.getArtifactIds(relatedArtifacts, TokenFactory.createRelationTypeSide(side, 1, "blah"));
- Assert.assertTrue(String.format("Expected %d matches found %d", expected.length, relatedArtifacts.size()),
- expected.length == relatedArtifacts.size());
- for (int value : expected) {
- Assert.assertTrue(String.format("Expected relation to id[%d]", value), relatedArtifacts.contains(value));
- }
- }
-
- private Map<Integer, RelationContainer> getRelationProviderList(RelationTypes relationTypeCache, int size) {
- Map<Integer, RelationContainer> toReturn = new HashMap<Integer, RelationContainer>();
- for (int i = 1; i <= size; i++) {
- toReturn.put(i, new RelationContainerImpl(i, relationTypeCache));
- }
- return toReturn;
- }
-
- public RelationTypes createAndPopulate() throws OseeCoreException {
- IRelationType type = mock(IRelationType.class);
- RelationTypes cache = mock(RelationTypes.class);
-
- when(type.getGuid()).thenReturn(1L);
- when(type.getName()).thenReturn("test");
-
- when(cache.getByUuid(1L)).thenReturn(type);
- when(cache.getSideAName(type)).thenReturn("sideAName");
- when(cache.getSideBName(type)).thenReturn("sideBName");
- when(cache.getArtifactTypeSideA(type)).thenReturn(CoreArtifactTypes.Artifact);
- when(cache.getArtifactTypeSideB(type)).thenReturn(CoreArtifactTypes.Artifact);
- when(cache.getMultiplicity(type)).thenReturn(RelationTypeMultiplicity.MANY_TO_MANY);
- when(cache.getDefaultOrderTypeGuid(type)).thenReturn("");
-
- when(cache.getSideName(type, RelationSide.SIDE_A)).thenReturn("sideAName");
- when(cache.getSideName(type, RelationSide.SIDE_B)).thenReturn("sideBName");
-
- when(cache.getArtifactType(eq(type), any(RelationSide.class))).thenReturn(CoreArtifactTypes.Artifact);
- return cache;
- }
-
- private void checkRelationCount(RelationContainer relationContainer, RelationSide side, int size) {
- int count = relationContainer.getRelationCount(TokenFactory.createRelationTypeSide(side, 1, "blah"));
- Assert.assertEquals(
- String.format("We did not get the expected number of relations back [%d != %d]", size, count), size, count);
- }
-
- private List<RelationData> getTestData() {
- List<RelationData> datas = new ArrayList<RelationData>();
- RelationCsvReader csvReader = new RelationCsvReader(datas);
- // #ArtIdA ArtIdB BranchId GammaId ModType Rationale RelationId RelationTypeId
- csvReader.onRow(1, 2, 1, 1L, ModificationType.NEW, "yay", 1, 1L);
- csvReader.onRow(1, 3, 1, 1L, ModificationType.NEW, "yay", 2, 1L);
- csvReader.onRow(1, 4, 1, 1L, ModificationType.NEW, "yay", 3, 1L);
- csvReader.onRow(1, 5, 1, 1L, ModificationType.NEW, "yay", 4, 1L);
- csvReader.onRow(1, 6, 1, 1L, ModificationType.NEW, "yay", 5, 1L);
- csvReader.onRow(1, 7, 1, 1L, ModificationType.NEW, "yay", 6, 1L);
- csvReader.onRow(1, 8, 1, 1L, ModificationType.NEW, "yay", 7, 1L);
- csvReader.onRow(1, 9, 1, 1L, ModificationType.NEW, "yay", 8, 1L);
- csvReader.onRow(1, 10, 1, 1L, ModificationType.NEW, "yay", 9, 1L);
- csvReader.onRow(3, 11, 1, 1L, ModificationType.NEW, "yay", 10, 1L);
- csvReader.onRow(1, 3, 1, 1L, ModificationType.NEW, "yay", 10, 1L);
- csvReader.onRow(3, 12, 1, 1L, ModificationType.NEW, "yay", 11, 1L);
- csvReader.onRow(3, 13, 1, 1L, ModificationType.NEW, "yay", 12, 1L);
- csvReader.onRow(3, 14, 1, 1L, ModificationType.NEW, "yay", 13, 1L);
- csvReader.onRow(3, 15, 1, 1L, ModificationType.NEW, "yay", 14, 1L);
- csvReader.onRow(3, 16, 1, 1L, ModificationType.NEW, "yay", 15, 1L);
- csvReader.onRow(4, 17, 1, 1L, ModificationType.NEW, "yay", 16, 1L);
- csvReader.onRow(4, 18, 1, 1L, ModificationType.NEW, "yay", 17, 1L);
- csvReader.onRow(4, 19, 1, 1L, ModificationType.NEW, "yay", 18, 1L);
- csvReader.onRow(4, 20, 1, 1L, ModificationType.NEW, "yay", 19, 1L);
- csvReader.onRow(4, 21, 1, 1L, ModificationType.NEW, "yay", 20, 1L);
- csvReader.onRow(4, 22, 1, 1L, ModificationType.NEW, "yay", 21, 1L);
- csvReader.onRow(4, 2, 1, 1L, ModificationType.NEW, "yay", 21, 1L);
- return datas;
- }
-
- public static class RelationCsvReader {
-
- private final List<RelationData> data;
-
- public RelationCsvReader(List<RelationData> data) {
- this.data = data;
- }
-
- public void onRow(Object... row) {
- //ArtIdA,ArtIdB,BranchId,GammaId,ModType,Rationale,RelationId,RelationTypeId
- if (row.length != 8) {
- Assert.assertTrue("Data file is not formatted correctly", false);
- }
-
- VersionData version = mock(VersionData.class);
- RelationData relationRow = Mockito.mock(RelationData.class);
-
- int index = 0;
- when(relationRow.getArtIdA()).thenReturn((Integer) row[index++]);
- when(relationRow.getArtIdB()).thenReturn((Integer) row[index++]);
- when(version.getBranchId()).thenReturn((Integer) row[index++]);
- when(version.getGammaId()).thenReturn((Long) row[index++]);
- when(relationRow.getModType()).thenReturn((ModificationType) row[index++]);
- when(relationRow.getRationale()).thenReturn((String) row[index++]);
- when(relationRow.getLocalId()).thenReturn((Integer) row[index++]);
- when(relationRow.getTypeUuid()).thenReturn((Long) row[index++]);
- when(relationRow.getVersion()).thenReturn(version);
-
- data.add(relationRow);
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java
deleted file mode 100644
index c4a8bf0533..0000000000
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImplTest.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * 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.loader;
-
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.osee.executor.admin.HasCancellation;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.DataLoader;
-import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
-import org.eclipse.osee.orcs.core.ds.QueryContext;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilderFactory;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoader;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-
-/**
- * Test Case for {@link ArtifactLoaderFactoryImpl}
- *
- * @author Andrew M. Finkbeiner
- * @author Roberto E. Escobar
- */
-public class ArtifactLoaderFactoryImplTest {
-
- // @formatter:off
- @Mock private DataLoaderFactory dataLoaderFactory;
- @Mock private ArtifactBuilderFactory builderFactory;
-
- @Mock private OrcsSession session;
- @Mock private QueryContext queryContext;
- @Mock private DataLoader dbLoader;
- @Mock private ArtifactBuilder builder;
- @Mock private HasCancellation cancellation;
-
- @Mock private ArtifactReadable art1;
- @Mock private ArtifactReadable art2;
- // @formatter:on
-
- private final IOseeBranch branch = CoreBranches.COMMON;
- private ArtifactLoaderFactory factory;
- private List<ArtifactReadable> artifacts;
-
- @Before
- public void setUp() {
- MockitoAnnotations.initMocks(this);
- factory = new ArtifactLoaderFactoryImpl(dataLoaderFactory, builderFactory);
- artifacts = Arrays.asList(art1, art2);
-
- String sessionId = GUID.create();
- when(session.getGuid()).thenReturn(sessionId);
- }
-
- @Test
- public void testLoadArtifactIdsAndMethodCalls() throws OseeCoreException {
- int[] ids = new int[] {1, 2, 3, 4, 5};
-
- when(dataLoaderFactory.fromBranchAndArtifactIds(session, branch, ids)).thenReturn(dbLoader);
-
- ArtifactLoader loader = factory.fromBranchAndArtifactIds(session, branch, ids);
- verify(dataLoaderFactory).fromBranchAndArtifactIds(session, branch, ids);
-
- loader.includeDeleted();
- verify(dbLoader).includeDeleted();
-
- loader.includeDeleted(true);
- verify(dbLoader).includeDeleted(true);
-
- when(dbLoader.isHeadTransaction()).thenReturn(true);
- assertEquals(true, loader.isHeadTransaction());
-
- when(dbLoader.getFromTransaction()).thenReturn(67);
- assertEquals(67, loader.getFromTransaction());
-
- when(dbLoader.getLoadLevel()).thenReturn(LoadLevel.SHALLOW);
- assertEquals(LoadLevel.SHALLOW, loader.getLoadLevel());
-
- loader.areDeletedIncluded();
- verify(dbLoader).areDeletedIncluded();
-
- loader.headTransaction();
- verify(dbLoader).headTransaction();
-
- loader.resetToDefaults();
- verify(dbLoader).resetToDefaults();
-
- loader.fromTransaction(36);
- verify(dbLoader).fromTransaction(36);
-
- loader.setLoadLevel(LoadLevel.FULL);
- verify(dbLoader).setLoadLevel(LoadLevel.FULL);
- }
-
- @Test
- public void testLoad() throws OseeCoreException {
- List<Integer> ids = Arrays.asList(1, 2, 3, 4, 5);
-
- when(dataLoaderFactory.fromBranchAndArtifactIds(session, branch, ids)).thenReturn(dbLoader);
-
- ArtifactLoader loader = factory.fromBranchAndArtifactIds(session, branch, ids);
- verify(dataLoaderFactory).fromBranchAndArtifactIds(session, branch, ids);
-
- when(builderFactory.createArtifactBuilder(session)).thenReturn(builder);
- when(builder.getArtifacts()).thenReturn(artifacts);
-
- List<ArtifactReadable> actual = loader.load(cancellation);
- verify(dbLoader).load(cancellation, builder);
- assertEquals(artifacts, actual);
- }
-
- @Test
- public void testGetResults() throws OseeCoreException {
- int[] ids = new int[] {1, 2, 3, 4, 5};
-
- when(dataLoaderFactory.fromBranchAndArtifactIds(session, branch, ids)).thenReturn(dbLoader);
-
- ArtifactLoader loader = factory.fromBranchAndArtifactIds(session, branch, ids);
- verify(dataLoaderFactory).fromBranchAndArtifactIds(session, branch, ids);
-
- when(builderFactory.createArtifactBuilder(session)).thenReturn(builder);
- when(builder.getArtifacts()).thenReturn(artifacts);
-
- ResultSet<ArtifactReadable> result = loader.getResults(cancellation);
-
- verify(dbLoader).load(cancellation, builder);
- assertEquals(artifacts.size(), result.size());
- checkEquals(artifacts, result);
- }
-
- @Test
- public void testQueryContext() throws OseeCoreException {
- when(dataLoaderFactory.fromQueryContext(queryContext)).thenReturn(dbLoader);
-
- ArtifactLoader loader = factory.fromQueryContext(session, queryContext);
- verify(dataLoaderFactory).fromQueryContext(queryContext);
-
- when(builderFactory.createArtifactBuilder(session)).thenReturn(builder);
- when(builder.getArtifacts()).thenReturn(artifacts);
-
- ResultSet<ArtifactReadable> result = loader.getResults(cancellation);
-
- verify(dbLoader).load(cancellation, builder);
- assertEquals(artifacts.size(), result.size());
- checkEquals(artifacts, result);
- }
-
- private void checkEquals(Iterable<ArtifactReadable> expected, Iterable<ArtifactReadable> actual) {
- Iterator<ArtifactReadable> actuals = actual.iterator();
- Iterator<ArtifactReadable> expecteds = expected.iterator();
- while (expecteds.hasNext() && actuals.hasNext()) {
- assertEquals(expecteds.next(), actuals.next());
- }
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ProxyTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ProxyTestSuite.java
deleted file mode 100644
index ac6a9780b7..0000000000
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/ProxyTestSuite.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.proxy;
-
-import org.eclipse.osee.orcs.core.internal.proxy.impl.ExternalArtifactManagerTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author Roberto E. Escobar
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({ExternalArtifactManagerTest.class})
-public class ProxyTestSuite {
- // Test Suite
-}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImplTest.java
new file mode 100644
index 0000000000..3e3a753eaa
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImplTest.java
@@ -0,0 +1,494 @@
+/*******************************************************************************
+ * 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.proxy.impl;
+
+import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Active;
+import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Annotation;
+import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Name;
+import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
+import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Allocation__Requirement;
+import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Child;
+import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Parent;
+import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.DEFAULT_HIERARCHY;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_CHILD;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_PARENT;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+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.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.util.GUID;
+import org.eclipse.osee.framework.jdk.core.util.HumanReadableId;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+import org.eclipse.osee.orcs.core.internal.graph.GraphData;
+import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
+import org.eclipse.osee.orcs.core.internal.util.ResultSets;
+import org.eclipse.osee.orcs.data.ArtifactId;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.AttributeId;
+import org.eclipse.osee.orcs.data.AttributeReadable;
+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;
+
+/**
+ * Test Case for @{link ArtifactReadOnlyImpl}
+ *
+ * @author Roberto E. Escobar
+ */
+public class ArtifactReadOnlyImplTest {
+
+ //@formatter:off
+ @Mock private ExternalArtifactManager proxyManager;
+ @Mock private RelationManager relationManager;
+ @Mock private OrcsSession session;
+ @Mock private Artifact proxiedObject;
+ @Mock private GraphData graph;
+
+ @Mock private IAttributeType attributeType;
+ @Mock private IArtifactType artifactType;
+
+ @Mock private ArtifactReadable readable1;
+ @Mock private Artifact artifact1;
+
+ @Mock private AttributeId attributeId;
+
+ @Mock private Attribute<Object> attribute1;
+ @Mock private AttributeReadable<Object> attributeReadable1;
+ //@formatter:on
+
+ private ArtifactReadable readOnly;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ readOnly = new ArtifactReadOnlyImpl(proxyManager, relationManager, session, proxiedObject);
+
+ when(proxiedObject.getGraph()).thenReturn(graph);
+ }
+
+ @Test
+ public void testGetArtifactType() throws OseeCoreException {
+ when(proxiedObject.getArtifactType()).thenReturn(artifactType);
+
+ IArtifactType actual = readOnly.getArtifactType();
+
+ assertEquals(artifactType, actual);
+ verify(proxiedObject).getArtifactType();
+ }
+
+ @Test
+ public void testGetBranch() throws OseeCoreException {
+ when(proxiedObject.getBranch()).thenReturn(COMMON);
+
+ IOseeBranch actual = readOnly.getBranch();
+
+ assertEquals(COMMON, actual);
+ verify(proxiedObject).getBranch();
+ }
+
+ @Test
+ public void testGetGuid() {
+ String guid = GUID.create();
+ when(proxiedObject.getGuid()).thenReturn(guid);
+
+ String actual = readOnly.getGuid();
+
+ assertEquals(guid, actual);
+ verify(proxiedObject).getGuid();
+ }
+
+ @Test
+ public void testGetHumanReadableId() {
+ String hrid = HumanReadableId.generate();
+ when(proxiedObject.getHumanReadableId()).thenReturn(hrid);
+
+ String actual = readOnly.getHumanReadableId();
+
+ assertEquals(hrid, actual);
+ verify(proxiedObject).getHumanReadableId();
+ }
+
+ @Test
+ public void testGetLocalId() {
+ when(proxiedObject.getLocalId()).thenReturn(45);
+
+ int actual = readOnly.getLocalId();
+
+ assertEquals(45, actual);
+ verify(proxiedObject).getLocalId();
+ }
+
+ @Test
+ public void testGetName() {
+ String name = "This is my name";
+ when(proxiedObject.getName()).thenReturn(name);
+
+ String actual = readOnly.getName();
+
+ assertEquals(name, actual);
+ verify(proxiedObject).getName();
+ }
+
+ @Test
+ public void testGetTransaction() {
+ int transaction = 411232;
+ when(proxiedObject.getTransaction()).thenReturn(transaction);
+
+ int actual = readOnly.getTransaction();
+
+ assertEquals(transaction, actual);
+ verify(proxiedObject).getTransaction();
+ }
+
+ @Test
+ public void testIsDeleted() {
+ when(proxiedObject.isDeleted()).thenReturn(true);
+
+ boolean actual = readOnly.isDeleted();
+
+ assertEquals(true, actual);
+ verify(proxiedObject).isDeleted();
+ }
+
+ @Test
+ public void testIsOfType() throws OseeCoreException {
+ IArtifactType type1 = mock(IArtifactType.class);
+ IArtifactType type2 = mock(IArtifactType.class);
+ when(proxiedObject.isOfType(type1, type2)).thenReturn(true);
+
+ boolean actual = readOnly.isOfType(type1, type2);
+
+ assertEquals(true, actual);
+ verify(proxiedObject).isOfType(type1, type2);
+ }
+
+ @Test
+ public void testGetExistingAttributeTypes() throws OseeCoreException {
+ List<? extends IAttributeType> types = Arrays.asList(Active, Name);
+ when(proxiedObject.getExistingAttributeTypes()).thenAnswer(answer(types));
+
+ Collection<? extends IAttributeType> actual = readOnly.getExistingAttributeTypes();
+
+ assertEquals(types, actual);
+ verify(proxiedObject).getExistingAttributeTypes();
+ }
+
+ @Test
+ public void testGetValidAttributeTypes() throws OseeCoreException {
+ List<? extends IAttributeType> types = Arrays.asList(Active, Name, Annotation);
+ when(proxiedObject.getValidAttributeTypes()).thenAnswer(answer(types));
+
+ Collection<? extends IAttributeType> actual = readOnly.getValidAttributeTypes();
+
+ assertEquals(types, actual);
+ verify(proxiedObject).getValidAttributeTypes();
+ }
+
+ @Test
+ public void testGetAttributeCount1() throws OseeCoreException {
+ when(proxiedObject.getAttributeCount(attributeType)).thenReturn(45);
+
+ int actual = readOnly.getAttributeCount(attributeType);
+
+ assertEquals(45, actual);
+ verify(proxiedObject).getAttributeCount(attributeType);
+ }
+
+ @Test
+ public void testGetAttributeCount2() throws OseeCoreException {
+ when(proxiedObject.getAttributeCount(attributeType, EXCLUDE_DELETED)).thenReturn(47);
+
+ int actual = readOnly.getAttributeCount(attributeType, EXCLUDE_DELETED);
+
+ assertEquals(47, actual);
+ verify(proxiedObject).getAttributeCount(attributeType, EXCLUDE_DELETED);
+ }
+
+ @Test
+ public void testIsAttributeTypeValid() throws OseeCoreException {
+ when(proxiedObject.isAttributeTypeValid(attributeType)).thenReturn(true);
+
+ boolean actual = readOnly.isAttributeTypeValid(attributeType);
+
+ assertEquals(true, actual);
+ verify(proxiedObject).isAttributeTypeValid(attributeType);
+ }
+
+ @Test
+ public void testGetAttributeValues() throws OseeCoreException {
+ List<Long> values = Arrays.asList(1L, 2L, 3L);
+ when(proxiedObject.getAttributeValues(attributeType)).thenAnswer(answer(values));
+
+ List<Long> actual = readOnly.getAttributeValues(attributeType);
+
+ assertEquals(values, actual);
+ verify(proxiedObject).getAttributeValues(attributeType);
+ }
+
+ @Test
+ public void testGetSoleAttributeValue() throws OseeCoreException {
+ Date date = new Date();
+ when(proxiedObject.getSoleAttributeValue(attributeType)).thenReturn(date);
+
+ Date actual = readOnly.getSoleAttributeValue(attributeType);
+
+ assertEquals(date, actual);
+ verify(proxiedObject).getSoleAttributeValue(attributeType);
+ }
+
+ @Test
+ public void testGetSoleAttributeAsString1() throws OseeCoreException {
+ String expected = "Hello";
+ when(proxiedObject.getSoleAttributeAsString(attributeType)).thenReturn(expected);
+
+ String actual = readOnly.getSoleAttributeAsString(attributeType);
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getSoleAttributeAsString(attributeType);
+ }
+
+ @Test
+ public void testGetSoleAttributeAsString2() throws OseeCoreException {
+ String expected = "AnotherValue";
+ when(proxiedObject.getSoleAttributeAsString(attributeType, "Hello")).thenReturn(expected);
+
+ String actual = readOnly.getSoleAttributeAsString(attributeType, "Hello");
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getSoleAttributeAsString(attributeType, "Hello");
+ }
+
+ @Test
+ public void testGetValidRelationTypes() throws OseeCoreException {
+ List<? extends IRelationType> types = Arrays.asList(CoreRelationTypes.Default_Hierarchical__Child);
+
+ when(relationManager.getValidRelationTypes(session, proxiedObject)).thenAnswer(answer(types));
+
+ Collection<? extends IRelationType> actual = readOnly.getValidRelationTypes();
+
+ assertEquals(types, actual);
+ verify(relationManager).getValidRelationTypes(session, proxiedObject);
+ }
+
+ @Test
+ public void testAreRelated() throws OseeCoreException {
+ when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1);
+ when(relationManager.areRelated(session, graph, proxiedObject, DEFAULT_HIERARCHY, artifact1)).thenReturn(true);
+
+ boolean actual = readOnly.areRelated(Default_Hierarchical__Child, readable1);
+
+ assertEquals(true, actual);
+ verify(proxyManager).asInternalArtifact(readable1);
+ verify(relationManager).areRelated(session, graph, proxiedObject, DEFAULT_HIERARCHY, artifact1);
+ }
+
+ @Test
+ public void testGetParent() throws OseeCoreException {
+ when(relationManager.getParent(session, graph, proxiedObject)).thenReturn(artifact1);
+ when(proxyManager.asExternalArtifact(session, artifact1)).thenReturn(readable1);
+
+ ArtifactReadable actual = readOnly.getParent();
+
+ assertEquals(readable1, actual);
+ verify(relationManager).getParent(session, graph, proxiedObject);
+ verify(proxyManager).asExternalArtifact(session, artifact1);
+ }
+
+ @Test
+ public void testGetExistingRelationTypes() throws OseeCoreException {
+ List<? extends IRelationType> types = Arrays.asList(Allocation__Requirement);
+ when(relationManager.getExistingRelationTypes(session, graph, proxiedObject)).thenAnswer(answer(types));
+
+ Collection<? extends IRelationType> actual = readOnly.getExistingRelationTypes();
+
+ assertEquals(types, actual);
+ verify(relationManager).getExistingRelationTypes(session, graph, proxiedObject);
+ }
+
+ @Test
+ public void testGetMaximumRelationAllowed() throws OseeCoreException {
+ IRelationTypeSide typeAndSide = Default_Hierarchical__Child;
+ when(relationManager.getMaximumRelationAllowed(session, DEFAULT_HIERARCHY, proxiedObject, IS_PARENT)).thenReturn(
+ 6);
+
+ int actual = readOnly.getMaximumRelationAllowed(typeAndSide);
+
+ assertEquals(6, actual);
+ verify(relationManager).getMaximumRelationAllowed(session, DEFAULT_HIERARCHY, proxiedObject, IS_PARENT);
+ }
+
+ @Test
+ public void testGetRationale() throws OseeCoreException {
+ String expected = "This is my rationale";
+ when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1);
+ when(relationManager.getRationale(session, graph, artifact1, DEFAULT_HIERARCHY, proxiedObject)).thenReturn(
+ expected);
+
+ String actual = readOnly.getRationale(Default_Hierarchical__Parent, readable1);
+
+ assertEquals(expected, actual);
+
+ verify(relationManager).getRationale(session, graph, artifact1, DEFAULT_HIERARCHY, proxiedObject);
+ }
+
+ @Test
+ public void testGetRelatedCount() throws OseeCoreException {
+ int expected = 35;
+ when(relationManager.getRelatedCount(session, graph, DEFAULT_HIERARCHY, proxiedObject, IS_CHILD)).thenReturn(
+ expected);
+
+ int actual = readOnly.getRelatedCount(Default_Hierarchical__Parent);
+
+ assertEquals(expected, actual);
+ verify(relationManager).getRelatedCount(session, graph, DEFAULT_HIERARCHY, proxiedObject, IS_CHILD);
+ }
+
+ @Test
+ public void testGetRelated() throws OseeCoreException {
+ ResultSet<ArtifactReadable> expected = ResultSets.singleton(readable1);
+
+ ResultSet<Artifact> resultSet1 = ResultSets.singleton(artifact1);
+ when(relationManager.getRelated(session, graph, DEFAULT_HIERARCHY, proxiedObject, IS_CHILD)).thenAnswer(
+ answer(resultSet1));
+ when(proxyManager.asExternalArtifacts(session, resultSet1)).thenReturn(expected);
+
+ ResultSet<ArtifactReadable> actual = readOnly.getRelated(Default_Hierarchical__Parent);
+
+ assertEquals(expected, actual);
+ verify(relationManager).getRelated(session, graph, DEFAULT_HIERARCHY, proxiedObject, IS_CHILD);
+ verify(proxyManager).asExternalArtifacts(session, resultSet1);
+ }
+
+ @Test
+ public void testGetChildren() throws OseeCoreException {
+ ResultSet<ArtifactReadable> expected = ResultSets.singleton(readable1);
+
+ ResultSet<Artifact> resultSet1 = ResultSets.singleton(artifact1);
+ when(relationManager.getChildren(session, graph, proxiedObject)).thenAnswer(answer(resultSet1));
+ when(proxyManager.asExternalArtifacts(session, resultSet1)).thenReturn(expected);
+
+ ResultSet<ArtifactReadable> actual = readOnly.getChildren();
+
+ assertEquals(expected, actual);
+ verify(relationManager).getChildren(session, graph, proxiedObject);
+ verify(proxyManager).asExternalArtifacts(session, resultSet1);
+ }
+
+ @Test
+ public void testGetAttributeById() throws OseeCoreException {
+ when(proxiedObject.getAttributeById(attributeId)).thenAnswer(answer(attribute1));
+ when(proxyManager.asExternalAttribute(session, attribute1)).thenReturn(attributeReadable1);
+
+ AttributeReadable<Object> actual = readOnly.getAttributeById(attributeId);
+
+ assertEquals(attributeReadable1, actual);
+ verify(proxiedObject).getAttributeById(attributeId);
+ verify(proxyManager).asExternalAttribute(session, attribute1);
+ }
+
+ @Test
+ public void testGetAttributes1() throws OseeCoreException {
+ List<Attribute<Object>> attributes1 = Collections.singletonList(attribute1);
+ ResultSet<? extends AttributeReadable<Object>> expected = ResultSets.singleton(attributeReadable1);
+ when(proxiedObject.getAttributes()).thenAnswer(answer(attributes1));
+ when(proxyManager.asExternalAttributes(session, attributes1)).thenAnswer(answer(expected));
+
+ ResultSet<? extends AttributeReadable<Object>> actual = readOnly.getAttributes();
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getAttributes();
+ verify(proxyManager).asExternalAttributes(session, attributes1);
+ }
+
+ @Test
+ public void testGetAttributes2() throws OseeCoreException {
+ List<Attribute<Object>> attributes1 = Collections.singletonList(attribute1);
+ ResultSet<? extends AttributeReadable<Object>> expected = ResultSets.singleton(attributeReadable1);
+ when(proxiedObject.getAttributes(EXCLUDE_DELETED)).thenAnswer(answer(attributes1));
+ when(proxyManager.asExternalAttributes(session, attributes1)).thenAnswer(answer(expected));
+
+ ResultSet<? extends AttributeReadable<Object>> actual = readOnly.getAttributes(EXCLUDE_DELETED);
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getAttributes(EXCLUDE_DELETED);
+ verify(proxyManager).asExternalAttributes(session, attributes1);
+ }
+
+ @Test
+ public void testGetAttributes3() throws OseeCoreException {
+ List<Attribute<Object>> attributes1 = Collections.singletonList(attribute1);
+ ResultSet<? extends AttributeReadable<Object>> expected = ResultSets.singleton(attributeReadable1);
+ when(proxiedObject.getAttributes(attributeType)).thenAnswer(answer(attributes1));
+ when(proxyManager.asExternalAttributes(session, attributes1)).thenAnswer(answer(expected));
+
+ ResultSet<? extends AttributeReadable<Object>> actual = readOnly.getAttributes(attributeType);
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getAttributes(attributeType);
+ verify(proxyManager).asExternalAttributes(session, attributes1);
+ }
+
+ @Test
+ public void testGetAttributes4() throws OseeCoreException {
+ List<Attribute<Object>> attributes1 = Collections.singletonList(attribute1);
+ ResultSet<? extends AttributeReadable<Object>> expected = ResultSets.singleton(attributeReadable1);
+ when(proxiedObject.getAttributes(attributeType, EXCLUDE_DELETED)).thenAnswer(answer(attributes1));
+ when(proxyManager.asExternalAttributes(session, attributes1)).thenAnswer(answer(expected));
+
+ ResultSet<? extends AttributeReadable<Object>> actual = readOnly.getAttributes(attributeType, EXCLUDE_DELETED);
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getAttributes(attributeType, EXCLUDE_DELETED);
+ verify(proxyManager).asExternalAttributes(session, attributes1);
+ }
+
+ @Test
+ public void testMatches() {
+ ArtifactId artifact = mock(ArtifactId.class);
+ when(proxiedObject.matches(artifact)).thenReturn(true);
+
+ boolean actual = readOnly.matches(artifact);
+
+ assertEquals(true, actual);
+ verify(proxiedObject).matches(artifact);
+ }
+
+ private static <T> Answer<T> answer(final T value) {
+ return new Answer<T>() {
+
+ @Override
+ public T answer(InvocationOnMock invocation) throws Throwable {
+ return value;
+ }
+ };
+ }
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AttributeReadOnlyImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AttributeReadOnlyImplTest.java
new file mode 100644
index 0000000000..77d255c814
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AttributeReadOnlyImplTest.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * 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.proxy.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Date;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.data.AttributeId;
+import org.eclipse.osee.orcs.data.AttributeReadable;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for @{link AttributeReadOnlyImpl}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AttributeReadOnlyImplTest {
+
+ //@formatter:off
+ @Mock private ExternalArtifactManager proxyManager;
+ @Mock private OrcsSession session;
+ @Mock private Attribute<Date> proxiedObject;
+
+ @Mock private IAttributeType attributeType;
+
+ @Mock private AttributeId attributeId;
+
+ @Mock private Attribute<Object> attribute1;
+ @Mock private AttributeReadable<Object> attributeReadable1;
+ //@formatter:on
+
+ private AttributeReadOnlyImpl<Date> readOnly;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ readOnly = new AttributeReadOnlyImpl<Date>(proxyManager, session, proxiedObject);
+ }
+
+ @Test
+ public void testGetAttributeType() throws OseeCoreException {
+ IAttributeType expected = attributeType;
+ when(proxiedObject.getAttributeType()).thenReturn(expected);
+
+ IAttributeType actual = readOnly.getAttributeType();
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getAttributeType();
+ }
+
+ @Test
+ public void testGetDisplayableString() throws OseeCoreException {
+ String expected = "Hello";
+ when(proxiedObject.getDisplayableString()).thenReturn(expected);
+
+ String actual = readOnly.getDisplayableString();
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getDisplayableString();
+ }
+
+ @Test
+ public void testGetGammaId() {
+ long expected = 1231232112L;
+ when(proxiedObject.getGammaId()).thenReturn(expected);
+
+ long actual = readOnly.getGammaId();
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getGammaId();
+ }
+
+ @Test
+ public void testGetLocalId() {
+ int expected = 123;
+ when(proxiedObject.getLocalId()).thenReturn(expected);
+
+ int actual = readOnly.getLocalId();
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getLocalId();
+ }
+
+ @Test
+ public void testGetModificationType() {
+ ModificationType expected = ModificationType.ARTIFACT_DELETED;
+ when(proxiedObject.getModificationType()).thenReturn(expected);
+
+ ModificationType actual = readOnly.getModificationType();
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getModificationType();
+ }
+
+ @Test
+ public void testGetValue() throws OseeCoreException {
+ Date expected = new Date();
+ when(proxiedObject.getValue()).thenReturn(expected);
+
+ Date actual = readOnly.getValue();
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).getValue();
+ }
+
+ @Test
+ public void testIsDeleted() {
+ boolean expected = true;
+ when(proxiedObject.isDeleted()).thenReturn(expected);
+
+ boolean actual = readOnly.isDeleted();
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).isDeleted();
+ }
+
+ @Test
+ public void testIsOfType() throws OseeCoreException {
+ boolean expected = true;
+ when(proxiedObject.isOfType(attributeType)).thenReturn(expected);
+
+ boolean actual = readOnly.isOfType(attributeType);
+
+ assertEquals(expected, actual);
+ verify(proxiedObject).isOfType(attributeType);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerTest.java
index 23f9c0f575..efca1a7bc1 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerTest.java
@@ -13,19 +13,22 @@ package org.eclipse.osee.orcs.core.internal.proxy.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import java.util.Arrays;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
-import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
import org.eclipse.osee.orcs.core.internal.relation.RelationNode;
import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.AttributeReadable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -41,54 +44,148 @@ public class ExternalArtifactManagerTest {
public ExpectedException thrown = ExpectedException.none();
// @formatter:off
+ @Mock private RelationManager relationManager;
@Mock private OrcsSession session;
- @Mock private ArtifactReadOnlyImpl readable;
@Mock private ArtifactReadOnlyImpl readable1;
@Mock private ArtifactReadOnlyImpl readable2;
@Mock private ArtifactReadOnlyImpl readable3;
- @Mock private ArtifactImpl artifact1;
- @Mock private ArtifactImpl artifact2;
- @Mock private ArtifactImpl artifact3;
+ @Mock private Artifact artifact1;
+ @Mock private Artifact artifact2;
+ @Mock private Artifact artifact3;
+
+ @Mock private Attribute<Integer> attribute1;
+ @Mock private Attribute<Integer> attribute2;
+ @Mock private Attribute<Integer> attribute3;
+
+ @Mock private AttributeReadable<Integer> attributeReadable1;
+ @Mock private AttributeReadable<Integer> attributeReadable2;
+ @Mock private AttributeReadable<Integer> attributeReadable3;
// @formatter:on
private ExternalArtifactManager proxyManager;
- private List<? extends Artifact> artifacts;
- private List<? extends ArtifactReadable> readables;
@Before
public void setUp() throws Exception {
initMocks(this);
- artifacts = Arrays.asList(artifact1, artifact2, artifact3);
- readables = Arrays.asList(readable1, readable2, readable3);
+ proxyManager = new ExternalArtifactManagerImpl(relationManager);
+ }
+
+ @Test
+ public void testNullArtifactReadable() throws OseeCoreException {
+ Artifact actual = proxyManager.asInternalArtifact(null);
+ assertNull(actual);
+ }
+
+ @Test
+ public void testNullArtifact() throws OseeCoreException {
+ ArtifactReadable actual = proxyManager.asExternalArtifact(session, null);
+ assertNull(actual);
+ }
+
+ @Test
+ public void testNullAttribute() throws OseeCoreException {
+ AttributeReadable<?> actual = proxyManager.asExternalAttribute(session, null);
+ assertNull(actual);
+ }
+
+ @Test
+ public void testAsArtifactReadable() throws OseeCoreException {
+ ArtifactReadable actual = proxyManager.asExternalArtifact(session, artifact1);
+
+ checkProxied(artifact1, actual);
+ }
+
+ @Test
+ public void testAsAttributeReadable() throws OseeCoreException {
+ AttributeReadable<Integer> actual = proxyManager.asExternalAttribute(session, attribute1);
- String sessionId = GUID.create();
- when(session.getGuid()).thenReturn(sessionId);
- proxyManager = new ExternalArtifactManagerImpl();
- when(readable.getProxiedObject()).thenReturn(artifact1);
+ checkProxied(attribute1, actual);
}
@Test
public void testAsArtifacts() throws OseeCoreException {
- ResultSet<? extends RelationNode> arts1 = proxyManager.asInternalArtifacts(readables);
- assertFalse(arts1.isEmpty());
- assertEquals(3, arts1.size());
+ when(readable1.getProxiedObject()).thenReturn(artifact1);
+ when(readable2.getProxiedObject()).thenReturn(artifact2);
+ when(readable3.getProxiedObject()).thenReturn(artifact3);
+
+ List<? extends ArtifactReadable> expected = Arrays.asList(readable1, readable2, readable3);
+
+ ResultSet<? extends RelationNode> actuals = proxyManager.asInternalArtifacts(expected);
+ assertFalse(actuals.isEmpty());
+ assertEquals(3, actuals.size());
+
+ Iterator<? extends RelationNode> iterator = actuals.iterator();
+ assertEquals(artifact1, iterator.next());
+ assertEquals(artifact2, iterator.next());
+ assertEquals(artifact3, iterator.next());
+
+ expected = Arrays.asList(readable1, null, readable3);
+ actuals = proxyManager.asInternalArtifacts(expected);
+ assertEquals(3, actuals.size());
+
+ iterator = actuals.iterator();
+ assertEquals(artifact1, iterator.next());
+ assertNull(iterator.next());
+ assertEquals(artifact3, iterator.next());
}
@Test
- public void testAsReadables() throws OseeCoreException {
- ResultSet<ArtifactReadable> asReadables = proxyManager.asExternalArtifacts(session, artifacts);
- assertFalse(asReadables.isEmpty());
- assertEquals(3, asReadables.size());
+ public void testAsArtifactReadables() throws OseeCoreException {
+ List<? extends Artifact> expected = Arrays.asList(artifact1, artifact2, artifact3);
+ ResultSet<ArtifactReadable> actuals = proxyManager.asExternalArtifacts(session, expected);
+ assertFalse(actuals.isEmpty());
+ assertEquals(3, actuals.size());
+
+ Iterator<ArtifactReadable> iterator = actuals.iterator();
+ for (int index = 0; index < expected.size(); index++) {
+ checkProxied(expected.get(index), iterator.next());
+ }
+
+ expected = Arrays.asList(artifact1, null, artifact3);
+ actuals = proxyManager.asExternalArtifacts(session, expected);
+ assertEquals(3, actuals.size());
+
+ iterator = actuals.iterator();
+ checkProxied(expected.get(0), iterator.next());
+ assertNull(iterator.next());
+ checkProxied(expected.get(2), iterator.next());
}
+ @SuppressWarnings("unchecked")
@Test
- public void testAsWriteable() throws OseeCoreException {
- ArtifactReadable readable = proxyManager.asExternalArtifact(session, artifact1);
- assertNotNull(readable);
- assertNotNull(proxyManager.asInternalArtifact(readable));
+ public void testAsAttributeReadables() throws OseeCoreException {
+ List<? extends Attribute<Integer>> expected = Arrays.asList(attribute1, attribute2, attribute3);
+ ResultSet<AttributeReadable<Integer>> actuals = proxyManager.asExternalAttributes(session, expected);
+ assertFalse(actuals.isEmpty());
+ assertEquals(3, actuals.size());
+
+ Iterator<AttributeReadable<Integer>> iterator = actuals.iterator();
+ for (int index = 0; index < expected.size(); index++) {
+ checkProxied(expected.get(index), iterator.next());
+ }
+
+ expected = Arrays.asList(attribute1, null, attribute3);
+ actuals = proxyManager.asExternalAttributes(session, expected);
+ assertEquals(3, actuals.size());
+
+ iterator = actuals.iterator();
+ checkProxied(expected.get(0), iterator.next());
+ assertNull(iterator.next());
+ checkProxied(expected.get(2), iterator.next());
}
+ @SuppressWarnings("unchecked")
+ private <T> void checkProxied(T expected, Object actual) {
+ assertNotNull(actual);
+
+ AbstractProxied<T> proxy = (AbstractProxied<T>) actual;
+ T proxied = proxy.getProxiedObject();
+
+ assertEquals(expected, proxied);
+ assertEquals(proxyManager, proxy.getProxyManager());
+ assertEquals(session, proxy.getSession());
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/LoaderTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ProxyImplTestSuite.java
index 521757c742..a1a94853b1 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/loader/LoaderTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ProxyImplTestSuite.java
@@ -8,7 +8,7 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.loader;
+package org.eclipse.osee.orcs.core.internal.proxy.impl;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -17,7 +17,7 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({ArtifactBuilderImplTest.class, ArtifactLoaderFactoryImplTest.class})
-public class LoaderTestSuite {
+@Suite.SuiteClasses({ArtifactReadOnlyImplTest.class, AttributeReadOnlyImplTest.class, ExternalArtifactManagerTest.class})
+public class ProxyImplTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationManagerTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationManagerTest.java
index 79e101890d..ad4dbdd5ae 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationManagerTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationManagerTest.java
@@ -10,9 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.relation;
-import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Parent;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.LEXICOGRAPHICAL_DESC;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.DEFAULT_HIERARCHY;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_CHILD;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_PARENT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -28,7 +30,6 @@ import java.util.List;
import java.util.Map;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.LoadLevel;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -57,11 +58,6 @@ import org.mockito.stubbing.Answer;
*/
public class RelationManagerTest {
- private static final IRelationType DEFAULT_HIERARCHY = TokenFactory.createRelationType(
- Default_Hierarchical__Parent.getGuid(), Default_Hierarchical__Parent.getName());
- private static final RelationSide IS_PARENT = RelationSide.SIDE_A;
- private static final RelationSide IS_CHILD = RelationSide.SIDE_B;
-
@Rule
public ExpectedException thrown = ExpectedException.none();
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidityTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidityTest.java
index e5a4ceae5e..b89ff1dd0d 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidityTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidityTest.java
@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -36,7 +37,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -54,7 +54,7 @@ public class RelationTypeValidityTest {
public ExpectedException thrown = ExpectedException.none();
// @formatter:off
- @Mock private RelationTypes cache;
+ @Mock private RelationTypes relTypes;
@Mock private RelationNode node;
@Mock private IArtifactType artifactType;
@Mock private IArtifactType artifactType2;
@@ -69,15 +69,15 @@ public class RelationTypeValidityTest {
@Before
public void init() throws OseeCoreException {
- MockitoAnnotations.initMocks(this);
+ initMocks(this);
- validity = new RelationTypeValidity(cache);
+ validity = new RelationTypeValidity(relTypes);
- when(cache.exists(TYPE_1)).thenReturn(true);
- when(cache.exists(relationType1)).thenReturn(true);
- when(cache.exists(relationType2)).thenReturn(true);
- when(cache.exists(relationType3)).thenReturn(true);
- when(cache.exists(relationType4)).thenReturn(true);
+ when(relTypes.exists(TYPE_1)).thenReturn(true);
+ when(relTypes.exists(relationType1)).thenReturn(true);
+ when(relTypes.exists(relationType2)).thenReturn(true);
+ when(relTypes.exists(relationType3)).thenReturn(true);
+ when(relTypes.exists(relationType4)).thenReturn(true);
}
@Test
@@ -103,7 +103,7 @@ public class RelationTypeValidityTest {
@Test
public void testMaximumRelationAllowedTypeDoesNotExist() throws OseeCoreException {
- when(cache.exists(TYPE_1)).thenReturn(false);
+ when(relTypes.exists(TYPE_1)).thenReturn(false);
thrown.expect(OseeArgumentException.class);
thrown.expectMessage(String.format("relationType [%s] does not exist", TYPE_1));
@@ -119,8 +119,8 @@ public class RelationTypeValidityTest {
@Test
public void testMaximumRelationAllowed1() throws OseeCoreException {
- when(cache.isArtifactTypeAllowed(TYPE_1, SIDE_B, artifactType)).thenReturn(true);
- when(cache.getMultiplicity(TYPE_1)).thenReturn(MANY_TO_MANY);
+ when(relTypes.isArtifactTypeAllowed(TYPE_1, SIDE_B, artifactType)).thenReturn(true);
+ when(relTypes.getMultiplicity(TYPE_1)).thenReturn(MANY_TO_MANY);
int actual = validity.getMaximumRelationsAllowed(TYPE_1, artifactType, SIDE_B);
assertEquals(Integer.MAX_VALUE, actual);
@@ -128,8 +128,8 @@ public class RelationTypeValidityTest {
@Test
public void testMaximumRelationAllowed2() throws OseeCoreException {
- when(cache.isArtifactTypeAllowed(TYPE_1, SIDE_B, artifactType)).thenReturn(true);
- when(cache.getMultiplicity(TYPE_1)).thenReturn(MANY_TO_ONE);
+ when(relTypes.isArtifactTypeAllowed(TYPE_1, SIDE_B, artifactType)).thenReturn(true);
+ when(relTypes.getMultiplicity(TYPE_1)).thenReturn(MANY_TO_ONE);
int actual = validity.getMaximumRelationsAllowed(TYPE_1, artifactType, SIDE_B);
assertEquals(1, actual);
@@ -137,7 +137,7 @@ public class RelationTypeValidityTest {
@Test
public void testMaximumRelationAllowed3() throws OseeCoreException {
- when(cache.isArtifactTypeAllowed(relationType1, SIDE_A, artifactType)).thenReturn(true);
+ when(relTypes.isArtifactTypeAllowed(relationType1, SIDE_A, artifactType)).thenReturn(true);
int actual = validity.getMaximumRelationsAllowed(TYPE_1, artifactType, SIDE_B);
assertEquals(0, actual);
@@ -147,7 +147,7 @@ public class RelationTypeValidityTest {
public void testValidRelationTypes() throws OseeCoreException {
final Collection<? extends IRelationType> types =
Arrays.asList(relationType1, relationType2, relationType3, relationType4);
- when(cache.getAll()).thenAnswer(new Answer<Collection<? extends IRelationType>>() {
+ when(relTypes.getAll()).thenAnswer(new Answer<Collection<? extends IRelationType>>() {
@Override
public Collection<? extends IRelationType> answer(InvocationOnMock invocation) throws Throwable {
@@ -155,17 +155,17 @@ public class RelationTypeValidityTest {
}
});
- when(cache.isArtifactTypeAllowed(relationType1, SIDE_B, artifactType)).thenReturn(true);
- when(cache.getMultiplicity(relationType1)).thenReturn(MANY_TO_MANY);
+ when(relTypes.isArtifactTypeAllowed(relationType1, SIDE_B, artifactType)).thenReturn(true);
+ when(relTypes.getMultiplicity(relationType1)).thenReturn(MANY_TO_MANY);
- when(cache.isArtifactTypeAllowed(relationType2, SIDE_A, artifactType)).thenReturn(false);
- when(cache.getMultiplicity(relationType2)).thenReturn(MANY_TO_ONE);
+ when(relTypes.isArtifactTypeAllowed(relationType2, SIDE_A, artifactType)).thenReturn(false);
+ when(relTypes.getMultiplicity(relationType2)).thenReturn(MANY_TO_ONE);
- when(cache.isArtifactTypeAllowed(relationType3, SIDE_A, artifactType)).thenReturn(true);
- when(cache.getMultiplicity(relationType3)).thenReturn(ONE_TO_ONE);
+ when(relTypes.isArtifactTypeAllowed(relationType3, SIDE_A, artifactType)).thenReturn(true);
+ when(relTypes.getMultiplicity(relationType3)).thenReturn(ONE_TO_ONE);
- when(cache.isArtifactTypeAllowed(relationType4, SIDE_A, artifactType)).thenReturn(false);
- when(cache.getMultiplicity(relationType4)).thenReturn(ONE_TO_MANY);
+ when(relTypes.isArtifactTypeAllowed(relationType4, SIDE_A, artifactType)).thenReturn(false);
+ when(relTypes.getMultiplicity(relationType4)).thenReturn(ONE_TO_MANY);
List<IRelationType> actual = validity.getValidRelationTypes(artifactType);
@@ -178,7 +178,7 @@ public class RelationTypeValidityTest {
@Test
public void testGetRelationMultiplicityState() throws OseeCoreException {
- when(cache.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
+ when(relTypes.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
MultiplicityState state = validity.getRelationMultiplicityState(TYPE_1, SIDE_B, 0);
assertEquals(MultiplicityState.IS_VALID, state);
@@ -192,7 +192,7 @@ public class RelationTypeValidityTest {
@Test
public void testCheckRelationTypeMultiplicity() throws OseeCoreException {
- when(cache.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
+ when(relTypes.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
when(node.getExceptionString()).thenReturn("node message");
thrown.expect(OseeStateException.class);
@@ -204,7 +204,7 @@ public class RelationTypeValidityTest {
@Test
public void testCheckRelationTypeMultiplicityNoException() throws OseeCoreException {
- when(cache.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
+ when(relTypes.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
when(node.getExceptionString()).thenReturn("node message");
ExpectedException.none();
@@ -213,13 +213,13 @@ public class RelationTypeValidityTest {
@Test
public void testIsRelationTypeValid() throws OseeCoreException {
- when(cache.isArtifactTypeAllowed(TYPE_1, SIDE_A, artifactType)).thenReturn(true);
+ when(relTypes.isArtifactTypeAllowed(TYPE_1, SIDE_A, artifactType)).thenReturn(true);
boolean actual = validity.isRelationTypeValid(TYPE_1, artifactType, SIDE_B);
assertEquals(false, actual);
- when(cache.isArtifactTypeAllowed(TYPE_1, SIDE_B, artifactType)).thenReturn(true);
- when(cache.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
+ when(relTypes.isArtifactTypeAllowed(TYPE_1, SIDE_B, artifactType)).thenReturn(true);
+ when(relTypes.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
actual = validity.isRelationTypeValid(TYPE_1, artifactType, SIDE_B);
assertEquals(true, actual);
@@ -230,8 +230,8 @@ public class RelationTypeValidityTest {
when(artifactType.toString()).thenReturn("artType1");
when(artifactType2.toString()).thenReturn("artType2");
- when(cache.isArtifactTypeAllowed(TYPE_1, SIDE_A, artifactType)).thenReturn(true);
- when(cache.getArtifactType(TYPE_1, SIDE_B)).thenReturn(artifactType2);
+ when(relTypes.isArtifactTypeAllowed(TYPE_1, SIDE_A, artifactType)).thenReturn(true);
+ when(relTypes.getArtifactType(TYPE_1, SIDE_B)).thenReturn(artifactType2);
when(node.getArtifactType()).thenReturn(artifactType);
when(node.getExceptionString()).thenReturn("node message");
@@ -244,8 +244,8 @@ public class RelationTypeValidityTest {
@Test
public void testCheckRelationTypeValidNoException() throws OseeCoreException {
when(node.getArtifactType()).thenReturn(artifactType);
- when(cache.isArtifactTypeAllowed(TYPE_1, SIDE_B, artifactType)).thenReturn(true);
- when(cache.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
+ when(relTypes.isArtifactTypeAllowed(TYPE_1, SIDE_B, artifactType)).thenReturn(true);
+ when(relTypes.getMultiplicity(TYPE_1)).thenReturn(ONE_TO_ONE);
ExpectedException.none();
validity.checkRelationTypeValid(TYPE_1, node, SIDE_B);
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImplTest.java
index 4279cfebff..8cd8ea95f2 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImplTest.java
@@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.core.internal.relation.impl;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import static org.eclipse.osee.framework.core.enums.CoreBranches.SYSTEM_ROOT;
import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Child;
-import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Parent;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.LEXICOGRAPHICAL_ASC;
@@ -22,6 +21,9 @@ import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.UNORD
import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.USER_DEFINED;
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.eclipse.osee.orcs.core.internal.relation.RelationUtil.DEFAULT_HIERARCHY;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_CHILD;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_PARENT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -48,7 +50,6 @@ import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.RelationTypeSide;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
@@ -59,6 +60,7 @@ import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
import org.eclipse.osee.orcs.core.internal.relation.RelationNode;
import org.eclipse.osee.orcs.core.internal.relation.RelationResolver;
import org.eclipse.osee.orcs.core.internal.relation.RelationTypeValidity;
+import org.eclipse.osee.orcs.core.internal.relation.RelationUtil;
import org.eclipse.osee.orcs.core.internal.relation.RelationVisitor;
import org.eclipse.osee.orcs.core.internal.relation.order.OrderManager;
import org.eclipse.osee.orcs.core.internal.relation.order.OrderManagerFactory;
@@ -83,10 +85,6 @@ public class RelationManagerImplTest {
private static final IRelationType TYPE_1 = TokenFactory.createRelationType(123456789L, "TYPE_1");
- private static final IRelationType DEFAULT_HIERARCHY = Default_Hierarchical__Parent;
- private static final RelationSide IS_PARENT = Default_Hierarchical__Parent.getSide();
- private static final RelationSide IS_CHILD = Default_Hierarchical__Child.getSide();
-
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -476,7 +474,7 @@ public class RelationManagerImplTest {
OseeCoreException myException = new OseeCoreException("Test Type Exception");
- doThrow(myException).when(validity).checkRelationTypeValid(TYPE_1, node1, SIDE_A);
+ doThrow(myException).when(validity).checkRelationTypeValid(TYPE_1, node1, SIDE_B);
thrown.expect(OseeCoreException.class);
thrown.expectMessage("Test Type Exception");
@@ -497,7 +495,7 @@ public class RelationManagerImplTest {
OseeCoreException myException = new OseeCoreException("Test Type Exception");
- doThrow(myException).when(validity).checkRelationTypeValid(TYPE_1, node2, SIDE_B);
+ doThrow(myException).when(validity).checkRelationTypeValid(TYPE_1, node2, SIDE_A);
thrown.expect(OseeCoreException.class);
thrown.expectMessage("Test Type Exception");
@@ -514,7 +512,7 @@ public class RelationManagerImplTest {
OseeCoreException myException = new OseeCoreException("Test Multiplicity Exception");
- doThrow(myException).when(validity).checkRelationTypeMultiplicity(TYPE_1, node1, SIDE_A, 1);
+ doThrow(myException).when(validity).checkRelationTypeMultiplicity(TYPE_1, node1, SIDE_B, 1);
thrown.expect(OseeCoreException.class);
thrown.expectMessage("Test Multiplicity Exception");
@@ -536,7 +534,7 @@ public class RelationManagerImplTest {
OseeCoreException myException = new OseeCoreException("Test Multiplicity Exception");
- doThrow(myException).when(validity).checkRelationTypeMultiplicity(TYPE_1, node2, SIDE_B, 1);
+ doThrow(myException).when(validity).checkRelationTypeMultiplicity(TYPE_1, node2, SIDE_A, 1);
thrown.expect(OseeCoreException.class);
thrown.expectMessage("Test Multiplicity Exception");
@@ -574,7 +572,7 @@ public class RelationManagerImplTest {
manager.relate(session, graph, node1, TYPE_1, node2, LEXICOGRAPHICAL_ASC);
- IRelationTypeSide typeSide = new RelationTypeSide(TYPE_1, SIDE_B);
+ IRelationTypeSide typeSide = RelationUtil.asTypeSide(TYPE_1, SIDE_B);
verify(container1).getRelation(node1, TYPE_1, node2, INCLUDE_DELETED);
verify(container2).getRelation(node1, TYPE_1, node2, INCLUDE_DELETED);
@@ -596,7 +594,7 @@ public class RelationManagerImplTest {
when(orderFactory.createOrderManager(node1)).thenReturn(orderManager1);
- IRelationTypeSide typeSide = new RelationTypeSide(TYPE_1, SIDE_B);
+ IRelationTypeSide typeSide = RelationUtil.asTypeSide(TYPE_1, SIDE_B);
when(orderManager1.getSorterId(typeSide)).thenReturn(UNORDERED);
manager.relate(session, graph, node1, TYPE_1, node2);
@@ -636,7 +634,7 @@ public class RelationManagerImplTest {
verify(resolver).resolve(session, graph, toOrder, SIDE_B);
- IRelationTypeSide typeSide = new RelationTypeSide(TYPE_1, SIDE_B);
+ IRelationTypeSide typeSide = RelationUtil.asTypeSide(TYPE_1, SIDE_B);
verify(orderManager1).sort(typeSide, nodesToOrder);
verify(orderManager1).setOrder(eq(typeSide), eq(USER_DEFINED), sortedListCaptor.capture());
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/CollectDirtyDataTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/ChangeSetBuilderTest.java
index 47bef4e7ef..5784f17255 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/CollectDirtyDataTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/ChangeSetBuilderTest.java
@@ -10,77 +10,80 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.transaction;
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.List;
+import static org.mockito.MockitoAnnotations.initMocks;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
+import org.eclipse.osee.orcs.core.ds.RelationData;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
-import org.junit.Assert;
+import org.eclipse.osee.orcs.core.internal.relation.Relation;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import com.google.common.collect.Iterables;
/**
- * Test Case for {@link CollectDirtyData}
+ * Test Case for {@link ChangeSetBuilder}
*
* @author Roberto E. Escobar
*/
-public class CollectDirtyDataTest {
+public class ChangeSetBuilderTest {
// @formatter:off
@Mock private Artifact artifact;
@Mock private Attribute<?> attribute;
-
+ @Mock private Relation relation;
+
@Mock private ArtifactData artifactData;
@Mock private AttributeData attributeData;
-
+ @Mock private RelationData relationData;
// @formatter:on
- private List<ArtifactTransactionData> data;
- private CollectDirtyData handler;
+ private ChangeSetBuilder handler;
@Before
public void init() {
- MockitoAnnotations.initMocks(this);
+ initMocks(this);
- data = new ArrayList<ArtifactTransactionData>();
- handler = new CollectDirtyData(data);
+ handler = new ChangeSetBuilder();
when(artifact.getOrcsData()).thenReturn(artifactData);
when(attribute.getOrcsData()).thenReturn(attributeData);
+ when(relation.getOrcsData()).thenReturn(relationData);
}
@Test
- public void testDontCollectNoneDirtyArtifact() {
+ public void testDontCollectNoneDirtyData() {
when(artifact.isDirty()).thenReturn(false);
+ when(attribute.isDirty()).thenReturn(false);
+ when(relation.isDirty()).thenReturn(false);
handler.visit(artifact);
-
- Assert.assertEquals(0, data.size());
-
- when(attribute.isDirty()).thenReturn(false);
handler.visit(attribute);
+ handler.visit(relation);
- Assert.assertEquals(0, data.size());
+ assertEquals(true, handler.getChangeSet().isEmpty());
}
@Test
- public void testVisitAndCollectDirtyArtifact() {
+ public void testVisitAndCollectDirtyData() {
when(artifact.isDirty()).thenReturn(true);
when(attribute.isDirty()).thenReturn(true);
+ when(relation.isDirty()).thenReturn(true);
handler.visit(artifact);
handler.visit(attribute);
+ handler.visit(relation);
- Assert.assertEquals(1, data.size());
+ assertEquals(3, handler.getChangeSet().size());
- ArtifactTransactionData txData = data.iterator().next();
+ OrcsChangeSet txData = handler.getChangeSet();
- Assert.assertEquals(artifactData, txData.getArtifactData());
- Assert.assertEquals(attributeData, txData.getAttributeData().get(0));
+ assertEquals(artifactData, Iterables.getOnlyElement(txData.getArtifactData()));
+ assertEquals(attributeData, Iterables.getOnlyElement(txData.getAttributeData()));
+ assertEquals(relationData, Iterables.getOnlyElement(txData.getRelationData()));
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImplTest.java
index 081cafa4be..8f09a40e6f 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImplTest.java
@@ -21,7 +21,10 @@ import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.PlainText
import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.QualificationMethod;
import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.RelationOrder;
import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.WordTemplateContent;
+import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.LEXICOGRAPHICAL_ASC;
import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.LEXICOGRAPHICAL_DESC;
+import static org.eclipse.osee.framework.core.enums.RelationSide.SIDE_B;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.DEFAULT_HIERARCHY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.doThrow;
@@ -33,9 +36,13 @@ import java.io.InputStream;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import org.eclipse.osee.executor.admin.CancellableCallable;
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.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -45,6 +52,8 @@ import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+import org.eclipse.osee.orcs.core.internal.relation.RelationUtil;
+import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.junit.Before;
@@ -61,6 +70,7 @@ import org.mockito.Mockito;
*/
public class TransactionBuilderImplTest {
+ private static final IRelationType TYPE_1 = TokenFactory.createRelationType(123456789L, "TYPE_1");
@Rule
public ExpectedException thrown = ExpectedException.none();
@@ -278,7 +288,7 @@ public class TransactionBuilderImplTest {
}
@Test
- public void TestSetAttributeById() throws OseeCoreException {
+ public void testSetAttributeById() throws OseeCoreException {
InputStream inputStream = Mockito.mock(InputStream.class);
factory.setAttributeById(expectedAuthor, attrId, inputStream);
@@ -358,4 +368,59 @@ public class TransactionBuilderImplTest {
factory.commit();
}
+ @Test
+ public void testSetRationale() throws OseeCoreException {
+ factory.setRationale(node1, DEFAULT_HIERARCHY, node2, "This is my rationale");
+
+ verify(txDataManager).setRationale(txData, node1, DEFAULT_HIERARCHY, node2, "This is my rationale");
+ }
+
+ @Test
+ public void testAddChildren() throws OseeCoreException {
+ List<ArtifactReadable> list = Arrays.asList(node1, node2);
+
+ factory.addChildren(expectedAuthor, list);
+
+ verify(txDataManager).addChildren(txData, expectedAuthor, list);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void TestAddChildrenAsList() throws OseeCoreException {
+ Iterable<? extends ArtifactId> children = Collections.EMPTY_LIST;
+ factory.addChildren(expectedAuthor, children);
+ verify(txDataManager).addChildren(txData, expectedAuthor, children);
+ }
+
+ @Test
+ public void testRelate() throws OseeCoreException {
+ factory.relate(node1, DEFAULT_HIERARCHY, node2);
+ verify(txDataManager).relate(txData, node1, DEFAULT_HIERARCHY, node2);
+ }
+
+ @Test
+ public void testRelateWithOrder() throws OseeCoreException {
+ factory.relate(node1, DEFAULT_HIERARCHY, node2, LEXICOGRAPHICAL_ASC);
+ verify(txDataManager).relate(txData, node1, DEFAULT_HIERARCHY, node2, LEXICOGRAPHICAL_ASC);
+ }
+
+ @Test
+ public void testUnrelateWithAandB() throws OseeCoreException {
+ factory.unrelate(node1, TYPE_1, node2);
+ verify(txDataManager).unrelate(txData, node1, TYPE_1, node2);
+ }
+
+ @Test
+ public void testUnrelateFromAllWithSide() throws OseeCoreException {
+ IRelationTypeSide asTypeSide = RelationUtil.asTypeSide(TYPE_1, SIDE_B);
+ factory.unrelateFromAll(asTypeSide, expectedAuthor);
+ verify(txDataManager).unrelateFromAll(txData, TYPE_1, expectedAuthor, SIDE_B);
+ }
+
+ @Test
+ public void testUnrelateFromAll() throws OseeCoreException {
+ factory.unrelateFromAll(expectedAuthor);
+ verify(txDataManager).unrelateFromAll(txData, expectedAuthor);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java
index c7b41ef9c6..f553821547 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionTestSuite.java
@@ -15,7 +15,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
- CollectDirtyDataTest.class,
+ ChangeSetBuilderTest.class,
TransactionBuilderImplTest.class,
TransactionFactoryImplTest.class,
TxCallableFactoryTest.class,
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactoryTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactoryTest.java
index da2aba622c..7653a52c59 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactoryTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactoryTest.java
@@ -32,7 +32,9 @@ import org.eclipse.osee.orcs.core.ds.TransactionData;
import org.eclipse.osee.orcs.core.ds.TransactionResult;
import org.eclipse.osee.orcs.core.ds.TxDataStore;
import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
+import org.eclipse.osee.orcs.core.internal.graph.GraphData;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
import org.eclipse.osee.orcs.core.internal.transaction.TxDataManager.TxDataLoader;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.junit.Assert;
@@ -61,9 +63,11 @@ public class TxCallableFactoryTest {
@Mock private ExternalArtifactManager proxyManager;
@Mock private ArtifactFactory artifactFactory;
+ @Mock private RelationManager relationManager;
@Mock private TxDataLoader loader;
@Mock private IOseeBranch branch;
+ @Mock private GraphData graph;
@Mock private TxDataStore txDataStore;
@Mock private ArtifactReadable userArtifact;
@@ -80,10 +84,11 @@ public class TxCallableFactoryTest {
@Before
public void init() {
MockitoAnnotations.initMocks(this);
- txManager = new TxDataManager(proxyManager, artifactFactory, loader);
+ txManager = new TxDataManager(proxyManager, artifactFactory, relationManager, loader);
txFactory = new TxCallableFactory(logger, txDataStore, txManager);
- data = new TxData(session, branch);
+ data = new TxData(session, graph);
+ when(graph.getBranch()).thenReturn(branch);
}
@SuppressWarnings("unchecked")
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java
index 80474334fb..070102ee49 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java
@@ -10,7 +10,13 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.transaction;
+import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.DirectSoftwareRequirement;
+import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Category;
+import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.Name;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
+import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.LEXICOGRAPHICAL_DESC;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.DEFAULT_HIERARCHY;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_CHILD;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.anyCollectionOf;
@@ -20,12 +26,14 @@ import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.data.ResultSetList;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
@@ -37,7 +45,10 @@ import org.eclipse.osee.orcs.core.ds.TransactionData;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl;
+import org.eclipse.osee.orcs.core.internal.graph.GraphData;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationNode;
import org.eclipse.osee.orcs.core.internal.transaction.TxData.TxState;
import org.eclipse.osee.orcs.core.internal.transaction.TxDataManager.TxDataLoader;
import org.eclipse.osee.orcs.core.internal.util.ResultSetIterable;
@@ -72,47 +83,81 @@ public class TxDataManagerTest {
@Mock private ExternalArtifactManager proxyManager;
@Mock private ArtifactFactory artifactFactory;
+ @Mock private RelationManager relationManager;
@Mock private TxDataLoader loader;
@Mock private TxData txData;
+ @Mock private GraphData graph;
+ @Mock private ArtifactId artifactId1;
+ @Mock private ArtifactId artifactId2;
+ @Mock private ArtifactId artifactId3;
@Mock private ArtifactReadable readable1;
@Mock private ArtifactReadable readable2;
- @Mock private Artifact artifact;
+ @Mock private ArtifactReadable readable3;
+ @Mock private Artifact artifact1;
@Mock private Artifact artifact2;
- @Mock private Artifact child;
- @Mock private ArtifactId artifactId;
+ @Mock private Artifact artifact3;
@Captor private ArgumentCaptor<Collection<ArtifactId>> idCaptor;
+ @Captor private ArgumentCaptor<List<? extends RelationNode>> nodeCaptor;
// @formatter:on
private TxDataManager txDataManager;
private String guid;
- private final Collection<? extends IAttributeType> types = Collections.emptyList();
+ private final Collection<? extends IAttributeType> types = Arrays.asList(Name, Category);
+ private String r1Guid;
+ private String r2Guid;
+ private String r3Guid;
@Before
public void init() throws OseeCoreException {
MockitoAnnotations.initMocks(this);
- txDataManager = new TxDataManager(proxyManager, artifactFactory, loader);
+ txDataManager = new TxDataManager(proxyManager, artifactFactory, relationManager, loader);
guid = GUID.create();
- when(artifact.getExistingAttributeTypes()).thenAnswer(answerValue(types));
+ when(artifact1.getExistingAttributeTypes()).thenAnswer(answerValue(types));
- when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact);
- when(proxyManager.asExternalArtifact(session, artifact)).thenReturn(readable1);
+ when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1);
+ when(proxyManager.asExternalArtifact(session, artifact1)).thenReturn(readable1);
when(txData.getSession()).thenReturn(session);
when(txData.getBranch()).thenReturn(branch);
+ when(txData.getGraph()).thenReturn(graph);
+
+ r1Guid = GUID.create();
+ r2Guid = GUID.create();
+ r3Guid = GUID.create();
+
+ when(artifactId1.getGuid()).thenReturn(r1Guid);
+ when(artifactId2.getGuid()).thenReturn(r2Guid);
+ when(artifactId3.getGuid()).thenReturn(r3Guid);
+
+ when(readable1.getGuid()).thenReturn(r1Guid);
+ when(readable2.getGuid()).thenReturn(r2Guid);
+ when(readable3.getGuid()).thenReturn(r3Guid);
+
+ when(readable1.getBranch()).thenReturn(branch);
+ when(readable2.getBranch()).thenReturn(branch);
+ when(readable3.getBranch()).thenReturn(branch);
+
+ when(artifact1.getGuid()).thenReturn(r1Guid);
+ when(artifact2.getGuid()).thenReturn(r2Guid);
+ when(artifact3.getGuid()).thenReturn(r3Guid);
+
+ when(artifact1.getBranch()).thenReturn(branch);
+ when(artifact2.getBranch()).thenReturn(branch);
+ when(artifact3.getBranch()).thenReturn(branch);
}
@Test
- public void testCreateTxData() {
+ public void testCreateTxData() throws OseeCoreException {
TxData newData = txDataManager.createTxData(session, branch);
assertNotNull(newData);
}
@Test
public void testTxCommitSuccess() {
- Iterable<Artifact> writeables = Arrays.asList(artifact);
+ Iterable<Artifact> writeables = Arrays.asList(artifact1);
when(txData.getAllWriteables()).thenReturn(writeables);
txDataManager.txCommitSuccess(txData);
@@ -154,20 +199,112 @@ public class TxDataManagerTest {
}
@Test
- public void testGetForWrite() throws OseeCoreException {
- ResultSet<Artifact> loaded = new ResultSetIterable<Artifact>(Collections.<Artifact> singleton(artifact));
- when(loader.loadArtifacts(eq(session), eq(branch), anyCollectionOf(ArtifactId.class))).thenReturn(loaded);
+ public void testGetForWriteId() throws OseeCoreException {
+ when(txData.getWriteable(artifactId1)).thenReturn(null);
+
+ ResultSet<Artifact> loaded = new ResultSetIterable<Artifact>(Collections.<Artifact> singleton(artifact1));
+ when(loader.loadArtifacts(eq(session), eq(graph), anyCollectionOf(ArtifactId.class))).thenReturn(loaded);
+
+ Artifact actual = txDataManager.getForWrite(txData, artifactId1);
+
+ verify(txData).getWriteable(artifactId1);
+ verify(loader).loadArtifacts(eq(session), eq(graph), idCaptor.capture());
+
+ assertEquals(artifactId1, idCaptor.getValue().iterator().next());
+ assertEquals(artifact1, actual);
+ }
+
+ @Test
+ public void testGetForWriteReadable() throws OseeCoreException {
+ when(txData.getWriteable(readable1)).thenReturn(null);
+ when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1);
+ when(artifactFactory.clone(artifact1)).thenReturn(artifact2);
+
+ Artifact actual = txDataManager.getForWrite(txData, readable1);
+
+ verify(txData).getWriteable(readable1);
+ verify(proxyManager).asInternalArtifact(readable1);
+ verify(artifactFactory).clone(artifact1);
+
+ assertEquals(artifact2, actual);
+ }
+
+ @Test
+ public void testGetForWriteReadableButIsFromDifferentBranch() throws OseeCoreException {
+ when(readable1.getBranch()).thenReturn(CoreBranches.COMMON);
+ when(txData.getWriteable(readable1)).thenReturn(null);
+
+ ResultSet<Artifact> loaded = new ResultSetIterable<Artifact>(Collections.<Artifact> singleton(artifact1));
+ when(loader.loadArtifacts(eq(session), eq(graph), anyCollectionOf(ArtifactId.class))).thenReturn(loaded);
Artifact actual = txDataManager.getForWrite(txData, readable1);
- verify(loader).loadArtifacts(eq(session), eq(branch), idCaptor.capture());
- assertEquals(artifact, actual);
+ verify(txData).getWriteable(readable1);
+ verify(readable1).getBranch();
+ verify(loader).loadArtifacts(eq(session), eq(graph), idCaptor.capture());
+
+ assertEquals(readable1, idCaptor.getValue().iterator().next());
+ assertEquals(artifact1, actual);
+ }
+
+ @Test
+ public void testGetForWriteArtifact() throws OseeCoreException {
+ when(txData.getWriteable(artifact1)).thenReturn(null);
+ when(artifactFactory.clone(artifact1)).thenReturn(artifact2);
+
+ Artifact actual = txDataManager.getForWrite(txData, artifact1);
+
+ verify(txData).getWriteable(artifact1);
+ verify(artifactFactory).clone(artifact1);
+
+ assertEquals(artifact2, actual);
+ }
+
+ @Test
+ public void testGetForWriteArtifactButIsFromDifferentBranch() throws OseeCoreException {
+ when(artifact1.getBranch()).thenReturn(CoreBranches.COMMON);
+ when(txData.getWriteable(readable1)).thenReturn(null);
+
+ ResultSet<Artifact> loaded = new ResultSetIterable<Artifact>(Collections.<Artifact> singleton(artifact2));
+ when(loader.loadArtifacts(eq(session), eq(graph), anyCollectionOf(ArtifactId.class))).thenReturn(loaded);
+
+ Artifact actual = txDataManager.getForWrite(txData, artifact1);
+
+ verify(txData).getWriteable(artifact1);
+ verify(artifact1).getBranch();
+ verify(loader).loadArtifacts(eq(session), eq(graph), idCaptor.capture());
+
+ assertEquals(artifact1, idCaptor.getValue().iterator().next());
+ assertEquals(artifact2, actual);
+ }
+
+ @Test
+ public void testGetForWriteMultiples() throws OseeCoreException {
+ List<? extends ArtifactId> ids = Arrays.asList(artifactId1, artifactId2, artifactId3);
+
+ when(txData.getWriteable(artifactId2)).thenReturn(artifact2);
+
+ List<Artifact> artifacts = Arrays.asList(artifact1, artifact3);
+ ResultSet<Artifact> loaded = new ResultSetList<Artifact>(artifacts);
+ when(loader.loadArtifacts(eq(session), eq(graph), anyCollectionOf(ArtifactId.class))).thenReturn(loaded);
+
+ Iterable<Artifact> actual = txDataManager.getForWrite(txData, ids);
+
+ verify(loader).loadArtifacts(eq(session), eq(graph), idCaptor.capture());
+ Iterator<ArtifactId> iterator1 = idCaptor.getValue().iterator();
+ assertEquals(artifactId1, iterator1.next());
+ assertEquals(artifactId3, iterator1.next());
+
+ Iterator<Artifact> iterator2 = actual.iterator();
+ assertEquals(artifact1, iterator2.next());
+ assertEquals(artifact2, iterator2.next());
+ assertEquals(artifact3, iterator2.next());
}
@Test
public void testGetForWriteDuringWrite() throws OseeCoreException {
- when(txData.add(artifact)).thenReturn(child);
- when(artifactFactory.clone(artifact)).thenReturn(artifact);
+ when(txData.add(artifact1)).thenReturn(artifact3);
+ when(artifactFactory.clone(artifact1)).thenReturn(artifact1);
thrown.expect(OseeArgumentException.class);
thrown.expectMessage("Another instance of writeable detected - writeable tracking would be inconsistent");
@@ -206,15 +343,13 @@ public class TxDataManagerTest {
public void testCreateArtifact() throws OseeCoreException {
when(txData.isCommitInProgress()).thenReturn(false);
when(txData.getTxState()).thenReturn(TxState.NEW_TX);
- when(artifactFactory.createArtifact(branch, CoreArtifactTypes.DirectSoftwareRequirement, guid)).thenReturn(
- artifact);
- when(proxyManager.asExternalArtifact(session, artifact)).thenReturn(readable1);
+ when(artifactFactory.createArtifact(branch, DirectSoftwareRequirement, guid)).thenReturn(artifact1);
+ when(proxyManager.asExternalArtifact(session, artifact1)).thenReturn(readable1);
ArtifactReadable actual =
- txDataManager.createArtifact(txData, CoreArtifactTypes.DirectSoftwareRequirement, "Direct SW requirement",
- guid);
+ txDataManager.createArtifact(txData, DirectSoftwareRequirement, "Direct SW requirement", guid);
- verify(artifactFactory).createArtifact(branch, CoreArtifactTypes.DirectSoftwareRequirement, guid);
+ verify(artifactFactory).createArtifact(branch, DirectSoftwareRequirement, guid);
assertEquals(readable1, actual);
}
@@ -222,14 +357,14 @@ public class TxDataManagerTest {
public void testCopyExisitingArtifact() throws OseeCoreException {
when(txData.isCommitInProgress()).thenReturn(false);
when(txData.getTxState()).thenReturn(TxState.NEW_TX);
- when(txData.getWriteable(readable1)).thenReturn(artifact);
- when(artifactFactory.copyArtifact(artifact, types, branch)).thenReturn(artifact2);
+ when(txData.getWriteable(readable1)).thenReturn(artifact1);
+ when(artifactFactory.copyArtifact(artifact1, types, branch)).thenReturn(artifact2);
when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2);
ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, readable1);
verify(txData).getWriteable(readable1);
- verify(artifactFactory).copyArtifact(artifact, types, branch);
+ verify(artifactFactory).copyArtifact(artifact1, types, branch);
verify(proxyManager).asExternalArtifact(session, artifact2);
assertEquals(readable2, actual);
@@ -241,16 +376,16 @@ public class TxDataManagerTest {
when(txData.getTxState()).thenReturn(TxState.NEW_TX);
when(readable1.getBranch()).thenReturn(branch);
when(txData.getWriteable(readable1)).thenReturn(null);
- when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact);
+ when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1);
- when(artifactFactory.copyArtifact(artifact, types, branch)).thenReturn(artifact2);
+ when(artifactFactory.copyArtifact(artifact1, types, branch)).thenReturn(artifact2);
when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2);
ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, readable1);
verify(txData).getWriteable(readable1);
verify(proxyManager).asInternalArtifact(readable1);
- verify(artifactFactory).copyArtifact(artifact, Collections.<IAttributeType> emptyList(), branch);
+ verify(artifactFactory).copyArtifact(artifact1, types, branch);
verify(proxyManager).asExternalArtifact(session, artifact2);
assertEquals(readable2, actual);
@@ -265,7 +400,7 @@ public class TxDataManagerTest {
@SuppressWarnings("unchecked")
ValueProvider<IOseeBranch, OrcsData> provider = Mockito.mock(ValueProvider.class);
- Artifact sourceArtifact = Mockito.spy(new ArtifactImpl(null, data, null, null, provider));
+ Artifact sourceArtifact = Mockito.spy(new ArtifactImpl(null, data, null, provider));
when(data.getGuid()).thenReturn(guid);
when(provider.get()).thenReturn(branch);
@@ -291,15 +426,15 @@ public class TxDataManagerTest {
public void testCopyArtifactId() throws OseeCoreException {
when(txData.isCommitInProgress()).thenReturn(false);
when(txData.getTxState()).thenReturn(TxState.NEW_TX);
- when(txData.getWriteable(artifactId)).thenReturn(artifact);
- when(artifact.getExistingAttributeTypes()).thenAnswer(answerValue(types));
- when(artifactFactory.copyArtifact(artifact, types, branch)).thenReturn(artifact2);
+ when(txData.getWriteable(artifactId1)).thenReturn(artifact1);
+ when(artifact1.getExistingAttributeTypes()).thenAnswer(answerValue(types));
+ when(artifactFactory.copyArtifact(artifact1, types, branch)).thenReturn(artifact2);
when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2);
- ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, artifactId);
+ ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, artifactId1);
- verify(txData).getWriteable(artifactId);
- verify(artifactFactory).copyArtifact(artifact, types, branch);
+ verify(txData).getWriteable(artifactId1);
+ verify(artifactFactory).copyArtifact(artifact1, types, branch);
verify(proxyManager).asExternalArtifact(session, artifact2);
assertEquals(readable2, actual);
@@ -313,7 +448,7 @@ public class TxDataManagerTest {
thrown.expect(OseeArgumentException.class);
thrown.expectMessage(String.format("Source branch is same branch as transaction branch[%s]", branch));
- txDataManager.introduceArtifact(txData, branch, artifactId);
+ txDataManager.introduceArtifact(txData, branch, artifactId1);
}
@Test
@@ -322,39 +457,123 @@ public class TxDataManagerTest {
when(txData.getTxState()).thenReturn(TxState.NEW_TX);
when(txData.getBranch()).thenReturn(branch);
- ResultSet<Artifact> loaded = new ResultSetIterable<Artifact>(Collections.<Artifact> singleton(artifact));
+ ResultSet<Artifact> loaded = new ResultSetIterable<Artifact>(Collections.<Artifact> singleton(artifact1));
when(loader.loadArtifacts(eq(session), eq(COMMON), anyCollectionOf(ArtifactId.class))).thenReturn(loaded);
- when(artifactFactory.introduceArtifact(artifact, branch)).thenReturn(artifact2);
+ when(artifactFactory.introduceArtifact(artifact1, branch)).thenReturn(artifact2);
when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2);
- ArtifactReadable actual = txDataManager.introduceArtifact(txData, COMMON, artifactId);
+ ArtifactReadable actual = txDataManager.introduceArtifact(txData, COMMON, artifactId1);
verify(loader).loadArtifacts(eq(session), eq(COMMON), idCaptor.capture());
- assertEquals(artifactId, idCaptor.getValue().iterator().next());
- verify(artifactFactory).introduceArtifact(artifact, branch);
+ assertEquals(artifactId1, idCaptor.getValue().iterator().next());
+ verify(artifactFactory).introduceArtifact(artifact1, branch);
verify(proxyManager).asExternalArtifact(session, artifact2);
assertEquals(readable2, actual);
}
@Test
public void testDeleteArtifact() throws OseeCoreException {
- when(artifactFactory.clone(artifact)).thenReturn(artifact2);
+ when(artifactFactory.clone(artifact1)).thenReturn(artifact2);
- txDataManager.deleteArtifact(txData, artifact);
+ txDataManager.deleteArtifact(txData, artifact1);
verify(artifact2).delete();
+ verify(relationManager).unrelateFromAll(session, graph, artifact2);
}
@Test
public void testCreateChangeData() throws OseeCoreException {
- Iterable<Artifact> writeables = Arrays.asList(artifact);
+ Iterable<Artifact> writeables = Arrays.asList(artifact1);
when(txData.getAllWriteables()).thenReturn(writeables);
- when(artifact.isDirty()).thenReturn(true);
+ when(artifact1.isDirty()).thenReturn(true);
TransactionData changeData = txDataManager.createChangeData(txData);
assertNotNull(changeData);
}
+ @Test
+ public void testSetRationale() throws OseeCoreException {
+ String rationale = "i have no rationale";
+
+ when(txData.getWriteable(readable1)).thenReturn(artifact1);
+ when(txData.getWriteable(readable2)).thenReturn(artifact3);
+
+ txDataManager.setRationale(txData, readable1, DEFAULT_HIERARCHY, readable2, rationale);
+
+ verify(relationManager).setRationale(session, graph, artifact1, DEFAULT_HIERARCHY, artifact3, rationale);
+ }
+
+ @Test
+ public void testRelate() throws OseeCoreException {
+ when(txData.getWriteable(readable1)).thenReturn(artifact1);
+ when(txData.getWriteable(readable2)).thenReturn(artifact2);
+ when(txData.getGraph()).thenReturn(graph);
+
+ txDataManager.relate(txData, readable1, DEFAULT_HIERARCHY, readable2);
+
+ verify(relationManager).relate(session, graph, artifact1, DEFAULT_HIERARCHY, artifact2);
+ }
+
+ @Test
+ public void testRelateWithOrder() throws OseeCoreException {
+ when(txData.getWriteable(readable1)).thenReturn(artifact1);
+ when(txData.getWriteable(readable2)).thenReturn(artifact2);
+ when(txData.getGraph()).thenReturn(graph);
+
+ txDataManager.relate(txData, readable1, DEFAULT_HIERARCHY, readable2, LEXICOGRAPHICAL_DESC);
+
+ verify(relationManager).relate(session, graph, artifact1, DEFAULT_HIERARCHY, artifact2, LEXICOGRAPHICAL_DESC);
+ }
+
+ @Test
+ public void testAddChildren() throws OseeCoreException {
+ List<? extends ArtifactReadable> children = Arrays.asList(readable2, readable3);
+
+ when(txData.getWriteable(readable1)).thenReturn(artifact1);
+ when(txData.getWriteable(readable2)).thenReturn(artifact2);
+ when(txData.getWriteable(readable3)).thenReturn(artifact3);
+ when(txData.getGraph()).thenReturn(graph);
+
+ txDataManager.addChildren(txData, readable1, children);
+
+ verify(relationManager).addChildren(eq(session), eq(graph), eq(artifact1), nodeCaptor.capture());
+
+ Iterator<? extends RelationNode> iterator = nodeCaptor.getValue().iterator();
+ assertEquals(artifact2, iterator.next());
+ assertEquals(artifact3, iterator.next());
+ }
+
+ @Test
+ public void testUnrelate() throws OseeCoreException {
+ when(txData.getWriteable(readable1)).thenReturn(artifact1);
+ when(txData.getWriteable(readable2)).thenReturn(artifact2);
+ when(txData.getGraph()).thenReturn(graph);
+
+ txDataManager.unrelate(txData, readable1, DEFAULT_HIERARCHY, readable2);
+
+ verify(relationManager).unrelate(session, graph, artifact1, DEFAULT_HIERARCHY, artifact2);
+ }
+
+ @Test
+ public void testUnrelateTypeFromAll() throws OseeCoreException {
+ when(txData.getWriteable(readable1)).thenReturn(artifact1);
+ when(txData.getGraph()).thenReturn(graph);
+
+ txDataManager.unrelateFromAll(txData, DEFAULT_HIERARCHY, readable1, IS_CHILD);
+
+ verify(relationManager).unrelateFromAll(session, graph, DEFAULT_HIERARCHY, artifact1, IS_CHILD);
+ }
+
+ @Test
+ public void testUnrelateFromAll() throws OseeCoreException {
+ when(txData.getWriteable(readable1)).thenReturn(artifact1);
+ when(txData.getGraph()).thenReturn(graph);
+
+ txDataManager.unrelateFromAll(txData, readable1);
+
+ verify(relationManager).unrelateFromAll(session, graph, artifact1);
+ }
+
private <T> Answer<T> answerValue(final T value) {
return new Answer<T>() {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTxDataImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTxDataImpl.java
deleted file mode 100644
index 917d3f7025..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTxDataImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * 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.ds;
-
-import java.util.LinkedList;
-import java.util.List;
-import org.eclipse.osee.framework.core.data.AbstractIdentity;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-
-/**
- * @author John Misinco
- */
-public class ArtifactTxDataImpl extends AbstractIdentity<String> implements ArtifactTransactionData {
-
- private final ArtifactData artifactData;
- private final List<AttributeData> attributeData;
- private final List<RelationData> relationData = new LinkedList<RelationData>();
-
- public ArtifactTxDataImpl(ArtifactData artifactData, List<AttributeData> attributeData) {
- super();
- this.artifactData = artifactData;
- this.attributeData = attributeData;
- }
-
- @Override
- public String getGuid() {
- return getArtifactData().getGuid();
- }
-
- @Override
- public ArtifactData getArtifactData() {
- return artifactData;
- }
-
- @Override
- public List<AttributeData> getAttributeData() {
- return attributeData;
- }
-
- @Override
- public List<RelationData> getRelationData() {
- return relationData;
- }
-
- @Override
- public void accept(OrcsVisitor visitor) throws OseeCoreException {
- visitor.visit(getArtifactData());
- for (AttributeData attributeData : getAttributeData()) {
- visitor.visit(attributeData);
- }
- for (RelationData relationData : getRelationData()) {
- visitor.visit(relationData);
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/HasRelationContainer.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/HasOrcsChangeSet.java
index 1c649bd6e9..3467764716 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/HasRelationContainer.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/HasOrcsChangeSet.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * 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
@@ -8,13 +8,13 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.relation;
-
+package org.eclipse.osee.orcs.core.ds;
/**
- * @author Andrew M. Finkbeiner
+ * @author Roberto E. Escobar
*/
-public interface HasRelationContainer {
+public interface HasOrcsChangeSet {
+
+ OrcsChangeSet getChangeSet();
- RelationContainer getRelationContainer();
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTransactionData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsChangeSet.java
index a1a169e2d0..12f2330197 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactTransactionData.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/OrcsChangeSet.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Boeing.
+ * 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
@@ -10,18 +10,18 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import java.util.List;
-import org.eclipse.osee.framework.core.data.Identity;
+/**
+ * @author Roberto E. Escobar
+ */
+public interface OrcsChangeSet extends OrcsVisitable {
-public interface ArtifactTransactionData extends Identity<String>, OrcsVisitable {
+ Iterable<ArtifactData> getArtifactData();
- @Override
- String getGuid();
+ Iterable<AttributeData> getAttributeData();
- ArtifactData getArtifactData();
+ Iterable<RelationData> getRelationData();
- List<AttributeData> getAttributeData();
-
- List<RelationData> getRelationData();
+ boolean isEmpty();
+ int size();
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java
index c72bb219d1..dd653107b4 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionData.java
@@ -10,11 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import java.util.List;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.orcs.data.ArtifactReadable;
-public interface TransactionData extends OrcsVisitable {
+public interface TransactionData extends HasOrcsChangeSet {
IOseeBranch getBranch();
@@ -22,6 +21,4 @@ public interface TransactionData extends OrcsVisitable {
String getComment();
- List<ArtifactTransactionData> getTxData();
-
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionResult.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionResult.java
index 050e717183..a6217773b8 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionResult.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TransactionResult.java
@@ -10,12 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.ds;
-import java.util.List;
import org.eclipse.osee.framework.core.model.TransactionRecord;
-public interface TransactionResult {
+public interface TransactionResult extends HasOrcsChangeSet {
TransactionRecord getTransaction();
- List<ArtifactTransactionData> getData();
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactBuilder.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactBuilder.java
deleted file mode 100644
index bca7d6f521..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactBuilder.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.util.List;
-import org.eclipse.osee.orcs.core.ds.LoadDataHandler;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public interface ArtifactBuilder extends LoadDataHandler {
-
- List<ArtifactReadable> getArtifacts();
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactBuilderFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactBuilderFactory.java
deleted file mode 100644
index 1021578f29..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactBuilderFactory.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 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;
-
-import org.eclipse.osee.orcs.OrcsSession;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public interface ArtifactBuilderFactory {
-
- ArtifactBuilder createArtifactBuilder(OrcsSession session);
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactLoader.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactLoader.java
deleted file mode 100644
index 0b88218038..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactLoader.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal;
-
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.executor.admin.HasCancellation;
-import org.eclipse.osee.framework.core.data.IAttributeType;
-import org.eclipse.osee.framework.core.data.IRelationType;
-import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.Loader;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public interface ArtifactLoader extends Loader {
-
- @Override
- ArtifactLoader includeDeleted();
-
- @Override
- ArtifactLoader includeDeleted(boolean enabled);
-
- @Override
- ArtifactLoader fromTransaction(int transactionId);
-
- @Override
- ArtifactLoader headTransaction();
-
- @Override
- ArtifactLoader setLoadLevel(LoadLevel loadLevel);
-
- @Override
- ArtifactLoader resetToDefaults();
-
- @Override
- ArtifactLoader loadAttributeType(IAttributeType... attributeType) throws OseeCoreException;
-
- @Override
- ArtifactLoader loadAttributeTypes(Collection<? extends IAttributeType> attributeTypes) throws OseeCoreException;
-
- @Override
- ArtifactLoader loadRelationType(IRelationType... relationType) throws OseeCoreException;
-
- @Override
- ArtifactLoader loadRelationTypes(Collection<? extends IRelationType> relationType) throws OseeCoreException;
-
- List<ArtifactReadable> load() throws OseeCoreException;
-
- List<ArtifactReadable> load(HasCancellation cancellation) throws OseeCoreException;
-
- ResultSet<ArtifactReadable> getResults() throws OseeCoreException;
-
- ResultSet<ArtifactReadable> getResults(HasCancellation cancellation) throws OseeCoreException;
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactLoaderFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactLoaderFactory.java
deleted file mode 100644
index da7838ea6c..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/ArtifactLoaderFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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;
-
-import java.util.Collection;
-import org.eclipse.osee.executor.admin.HasCancellation;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.QueryContext;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface ArtifactLoaderFactory {
-
- int getCount(HasCancellation cancellation, QueryContext queryContext) throws OseeCoreException;
-
- ArtifactLoader fromQueryContext(OrcsSession session, QueryContext queryContext) throws OseeCoreException;
-
- ArtifactLoader fromBranchAndArtifactIds(OrcsSession session, IOseeBranch branch, Collection<Integer> artifactIds) throws OseeCoreException;
-
- ArtifactLoader fromBranchAndArtifactIds(OrcsSession session, IOseeBranch branch, int... artifactIds) throws OseeCoreException;
-
-}
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 5c3555215e..d0cbfa3a2d 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
@@ -41,13 +41,19 @@ import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeClassRegistry;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeClassResolver;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
+import org.eclipse.osee.orcs.core.internal.graph.GraphBuilderFactory;
+import org.eclipse.osee.orcs.core.internal.graph.GraphData;
+import org.eclipse.osee.orcs.core.internal.graph.GraphFactory;
+import org.eclipse.osee.orcs.core.internal.graph.GraphProvider;
+import org.eclipse.osee.orcs.core.internal.graph.impl.GraphFactoryImpl;
import org.eclipse.osee.orcs.core.internal.indexer.IndexerModule;
-import org.eclipse.osee.orcs.core.internal.loader.ArtifactBuilderFactoryImpl;
-import org.eclipse.osee.orcs.core.internal.loader.ArtifactLoaderFactoryImpl;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
import org.eclipse.osee.orcs.core.internal.proxy.impl.ExternalArtifactManagerImpl;
import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
-import org.eclipse.osee.orcs.core.internal.relation.RelationGraphImpl;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManagerFactory;
+import org.eclipse.osee.orcs.core.internal.relation.RelationNodeLoader;
+import org.eclipse.osee.orcs.core.internal.relation.impl.RelationNodeLoaderImpl;
import org.eclipse.osee.orcs.core.internal.search.QueryModule;
import org.eclipse.osee.orcs.core.internal.session.OrcsSessionImpl;
import org.eclipse.osee.orcs.core.internal.transaction.TransactionFactoryImpl;
@@ -59,7 +65,6 @@ import org.eclipse.osee.orcs.core.internal.types.BranchHierarchyProvider;
import org.eclipse.osee.orcs.core.internal.types.OrcsTypesModule;
import org.eclipse.osee.orcs.core.internal.util.ValueProviderFactory;
import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.search.QueryFactory;
import org.eclipse.osee.orcs.search.QueryIndexer;
import org.eclipse.osee.orcs.transaction.TransactionFactory;
@@ -74,12 +79,9 @@ public class OrcsApiImpl implements OrcsApi {
private OrcsDataStore dataStore;
private AttributeClassRegistry registry;
private TempCachingService cacheService;
-
private ExecutorAdmin executorAdmin;
private SystemPreferences preferences;
- private ExternalArtifactManager proxyManager;
- private ArtifactLoaderFactory loaderFactory;
private QueryModule queryModule;
private IndexerModule indexerModule;
private OrcsTypesModule typesModule;
@@ -146,30 +148,40 @@ public class OrcsApiImpl implements OrcsApi {
AttributeClassResolver resolver = new AttributeClassResolver(registry, orcsTypes.getAttributeTypes());
AttributeFactory attributeFactory =
new AttributeFactory(resolver, module.getDataFactory(), orcsTypes.getAttributeTypes());
-
ValueProviderFactory providerFactory = new ValueProviderFactory(cacheService.getBranchCache());
+ ArtifactFactory artifactFactory =
+ new ArtifactFactory(module.getDataFactory(), attributeFactory, orcsTypes.getArtifactTypes(), providerFactory);
RelationFactory relationFactory =
new RelationFactory(orcsTypes.getRelationTypes(), module.getDataFactory(), providerFactory);
- ArtifactFactory artifactFactory =
- new ArtifactFactory(module.getDataFactory(), attributeFactory, relationFactory, orcsTypes.getArtifactTypes(),
- providerFactory);
+ final GraphFactory graphFactory =
+ new GraphFactoryImpl(cacheService.getBranchCache(), cacheService.getTransactionCache());
+ GraphBuilderFactory graphBuilderFactory =
+ new GraphBuilderFactory(logger, artifactFactory, attributeFactory, relationFactory);
- proxyManager = new ExternalArtifactManagerImpl();
+ RelationNodeLoader nodeLoader = new RelationNodeLoaderImpl(module.getDataLoaderFactory(), graphBuilderFactory);
+ RelationManager relationManager =
+ RelationManagerFactory.createRelationManager(logger, orcsTypes.getRelationTypes(), relationFactory, nodeLoader);
- ArtifactBuilderFactory builderFactory =
- new ArtifactBuilderFactoryImpl(logger, proxyManager, artifactFactory, attributeFactory, relationFactory);
+ GraphProvider graphProvider = new GraphProvider() {
+
+ @Override
+ public GraphData getGraph(OrcsSession session, IOseeBranch branch, int transactionId) throws OseeCoreException {
+ return graphFactory.createGraph(branch, transactionId);
+ }
+ };
- loaderFactory = new ArtifactLoaderFactoryImpl(module.getDataLoaderFactory(), builderFactory);
+ ExternalArtifactManager proxyManager = new ExternalArtifactManagerImpl(relationManager);
- TxDataLoader txDataLoader = new TxDataLoaderImpl();
- txDataManager = new TxDataManager(proxyManager, artifactFactory, txDataLoader);
+ TxDataLoader txDataLoader =
+ new TxDataLoaderImpl(module.getDataLoaderFactory(), graphFactory, graphBuilderFactory, graphProvider);
+ txDataManager = new TxDataManager(proxyManager, artifactFactory, relationManager, txDataLoader);
txCallableFactory = new TxCallableFactory(logger, module.getTxDataStore(), txDataManager);
queryModule =
- new QueryModule(logger, module.getQueryEngine(), builderFactory, orcsTypes.getArtifactTypes(),
- orcsTypes.getAttributeTypes());
+ new QueryModule(logger, module.getQueryEngine(), graphBuilderFactory, graphProvider,
+ orcsTypes.getArtifactTypes(), orcsTypes.getAttributeTypes(), proxyManager);
indexerModule = new IndexerModule(logger, preferences, executorAdmin, dataStore.getQueryEngineIndexer());
indexerModule.start(getSystemSession(), orcsTypes.getAttributeTypes());
@@ -180,8 +192,12 @@ public class OrcsApiImpl implements OrcsApi {
indexerModule.stop();
}
queryModule = null;
- loaderFactory = null;
- proxyManager = null;
+ txDataManager = null;
+ txCallableFactory = null;
+ module = null;
+ if (typesModule != null) {
+ typesModule.stop();
+ }
systemSession = null;
}
@@ -202,12 +218,6 @@ public class OrcsApiImpl implements OrcsApi {
}
@Override
- public GraphReadable getGraph(ApplicationContext context) {
- OrcsSession session = getSession(context);
- return new RelationGraphImpl(session, loaderFactory, getOrcsTypes(context).getRelationTypes(), proxyManager);
- }
-
- @Override
public OrcsBranch getBranchOps(final ApplicationContext context) {
OrcsSession session = getSession(context);
LazyObject<ArtifactReadable> systemUser = new LazyObject<ArtifactReadable>() {
@@ -278,4 +288,5 @@ public class OrcsApiImpl implements OrcsApi {
String sessionId = GUID.create();
return new OrcsSessionImpl(sessionId);
}
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java
index 4cdec8b32b..6b647f179d 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/Artifact.java
@@ -15,7 +15,6 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
import org.eclipse.osee.orcs.core.ds.HasOrcsData;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeManager;
-import org.eclipse.osee.orcs.core.internal.relation.HasRelationContainer;
import org.eclipse.osee.orcs.core.internal.relation.RelationNode;
import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.HasTransaction;
@@ -23,7 +22,7 @@ import org.eclipse.osee.orcs.data.HasTransaction;
/**
* @author Megumi Telles
*/
-public interface Artifact extends HasRelationContainer, ArtifactId, AttributeManager, HasTransaction, ArtifactVisitable, HasOrcsData<ArtifactData>, RelationNode {
+public interface Artifact extends ArtifactId, AttributeManager, HasTransaction, ArtifactVisitable, HasOrcsData<ArtifactData>, RelationNode {
void setArtifactType(IArtifactType artifactType) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java
index 7e99abde84..0a89bf7f8a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactFactory.java
@@ -26,8 +26,6 @@ import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
-import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
-import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
import org.eclipse.osee.orcs.core.internal.util.ValueProviderFactory;
import org.eclipse.osee.orcs.data.ArtifactTypes;
@@ -40,15 +38,13 @@ public class ArtifactFactory {
private final ArtifactDataFactory factory;
private final AttributeFactory attributeFactory;
- private final RelationFactory relationFactory;
private final ArtifactTypes artifactTypeCache;
private final ValueProviderFactory providerFactory;
- public ArtifactFactory(ArtifactDataFactory factory, AttributeFactory attributeFactory, RelationFactory relationFactory, ArtifactTypes artifactTypeCache, ValueProviderFactory providerFactory) {
+ public ArtifactFactory(ArtifactDataFactory factory, AttributeFactory attributeFactory, ArtifactTypes artifactTypeCache, ValueProviderFactory providerFactory) {
super();
this.factory = factory;
this.attributeFactory = attributeFactory;
- this.relationFactory = relationFactory;
this.artifactTypeCache = artifactTypeCache;
this.providerFactory = providerFactory;
}
@@ -56,9 +52,8 @@ public class ArtifactFactory {
@SuppressWarnings("unused")
public Artifact createArtifact(ArtifactData artifactData) throws OseeCoreException {
//TODO implement an artifact class resolver for specific artifact types
- RelationContainer relationContainer = relationFactory.createRelationContainer(artifactData.getLocalId());
ValueProvider<Branch, OrcsData> branchProvider = providerFactory.createBranchProvider(artifactData);
- return new ArtifactImpl(artifactTypeCache, artifactData, attributeFactory, relationContainer, branchProvider);
+ return new ArtifactImpl(artifactTypeCache, artifactData, attributeFactory, branchProvider);
}
public Artifact createArtifact(IOseeBranch branch, IArtifactType artifactType, String guid) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java
index 5e8434a3e5..b958e1ba57 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/artifact/ArtifactImpl.java
@@ -26,7 +26,6 @@ import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
import org.eclipse.osee.orcs.core.internal.attribute.AttributeManagerImpl;
import org.eclipse.osee.orcs.core.internal.graph.GraphData;
-import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
import org.eclipse.osee.orcs.core.internal.relation.order.OrderChange;
import org.eclipse.osee.orcs.core.internal.util.ValueProvider;
import org.eclipse.osee.orcs.data.ArtifactTypes;
@@ -40,14 +39,11 @@ public class ArtifactImpl extends AttributeManagerImpl implements Artifact {
private ArtifactData artifactData;
private GraphData graph;
- private final RelationContainer relationContainer;
-
- public ArtifactImpl(ArtifactTypes artifactTypeCache, ArtifactData artifactData, AttributeFactory attributeFactory, RelationContainer relationContainer, ValueProvider<? extends IOseeBranch, OrcsData> branchProvider) {
+ public ArtifactImpl(ArtifactTypes artifactTypeCache, ArtifactData artifactData, AttributeFactory attributeFactory, ValueProvider<? extends IOseeBranch, OrcsData> branchProvider) {
super(attributeFactory);
this.artifactTypeCache = artifactTypeCache;
this.artifactData = artifactData;
this.branchProvider = branchProvider;
- this.relationContainer = relationContainer;
this.objectEditState = EditState.NO_CHANGE;
}
@@ -62,11 +58,6 @@ public class ArtifactImpl extends AttributeManagerImpl implements Artifact {
}
@Override
- public RelationContainer getRelationContainer() {
- return relationContainer;
- }
-
- @Override
public ArtifactData getOrcsData() {
return artifactData;
}
@@ -175,7 +166,7 @@ public class ArtifactImpl extends AttributeManagerImpl implements Artifact {
@Override
public String getExceptionString() {
try {
- return String.format("artifact type [%s] guid[%s] on branch[%s]", getArtifactType(), getGuid(), getBranch());
+ return String.format("artifact type[%s] guid[%s] on branch[%s]", getArtifactType(), getGuid(), getBranch());
} catch (OseeCoreException ex) {
return Lib.exceptionToString(ex);
}
@@ -225,4 +216,13 @@ public class ArtifactImpl extends AttributeManagerImpl implements Artifact {
}
}
+ @Override
+ public String toString() {
+ try {
+ return String.format("artifact [type=[%s] guid=[%s] branch=[%s]]", getArtifactType(), getGuid(), getBranch());
+ } catch (OseeCoreException ex) {
+ return Lib.exceptionToString(ex);
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderFactoryImpl.java
deleted file mode 100644
index 3c28ba9465..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderFactoryImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * 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.loader;
-
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilderFactory;
-import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
-import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
-import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
-import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class ArtifactBuilderFactoryImpl implements ArtifactBuilderFactory {
-
- private final Log logger;
- private final ExternalArtifactManager proxyFactory;
-
- private final ArtifactFactory artifactFactory;
- private final AttributeFactory attributeFactory;
- private final RelationFactory relationFactory;
-
- public ArtifactBuilderFactoryImpl(Log logger, ExternalArtifactManager proxyFactory, ArtifactFactory artifactFactory, AttributeFactory attributeFactory, RelationFactory relationFactory) {
- super();
- this.logger = logger;
- this.proxyFactory = proxyFactory;
- this.artifactFactory = artifactFactory;
- this.attributeFactory = attributeFactory;
- this.relationFactory = relationFactory;
- }
-
- @Override
- public ArtifactBuilder createArtifactBuilder(OrcsSession session) {
- return new ArtifactBuilderImpl(logger, proxyFactory, artifactFactory, attributeFactory, relationFactory, session);
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java
deleted file mode 100644
index 92ce2fca06..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactBuilderImpl.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * 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.loader;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.ds.LoadDataHandlerAdapter;
-import org.eclipse.osee.orcs.core.ds.LoadDescription;
-import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
-import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
-import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
-import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory;
-import org.eclipse.osee.orcs.core.internal.attribute.AttributeManager;
-import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
-import org.eclipse.osee.orcs.core.internal.relation.RelationContainer;
-import org.eclipse.osee.orcs.core.internal.relation.RelationFactory;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class ArtifactBuilderImpl extends LoadDataHandlerAdapter implements ArtifactBuilder {
-
- private final Log logger;
- private final ExternalArtifactManager proxyFactory;
- private final ArtifactFactory artifactFactory;
- private final AttributeFactory attributeFactory;
- private final RelationFactory relationFactory;
- private final OrcsSession session;
-
- private final Set<Artifact> created = new HashSet<Artifact>();
- private final Map<Integer, RelationContainer> relations = new HashMap<Integer, RelationContainer>();
- private final Map<Integer, AttributeManager> attributes = new HashMap<Integer, AttributeManager>();
- private final Map<Integer, Artifact> artifacts = new LinkedHashMap<Integer, Artifact>();
- private List<ArtifactReadable> readables;
-
- public ArtifactBuilderImpl(Log logger, ExternalArtifactManager proxyFactory, ArtifactFactory artifactFactory, AttributeFactory attributeFactory, RelationFactory relationFactory, OrcsSession session) {
- super();
- this.logger = logger;
- this.proxyFactory = proxyFactory;
- this.artifactFactory = artifactFactory;
- this.attributeFactory = attributeFactory;
- this.relationFactory = relationFactory;
- this.session = session;
- }
-
- @Override
- public List<ArtifactReadable> getArtifacts() {
- return readables != null ? readables : Collections.<ArtifactReadable> emptyList();
- }
-
- @Override
- public void onLoadDescription(LoadDescription data) {
- //
- };
-
- @Override
- public void onLoadStart() {
- artifacts.clear();
- relations.clear();
- attributes.clear();
- created.clear();
- readables = null;
- }
-
- @Override
- public void onLoadEnd() throws OseeCoreException {
- super.onLoadEnd();
- relations.clear();
- attributes.clear();
- collectResults();
- }
-
- private void collectResults() throws OseeCoreException {
- // Make artifacts available to others
- // for (Artifact artifact : created) {
- // cache.cache(artifact);
- // }
- created.clear();
-
- readables = new ArrayList<ArtifactReadable>(artifacts.size());
- for (Artifact artifact : artifacts.values()) {
- ArtifactReadable readable = proxyFactory.asExternalArtifact(session, artifact);
- readables.add(readable);
- }
- artifacts.clear();
- }
-
- private Artifact getCachedArtifact(ArtifactData data) {
- Artifact toReturn = null;
- if (artifacts != null) {
- toReturn = artifacts.get(data.getLocalId());
- if (toReturn == null) {
- // toReturn = cache.get(data);
- }
- }
- return toReturn;
- }
-
- @Override
- public void onData(ArtifactData data) throws OseeCoreException {
- Artifact artifact = getCachedArtifact(data);
- if (artifact == null) {
- artifact = artifactFactory.createArtifact(data);
- created.add(artifact);
- }
- artifacts.put(artifact.getLocalId(), artifact);
- attributes.put(artifact.getLocalId(), artifact);
- relations.put(artifact.getLocalId(), artifact.getRelationContainer());
- }
-
- @Override
- public void onData(AttributeData data) throws OseeCoreException {
- AttributeManager container = attributes.get(data.getArtifactId());
- if (container == null) {
- logger.warn("Orphaned attribute detected - [%s]", data);
- } else {
- attributeFactory.createAttribute(container, data);
- }
- }
-
- @Override
- public void onData(RelationData data) throws OseeCoreException {
- addRelationFor(data.getArtIdA(), data);
- addRelationFor(data.getArtIdB(), data);
- }
-
- private void addRelationFor(int id, RelationData data) throws OseeCoreException {
- RelationContainer container = relations.get(id);
- if (container == null) {
- container = relationFactory.createRelationContainer(id);
- }
- container.add(data);
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImpl.java
deleted file mode 100644
index 6d74a5cb83..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderFactoryImpl.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.loader;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.util.Collection;
-import org.eclipse.osee.executor.admin.HasCancellation;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.DataLoader;
-import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
-import org.eclipse.osee.orcs.core.ds.QueryContext;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilderFactory;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoader;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class ArtifactLoaderFactoryImpl implements ArtifactLoaderFactory {
-
- private final DataLoaderFactory dataLoaderFactory;
- private final ArtifactBuilderFactory builderFactory;
-
- public ArtifactLoaderFactoryImpl(DataLoaderFactory dataLoaderFactory, ArtifactBuilderFactory builderFactory) {
- super();
- this.dataLoaderFactory = dataLoaderFactory;
- this.builderFactory = builderFactory;
- }
-
- @Override
- public int getCount(HasCancellation cancellation, QueryContext queryContext) throws OseeCoreException {
- return dataLoaderFactory.getCount(cancellation, queryContext);
- }
-
- @Override
- public ArtifactLoader fromQueryContext(OrcsSession session, QueryContext queryContext) throws OseeCoreException {
- DataLoader loader = dataLoaderFactory.fromQueryContext(queryContext);
- return create(session, loader);
- }
-
- @Override
- public ArtifactLoader fromBranchAndArtifactIds(OrcsSession session, IOseeBranch branch, Collection<Integer> artifactIds) throws OseeCoreException {
- DataLoader loader = dataLoaderFactory.fromBranchAndArtifactIds(session, branch, artifactIds);
- return create(session, loader);
- }
-
- @Override
- public ArtifactLoader fromBranchAndArtifactIds(OrcsSession session, IOseeBranch branch, int... artifactIds) throws OseeCoreException {
- DataLoader loader = dataLoaderFactory.fromBranchAndArtifactIds(session, branch, artifactIds);
- return create(session, loader);
- }
-
- @SuppressWarnings("unchecked")
- private <T> T create(OrcsSession session, DataLoader loader) {
- InvocationHandler handler = new ArtifactLoaderInvocationHandler(builderFactory, session, loader);
- Class<?>[] types = new Class<?>[] {ArtifactLoader.class};
- return (T) Proxy.newProxyInstance(ArtifactLoader.class.getClassLoader(), types, handler);
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderInvocationHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderInvocationHandler.java
deleted file mode 100644
index f177c3cc55..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/loader/ArtifactLoaderInvocationHandler.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * 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.loader;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.List;
-import org.eclipse.osee.executor.admin.HasCancellation;
-import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.DataLoader;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilderFactory;
-import org.eclipse.osee.orcs.core.internal.util.ResultSets;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class ArtifactLoaderInvocationHandler implements InvocationHandler {
-
- private final OrcsSession session;
- private final DataLoader proxied;
- private final ArtifactBuilderFactory builderFactory;
-
- public ArtifactLoaderInvocationHandler(ArtifactBuilderFactory builderFactory, OrcsSession session, DataLoader proxied) {
- super();
- this.session = session;
- this.proxied = proxied;
- this.builderFactory = builderFactory;
- }
-
- @Override
- public Object invoke(Object object, Method method, Object[] args) throws Throwable {
- Object toReturn = null;
- if (isLoad(method)) {
- HasCancellation cancellation = null;
- if (args != null && args.length > 0) {
- cancellation = (HasCancellation) args[0];
- }
- toReturn = load(cancellation);
- } else if (isGetResults(method)) {
- HasCancellation cancellation = null;
- if (args != null && args.length > 0) {
- cancellation = (HasCancellation) args[0];
- }
- toReturn = getResults(cancellation);
- } else {
- Method delegateMethod = getMethodFor(proxied.getClass(), method);
- toReturn = delegateMethod.invoke(proxied, args);
- if (toReturn instanceof DataLoader) {
- toReturn = object;
- }
- }
- return toReturn;
- }
-
- private ResultSet<ArtifactReadable> getResults(HasCancellation cancellation) throws OseeCoreException {
- List<ArtifactReadable> data = load(cancellation);
- return ResultSets.newResultSet(data);
- }
-
- private boolean isLoad(Method method) {
- return "load".equals(method.getName());
- }
-
- private boolean isGetResults(Method method) {
- return "getResults".equals(method.getName());
- }
-
- private List<ArtifactReadable> load(HasCancellation cancellation) throws OseeCoreException {
- ArtifactBuilder builder = builderFactory.createArtifactBuilder(session);
- proxied.load(cancellation, builder);
- return builder.getArtifacts();
- }
-
- private Method getMethodFor(Class<?> clazz, Method method) {
- Method toReturn = null;
- try {
- toReturn = clazz.getMethod(method.getName(), method.getParameterTypes());
- } catch (Exception ex) {
- // Do Nothing;
- }
- return toReturn;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ExternalArtifactManager.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ExternalArtifactManager.java
index 74b17870e8..c7778c5518 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ExternalArtifactManager.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/ExternalArtifactManager.java
@@ -14,8 +14,10 @@ import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.relation.RelationNode;
import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.AttributeReadable;
/**
* @author Megumi Telles
@@ -30,4 +32,8 @@ public interface ExternalArtifactManager {
ArtifactReadable asExternalArtifact(OrcsSession session, Artifact artifact) throws OseeCoreException;
+ <T> AttributeReadable<T> asExternalAttribute(OrcsSession session, Attribute<T> attribute) throws OseeCoreException;
+
+ <T> ResultSet<AttributeReadable<T>> asExternalAttributes(OrcsSession session, Iterable<? extends Attribute<T>> attributes) throws OseeCoreException;
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AbstractProxied.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AbstractProxied.java
new file mode 100644
index 0000000000..2fed2ed8e7
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AbstractProxied.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.proxy.impl;
+
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public abstract class AbstractProxied<T> {
+
+ private final T proxiedObject;
+ private final OrcsSession session;
+ private final ExternalArtifactManager proxyManager;
+
+ public AbstractProxied(ExternalArtifactManager proxyManager, OrcsSession session, T proxiedObject) {
+ super();
+ this.proxiedObject = proxiedObject;
+ this.session = session;
+ this.proxyManager = proxyManager;
+ }
+
+ protected OrcsSession getSession() {
+ return session;
+ }
+
+ protected ExternalArtifactManager getProxyManager() {
+ return proxyManager;
+ }
+
+ protected T getProxiedObject() {
+ return proxiedObject;
+ }
+
+ @Override
+ public String toString() {
+ return getProxiedObject().toString();
+ }
+
+ @Override
+ public boolean equals(Object arg0) {
+ return getProxiedObject().equals(arg0);
+ }
+
+ @Override
+ public int hashCode() {
+ return getProxiedObject().hashCode();
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java
index 44d19b4177..b260457355 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ArtifactReadOnlyImpl.java
@@ -10,17 +10,28 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.proxy.impl;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.asRelationType;
import java.util.Collection;
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.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.Identity;
+import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
+import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+import org.eclipse.osee.orcs.core.internal.graph.GraphData;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationNode;
+import org.eclipse.osee.orcs.core.internal.relation.RelationUtil;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeId;
import org.eclipse.osee.orcs.data.AttributeReadable;
@@ -28,17 +39,21 @@ import org.eclipse.osee.orcs.data.AttributeReadable;
/**
* @author Megumi Telles
*/
-public class ArtifactReadOnlyImpl implements ArtifactReadable {
+public class ArtifactReadOnlyImpl extends AbstractProxied<Artifact> implements ArtifactReadable {
- private final Artifact proxiedObject;
- private final OrcsSession session;
- private final ExternalArtifactManager proxyManager;
+ private final RelationManager relationManager;
- public ArtifactReadOnlyImpl(ExternalArtifactManager proxyManager, OrcsSession session, Artifact proxiedObject) {
- super();
- this.proxiedObject = proxiedObject;
- this.session = session;
- this.proxyManager = proxyManager;
+ public ArtifactReadOnlyImpl(ExternalArtifactManager proxyManager, RelationManager relationManager, OrcsSession session, Artifact proxiedObject) {
+ super(proxyManager, session, proxiedObject);
+ this.relationManager = relationManager;
+ }
+
+ private RelationManager getRelationManager() {
+ return relationManager;
+ }
+
+ private GraphData getGraphData() {
+ return getProxiedObject().getGraph();
}
@Override
@@ -47,13 +62,13 @@ public class ArtifactReadOnlyImpl implements ArtifactReadable {
}
@Override
- public boolean matches(Identity<?>... identities) {
- return false;
+ public String getName() {
+ return getProxiedObject().getName();
}
@Override
- public String getName() {
- return getProxiedObject().getName();
+ public boolean matches(Identity<?>... identities) {
+ return getProxiedObject().matches(identities);
}
@Override
@@ -63,12 +78,27 @@ public class ArtifactReadOnlyImpl implements ArtifactReadable {
@Override
public IOseeBranch getBranch() throws OseeCoreException {
- return proxiedObject.getBranch();
+ return getProxiedObject().getBranch();
}
@Override
public int getTransaction() {
- return proxiedObject.getTransaction();
+ return getProxiedObject().getTransaction();
+ }
+
+ @Override
+ public String getHumanReadableId() {
+ return getProxiedObject().getHumanReadableId();
+ }
+
+ @Override
+ public IArtifactType getArtifactType() throws OseeCoreException {
+ return getProxiedObject().getArtifactType();
+ }
+
+ @Override
+ public boolean isOfType(IArtifactType... otherTypes) throws OseeCoreException {
+ return getProxiedObject().isOfType(otherTypes);
}
@Override
@@ -117,75 +147,107 @@ public class ArtifactReadOnlyImpl implements ArtifactReadable {
}
@Override
- public boolean isDeleted() {
- return getProxiedObject().isDeleted();
+ public ResultSet<? extends AttributeReadable<Object>> getAttributes() throws OseeCoreException {
+ List<Attribute<Object>> attributes = getProxiedObject().getAttributes();
+ return getProxyManager().asExternalAttributes(getSession(), attributes);
}
@Override
- public String getHumanReadableId() {
- return getProxiedObject().getHumanReadableId();
+ public <T> ResultSet<? extends AttributeReadable<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException {
+ List<Attribute<T>> attributes = getProxiedObject().getAttributes(attributeType);
+ return getProxyManager().asExternalAttributes(getSession(), attributes);
}
@Override
- public IArtifactType getArtifactType() throws OseeCoreException {
- return getProxiedObject().getArtifactType();
+ public ResultSet<? extends AttributeReadable<Object>> getAttributes(DeletionFlag deletionFlag) throws OseeCoreException {
+ List<Attribute<Object>> attributes = getProxiedObject().getAttributes(deletionFlag);
+ return getProxyManager().asExternalAttributes(getSession(), attributes);
}
@Override
- public boolean isOfType(IArtifactType... otherTypes) throws OseeCoreException {
- return getProxiedObject().isOfType(otherTypes);
+ public <T> ResultSet<? extends AttributeReadable<T>> getAttributes(IAttributeType attributeType, DeletionFlag deletionFlag) throws OseeCoreException {
+ List<Attribute<T>> attributes = getProxiedObject().getAttributes(attributeType, deletionFlag);
+ return getProxyManager().asExternalAttributes(getSession(), attributes);
}
@Override
- public boolean equals(Object obj) {
- return proxiedObject.equals(obj);
+ public AttributeReadable<Object> getAttributeById(AttributeId attributeId) throws OseeCoreException {
+ Attribute<Object> attribute = getProxiedObject().getAttributeById(attributeId);
+ return getProxyManager().asExternalAttribute(getSession(), attribute);
}
@Override
- public int hashCode() {
- return proxiedObject.hashCode();
+ public boolean isDeleted() {
+ return getProxiedObject().isDeleted();
}
@Override
- public String toString() {
- return proxiedObject.toString();
+ public int getMaximumRelationAllowed(IRelationTypeSide typeAndSide) throws OseeCoreException {
+ IRelationType type = asRelationType(typeAndSide);
+ RelationSide side = whichSideAmIOn(typeAndSide);
+ return getRelationManager().getMaximumRelationAllowed(getSession(), type, getProxiedObject(), side);
}
- public Artifact getProxiedObject() {
- return proxiedObject;
+ @Override
+ public Collection<? extends IRelationType> getValidRelationTypes() throws OseeCoreException {
+ return getRelationManager().getValidRelationTypes(getSession(), getProxiedObject());
}
- protected OrcsSession getSession() {
- return session;
+ @Override
+ public Collection<? extends IRelationType> getExistingRelationTypes() throws OseeCoreException {
+ return getRelationManager().getExistingRelationTypes(getSession(), getGraphData(), getProxiedObject());
}
- public ExternalArtifactManager getProxyManager() {
- return proxyManager;
+ @Override
+ public ArtifactReadable getParent() throws OseeCoreException {
+ Artifact parent = getRelationManager().getParent(getSession(), getGraphData(), getProxiedObject());
+ return getProxyManager().asExternalArtifact(getSession(), parent);
}
@Override
- public List<? extends AttributeReadable<Object>> getAttributes() throws OseeCoreException {
- return getProxiedObject().getAttributes();
+ public ResultSet<ArtifactReadable> getChildren() throws OseeCoreException {
+ ResultSet<Artifact> children = getRelationManager().getChildren(getSession(), getGraphData(), getProxiedObject());
+ return getProxyManager().asExternalArtifacts(getSession(), children);
}
@Override
- public <T> List<? extends AttributeReadable<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException {
- return getProxiedObject().getAttributes(attributeType);
+ public ResultSet<ArtifactReadable> getRelated(IRelationTypeSide typeAndSide) throws OseeCoreException {
+ IRelationType type = asRelationType(typeAndSide);
+ RelationSide side = whichSideAmIOn(typeAndSide);
+ ResultSet<Artifact> related =
+ getRelationManager().getRelated(getSession(), getGraphData(), type, getProxiedObject(), side);
+ return getProxyManager().asExternalArtifacts(getSession(), related);
}
@Override
- public List<? extends AttributeReadable<Object>> getAttributes(DeletionFlag deletionFlag) throws OseeCoreException {
- return getProxiedObject().getAttributes(deletionFlag);
+ public int getRelatedCount(IRelationTypeSide typeAndSide) throws OseeCoreException {
+ IRelationType type = asRelationType(typeAndSide);
+ RelationSide side = whichSideAmIOn(typeAndSide);
+ return getRelationManager().getRelatedCount(getSession(), getGraphData(), type, getProxiedObject(), side);
}
@Override
- public <T> List<? extends AttributeReadable<T>> getAttributes(IAttributeType attributeType, DeletionFlag deletionFlag) throws OseeCoreException {
- return getProxiedObject().getAttributes(attributeType, deletionFlag);
+ public boolean areRelated(IRelationTypeSide typeAndSide, ArtifactReadable readable) throws OseeCoreException {
+ IRelationType type = asRelationType(typeAndSide);
+ Pair<RelationNode, RelationNode> nodes = asABNodes(typeAndSide.getSide(), readable);
+ return getRelationManager().areRelated(getSession(), getGraphData(), nodes.getFirst(), type, nodes.getSecond());
}
@Override
- public AttributeReadable<Object> getAttributeById(AttributeId attributeId) throws OseeCoreException {
- return getProxiedObject().getAttributeById(attributeId);
+ public String getRationale(IRelationTypeSide typeAndSide, ArtifactReadable readable) throws OseeCoreException {
+ IRelationType type = asRelationType(typeAndSide);
+ Pair<RelationNode, RelationNode> nodes = asABNodes(typeAndSide.getSide(), readable);
+ return getRelationManager().getRationale(getSession(), getGraphData(), nodes.getFirst(), type, nodes.getSecond());
+ }
+
+ private Pair<RelationNode, RelationNode> asABNodes(RelationSide side, ArtifactReadable readable) throws OseeCoreException {
+ Artifact thisArtifact = getProxiedObject();
+ Artifact otherArtifact = getProxyManager().asInternalArtifact(readable);
+ return RelationUtil.asABNodes(thisArtifact, otherArtifact, side);
+ }
+
+ private RelationSide whichSideAmIOn(IRelationTypeSide typeAndSide) {
+ return typeAndSide.getSide().oppositeSide();
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AttributeReadOnlyImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AttributeReadOnlyImpl.java
new file mode 100644
index 0000000000..2e46bfb3db
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/AttributeReadOnlyImpl.java
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.proxy.impl;
+
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.data.AttributeReadable;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeReadOnlyImpl<T> extends AbstractProxied<Attribute<T>> implements AttributeReadable<T> {
+
+ public AttributeReadOnlyImpl(ExternalArtifactManager proxyManager, OrcsSession session, Attribute<T> proxiedObject) {
+ super(proxyManager, session, proxiedObject);
+ }
+
+ @Override
+ public int getLocalId() {
+ return getProxiedObject().getLocalId();
+ }
+
+ @Override
+ public boolean isDeleted() {
+ return getProxiedObject().isDeleted();
+ }
+
+ @Override
+ public long getGammaId() {
+ return getProxiedObject().getGammaId();
+ }
+
+ @Override
+ public ModificationType getModificationType() {
+ return getProxiedObject().getModificationType();
+ }
+
+ @Override
+ public IAttributeType getAttributeType() throws OseeCoreException {
+ return getProxiedObject().getAttributeType();
+ }
+
+ @Override
+ public boolean isOfType(IAttributeType otherAttributeType) throws OseeCoreException {
+ return getProxiedObject().isOfType(otherAttributeType);
+ }
+
+ @Override
+ public T getValue() throws OseeCoreException {
+ return getProxiedObject().getValue();
+ }
+
+ @Override
+ public String getDisplayableString() throws OseeCoreException {
+ return getProxiedObject().getDisplayableString();
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerImpl.java
index 581562f9f5..e3e56e1139 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/proxy/impl/ExternalArtifactManagerImpl.java
@@ -13,10 +13,14 @@ package org.eclipse.osee.orcs.core.internal.proxy.impl;
import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
import org.eclipse.osee.orcs.core.internal.relation.RelationNode;
import org.eclipse.osee.orcs.core.internal.util.ResultSetIterable;
+import org.eclipse.osee.orcs.core.internal.util.ResultSets;
import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.AttributeReadable;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
@@ -25,8 +29,34 @@ import com.google.common.collect.Iterables;
*/
public class ExternalArtifactManagerImpl implements ExternalArtifactManager {
- public ExternalArtifactManagerImpl() {
+ private final Function<ArtifactReadable, Artifact> readableToArtifact;
+ private final RelationManager relationManager;
+
+ public ExternalArtifactManagerImpl(RelationManager relationManager) {
super();
+ this.relationManager = relationManager;
+ this.readableToArtifact = new ReadableToArtifactFunction();
+ }
+
+ @Override
+ public Artifact asInternalArtifact(ArtifactReadable external) {
+ return external == null ? null : ((ArtifactReadOnlyImpl) external).getProxiedObject();
+ }
+
+ @Override
+ public ArtifactReadable asExternalArtifact(OrcsSession session, Artifact artifact) {
+ return artifact == null ? null : new ArtifactReadOnlyImpl(this, relationManager, session, artifact);
+ }
+
+ @Override
+ public <T> AttributeReadable<T> asExternalAttribute(OrcsSession session, Attribute<T> attribute) {
+ return attribute == null ? null : new AttributeReadOnlyImpl<T>(this, session, attribute);
+ }
+
+ @Override
+ public ResultSet<? extends RelationNode> asInternalArtifacts(Iterable<? extends ArtifactReadable> externals) {
+ Iterable<Artifact> transformed = Iterables.transform(externals, readableToArtifact);
+ return ResultSets.newResultSet(transformed);
}
@Override
@@ -43,25 +73,23 @@ public class ExternalArtifactManagerImpl implements ExternalArtifactManager {
}
@Override
- public ResultSet<? extends RelationNode> asInternalArtifacts(Iterable<? extends ArtifactReadable> externals) {
- Iterable<Artifact> transformed = Iterables.transform(externals, new Function<ArtifactReadable, Artifact>() {
+ public <T> ResultSet<AttributeReadable<T>> asExternalAttributes(final OrcsSession session, Iterable<? extends Attribute<T>> attributes) {
+ Iterable<AttributeReadable<T>> transformed =
+ Iterables.transform(attributes, new Function<Attribute<T>, AttributeReadable<T>>() {
- @Override
- public Artifact apply(ArtifactReadable external) {
- return asInternalArtifact(external);
- }
- });
- return new ResultSetIterable<Artifact>(transformed);
- }
-
- @Override
- public Artifact asInternalArtifact(ArtifactReadable external) {
- return ((ArtifactReadOnlyImpl) external).getProxiedObject();
+ @Override
+ public AttributeReadable<T> apply(Attribute<T> internal) {
+ return asExternalAttribute(session, internal);
+ }
+ });
+ return ResultSets.newResultSet(transformed);
}
- @Override
- public ArtifactReadable asExternalArtifact(OrcsSession session, Artifact artifact) {
- return new ArtifactReadOnlyImpl(ExternalArtifactManagerImpl.this, session, artifact);
- }
+ private final class ReadableToArtifactFunction implements Function<ArtifactReadable, Artifact> {
+ @Override
+ public Artifact apply(ArtifactReadable external) {
+ return asInternalArtifact(external);
+ }
+ };
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationContainer.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationContainer.java
deleted file mode 100644
index 5de4159463..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationContainer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.relation;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.core.data.IRelationTypeSide;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.RelationData;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public interface RelationContainer {
-
- void add(RelationData nextRelation) throws OseeCoreException;
-
- Collection<IRelationTypeSide> getExistingRelationTypes();
-
- void getArtifactIds(Collection<Integer> results, IRelationTypeSide relationTypeSide);
-
- int getRelationCount(IRelationTypeSide relationTypeSide);
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationContainerImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationContainerImpl.java
deleted file mode 100644
index 7e35d4311b..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationContainerImpl.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.relation;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import org.eclipse.osee.framework.core.data.IRelationType;
-import org.eclipse.osee.framework.core.data.IRelationTypeSide;
-import org.eclipse.osee.framework.core.data.TokenFactory;
-import org.eclipse.osee.framework.core.enums.RelationSide;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.util.Conditions;
-import org.eclipse.osee.orcs.core.ds.RelationData;
-import org.eclipse.osee.orcs.data.RelationTypes;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class RelationContainerImpl implements RelationContainer {
-
- private final Map<IRelationTypeSide, List<RelationData>> relations =
- new ConcurrentHashMap<IRelationTypeSide, List<RelationData>>();
-
- private final int parentId;
- private final RelationTypes relationTypeCache;
-
- public RelationContainerImpl(int parentId, RelationTypes relationTypeCache) {
- this.parentId = parentId;
- this.relationTypeCache = relationTypeCache;
- }
-
- @Override
- public void add(RelationData nextRelation) throws OseeCoreException {
- IRelationTypeSide relationTypeSide = getRelationTypeSide(nextRelation);
- List<RelationData> rows = relations.get(relationTypeSide);
- if (rows == null) {
- rows = new CopyOnWriteArrayList<RelationData>();
- relations.put(relationTypeSide, rows);
- }
- rows.add(nextRelation);
- }
-
- @Override
- public void getArtifactIds(Collection<Integer> results, IRelationTypeSide relationTypeSide) {
- List<RelationData> rows = relations.get(relationTypeSide);
- if (rows != null) {
- for (RelationData row : rows) {
- Integer artId = row.getArtIdOn(relationTypeSide.getSide());
- results.add(artId);
- }
- }
- }
-
- @Override
- public Collection<IRelationTypeSide> getExistingRelationTypes() {
- return relations.keySet();
- }
-
- @Override
- public int getRelationCount(IRelationTypeSide relationTypeSide) {
- List<RelationData> rows = relations.get(relationTypeSide);
- return rows != null ? rows.size() : 0;
- }
-
- private IRelationType getRelationType(RelationData relationRow) throws OseeCoreException {
- long uuid = relationRow.getTypeUuid();
- IRelationType type = relationTypeCache.getByUuid(uuid);
- Conditions.checkNotNull(type, "RelationType", "Unknown relation type. UUID[%d]", uuid);
- return type;
- }
-
- private RelationSide getRelationSide(RelationData row) {
- if (row.getArtIdA() == parentId) {
- return RelationSide.SIDE_B;
- } else { //row.getArtIdB() == parentId
- return RelationSide.SIDE_A;
- }
- }
-
- private IRelationTypeSide getRelationTypeSide(RelationData relationRow) throws OseeCoreException {
- IRelationType type = getRelationType(relationRow);
- RelationSide side = getRelationSide(relationRow);
- IRelationTypeSide relationTypeSide = TokenFactory.createRelationTypeSide(side, type.getGuid(), type.getName());
- return relationTypeSide;
- }
-
- public Collection<List<RelationData>> getRelationData() {
- return relations.values();
- }
-
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationFactory.java
index c63167c953..123bea6fc6 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationFactory.java
@@ -39,10 +39,6 @@ public class RelationFactory {
this.providerFactory = providerFactory;
}
- public RelationContainer createRelationContainer(int artId) {
- return new RelationContainerImpl(artId, relationTypes);
- }
-
public RelationNodeAdjacencies createRelationContainer() {
return new RelationNodeAdjacencies();
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationGraphImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationGraphImpl.java
deleted file mode 100644
index abde78f60c..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationGraphImpl.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.orcs.core.internal.relation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import org.eclipse.osee.framework.core.data.IArtifactType;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.data.IRelationType;
-import org.eclipse.osee.framework.core.data.IRelationTypeSide;
-import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.framework.core.enums.RelationSide;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.internal.ArtifactLoaderFactory;
-import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
-import org.eclipse.osee.orcs.core.internal.util.ResultSets;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.GraphReadable;
-import org.eclipse.osee.orcs.data.RelationTypes;
-
-/**
- * @author Andrew M. Finkbeiner
- */
-public class RelationGraphImpl implements GraphReadable {
-
- private final OrcsSession session;
- private final ArtifactLoaderFactory loader;
- private final RelationTypes relationTypeCache;
- private final ExternalArtifactManager proxyManager;
-
- public RelationGraphImpl(OrcsSession session, ArtifactLoaderFactory loader, RelationTypes relationTypeCache, ExternalArtifactManager proxyManager) {
- super();
- this.session = session;
- this.loader = loader;
- this.relationTypeCache = relationTypeCache;
- this.proxyManager = proxyManager;
- }
-
- private RelationContainer getRelationContainer(ArtifactReadable readable) throws OseeCoreException {
- RelationContainer toReturn = null;
- Object object = proxyManager.asInternalArtifact(readable);
- if (object instanceof HasRelationContainer) {
- HasRelationContainer proxy = (HasRelationContainer) object;
- toReturn = proxy.getRelationContainer();
- }
- return toReturn;
- }
-
- private List<ArtifactReadable> loadRelated(IOseeBranch branch, Collection<Integer> artifactIds) throws OseeCoreException {
- return loader.fromBranchAndArtifactIds(session, branch, artifactIds).setLoadLevel(LoadLevel.FULL).load();
- }
-
- private void loadRelatedArtifactIds(ArtifactReadable art, IRelationTypeSide relationTypeSide, Collection<Integer> results) throws OseeCoreException {
- RelationContainer container = getRelationContainer(art);
- container.getArtifactIds(results, relationTypeSide);
- }
-
- @Override
- public ArtifactReadable getParent(ArtifactReadable art) throws OseeCoreException {
- return getRelatedArtifacts(CoreRelationTypes.Default_Hierarchical__Parent, art).getExactlyOne();
- }
-
- @Override
- public ResultSet<ArtifactReadable> getChildren(ArtifactReadable art) throws OseeCoreException {
- return getRelatedArtifacts(CoreRelationTypes.Default_Hierarchical__Child, art);
- }
-
- @Override
- public Collection<IRelationTypeSide> getExistingRelationTypes(ArtifactReadable art) throws OseeCoreException {
- RelationContainer container = getRelationContainer(art);
- return container.getExistingRelationTypes();
- }
-
- @Override
- public ResultSet<ArtifactReadable> getRelatedArtifacts(IRelationTypeSide relationTypeSide, ArtifactReadable art) throws OseeCoreException {
- List<Integer> artIds = new ArrayList<Integer>();
- loadRelatedArtifactIds(art, relationTypeSide, artIds);
- List<ArtifactReadable> toReturn;
- if (artIds.isEmpty()) {
- toReturn = Collections.emptyList();
- } else {
- toReturn = loadRelated(art.getBranch(), artIds);
- }
- return ResultSets.newResultSet(toReturn);
- }
-
- @Override
- public List<IRelationType> getValidRelationTypes(ArtifactReadable art) throws OseeCoreException {
- IArtifactType artifactType = art.getArtifactType();
-
- Collection<? extends IRelationType> relationTypes = relationTypeCache.getAll();
- List<IRelationType> validRelationTypes = new LinkedList<IRelationType>();
- for (IRelationType relationType : relationTypes) {
- int sideAMax = getRelationSideMax(relationType, artifactType, RelationSide.SIDE_A);
- int sideBMax = getRelationSideMax(relationType, artifactType, RelationSide.SIDE_B);
- boolean onSideA = sideBMax > 0;
- boolean onSideB = sideAMax > 0;
- if (onSideA || onSideB) {
- validRelationTypes.add(relationType);
- }
- }
- return validRelationTypes;
- }
-
- @Override
- public int getRelationSideMax(IRelationType relationType, IArtifactType artifactType, RelationSide relationSide) throws OseeCoreException {
- int toReturn = 0;
- if (relationTypeCache.isArtifactTypeAllowed(relationType, relationSide, artifactType)) {
- toReturn = relationTypeCache.getMultiplicity(relationType).getLimit(relationSide);
- }
- return toReturn;
- }
-
- @Override
- public RelationTypes getTypes() {
- return relationTypeCache;
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidity.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidity.java
index 56a28ceaea..2403a19b4a 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidity.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationTypeValidity.java
@@ -76,9 +76,10 @@ public class RelationTypeValidity {
return toReturn;
}
- public MultiplicityState getRelationMultiplicityState(IRelationType type, RelationSide side, int count) throws OseeCoreException {
+ public MultiplicityState getRelationMultiplicityState(IRelationType type, RelationSide side, int count) throws OseeCoreException {
Conditions.checkNotNull(type, "type");
Conditions.checkNotNull(side, "relationSide");
+ checkTypeExists(type);
RelationTypeMultiplicity multiplicity = relationTypes.getMultiplicity(type);
@@ -90,6 +91,13 @@ public class RelationTypeValidity {
return toReturn;
}
+ public boolean isRelationTypeValid(IRelationType relationType, IArtifactType artifactType, RelationSide relationSide) throws OseeCoreException {
+ checkTypeExists(relationType);
+ Conditions.checkNotNull(artifactType, "artifactType");
+ Conditions.checkNotNull(relationSide, "relationSide");
+ return getRelationSideMax(relationType, artifactType, relationSide) > 0;
+ }
+
public List<IRelationType> getValidRelationTypes(IArtifactType artifactType) throws OseeCoreException {
Conditions.checkNotNull(artifactType, "artifactType");
Collection<? extends IRelationType> types = relationTypes.getAll();
@@ -102,20 +110,8 @@ public class RelationTypeValidity {
return toReturn;
}
- public boolean isRelationTypeValid(IRelationType relationType, IArtifactType artifactType, RelationSide relationSide) throws OseeCoreException {
- checkTypeExists(relationType);
- Conditions.checkNotNull(artifactType, "artifactType");
- Conditions.checkNotNull(relationSide, "relationSide");
- return getRelationSideMax(relationType, artifactType, relationSide) > 0;
- }
-
- private void checkTypeExists(IRelationType type) throws OseeCoreException {
- Conditions.checkExpressionFailOnTrue(!relationTypes.exists(type), "relationType [%s] does not exist", type);
- }
-
private boolean isTypeAllowed(IArtifactType artifactType, IRelationType relationType) throws OseeCoreException {
boolean result = false;
- checkTypeExists(relationType);
for (RelationSide side : RelationSide.values()) {
int sideMax = getRelationSideMax(relationType, artifactType, side);
if (sideMax > 0) {
@@ -126,6 +122,11 @@ public class RelationTypeValidity {
return result;
}
+ private void checkTypeExists(IRelationType type) throws OseeCoreException {
+ boolean exists = relationTypes.exists(type);
+ Conditions.checkExpressionFailOnTrue(!exists, "relationType [%s] does not exist", type);
+ }
+
private int getRelationSideMax(IRelationType relationType, IArtifactType artifactType, RelationSide relationSide) throws OseeCoreException {
int toReturn = 0;
if (relationTypes.isArtifactTypeAllowed(relationType, relationSide, artifactType)) {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationUtil.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationUtil.java
new file mode 100644
index 0000000000..09b3d521dd
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationUtil.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * 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.relation;
+
+import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Parent;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.enums.RelationSide;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.Pair;
+import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class RelationUtil {
+
+ public static final IRelationType DEFAULT_HIERARCHY = TokenFactory.createRelationType(
+ Default_Hierarchical__Parent.getGuid(), Default_Hierarchical__Parent.getName());
+ public static final RelationSide IS_PARENT = RelationSide.SIDE_A;
+ public static final RelationSide IS_CHILD = RelationSide.SIDE_B;
+
+ private RelationUtil() {
+ // Utility
+ }
+
+ public static IRelationType asRelationType(IRelationTypeSide typeAndSide) {
+ return TokenFactory.createRelationType(typeAndSide.getGuid(), typeAndSide.getName());
+ }
+
+ public static IRelationTypeSide asTypeSide(IRelationType type, RelationSide side) {
+ return TokenFactory.createRelationTypeSide(side, type.getGuid(), type.getName());
+ }
+
+ /**
+ * Orders artifacts into a and b relation nodes using relation side parameter as a specification of where art2 is in
+ * the set.
+ *
+ * @param art1 The First artifact
+ * @param art2 The Second artifact
+ * @param side What side is artifact 2 on
+ * @return pair of nodes in a,b order
+ * @throws OseeCoreException
+ */
+ public static Pair<RelationNode, RelationNode> asABNodes(Artifact art1, Artifact art2, RelationSide side) {
+ RelationNode aNode;
+ RelationNode bNode;
+ if (RelationSide.SIDE_A == side) {
+ aNode = art2;
+ bNode = art1;
+ } else {
+ aNode = art1;
+ bNode = art2;
+ }
+ return new Pair<RelationNode, RelationNode>(aNode, bNode);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImpl.java
index dc4dccacda..a6ad605846 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationManagerImpl.java
@@ -10,14 +10,16 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.relation.impl;
-import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Child;
-import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Parent;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
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.eclipse.osee.framework.core.util.Conditions.checkNotNull;
import static org.eclipse.osee.framework.jdk.core.util.Strings.emptyString;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.DEFAULT_HIERARCHY;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_CHILD;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.IS_PARENT;
+import static org.eclipse.osee.orcs.core.internal.relation.RelationUtil.asTypeSide;
import static org.eclipse.osee.orcs.core.internal.util.OrcsConditions.checkBranch;
import static org.eclipse.osee.orcs.core.internal.util.OrcsConditions.checkOnGraph;
import static org.eclipse.osee.orcs.core.internal.util.OrcsConditions.checkRelateSelf;
@@ -39,7 +41,6 @@ import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.model.RelationTypeSide;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
@@ -61,10 +62,6 @@ import org.eclipse.osee.orcs.core.internal.util.ResultSets;
*/
public class RelationManagerImpl implements RelationManager {
- private static final IRelationType DEFAULT_HIERARCHY = Default_Hierarchical__Parent;
- private static final RelationSide IS_PARENT = Default_Hierarchical__Parent.getSide();
- private static final RelationSide IS_CHILD = Default_Hierarchical__Child.getSide();
-
private final Log logger;
private final RelationTypeValidity validity;
private final RelationResolver resolver;
@@ -219,8 +216,9 @@ public class RelationManagerImpl implements RelationManager {
checkBranch(aNode, bNode);
checkRelateSelf(aNode, bNode);
- checkTypeAndCanAdd(session, graph, type, aNode, SIDE_A);
- checkTypeAndCanAdd(session, graph, type, bNode, SIDE_B);
+ // Check we can create the type on other side of each node
+ checkTypeAndCanAdd(session, graph, type, aNode, SIDE_B);
+ checkTypeAndCanAdd(session, graph, type, bNode, SIDE_A);
Relation relation = getRelation(session, graph, aNode, type, bNode, INCLUDE_DELETED).getOneOrNull();
boolean updated = false;
@@ -437,8 +435,4 @@ public class RelationManagerImpl implements RelationManager {
}
}
}
-
- private static IRelationTypeSide asTypeSide(IRelationType type, RelationSide side) {
- return new RelationTypeSide(type, side);
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImpl.java
index f9867b54d3..b7cd930bfc 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImpl.java
@@ -43,6 +43,7 @@ public class RelationNodeLoaderImpl implements RelationNodeLoader {
DataLoader loader = dataLoaderFactory.fromBranchAndArtifactIds(session, graph.getBranch(), ids);
loader.setLoadLevel(level);
loader.fromTransaction(graph.getTransaction());
+ loader.includeDeleted();
loader.load(null, builder);
return getResults(builder);
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java
index 16746d7c6d..f13d5e566b 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/ArtifactMatchDataHandler.java
@@ -18,9 +18,12 @@ import java.util.List;
import java.util.Map;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
+import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.LoadDataHandlerDecorator;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
+import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.graph.GraphBuilder;
+import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.search.Match;
@@ -34,14 +37,21 @@ import com.google.common.collect.Multimaps;
*/
public class ArtifactMatchDataHandler extends LoadDataHandlerDecorator {
- private final ArtifactBuilder handler;
+ private final OrcsSession session;
+ private final ExternalArtifactManager proxyManager;
private Map<Integer, ArtifactMatch> matches;
private List<Match<ArtifactReadable, AttributeReadable<?>>> results;
- public ArtifactMatchDataHandler(ArtifactBuilder handler) {
+ public ArtifactMatchDataHandler(OrcsSession session, GraphBuilder handler, ExternalArtifactManager proxyManager) {
super(handler);
- this.handler = handler;
+ this.session = session;
+ this.proxyManager = proxyManager;
+ }
+
+ @Override
+ protected GraphBuilder getHandler() {
+ return (GraphBuilder) super.getHandler();
}
@Override
@@ -71,26 +81,25 @@ public class ArtifactMatchDataHandler extends LoadDataHandlerDecorator {
buildResults();
}
- private void buildResults() {
- List<ArtifactReadable> loaded = handler.getArtifacts();
-
- if (loaded.isEmpty()) {
- results = Collections.emptyList();
- } else {
- results = Lists.newLinkedList();
- for (ArtifactReadable item : loaded) {
- ArtifactMatch artifactMatch = matches.get(item.getLocalId());
- if (artifactMatch != null) {
- artifactMatch.setArtifactReadable(item);
- }
- results.add(artifactMatch);
+ private void buildResults() throws OseeCoreException {
+ Iterable<Artifact> loaded = getHandler().getArtifacts();
+
+ for (Artifact item : loaded) {
+ ArtifactMatch artifactMatch = matches.get(item.getLocalId());
+ if (artifactMatch != null) {
+ ArtifactReadable readable = proxyManager.asExternalArtifact(session, item);
+ artifactMatch.setArtifactReadable(readable);
+ }
+ if (results == null) {
+ results = Lists.newLinkedList();
}
+ results.add(artifactMatch);
}
matches = null;
}
public List<Match<ArtifactReadable, AttributeReadable<?>>> getResults() {
- return results;
+ return results != null ? results : Collections.<Match<ArtifactReadable, AttributeReadable<?>>> emptyList();
}
private static <K, V> ListMultimap<K, V> newLinkedHashListMultimap() {
@@ -133,8 +142,7 @@ public class ArtifactMatchDataHandler extends LoadDataHandlerDecorator {
@Override
public Collection<AttributeReadable<?>> getElements() throws OseeCoreException {
Collection<AttributeReadable<?>> filtered = Lists.newLinkedList();
- List<? extends AttributeReadable<Object>> attributes = item.getAttributes();
- for (AttributeReadable<?> attribute : attributes) {
+ for (AttributeReadable<?> attribute : item.getAttributes()) {
if (matches.containsKey(attribute.getLocalId())) {
filtered.add(attribute);
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
index 4584b72573..8f1ecc8da7 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/CallableQueryFactory.java
@@ -24,13 +24,17 @@ import org.eclipse.osee.orcs.core.ds.OptionsUtil;
import org.eclipse.osee.orcs.core.ds.QueryCollector;
import org.eclipse.osee.orcs.core.ds.QueryData;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilder;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilderFactory;
+import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.graph.GraphBuilder;
+import org.eclipse.osee.orcs.core.internal.graph.GraphBuilderFactory;
+import org.eclipse.osee.orcs.core.internal.graph.GraphProvider;
+import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
import org.eclipse.osee.orcs.core.internal.util.ResultSets;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.HasLocalId;
import org.eclipse.osee.orcs.search.Match;
+import com.google.common.collect.Iterables;
/**
* @author Roberto E. Escobar
@@ -40,14 +44,18 @@ public class CallableQueryFactory {
private final Log logger;
private final QueryEngine queryEngine;
private final QueryCollector collector;
- private final ArtifactBuilderFactory builderFactory;
+ private final GraphBuilderFactory builderFactory;
+ private final GraphProvider provider;
+ private final ExternalArtifactManager proxyManager;
- public CallableQueryFactory(Log logger, QueryEngine queryEngine, QueryCollector collector, ArtifactBuilderFactory builderFactory) {
+ public CallableQueryFactory(Log logger, QueryEngine queryEngine, QueryCollector collector, GraphBuilderFactory builderFactory, GraphProvider provider, ExternalArtifactManager proxyManager) {
super();
this.logger = logger;
this.queryEngine = queryEngine;
this.collector = collector;
this.builderFactory = builderFactory;
+ this.provider = provider;
+ this.proxyManager = proxyManager;
}
public CancellableCallable<Integer> createCount(OrcsSession session, QueryData queryData) {
@@ -86,12 +94,12 @@ public class CallableQueryFactory {
@Override
protected ResultSet<ArtifactReadable> innerCall() throws Exception {
- ArtifactBuilder handler = builderFactory.createArtifactBuilder(getSession());
+ GraphBuilder handler = builderFactory.createGraphBuilder(provider);
OptionsUtil.setLoadLevel(getQueryData().getOptions(), LoadLevel.FULL);
queryEngine.createArtifactQuery(getSession(), getQueryData(), handler).call();
- List<ArtifactReadable> results = handler.getArtifacts();
- setItemsFound(results.size());
- return ResultSets.newResultSet(results);
+ Iterable<Artifact> results = handler.getArtifacts();
+ setItemsFound(Iterables.size(results));
+ return proxyManager.asExternalArtifacts(getSession(), results);
}
};
}
@@ -101,18 +109,16 @@ public class CallableQueryFactory {
@Override
protected ResultSet<Match<ArtifactReadable, AttributeReadable<?>>> innerCall() throws Exception {
- ArtifactBuilder builder = builderFactory.createArtifactBuilder(getSession());
- ArtifactMatchDataHandler handler = new ArtifactMatchDataHandler(builder);
+ GraphBuilder handler = builderFactory.createGraphBuilder(provider);
+ ArtifactMatchDataHandler matchHandler = new ArtifactMatchDataHandler(getSession(), handler, proxyManager);
OptionsUtil.setLoadLevel(getQueryData().getOptions(), LoadLevel.FULL);
- queryEngine.createArtifactQuery(getSession(), getQueryData(), handler).call();
-
- List<Match<ArtifactReadable, AttributeReadable<?>>> results = handler.getResults();
- setItemsFound(results.size());
+ queryEngine.createArtifactQuery(getSession(), getQueryData(), matchHandler).call();
+ List<Match<ArtifactReadable, AttributeReadable<?>>> results = matchHandler.getResults();
+ setItemsFound(Iterables.size(results));
return ResultSets.newResultSet(results);
}
};
}
-
private abstract class AbstractSearchCallable<T> extends CancellableCallable<T> {
private final OrcsSession session;
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
index d82520e816..b798a82ea8 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryModule.java
@@ -13,8 +13,10 @@ package org.eclipse.osee.orcs.core.internal.search;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.ds.QueryEngine;
-import org.eclipse.osee.orcs.core.internal.ArtifactBuilderFactory;
import org.eclipse.osee.orcs.core.internal.HasStatistics;
+import org.eclipse.osee.orcs.core.internal.graph.GraphBuilderFactory;
+import org.eclipse.osee.orcs.core.internal.graph.GraphProvider;
+import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
import org.eclipse.osee.orcs.data.ArtifactTypes;
import org.eclipse.osee.orcs.data.AttributeTypes;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -30,10 +32,11 @@ public class QueryModule implements HasStatistics<QueryStatistics> {
private final CriteriaFactory criteriaFctry;
private final CallableQueryFactory callableQueryFactory;
- public QueryModule(Log logger, QueryEngine queryEngine, ArtifactBuilderFactory builderFactory, ArtifactTypes artifactTypeCache, AttributeTypes attributeTypeCache) {
+ public QueryModule(Log logger, QueryEngine queryEngine, GraphBuilderFactory builderFactory, GraphProvider provider, ArtifactTypes artifactTypeCache, AttributeTypes attributeTypeCache, ExternalArtifactManager proxyManager) {
QueryStatsCollectorImpl queryStatsCollector = new QueryStatsCollectorImpl(statistics);
this.criteriaFctry = new CriteriaFactory(artifactTypeCache, attributeTypeCache);
- this.callableQueryFactory = new CallableQueryFactory(logger, queryEngine, queryStatsCollector, builderFactory);
+ this.callableQueryFactory =
+ new CallableQueryFactory(logger, queryEngine, queryStatsCollector, builderFactory, provider, proxyManager);
}
public QueryFactory createQueryFactory(OrcsSession session) {
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/ChangeSetBuilder.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/ChangeSetBuilder.java
new file mode 100644
index 0000000000..a400ad070a
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/ChangeSetBuilder.java
@@ -0,0 +1,118 @@
+/*******************************************************************************
+ * 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.transaction;
+
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.orcs.core.ds.ArtifactData;
+import org.eclipse.osee.orcs.core.ds.AttributeData;
+import org.eclipse.osee.orcs.core.ds.HasOrcsChangeSet;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
+import org.eclipse.osee.orcs.core.ds.OrcsVisitor;
+import org.eclipse.osee.orcs.core.ds.RelationData;
+import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.artifact.ArtifactVisitor;
+import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
+import org.eclipse.osee.orcs.core.internal.relation.Relation;
+import org.eclipse.osee.orcs.core.internal.relation.RelationVisitor;
+import com.google.common.collect.Lists;
+
+/**
+ * Collect all the dirty OrcsData's into a changeSet;
+ *
+ * @author Roberto E. Escobar
+ */
+public class ChangeSetBuilder implements ArtifactVisitor, RelationVisitor, HasOrcsChangeSet {
+
+ private final OrcsChangeSetImpl changeSet;
+
+ public ChangeSetBuilder() {
+ this.changeSet = new OrcsChangeSetImpl();
+ }
+
+ @Override
+ public void visit(Artifact artifact) {
+ if (artifact.isDirty()) {
+ changeSet.arts.add(artifact.getOrcsData());
+ }
+ }
+
+ @Override
+ public void visit(Attribute<?> attribute) {
+ if (attribute.isDirty()) {
+ changeSet.attrs.add(attribute.getOrcsData());
+ }
+ }
+
+ @Override
+ public void visit(Relation relation) {
+ if (relation.isDirty()) {
+ changeSet.rels.add(relation.getOrcsData());
+ }
+ }
+
+ @Override
+ public OrcsChangeSet getChangeSet() {
+ return changeSet;
+ }
+
+ private static final class OrcsChangeSetImpl implements OrcsChangeSet {
+
+ private final List<ArtifactData> arts = Lists.newArrayList();
+ private final List<AttributeData> attrs = Lists.newArrayList();
+ private final List<RelationData> rels = Lists.newArrayList();
+
+ @Override
+ public void accept(OrcsVisitor visitor) throws OseeCoreException {
+ for (ArtifactData data : getArtifactData()) {
+ visitor.visit(data);
+ }
+ for (AttributeData data : getAttributeData()) {
+ visitor.visit(data);
+ }
+ for (RelationData data : getRelationData()) {
+ visitor.visit(data);
+ }
+ }
+
+ @Override
+ public List<ArtifactData> getArtifactData() {
+ return arts;
+ }
+
+ @Override
+ public List<AttributeData> getAttributeData() {
+ return attrs;
+ }
+
+ @Override
+ public List<RelationData> getRelationData() {
+ return rels;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return arts.isEmpty() && attrs.isEmpty() && rels.isEmpty();
+ }
+
+ @Override
+ public int size() {
+ return arts.size() + attrs.size() + rels.size();
+ }
+
+ @Override
+ public String toString() {
+ return "OrcsChangeSetImpl [arts=" + arts + ", attrs=" + attrs + ", rels=" + rels + "]";
+ }
+
+ }
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/CollectDirtyData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/CollectDirtyData.java
deleted file mode 100644
index 13c4a3a9b7..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/CollectDirtyData.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * 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.transaction;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
-import org.eclipse.osee.orcs.core.ds.ArtifactTxDataImpl;
-import org.eclipse.osee.orcs.core.ds.AttributeData;
-import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
-import org.eclipse.osee.orcs.core.internal.artifact.ArtifactVisitor;
-import org.eclipse.osee.orcs.core.internal.attribute.Attribute;
-
-/**
- * Collect all the dirty internal OrcsData
- *
- * @author Roberto E. Escobar
- */
-public class CollectDirtyData implements ArtifactVisitor {
-
- private final List<ArtifactTransactionData> data;
-
- private ArtifactTransactionData txData;
-
- public CollectDirtyData(List<ArtifactTransactionData> data) {
- this.data = data;
- }
-
- @Override
- public void visit(Artifact artifact) {
- if (artifact.isDirty()) {
- txData = new ArtifactTxDataImpl(artifact.getOrcsData(), new ArrayList<AttributeData>());
- data.add(txData);
- }
- }
-
- @Override
- public void visit(Attribute<?> attribute) {
- if (attribute.isDirty()) {
- txData.getAttributeData().add(attribute.getOrcsData());
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java
index e748c64b22..648e398d34 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionBuilderImpl.java
@@ -11,16 +11,21 @@
package org.eclipse.osee.orcs.core.internal.transaction;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.Collection;
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.IOseeBranch;
+import org.eclipse.osee.framework.core.data.IRelationSorterId;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.relation.RelationUtil;
import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeId;
@@ -219,6 +224,57 @@ public class TransactionBuilderImpl implements TransactionBuilder {
}
@Override
+ public void addChildren(ArtifactId artA, ArtifactId... children) throws OseeCoreException {
+ addChildren(artA, Arrays.asList(children));
+ }
+
+ @Override
+ public void addChildren(ArtifactId artA, Iterable<? extends ArtifactId> children) throws OseeCoreException {
+ txManager.addChildren(txData, artA, children);
+ }
+
+ @Override
+ public void relate(ArtifactId artA, IRelationType relType, ArtifactId artB) throws OseeCoreException {
+ txManager.relate(txData, artA, relType, artB);
+ }
+
+ @Override
+ public void relate(ArtifactId artA, IRelationType relType, ArtifactId artB, String rationale) throws OseeCoreException {
+ txManager.relate(txData, artA, relType, artB, rationale);
+ }
+
+ @Override
+ public void relate(ArtifactId artA, IRelationType relType, ArtifactId artB, IRelationSorterId sortType) throws OseeCoreException {
+ txManager.relate(txData, artA, relType, artB, sortType);
+ }
+
+ @Override
+ public void relate(ArtifactId artA, IRelationType relType, ArtifactId artB, String rationale, IRelationSorterId sortType) throws OseeCoreException {
+ txManager.relate(txData, artA, relType, artB, rationale, sortType);
+ }
+
+ @Override
+ public void setRationale(ArtifactId artA, IRelationType relType, ArtifactId artB, String rationale) throws OseeCoreException {
+ txManager.setRationale(txData, artA, relType, artB, rationale);
+ }
+
+ @Override
+ public void unrelate(ArtifactId artA, IRelationType relType, ArtifactId artB) throws OseeCoreException {
+ txManager.unrelate(txData, artA, relType, artB);
+ }
+
+ @Override
+ public void unrelateFromAll(IRelationTypeSide typeAndSide, ArtifactId art) throws OseeCoreException {
+ IRelationType type = RelationUtil.asRelationType(typeAndSide);
+ txManager.unrelateFromAll(txData, type, art, typeAndSide.getSide());
+ }
+
+ @Override
+ public void unrelateFromAll(ArtifactId artA) throws OseeCoreException {
+ txManager.unrelateFromAll(txData, artA);
+ }
+
+ @Override
public void deleteArtifact(ArtifactId sourceArtifact) throws OseeCoreException {
txManager.deleteArtifact(txData, sourceArtifact);
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionDataImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionDataImpl.java
deleted file mode 100644
index 0a153daf86..0000000000
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionDataImpl.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * 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.transaction;
-
-import java.util.List;
-import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
-import org.eclipse.osee.orcs.core.ds.OrcsVisitor;
-import org.eclipse.osee.orcs.core.ds.TransactionData;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TransactionDataImpl implements TransactionData {
-
- private final IOseeBranch branch;
- private final ArtifactReadable readable;
- private final String comment;
- private final List<ArtifactTransactionData> data;
-
- public TransactionDataImpl(IOseeBranch branch, ArtifactReadable readable, String comment, List<ArtifactTransactionData> data) {
- super();
- this.branch = branch;
- this.readable = readable;
- this.comment = comment;
- this.data = data;
- }
-
- @Override
- public IOseeBranch getBranch() {
- return branch;
- }
-
- @Override
- public ArtifactReadable getAuthor() {
- return readable;
- }
-
- @Override
- public String getComment() {
- return comment;
- }
-
- @Override
- public List<ArtifactTransactionData> getTxData() {
- return data;
- }
-
- @Override
- public void accept(OrcsVisitor visitor) throws OseeCoreException {
- for (ArtifactTransactionData data : getTxData()) {
- data.accept(visitor);
- }
- }
-
- @Override
- public String toString() {
- return "TransactionDataImpl [branch=" + branch + ", readable=" + readable + ", comment=" + comment + ", data=" + data + "]";
- }
-}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxData.java
index d184e5fcca..603313d796 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxData.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxData.java
@@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.graph.GraphData;
import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.HasSession;
@@ -33,7 +34,7 @@ public class TxData implements HasSession {
}
private final OrcsSession session;
- private final IOseeBranch branch;
+ private final GraphData graph;
private final Map<String, Artifact> writeables = new HashMap<String, Artifact>();
private final Map<String, ArtifactReadable> readables = new HashMap<String, ArtifactReadable>();
@@ -43,9 +44,9 @@ public class TxData implements HasSession {
private volatile boolean isCommitInProgress;
private volatile TxState txState;
- public TxData(OrcsSession session, IOseeBranch branch) {
+ public TxData(OrcsSession session, GraphData graph) {
this.session = session;
- this.branch = branch;
+ this.graph = graph;
this.txState = TxState.NEW_TX;
}
@@ -61,7 +62,11 @@ public class TxData implements HasSession {
}
public IOseeBranch getBranch() {
- return branch;
+ return graph.getBranch();
+ }
+
+ public GraphData getGraph() {
+ return graph;
}
public ArtifactReadable getAuthor() {
@@ -118,7 +123,7 @@ public class TxData implements HasSession {
@Override
public String toString() {
- return "TxData [session=" + session + ", branch=" + branch + ", author=" + author + ", comment=" + comment + "]";
+ return "TxData [session=" + session + ", graph=" + graph + ", author=" + author + ", comment=" + comment + ", isCommitInProgress=" + isCommitInProgress + ", txState=" + txState + "]";
}
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java
index a206854ebe..bf9d8c17f6 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java
@@ -11,12 +11,23 @@
package org.eclipse.osee.orcs.core.internal.transaction;
import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.Set;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.enums.LoadLevel;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.orcs.core.ds.DataLoader;
+import org.eclipse.osee.orcs.core.ds.DataLoaderFactory;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
+import org.eclipse.osee.orcs.core.internal.graph.GraphBuilder;
+import org.eclipse.osee.orcs.core.internal.graph.GraphBuilderFactory;
+import org.eclipse.osee.orcs.core.internal.graph.GraphData;
+import org.eclipse.osee.orcs.core.internal.graph.GraphFactory;
+import org.eclipse.osee.orcs.core.internal.graph.GraphProvider;
import org.eclipse.osee.orcs.core.internal.transaction.TxDataManager.TxDataLoader;
+import org.eclipse.osee.orcs.core.internal.util.ResultSetIterable;
import org.eclipse.osee.orcs.data.ArtifactId;
/**
@@ -25,14 +36,49 @@ import org.eclipse.osee.orcs.data.ArtifactId;
*/
public class TxDataLoaderImpl implements TxDataLoader {
- public TxDataLoaderImpl() {
+ private final DataLoaderFactory dataLoaderFactory;
+ private final GraphFactory graphFactory;
+ private final GraphBuilderFactory graphBuilderFactory;
+ private final GraphProvider graphProvider;
+
+ public TxDataLoaderImpl(DataLoaderFactory dataLoaderFactory, GraphFactory graphFactory, GraphBuilderFactory graphBuilderFactory, GraphProvider graphProvider) {
super();
+ this.dataLoaderFactory = dataLoaderFactory;
+ this.graphProvider = graphProvider;
+ this.graphFactory = graphFactory;
+ this.graphBuilderFactory = graphBuilderFactory;
+ }
+
+ private DataLoader createLoader(OrcsSession session, IOseeBranch branch, Collection<ArtifactId> artifactIds) throws OseeCoreException {
+ Set<String> ids = new LinkedHashSet<String>();
+ for (ArtifactId artifactId : artifactIds) {
+ ids.add(artifactId.getGuid());
+ }
+ DataLoader loader = dataLoaderFactory.fromBranchAndIds(session, branch, ids);
+ loader.setLoadLevel(LoadLevel.FULL);
+ return loader;
}
- @SuppressWarnings("unused")
@Override
public ResultSet<Artifact> loadArtifacts(OrcsSession session, IOseeBranch branch, Collection<ArtifactId> artifactIds) throws OseeCoreException {
- throw new UnsupportedOperationException("Late loading of artifacts is not supported at this time.");
+ DataLoader loader = createLoader(session, branch, artifactIds);
+ GraphBuilder handler = graphBuilderFactory.createGraphBuilder(graphProvider);
+ loader.load(null, handler);
+ return new ResultSetIterable<Artifact>(handler.getArtifacts());
+ }
+
+ @Override
+ public ResultSet<Artifact> loadArtifacts(OrcsSession session, GraphData graph, Collection<ArtifactId> artifactIds) throws OseeCoreException {
+ DataLoader loader = createLoader(session, graph.getBranch(), artifactIds);
+ loader.fromTransaction(graph.getTransaction());
+ GraphBuilder handler = graphBuilderFactory.createBuilderForGraph(graph);
+ loader.load(null, handler);
+ return new ResultSetIterable<Artifact>(handler.getArtifacts());
+ }
+
+ @Override
+ public GraphData createGraph(IOseeBranch branch) throws OseeCoreException {
+ return graphFactory.createGraphSetToHeadTx(branch);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java
index bf5a67fc21..272f7b2b12 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.orcs.core.internal.transaction;
import static java.util.Collections.singleton;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
@@ -20,22 +19,27 @@ 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.data.IRelationSorterId;
+import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.data.ResultSet;
+import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeStateException;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
-import org.eclipse.osee.orcs.core.ds.OrcsVisitor;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
import org.eclipse.osee.orcs.core.ds.TransactionData;
import org.eclipse.osee.orcs.core.internal.artifact.Artifact;
import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory;
-import org.eclipse.osee.orcs.core.internal.artifact.ArtifactVisitable;
+import org.eclipse.osee.orcs.core.internal.graph.GraphData;
import org.eclipse.osee.orcs.core.internal.proxy.ExternalArtifactManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationManager;
+import org.eclipse.osee.orcs.core.internal.relation.RelationNode;
import org.eclipse.osee.orcs.core.internal.transaction.TxData.TxState;
import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.ArtifactReadable;
+import com.google.common.collect.Lists;
/**
* @author Roberto E. Escobar
@@ -45,22 +49,29 @@ public class TxDataManager {
public interface TxDataLoader {
+ GraphData createGraph(IOseeBranch branch) throws OseeCoreException;
+
ResultSet<Artifact> loadArtifacts(OrcsSession session, IOseeBranch branch, Collection<ArtifactId> artifactIds) throws OseeCoreException;
+ ResultSet<Artifact> loadArtifacts(OrcsSession session, GraphData graph, Collection<ArtifactId> singleton) throws OseeCoreException;
+
}
private final ExternalArtifactManager proxyManager;
private final ArtifactFactory artifactFactory;
+ private final RelationManager relationManager;
private final TxDataLoader loader;
- public TxDataManager(ExternalArtifactManager proxyManager, ArtifactFactory artifactFactory, TxDataLoader loader) {
+ public TxDataManager(ExternalArtifactManager proxyManager, ArtifactFactory artifactFactory, RelationManager relationManager, TxDataLoader loader) {
this.proxyManager = proxyManager;
this.artifactFactory = artifactFactory;
+ this.relationManager = relationManager;
this.loader = loader;
}
- public TxData createTxData(OrcsSession session, IOseeBranch branch) {
- return new TxData(session, branch);
+ public TxData createTxData(OrcsSession session, IOseeBranch branch) throws OseeCoreException {
+ GraphData graphData = loader.createGraph(branch);
+ return new TxData(session, graphData);
}
public void txCommitSuccess(TxData txData) {
@@ -84,6 +95,10 @@ public class TxDataManager {
txData.setCommitInProgress(false);
}
+ private GraphData getGraphForWrite(TxData txData) {
+ return txData.getGraph();
+ }
+
public Iterable<Artifact> getForWrite(TxData txData, Iterable<? extends ArtifactId> ids) throws OseeCoreException {
checkChangesAllowed(txData);
Set<ArtifactId> toLoad = new LinkedHashSet<ArtifactId>();
@@ -99,7 +114,7 @@ public class TxDataManager {
items.put(artifactId.getGuid(), node);
}
if (!toLoad.isEmpty()) {
- Iterable<Artifact> result = loader.loadArtifacts(txData.getSession(), txData.getBranch(), toLoad);
+ Iterable<Artifact> result = loader.loadArtifacts(txData.getSession(), txData.getGraph(), toLoad);
for (Artifact node : result) {
items.put(node.getGuid(), node);
checkAndAdd(txData, node);
@@ -113,7 +128,7 @@ public class TxDataManager {
Artifact node = findArtifactLocallyForWrite(txData, artifactId);
if (node == null) {
ResultSet<Artifact> result =
- loader.loadArtifacts(txData.getSession(), txData.getBranch(), singleton(artifactId));
+ loader.loadArtifacts(txData.getSession(), txData.getGraph(), singleton(artifactId));
node = result.getExactlyOne();
}
checkAndAdd(txData, node);
@@ -125,18 +140,25 @@ public class TxDataManager {
if (node == null) {
if (artifactId instanceof Artifact) {
Artifact source = (Artifact) artifactId;
- node = copyArtifactForWrite(txData, source);
+ if (txData.getBranch().equals(source.getBranch())) {
+ node = copyArtifactForWrite(txData, source);
+ }
} else if (artifactId instanceof ArtifactReadable) {
ArtifactReadable external = (ArtifactReadable) artifactId;
- Artifact source = proxyManager.asInternalArtifact(external);
- node = copyArtifactForWrite(txData, source);
+ if (txData.getBranch().equals(external.getBranch())) {
+ Artifact source = proxyManager.asInternalArtifact(external);
+ node = copyArtifactForWrite(txData, source);
+ }
}
}
return node;
}
private Artifact copyArtifactForWrite(TxData txData, Artifact source) throws OseeCoreException {
- return artifactFactory.clone(source);
+ Artifact artifact = artifactFactory.clone(source);
+ txData.getGraph().addNode(artifact);
+ relationManager.cloneRelations(txData.getSession(), source, artifact);
+ return artifact;
}
private Artifact getSourceArtifact(TxData txData, IOseeBranch fromBranch, ArtifactId artifactId) throws OseeCoreException {
@@ -234,6 +256,8 @@ public class TxDataManager {
boolean isDifferent = oldArtifact != null && oldArtifact != artifact;
Conditions.checkExpressionFailOnTrue(isDifferent,
"Another instance of writeable detected - writeable tracking would be inconsistent");
+
+ txData.getGraph().addNode(artifact);
}
private void checkAreOnDifferentBranches(TxData txData, IOseeBranch sourceBranch) throws OseeCoreException {
@@ -244,19 +268,85 @@ public class TxDataManager {
public void deleteArtifact(TxData txData, ArtifactId sourceArtifact) throws OseeCoreException {
Artifact asArtifact = getForWrite(txData, sourceArtifact);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.unrelateFromAll(txData.getSession(), graph, asArtifact);
asArtifact.delete();
}
+ public void addChildren(TxData txData, ArtifactId artA, Iterable<? extends ArtifactId> children) throws OseeCoreException {
+ OrcsSession session = txData.getSession();
+ Artifact asArtifact = getForWrite(txData, artA);
+ GraphData graph = getGraphForWrite(txData);
+ Iterable<? extends RelationNode> artifacts = getForWrite(txData, children);
+ List<RelationNode> nodes = Lists.newLinkedList(artifacts);
+ relationManager.addChildren(session, graph, asArtifact, nodes);
+ }
+
+ public void relate(TxData txData, ArtifactId artA, IRelationType type, ArtifactId artB) throws OseeCoreException {
+ Artifact asArtifactA = getForWrite(txData, artA);
+ Artifact asArtifactB = getForWrite(txData, artB);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.relate(txData.getSession(), graph, asArtifactA, type, asArtifactB);
+ }
+
+ public void relate(TxData txData, ArtifactId artA, IRelationType type, ArtifactId artB, String rationale) throws OseeCoreException {
+ Artifact asArtifactA = getForWrite(txData, artA);
+ Artifact asArtifactB = getForWrite(txData, artB);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.relate(txData.getSession(), graph, asArtifactA, type, asArtifactB, rationale);
+ }
+
+ public void relate(TxData txData, ArtifactId artA, IRelationType type, ArtifactId artB, IRelationSorterId sortType) throws OseeCoreException {
+ Artifact asArtifactA = getForWrite(txData, artA);
+ Artifact asArtifactB = getForWrite(txData, artB);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.relate(txData.getSession(), graph, asArtifactA, type, asArtifactB, sortType);
+ }
+
+ public void relate(TxData txData, ArtifactId artA, IRelationType type, ArtifactId artB, String rationale, IRelationSorterId sortType) throws OseeCoreException {
+ Artifact asArtifactA = getForWrite(txData, artA);
+ Artifact asArtifactB = getForWrite(txData, artB);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.relate(txData.getSession(), graph, asArtifactA, type, asArtifactB, rationale, sortType);
+ }
+
+ public void setRationale(TxData txData, ArtifactId artA, IRelationType type, ArtifactId artB, String rationale) throws OseeCoreException {
+ Artifact asArtifactA = getForWrite(txData, artA);
+ Artifact asArtifactB = getForWrite(txData, artB);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.setRationale(txData.getSession(), graph, asArtifactA, type, asArtifactB, rationale);
+ }
+
+ public void unrelate(TxData txData, ArtifactId artA, IRelationType type, ArtifactId artB) throws OseeCoreException {
+ Artifact asArtifactA = getForWrite(txData, artA);
+ Artifact asArtifactB = getForWrite(txData, artB);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.unrelate(txData.getSession(), graph, asArtifactA, type, asArtifactB);
+ }
+
+ public void unrelateFromAll(TxData txData, ArtifactId artA) throws OseeCoreException {
+ Artifact asArtifactA = getForWrite(txData, artA);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.unrelateFromAll(txData.getSession(), graph, asArtifactA);
+ }
+
+ public void unrelateFromAll(TxData txData, IRelationType type, ArtifactId artA, RelationSide side) throws OseeCoreException {
+ Artifact asArtifactA = getForWrite(txData, artA);
+ GraphData graph = getGraphForWrite(txData);
+ relationManager.unrelateFromAll(txData.getSession(), graph, type, asArtifactA, side);
+ }
+
public TransactionData createChangeData(TxData txData) throws OseeCoreException {
- List<ArtifactTransactionData> changes = new ArrayList<ArtifactTransactionData>();
- CollectDirtyData visitor = new CollectDirtyData(changes);
+ OrcsSession session = txData.getSession();
+ GraphData graph = txData.getGraph();
+
+ ChangeSetBuilder builder = new ChangeSetBuilder();
for (Artifact artifact : txData.getAllWriteables()) {
- if (artifact.isDirty()) {
- ArtifactVisitable visitable = artifact;
- visitable.accept(visitor);
- }
+ artifact.accept(builder);
+ relationManager.accept(session, graph, artifact, builder);
}
- return new TransactionDataImpl(txData.getBranch(), txData.getAuthor(), txData.getComment(), changes);
+ OrcsChangeSet changeSet = builder.getChangeSet();
+ return new TransactionDataImpl(txData.getBranch(), txData.getAuthor(), txData.getComment(), changeSet);
}
private static final class TransactionDataImpl implements TransactionData {
@@ -264,14 +354,14 @@ public class TxDataManager {
private final IOseeBranch branch;
private final ArtifactReadable author;
private final String comment;
- private final List<ArtifactTransactionData> data;
+ private final OrcsChangeSet changeSet;
- public TransactionDataImpl(IOseeBranch branch, ArtifactReadable author, String comment, List<ArtifactTransactionData> data) {
+ public TransactionDataImpl(IOseeBranch branch, ArtifactReadable author, String comment, OrcsChangeSet changeSet) {
super();
this.branch = branch;
this.author = author;
this.comment = comment;
- this.data = data;
+ this.changeSet = changeSet;
}
@Override
@@ -290,21 +380,15 @@ public class TxDataManager {
}
@Override
- public List<ArtifactTransactionData> getTxData() {
- return data;
- }
-
- @Override
- public void accept(OrcsVisitor visitor) throws OseeCoreException {
- for (ArtifactTransactionData data : getTxData()) {
- data.accept(visitor);
- }
+ public OrcsChangeSet getChangeSet() {
+ return changeSet;
}
@Override
public String toString() {
- return "TransactionDataImpl [branch=" + branch + ", readable=" + author + ", comment=" + comment + ", data=" + data + "]";
+ return "TransactionDataImpl [branch=" + branch + ", author=" + author + ", comment=" + comment + ", changeSet=" + changeSet + "]";
}
+
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriterTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriterTest.java
index 0060b07551..fc01d60eec 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriterTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriterTest.java
@@ -15,7 +15,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -31,7 +30,7 @@ import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
import org.eclipse.osee.orcs.db.internal.transaction.TransactionWriter.SqlOrderEnum;
import org.junit.Assert;
import org.junit.Before;
@@ -69,9 +68,9 @@ public class TransactionWriterTest {
@Mock private IOseeStatement chStmt;
@Captor private ArgumentCaptor<List<Object[]>> paramCaptor;
+ @Mock private OrcsChangeSet changeSet;
//@formatter:on
- private List<ArtifactTransactionData> txData;
private TransactionWriter writer;
private List<DaoToSql> stores;
@@ -81,8 +80,6 @@ public class TransactionWriterTest {
writer = new TransactionWriter(logger, dbService, builder);
- txData = new ArrayList<ArtifactTransactionData>();
-
stores = Arrays.asList(dao1, dao2);
final Map<SqlOrderEnum, ArtifactJoinQuery> joins = new LinkedHashMap<SqlOrderEnum, ArtifactJoinQuery>();
@@ -131,9 +128,9 @@ public class TransactionWriterTest {
public void testWrite() throws OseeCoreException {
InOrder inOrder = inOrder(builder, tx, join1, join2, dao1, dao2, dbService, chStmt);
- writer.write(connection, tx, txData);
+ writer.write(connection, tx, changeSet);
- inOrder.verify(builder).accept(tx, txData);
+ inOrder.verify(builder).accept(tx, changeSet);
inOrder.verify(builder).getBinaryStores();
inOrder.verify(dao1).persist();
inOrder.verify(dao2).persist();
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java
index a50757284f..01d9f16c73 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -39,9 +38,9 @@ import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.HumanReadableId;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.DataProxy;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.RelationData;
import org.eclipse.osee.orcs.core.ds.VersionData;
@@ -100,14 +99,13 @@ public class TxSqlBuilderTest {
@Mock private IdentityService identityService;
@Mock private TransactionRecord tx;
- @Mock private ArtifactTransactionData data;
+ @Mock private OrcsChangeSet txData;
@Mock private DataProxy dataProxy;
@Mock private ArtifactJoinQuery join;
// @formatter:on
private VersionData versionData;
- private List<ArtifactTransactionData> txData;
private TxSqlBuilderImpl builder;
private ArtifactData artData;
@@ -131,9 +129,6 @@ public class TxSqlBuilderTest {
};
- txData = new ArrayList<ArtifactTransactionData>();
- txData.add(data);
-
artData = new ArtifactDataImpl(versionData);
artData.setLocalId(ITEM_ID);
artData.setTypeUuid(TYPE_UUID);
@@ -178,7 +173,7 @@ public class TxSqlBuilderTest {
@Test
public void testAccept() throws OseeCoreException {
builder.accept(tx, txData);
- verify(data).accept(builder);
+ verify(txData).accept(builder);
assertTrue(builder.getBinaryStores().isEmpty());
assertTrue(builder.getTxNotCurrents().isEmpty());
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
index 92f7c3351f..a017219353 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.orcs.db.internal.transaction;
import java.util.Date;
-import java.util.List;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
@@ -27,7 +26,7 @@ import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsSession;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
import org.eclipse.osee.orcs.core.ds.TransactionData;
import org.eclipse.osee.orcs.core.ds.TransactionResult;
import org.eclipse.osee.orcs.data.ArtifactReadable;
@@ -77,27 +76,27 @@ public final class CommitTransactionDatabaseTxCallable extends AbstractDatastore
/////
// TODO:
// 1. Make this whole method a critical region on a per branch basis - can only write to a branch on one thread at time
- List<ArtifactTransactionData> txData = transactionData.getTxData();
String comment = transactionData.getComment();
Branch branch = branchCache.get(transactionData.getBranch());
ArtifactReadable author = transactionData.getAuthor();
+ OrcsChangeSet changeSet = transactionData.getChangeSet();
Conditions.checkNotNull(branch, "branch");
Conditions.checkNotNull(author, "transaction author");
Conditions.checkNotNullOrEmpty(comment, "transaction comment");
- Conditions.checkNotNullOrEmpty(txData, "artifacts modified");
+ Conditions.checkExpressionFailOnTrue(changeSet.isEmpty(), "No data was modified");
process(TxWritePhaseEnum.BEFORE_TX_WRITE);
TransactionRecord txRecord = createTransactionRecord(branch, author, comment, getNextTransactionId());
- writer.write(connection, txRecord, txData);
+ writer.write(connection, txRecord, changeSet);
if (branch.getBranchState() == BranchState.CREATED) {
branch.setBranchState(BranchState.MODIFIED);
branchCache.storeItems(branch);
}
transactionCache.cache(txRecord);
- return new TransactionResultImpl(txRecord, txData);
+ return new TransactionResultImpl(txRecord, changeSet);
}
@Override
@@ -122,12 +121,12 @@ public final class CommitTransactionDatabaseTxCallable extends AbstractDatastore
RelationalConstants.ART_ID_SENTINEL, txType, branchCache);
}
- private final class TransactionResultImpl implements TransactionResult {
+ private static final class TransactionResultImpl implements TransactionResult {
private final TransactionRecord tx;
- private final List<ArtifactTransactionData> data;
+ private final OrcsChangeSet data;
- public TransactionResultImpl(TransactionRecord tx, List<ArtifactTransactionData> data) {
+ public TransactionResultImpl(TransactionRecord tx, OrcsChangeSet data) {
super();
this.tx = tx;
this.data = data;
@@ -139,7 +138,7 @@ public final class CommitTransactionDatabaseTxCallable extends AbstractDatastore
}
@Override
- public List<ArtifactTransactionData> getData() {
+ public OrcsChangeSet getChangeSet() {
return data;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java
index 9ff1ef4778..ee7b91e622 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/ComodificationCheck.java
@@ -43,7 +43,7 @@ public class ComodificationCheck implements TransactionProcessor {
OnLoadChecker checker = new OnLoadChecker();
cancellation.checkForCancelled();
- txData.accept(checker);
+ txData.getChangeSet().accept(checker);
if (!checker.getArtifactIds().isEmpty()) {
DataLoader loader = dataLoader.fromBranchAndArtifactIds(session, txData.getBranch(), checker.getArtifactIds());
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionIndexer.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionIndexer.java
index c6acf03725..649a2c7ae9 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionIndexer.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionIndexer.java
@@ -43,7 +43,7 @@ public class TransactionIndexer implements TransactionProcessor {
public void process(final HasCancellation cancellation, OrcsSession session, TransactionData txData) {
try {
final Set<AttributeData> datas = new LinkedHashSet<AttributeData>();
- txData.accept(new OrcsVisitorAdapter() {
+ txData.getChangeSet().accept(new OrcsVisitorAdapter() {
@Override
public void visit(AttributeData data) {
datas.add(data);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriter.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriter.java
index f61c5ba56c..c1f37bf6fa 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriter.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TransactionWriter.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.orcs.db.internal.transaction;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
import org.eclipse.osee.framework.core.enums.TxChange;
@@ -22,7 +21,7 @@ import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
/**
* @author Roberto E. Escobar
@@ -116,7 +115,7 @@ public class TransactionWriter {
}
}
- public void write(OseeConnection connection, TransactionRecord tx, Collection<ArtifactTransactionData> txData) throws OseeCoreException {
+ public void write(OseeConnection connection, TransactionRecord tx, OrcsChangeSet txData) throws OseeCoreException {
sqlBuilder.accept(tx, txData);
try {
binaryStores = sqlBuilder.getBinaryStores();
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java
index dddf45a0cc..f1ae616c2f 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilder.java
@@ -10,14 +10,13 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.transaction;
-import java.util.Collection;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
import org.eclipse.osee.orcs.db.internal.transaction.TransactionWriter.SqlOrderEnum;
/**
@@ -27,7 +26,7 @@ public interface TxSqlBuilder {
void clear();
- void accept(TransactionRecord tx, Collection<ArtifactTransactionData> txData) throws OseeCoreException;
+ void accept(TransactionRecord tx, OrcsChangeSet txData) throws OseeCoreException;
Set<Entry<SqlOrderEnum, ArtifactJoinQuery>> getTxNotCurrents();
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java
index 65ca82a75e..16c2016d3f 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.orcs.db.internal.transaction;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -28,9 +27,9 @@ import org.eclipse.osee.framework.database.core.ArtifactJoinQuery;
import org.eclipse.osee.framework.database.core.JoinUtility;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.orcs.core.ds.ArtifactData;
-import org.eclipse.osee.orcs.core.ds.ArtifactTransactionData;
import org.eclipse.osee.orcs.core.ds.AttributeData;
import org.eclipse.osee.orcs.core.ds.DataProxy;
+import org.eclipse.osee.orcs.core.ds.OrcsChangeSet;
import org.eclipse.osee.orcs.core.ds.OrcsData;
import org.eclipse.osee.orcs.core.ds.OrcsVisitor;
import org.eclipse.osee.orcs.core.ds.RelationData;
@@ -89,7 +88,7 @@ public class TxSqlBuilderImpl implements OrcsVisitor, TxSqlBuilder {
}
@Override
- public void accept(TransactionRecord tx, Collection<ArtifactTransactionData> artifactTransactionData) throws OseeCoreException {
+ public void accept(TransactionRecord tx, OrcsChangeSet changeSet) throws OseeCoreException {
txId = tx.getId();
binaryStores = new ArrayList<DaoToSql>();
dataItemInserts = new HashCollection<SqlOrderEnum, Object[]>();
@@ -97,9 +96,7 @@ public class TxSqlBuilderImpl implements OrcsVisitor, TxSqlBuilder {
addRow(SqlOrderEnum.TXS_DETAIL, txId, tx.getComment(), tx.getTimeStamp(), tx.getAuthor(), tx.getBranchId(),
tx.getTxType().getId());
- for (ArtifactTransactionData txData : artifactTransactionData) {
- txData.accept(this);
- }
+ changeSet.accept(this);
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactsResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactsResource.java
index f4fb5fc7a0..24e843e3d0 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactsResource.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/ArtifactsResource.java
@@ -23,7 +23,6 @@ import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.search.QueryFactory;
/**
@@ -61,12 +60,10 @@ public class ArtifactsResource {
public String getAsHtml() throws OseeCoreException {
IOseeBranch branch = TokenFactory.createBranch(branchUuid, "");
QueryFactory factory = OrcsApplication.getOrcsApi().getQueryFactory(null);
- ResultSet<ArtifactReadable> results =
- factory.fromBranch(branch).andNameEquals(DEFAULT_HIERARCHY_ROOT_NAME).getResults();
+ ResultSet<ArtifactReadable> results = factory.fromBranch(branch).andNameEquals(DEFAULT_HIERARCHY_ROOT_NAME).getResults();
ArtifactReadable rootArtifact = results.getExactlyOne();
- GraphReadable graph = OrcsApplication.getOrcsApi().getGraph(null);
- ResultSet<ArtifactReadable> arts = graph.getChildren(rootArtifact);
+ ResultSet<ArtifactReadable> arts = rootArtifact.getChildren();
HtmlWriter writer = new HtmlWriter(uriInfo);
return writer.toHtml(arts);
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java
index f4922ea71b..44b78488e8 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/HtmlWriter.java
@@ -23,7 +23,6 @@ import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
-import org.eclipse.osee.orcs.data.GraphReadable;
/**
* @author Roberto E. Escobar
@@ -100,8 +99,7 @@ public class HtmlWriter {
}
int count = 0;
- GraphReadable graph = OrcsApplication.getOrcsApi().getGraph(null);
- for (ArtifactReadable art : graph.getChildren(artifact)) {
+ for (ArtifactReadable art : artifact.getChildren()) {
URI uri1;
if (isAtEndOfPath(uriInfo.getPath(), "artifact")) {
uri1 = uriInfo.getAbsolutePathBuilder().path("{uuid}").build(art.getGuid());
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java
index d278c4cce5..50e639f253 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsRelationLoadingTest.java
@@ -25,7 +25,6 @@ import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.ApplicationContext;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
-import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.db.mock.OsgiService;
import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -51,12 +50,11 @@ public class OrcsRelationLoadingTest {
ApplicationContext context = null; // TODO use real application context
QueryFactory queryFactory = orcsApi.getQueryFactory(context);
- GraphReadable graph = orcsApi.getGraph(context);
- checkRelationsForCommonBranch(orcsApi, queryFactory, graph, context);
- checkRelationsForSawBranch(orcsApi, queryFactory, graph, context);
+ checkRelationsForCommonBranch(orcsApi, queryFactory, context);
+ checkRelationsForSawBranch(orcsApi, queryFactory, context);
}
- private void checkRelationsForCommonBranch(OrcsApi oseeApi, QueryFactory queryFactory, GraphReadable graph, ApplicationContext context) throws OseeCoreException {
+ private void checkRelationsForCommonBranch(OrcsApi oseeApi, QueryFactory queryFactory, ApplicationContext context) throws OseeCoreException {
QueryBuilder builder = queryFactory.fromBranch(CoreBranches.COMMON).andLocalIds(Arrays.asList(6, 7, 8));
ResultSet<ArtifactReadable> resultSet = builder.getResults();
@@ -69,15 +67,15 @@ public class OrcsRelationLoadingTest {
ArtifactReadable art8 = lookup.get(8);
//art 6 has no relations
- assertEquals(0, graph.getExistingRelationTypes(art6).size());
+ assertEquals(0, art6.getExistingRelationTypes().size());
//art 7 has 3
// REL_LINK_ID REL_LINK_TYPE_ID A_ART_ID B_ART_ID RATIONALE GAMMA_ID TX_CURRENT MOD_TYPE BRANCH_ID TRANSACTION_ID GAMMA_ID
// 1 219 7 8 53
// 3 219 7 15 54
// 2 219 1 7 52
- assertEquals(2, graph.getExistingRelationTypes(art7).size());
- assertEquals(2, graph.getRelatedArtifacts(CoreRelationTypes.Default_Hierarchical__Child, art7).size());
- assertEquals(1, graph.getRelatedArtifacts(CoreRelationTypes.Default_Hierarchical__Parent, art7).size());
+ assertEquals(1, art7.getExistingRelationTypes().size());
+ assertEquals(2, art7.getRelated(CoreRelationTypes.Default_Hierarchical__Child).size());
+ assertEquals(1, art7.getRelated(CoreRelationTypes.Default_Hierarchical__Parent).size());
//art8 has
// REL_LINK_ID REL_LINK_TYPE_ID A_ART_ID B_ART_ID RATIONALE GAMMA_ID TX_CURRENT MOD_TYPE BRANCH_ID TRANSACTION_ID GAMMA_ID
@@ -87,13 +85,13 @@ public class OrcsRelationLoadingTest {
// 6 233 8 19 76
// 5 233 8 18 78
// 1 219 7 8 53
- assertEquals(2, graph.getExistingRelationTypes(art8).size());
- assertEquals(1, graph.getRelatedArtifacts(CoreRelationTypes.Default_Hierarchical__Parent, art8).size());
- assertEquals(5, graph.getRelatedArtifacts(CoreRelationTypes.Users_User, art8).size());
+ assertEquals(2, art8.getExistingRelationTypes().size());
+ assertEquals(1, art8.getRelated(CoreRelationTypes.Default_Hierarchical__Parent).size());
+ assertEquals(5, art8.getRelated(CoreRelationTypes.Users_User).size());
}
- private void checkRelationsForSawBranch(OrcsApi oseeApi, QueryFactory queryFactory, GraphReadable graph, ApplicationContext context) throws OseeCoreException {
+ private void checkRelationsForSawBranch(OrcsApi oseeApi, QueryFactory queryFactory, ApplicationContext context) throws OseeCoreException {
QueryBuilder builder =
queryFactory.fromBranch(TestBranches.SAW_Bld_1).and(CoreAttributeTypes.Name, Operator.EQUAL,
"Design Constraints");
@@ -107,9 +105,9 @@ public class OrcsRelationLoadingTest {
//art 7 has no relations
//artifact has 3 children and 1 parent
- assertEquals(2, graph.getExistingRelationTypes(artifact).size());
- assertEquals(3, graph.getRelatedArtifacts(CoreRelationTypes.Default_Hierarchical__Child, artifact).size());
- assertEquals(1, graph.getRelatedArtifacts(CoreRelationTypes.Default_Hierarchical__Parent, artifact).size());
+ assertEquals(1, artifact.getExistingRelationTypes().size());
+ assertEquals(3, artifact.getRelated(CoreRelationTypes.Default_Hierarchical__Child).size());
+ assertEquals(1, artifact.getRelated(CoreRelationTypes.Default_Hierarchical__Parent).size());
}
private Map<Integer, ArtifactReadable> createLookup(Iterable<ArtifactReadable> arts) {
diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java
index c3fde54fd3..7bd1ec44e7 100644
--- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java
+++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java
@@ -10,13 +10,23 @@
*******************************************************************************/
package org.eclipse.osee.orcs.api;
+import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Component;
+import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.GeneralDocument;
+import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
+import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Child;
+import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Parent;
+import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Dependency__Artifact;
+import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Dependency__Dependency;
+import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.LEXICOGRAPHICAL_DESC;
import static org.eclipse.osee.orcs.OrcsIntegrationRule.integrationRule;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.util.Iterator;
import java.util.concurrent.Callable;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.ResultSet;
@@ -24,6 +34,7 @@ import org.eclipse.osee.framework.core.data.TokenFactory;
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.CoreRelationTypes;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
@@ -88,7 +99,7 @@ public class OrcsTransactionTest {
public void testWritingUriAttribute() throws OseeCoreException {
final String requirementText = "The engine torque shall be directly controllable through the engine control unit";
- TransactionBuilder tx = txFactory.createTransaction(CoreBranches.COMMON, userArtifact, testName.getMethodName());
+ TransactionBuilder tx = createTx();
ArtifactId torqueRequirement =
tx.createArtifact(CoreArtifactTypes.SoftwareRequirementPlainText, "Engine Torque Control");
@@ -157,8 +168,7 @@ public class OrcsTransactionTest {
query.fromBranch(CoreBranches.COMMON).andIds(SystemUser.Guest).getResults().getExactlyOne();
// duplicate on same branch
- TransactionBuilder transaction1 =
- txFactory.createTransaction(CoreBranches.COMMON, userArtifact, testName.getMethodName());
+ TransactionBuilder transaction1 = createTx();
ArtifactId duplicate = transaction1.copyArtifact(guestUser);
transaction1.commit();
ArtifactReadable guestUserDup =
@@ -206,7 +216,7 @@ public class OrcsTransactionTest {
ArtifactReadable guestUser =
query.fromBranch(CoreBranches.COMMON).andIds(SystemUser.Guest).getResults().getExactlyOne();
- TransactionBuilder tx = txFactory.createTransaction(CoreBranches.COMMON, userArtifact, testName.getMethodName());
+ TransactionBuilder tx = createTx();
thrown.expect(OseeArgumentException.class);
tx.introduceArtifact(guestUser);
@@ -218,7 +228,7 @@ public class OrcsTransactionTest {
ArtifactReadable originalGuest = queryBuilder.getResults().getExactlyOne();
- TransactionBuilder tx = txFactory.createTransaction(CoreBranches.COMMON, userArtifact, testName.getMethodName());
+ TransactionBuilder tx = createTx();
tx.setSoleAttributeFromString(originalGuest, CoreAttributeTypes.Name, "Test");
tx.commit();
@@ -230,7 +240,7 @@ public class OrcsTransactionTest {
@Test
public void testDeleteArtifact() throws OseeCoreException {
- TransactionBuilder tx = txFactory.createTransaction(CoreBranches.COMMON, userArtifact, testName.getMethodName());
+ TransactionBuilder tx = createTx();
ArtifactId artifact = tx.createArtifact(CoreArtifactTypes.AccessControlModel, "deleteMe");
tx.commit();
@@ -247,7 +257,7 @@ public class OrcsTransactionTest {
@Test
public void testArtifactGetTransaction() throws OseeCoreException {
- TransactionBuilder tx = txFactory.createTransaction(CoreBranches.COMMON, userArtifact, testName.getMethodName());
+ TransactionBuilder tx = createTx();
String guid = tx.createArtifact(CoreArtifactTypes.Component, "A component").getGuid();
int startingTx = tx.commit().getId();
@@ -256,7 +266,7 @@ public class OrcsTransactionTest {
query.fromBranch(CoreBranches.COMMON).andGuidsOrHrids(guid).getResults().getExactlyOne();
assertEquals(startingTx, artifact.getTransaction());
- TransactionBuilder tx2 = txFactory.createTransaction(CoreBranches.COMMON, userArtifact, testName.getMethodName());
+ TransactionBuilder tx2 = createTx();
tx2.setName(artifact, "Modified - component");
int lastTx = tx2.commit().getId();
@@ -267,6 +277,251 @@ public class OrcsTransactionTest {
assertEquals(lastTx, currentArtifact.getTransaction());
}
+ @Test
+ public void testRelate() throws OseeCoreException {
+ TransactionBuilder tx1 = createTx();
+ ArtifactId art1 = tx1.createArtifact(CoreArtifactTypes.Component, "A component");
+ ArtifactId art2 = tx1.createArtifact(CoreArtifactTypes.Component, "B component");
+ tx1.relate(art1, CoreRelationTypes.Default_Hierarchical__Child, art2);
+ tx1.commit();
+
+ ArtifactReadable artifact = query.fromBranch(CoreBranches.COMMON).andIds(art1).getResults().getExactlyOne();
+ assertEquals("A component", artifact.getName());
+
+ ResultSet<ArtifactReadable> children = artifact.getChildren();
+ assertEquals(1, children.size());
+ assertEquals("B component", children.getExactlyOne().getName());
+ }
+
+ @Test
+ public void testRelateWithSortType() throws OseeCoreException {
+ TransactionBuilder tx1 = createTx();
+ ArtifactId art1 = tx1.createArtifact(CoreArtifactTypes.Component, "A component");
+ ArtifactId art2 = tx1.createArtifact(CoreArtifactTypes.Component, "B component");
+ ArtifactId art3 = tx1.createArtifact(CoreArtifactTypes.Component, "C component");
+ tx1.addChildren(art1, art2, art3);
+ int tx1Id = tx1.commit().getId();
+
+ QueryBuilder art1Query = query.fromBranch(CoreBranches.COMMON).andIds(art1);
+
+ ArtifactReadable artifact = art1Query.getResults().getExactlyOne();
+ assertEquals("A component", artifact.getName());
+ assertEquals(tx1Id, artifact.getTransaction());
+
+ ResultSet<ArtifactReadable> children = artifact.getChildren();
+ assertEquals(2, children.size());
+
+ Iterator<ArtifactReadable> iterator = children.iterator();
+ assertEquals("B component", iterator.next().getName());
+ assertEquals("C component", iterator.next().getName());
+
+ TransactionBuilder tx2 = createTx();
+ ArtifactId art4 = tx2.createArtifact(Component, "D component");
+ tx2.relate(art1, Default_Hierarchical__Child, art4, LEXICOGRAPHICAL_DESC);
+ int tx2Id = tx2.commit().getId();
+
+ ArtifactReadable artifact21 = art1Query.getResults().getExactlyOne();
+ assertEquals("A component", artifact21.getName());
+ assertEquals(tx2Id, artifact21.getTransaction());
+
+ ResultSet<ArtifactReadable> children2 = artifact21.getChildren();
+ assertEquals(3, children2.size());
+
+ Iterator<ArtifactReadable> iterator2 = children2.iterator();
+ assertEquals("D component", iterator2.next().getName());
+ assertEquals("C component", iterator2.next().getName());
+ assertEquals("B component", iterator2.next().getName());
+ }
+
+ @Test
+ public void testAddChildren() throws OseeCoreException {
+ TransactionBuilder tx1 = createTx();
+ ArtifactId art1 = tx1.createArtifact(Component, "A component");
+ ArtifactId art2 = tx1.createArtifact(Component, "C component");
+ ArtifactId art3 = tx1.createArtifact(Component, "B component");
+ tx1.commit();
+
+ TransactionBuilder tx2 = createTx();
+ tx2.addChildren(art1, art2, art3);
+ tx2.commit();
+
+ ArtifactReadable artifact1 = query.fromBranch(CoreBranches.COMMON).andIds(art1).getResults().getExactlyOne();
+ assertEquals("A component", artifact1.getName());
+
+ ResultSet<ArtifactReadable> children = artifact1.getChildren();
+ assertEquals(2, children.size());
+
+ Iterator<ArtifactReadable> iterator = children.iterator();
+ ArtifactReadable artifact3 = iterator.next();
+ ArtifactReadable artifact2 = iterator.next();
+
+ assertEquals(art3, artifact3);
+ assertEquals(art2, artifact2);
+
+ assertEquals("B component", artifact3.getName());
+ assertEquals("C component", artifact2.getName());
+
+ assertEquals(artifact1, artifact2.getParent());
+ assertEquals(artifact1, artifact3.getParent());
+ }
+
+ @Test
+ public void testSetRationale() throws OseeCoreException {
+ String rationale = "This is my rationale";
+
+ TransactionBuilder tx1 = createTx();
+ ArtifactId art1 = tx1.createArtifact(Component, "A component");
+ ArtifactId art2 = tx1.createArtifact(Component, "B component");
+
+ tx1.relate(art1, Default_Hierarchical__Child, art2);
+ tx1.setRationale(art1, Default_Hierarchical__Child, art2, rationale);
+
+ tx1.commit();
+
+ ArtifactReadable artifact = query.fromBranch(CoreBranches.COMMON).andIds(art1).getResults().getExactlyOne();
+ assertEquals("A component", artifact.getName());
+
+ ResultSet<ArtifactReadable> children = artifact.getChildren();
+ assertEquals(1, children.size());
+
+ ArtifactReadable otherArtifact = children.getExactlyOne();
+ assertEquals("B component", otherArtifact.getName());
+
+ String actual1 = artifact.getRationale(Default_Hierarchical__Child, otherArtifact);
+ assertEquals(rationale, actual1);
+
+ String actual2 = otherArtifact.getRationale(Default_Hierarchical__Parent, artifact);
+ assertEquals(rationale, actual2);
+ }
+
+ @Test
+ public void testUnrelate() throws OseeCoreException {
+ TransactionBuilder tx1 = createTx();
+ ArtifactId art1 = tx1.createArtifact(Component, "A component");
+ ArtifactId art2 = tx1.createArtifact(Component, "C component");
+ ArtifactId art3 = tx1.createArtifact(Component, "B component");
+ tx1.addChildren(art1, art2, art3);
+ ArtifactId art4 = tx1.createArtifact(GeneralDocument, "Document");
+ tx1.relate(art1, Dependency__Dependency, art4);
+ int txId = tx1.commit().getId();
+
+ ArtifactReadable artifact4 = query.fromBranch(CoreBranches.COMMON).andIds(art4).getResults().getExactlyOne();
+ assertEquals(art4, artifact4);
+
+ ArtifactReadable artifact1 = artifact4.getRelated(CoreRelationTypes.Dependency__Artifact).getExactlyOne();
+ assertEquals(art1, artifact1);
+
+ Iterator<ArtifactReadable> iterator = artifact1.getChildren().iterator();
+ assertEquals(art3, iterator.next());
+ assertEquals(art2, iterator.next());
+
+ // Un-relate a child
+ TransactionBuilder tx2 = createTx();
+ tx2.unrelate(art1, Default_Hierarchical__Child, art2);
+ int txId2 = tx2.commit().getId();
+
+ artifact4 = query.fromBranch(CoreBranches.COMMON).andIds(art4).getResults().getExactlyOne();
+ assertEquals(art4, artifact4);
+
+ artifact1 = artifact4.getRelated(CoreRelationTypes.Dependency__Artifact).getExactlyOne();
+ assertEquals(art1, artifact1);
+
+ assertEquals(art3, artifact1.getChildren().getExactlyOne());
+ }
+
+ @Test
+ public void testUnrelateFromAllByType() throws OseeCoreException {
+ TransactionBuilder tx1 = createTx();
+ ArtifactId art1 = tx1.createArtifact(Component, "A component");
+ ArtifactId art2 = tx1.createArtifact(Component, "C component");
+ ArtifactId art3 = tx1.createArtifact(Component, "B component");
+ tx1.addChildren(art1, art2, art3);
+
+ ArtifactId art4 = tx1.createArtifact(GeneralDocument, "Document");
+ tx1.relate(art1, Dependency__Dependency, art4);
+ tx1.commit();
+
+ ArtifactReadable artifact4 = query.fromBranch(COMMON).andIds(art4).getResults().getExactlyOne();
+ assertEquals(art4, artifact4);
+
+ ArtifactReadable artifact1 = artifact4.getRelated(Dependency__Artifact).getExactlyOne();
+ assertEquals(art1, artifact1);
+
+ Iterator<ArtifactReadable> iterator = artifact1.getChildren().iterator();
+ assertEquals(art3, iterator.next());
+ assertEquals(art2, iterator.next());
+
+ // Unrelate All children
+ TransactionBuilder tx2 = createTx();
+ tx2.unrelateFromAll(Default_Hierarchical__Parent, art1);
+ tx2.commit();
+
+ artifact4 = query.fromBranch(COMMON).andIds(art4).getResults().getExactlyOne();
+ assertEquals(art4, artifact4);
+
+ artifact1 = artifact4.getRelated(Dependency__Artifact).getExactlyOne();
+ assertEquals(art1, artifact1);
+
+ assertEquals(true, artifact1.getChildren().isEmpty());
+ }
+
+ @Test
+ public void testUnrelateFromAll() throws OseeCoreException {
+ ArtifactReadable artifact1;
+ ArtifactReadable artifact2;
+ ArtifactReadable artifact3;
+ ArtifactReadable artifact4;
+
+ TransactionBuilder tx1 = createTx();
+ ArtifactId art1 = tx1.createArtifact(Component, "A component");
+ ArtifactId art2 = tx1.createArtifact(Component, "C component");
+ ArtifactId art3 = tx1.createArtifact(Component, "B component");
+ tx1.addChildren(art1, art2, art3);
+
+ ArtifactId art4 = tx1.createArtifact(GeneralDocument, "Document");
+ tx1.relate(art1, Dependency__Dependency, art4);
+ tx1.commit();
+
+ artifact4 = query.fromBranch(COMMON).andIds(art4).getResults().getExactlyOne();
+ assertEquals(art4, artifact4);
+
+ artifact1 = artifact4.getRelated(Dependency__Artifact).getExactlyOne();
+ assertEquals(art1, artifact1);
+
+ Iterator<ArtifactReadable> iterator = artifact1.getChildren().iterator();
+ assertEquals(art3, iterator.next());
+ assertEquals(art2, iterator.next());
+
+ TransactionBuilder tx2 = createTx();
+ tx2.unrelateFromAll(art1);
+ tx2.commit();
+
+ ResultSet<ArtifactReadable> arts =
+ query.fromBranch(COMMON).andIds(art1, art2, art3, art4).includeDeleted().getResults();
+ Iterator<ArtifactReadable> iterator2 = arts.iterator();
+ artifact1 = iterator2.next();
+ artifact2 = iterator2.next();
+ artifact3 = iterator2.next();
+ artifact4 = iterator2.next();
+
+ assertEquals(art1, artifact1);
+ assertEquals(art2, artifact2);
+ assertEquals(art3, artifact3);
+ assertEquals(art4, artifact4);
+
+ assertEquals(true, artifact1.getChildren().isEmpty());
+ assertEquals(true, artifact1.getRelated(Dependency__Dependency).isEmpty());
+
+ assertNull(artifact2.getParent());
+ assertNull(artifact3.getParent());
+
+ assertEquals(true, artifact4.getRelated(Dependency__Artifact).isEmpty());
+ }
+
+ private TransactionBuilder createTx() throws OseeCoreException {
+ return txFactory.createTransaction(COMMON, userArtifact, testName.getMethodName());
+ }
+
private ArtifactReadable getSystemUser() throws OseeCoreException {
return query.fromBranch(CoreBranches.COMMON).andIds(SystemUser.OseeSystem).getResults().getExactlyOne();
}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java
index 65137cb43e..2c37e86191 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsApi.java
@@ -12,7 +12,6 @@ package org.eclipse.osee.orcs;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.core.model.cache.TransactionCache;
-import org.eclipse.osee.orcs.data.GraphReadable;
import org.eclipse.osee.orcs.search.QueryFactory;
import org.eclipse.osee.orcs.search.QueryIndexer;
import org.eclipse.osee.orcs.transaction.TransactionFactory;
@@ -27,8 +26,6 @@ public interface OrcsApi {
QueryFactory getQueryFactory(ApplicationContext context);
- GraphReadable getGraph(ApplicationContext context);
-
OrcsBranch getBranchOps(ApplicationContext context);
OrcsAdmin getAdminOps(ApplicationContext context);
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactReadable.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactReadable.java
index 691e31f621..e7820828df 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactReadable.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/ArtifactReadable.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
+ * 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
@@ -14,10 +14,14 @@ import java.util.Collection;
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.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
+import org.eclipse.osee.framework.core.data.ResultSet;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
/**
+ * @author Megumi Telles
* @author Roberto E. Escobar
* @author Andrew M. Finkbeiner
*/
@@ -53,12 +57,31 @@ public interface ArtifactReadable extends ArtifactId, HasLocalId, HasBranch, Has
AttributeReadable<Object> getAttributeById(AttributeId attributeId) throws OseeCoreException;
- List<? extends AttributeReadable<Object>> getAttributes() throws OseeCoreException;
+ ResultSet<? extends AttributeReadable<Object>> getAttributes() throws OseeCoreException;
- <T> List<? extends AttributeReadable<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException;
+ <T> ResultSet<? extends AttributeReadable<T>> getAttributes(IAttributeType attributeType) throws OseeCoreException;
- List<? extends AttributeReadable<Object>> getAttributes(DeletionFlag deletionFlag) throws OseeCoreException;
+ ResultSet<? extends AttributeReadable<Object>> getAttributes(DeletionFlag deletionFlag) throws OseeCoreException;
- <T> List<? extends AttributeReadable<T>> getAttributes(IAttributeType attributeType, DeletionFlag deletionFlag) throws OseeCoreException;
+ <T> ResultSet<? extends AttributeReadable<T>> getAttributes(IAttributeType attributeType, DeletionFlag deletionFlag) throws OseeCoreException;
-} \ No newline at end of file
+ ////////////////////
+ int getMaximumRelationAllowed(IRelationTypeSide relationTypeSide) throws OseeCoreException;
+
+ Collection<? extends IRelationType> getValidRelationTypes() throws OseeCoreException;
+
+ Collection<? extends IRelationType> getExistingRelationTypes() throws OseeCoreException;
+
+ ArtifactReadable getParent() throws OseeCoreException;
+
+ ResultSet<ArtifactReadable> getChildren() throws OseeCoreException;
+
+ ResultSet<ArtifactReadable> getRelated(IRelationTypeSide relationTypeSide) throws OseeCoreException;
+
+ boolean areRelated(IRelationTypeSide typeAndSide, ArtifactReadable readable) throws OseeCoreException;
+
+ int getRelatedCount(IRelationTypeSide typeAndSide) throws OseeCoreException;
+
+ String getRationale(IRelationTypeSide typeAndSide, ArtifactReadable readable) throws OseeCoreException;
+
+}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/GraphReadable.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/GraphReadable.java
deleted file mode 100644
index 7acfa12a20..0000000000
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/GraphReadable.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * 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.data;
-
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.framework.core.data.IArtifactType;
-import org.eclipse.osee.framework.core.data.IRelationType;
-import org.eclipse.osee.framework.core.data.IRelationTypeSide;
-import org.eclipse.osee.framework.core.data.Readable;
-import org.eclipse.osee.framework.core.data.ResultSet;
-import org.eclipse.osee.framework.core.enums.RelationSide;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-
-public interface GraphReadable extends Readable {
-
- Collection<IRelationTypeSide> getExistingRelationTypes(ArtifactReadable art) throws OseeCoreException;
-
- List<IRelationType> getValidRelationTypes(ArtifactReadable art) throws OseeCoreException;
-
- ///////
- ArtifactReadable getParent(ArtifactReadable art) throws OseeCoreException;
-
- ResultSet<ArtifactReadable> getChildren(ArtifactReadable art) throws OseeCoreException;
-
- ResultSet<ArtifactReadable> getRelatedArtifacts(IRelationTypeSide relationTypeSide, ArtifactReadable art) throws OseeCoreException;
-
- int getRelationSideMax(IRelationType relationType, IArtifactType artifactType, RelationSide relationSide) throws OseeCoreException;
-
- RelationTypes getTypes();
-}
diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java
index fa724d6081..99bbaecddb 100644
--- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java
+++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionBuilder.java
@@ -15,6 +15,9 @@ 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.data.IRelationSorterId;
+import org.eclipse.osee.framework.core.data.IRelationType;
+import org.eclipse.osee.framework.core.data.IRelationTypeSide;
import org.eclipse.osee.framework.core.data.Identifiable;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.TransactionRecord;
@@ -97,4 +100,26 @@ public interface TransactionBuilder {
void deleteAttributesWithValue(ArtifactId art, IAttributeType attributeType, Object value) throws OseeCoreException;
+ /// TX
+
+ void addChildren(ArtifactId artA, Iterable<? extends ArtifactId> children) throws OseeCoreException;
+
+ void addChildren(ArtifactId artA, ArtifactId... children) throws OseeCoreException;
+
+ void relate(ArtifactId artA, IRelationType relType, ArtifactId artB) throws OseeCoreException;
+
+ void relate(ArtifactId artA, IRelationType relType, ArtifactId artB, String rationale) throws OseeCoreException;
+
+ void relate(ArtifactId artA, IRelationType relType, ArtifactId artB, IRelationSorterId sortType) throws OseeCoreException;
+
+ void relate(ArtifactId artA, IRelationType relType, ArtifactId artB, String rationale, IRelationSorterId sortType) throws OseeCoreException;
+
+ void setRationale(ArtifactId artA, IRelationType relType, ArtifactId artB, String rationale) throws OseeCoreException;
+
+ void unrelate(ArtifactId artA, IRelationType relType, ArtifactId artB) throws OseeCoreException;
+
+ void unrelateFromAll(ArtifactId art) throws OseeCoreException;
+
+ void unrelateFromAll(IRelationTypeSide typeSide, ArtifactId art) throws OseeCoreException;
+
}

Back to the top