Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-07-21 23:48:51 +0000
committerRoberto E. Escobar2014-08-28 23:59:37 +0000
commitd0fe47df4dbfcf28443380c4ad8b7e2f8d1a0a63 (patch)
tree447e54b6ed6a86d1e52e59522f6548f82504cefa
parent9b38953459291fd0aec45887e63e4e460030fda9 (diff)
downloadorg.eclipse.osee-d0fe47df4dbfcf28443380c4ad8b7e2f8d1a0a63.tar.gz
org.eclipse.osee-d0fe47df4dbfcf28443380c4ad8b7e2f8d1a0a63.tar.xz
org.eclipse.osee-d0fe47df4dbfcf28443380c4ad8b7e2f8d1a0a63.zip
bug[ats_ATS64228]: Server side relations undelete issue
During transactions, server side code fails to see undeleted items if artifacts are pre-loaded and used as writeables for the transaction. Change-Id: Iaf01dfa42d0260e47ea289166013c414a7626f31
-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 2a699f9a6f..95ae043cdf 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 e6135f750d..58346f7e9b 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 c760b5783f..120a251221 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 221e95ef4c..ce92959db5 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