Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManagerTest.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataLoaderImpl.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java52
-rw-r--r--plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java29
4 files changed, 70 insertions, 17 deletions
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 2a699f9a6f0..95ae043cdf8 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
@@ -240,6 +240,7 @@ public class TxDataManagerTest {
public void testGetForWriteReadableButIsFromDifferentBranch() throws OseeCoreException {
when(readable1.getBranch()).thenReturn(CoreBranches.COMMON);
when(txData.getWriteable(readable1)).thenReturn(null);
+ when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1);
ResultSet<Artifact> loaded = ResultSets.singleton(artifact1);
when(loader.loadArtifacts(eq(session), eq(graph), anyCollectionOf(ArtifactId.class))).thenReturn(loaded);
@@ -247,7 +248,8 @@ public class TxDataManagerTest {
Artifact actual = txDataManager.getForWrite(txData, readable1);
verify(txData).getWriteable(readable1);
- verify(readable1).getBranch();
+ verify(proxyManager).asInternalArtifact(readable1);
+ verify(artifact1).getBranch();
verify(loader).loadArtifacts(eq(session), eq(graph), idCaptor.capture());
assertEquals(readable1, idCaptor.getValue().iterator().next());
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 e6135f750d9..58346f7e9b2 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
@@ -56,6 +56,8 @@ public class TxDataLoaderImpl implements TxDataLoader {
}
DataLoader loader = dataLoaderFactory.newDataLoaderFromGuids(session, branch, ids);
loader.withLoadLevel(LoadLevel.ALL);
+ loader.includeDeletedAttributes();
+ loader.includeDeletedRelations();
return loader;
}
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 c760b5783fc..120a2512211 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
@@ -145,25 +145,40 @@ public class TxDataManager {
private Artifact findArtifactLocallyForWrite(TxData txData, ArtifactId artifactId) throws OseeCoreException {
Artifact node = txData.getWriteable(artifactId);
if (node == null) {
+ Artifact source = null;
if (artifactId instanceof Artifact) {
- Artifact source = (Artifact) artifactId;
- if (txData.getBranch().equals(source.getBranch())) {
- node = copyArtifactForWrite(txData, source);
- }
+ source = (Artifact) artifactId;
} else if (artifactId instanceof ArtifactReadable) {
- ArtifactReadable external = (ArtifactReadable) artifactId;
- if (txData.getBranch().equals(external.getBranch())) {
- int txId = txData.getGraph().getTransaction();
- if (txId == external.getTransaction()) {
- Artifact source = proxyManager.asInternalArtifact(external);
- node = copyArtifactForWrite(txData, source);
- }
- }
+ ArtifactReadable readable = (ArtifactReadable) artifactId;
+ source = proxyManager.asInternalArtifact(readable);
+ }
+ if (isFromSameStripe(txData, source) && includesDeletedData(source)) {
+ node = copyArtifactForWrite(txData, source);
}
}
return node;
}
+ private boolean isFromSameStripe(TxData txData, Artifact artifact) {
+ boolean result = false;
+ if (artifact != null && txData.getBranch().equals(artifact.getBranch())) {
+ int txId = txData.getGraph().getTransaction();
+ if (txId == artifact.getTransaction()) {
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ private boolean includesDeletedData(Artifact artifact) {
+ boolean result = false;
+ if (artifact != null) {
+ result = true;
+ // Check load options
+ }
+ return result;
+ }
+
private Artifact copyArtifactForWrite(TxData txData, Artifact source) throws OseeCoreException {
Artifact artifact = artifactFactory.clone(source);
txData.getGraph().addNode(artifact);
@@ -178,17 +193,22 @@ public class TxDataManager {
}
if (source == null) {
+ Artifact artifactSrc = null;
if (artifactId instanceof Artifact) {
- Artifact artifact = (Artifact) artifactId;
- if (fromBranch.equals(artifact.getBranch())) {
- source = artifact;
+ Artifact external = (Artifact) artifactId;
+ if (fromBranch.equals(external.getBranch())) {
+ artifactSrc = external;
}
} else if (artifactId instanceof ArtifactReadable) {
ArtifactReadable external = (ArtifactReadable) artifactId;
if (fromBranch.equals(external.getBranch())) {
- source = proxyManager.asInternalArtifact(external);
+ artifactSrc = proxyManager.asInternalArtifact(external);
}
}
+
+ if (includesDeletedData(artifactSrc)) {
+ source = artifactSrc;
+ }
}
if (source == null) {
ResultSet<Artifact> loadArtifacts =
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 221e95ef4c9..ce92959db5c 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
@@ -979,6 +979,35 @@ public class OrcsTransactionTest {
assertEquals("rationale5", rationale);
}
+ @Test
+ public void testRelateUnrelateMultipleTimes() {
+ TransactionBuilder tx = createTx();
+ ArtifactId art1 = tx.createArtifact(CoreArtifactTypes.Component, "A component");
+ ArtifactId art2 = tx.createArtifact(CoreArtifactTypes.User, "User Artifact");
+ tx.relate(art1, CoreRelationTypes.Users_User, art2, "rationale1");
+ tx.commit();
+
+ ArtifactReadable art = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne();
+ ArtifactReadable otherSide = art.getRelated(CoreRelationTypes.Users_User).getExactlyOne();
+ assertEquals(true, art.areRelated(CoreRelationTypes.Users_User, otherSide));
+
+ tx = createTx();
+ tx.unrelate(art1, CoreRelationTypes.Users_User, art2);
+ tx.commit();
+
+ art = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne();
+ ResultSet<ArtifactReadable> otherSideResults = art.getRelated(CoreRelationTypes.Users_User);
+ assertEquals(true, otherSideResults.isEmpty());
+
+ tx = createTx();
+ tx.relate(art1, CoreRelationTypes.Users_User, art2);
+ tx.commit();
+
+ art = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne();
+ otherSide = art.getRelated(CoreRelationTypes.Users_User).getExactlyOne();
+ assertEquals(true, art.areRelated(CoreRelationTypes.Users_User, otherSide));
+ }
+
private TransactionBuilder createTx() throws OseeCoreException {
return txFactory.createTransaction(COMMON, userArtifact, testName.getMethodName());
}

Back to the top