diff options
author | Ryan D. Brooks | 2015-10-09 17:19:00 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2015-10-14 17:55:41 +0000 |
commit | 9f76ee885c1abe8c347b5c78030507d2e18baefd (patch) | |
tree | 5714b9bb5a4bf34eefd311af7c7f2216505a7adf | |
parent | 11bbe3bf0aa55b74c97de537c1c926143ea5a9fc (diff) | |
download | org.eclipse.osee-directBranch.tar.gz org.eclipse.osee-directBranch.tar.xz org.eclipse.osee-directBranch.zip |
refactor: Use branchId directlydirectBranch
Change-Id: If644710231def11448928f06b4fdedf758295d27
81 files changed, 589 insertions, 881 deletions
diff --git a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/OseeLinkBuilder.java b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/OseeLinkBuilder.java index f4a256f8dc2..e901d2af744 100644 --- a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/OseeLinkBuilder.java +++ b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/OseeLinkBuilder.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.define.report.internal.wordupdate; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.orcs.data.ArtifactReadable; /** @@ -76,21 +75,21 @@ public class OseeLinkBuilder { "5r02CRpYI5HheF3UM0UhBZCR907SRkdOCR7muHF0sPClCVJ+87X1/uQe3q5J+a6bFRbvqSUUUV55" + "YUUUUAFZV54Y8P6jdPdX2h6Zc3MmN809pG7tgYGSRk8AD8KKKuFScHeDt6Ba5owQRW0EcEESRQxK" + "EjjjUKqKBgAAcAAdqkooqG76sAooooAKKKKAP//Z"; - + private static final String PIC_TAG_DATA = "<w:r><w:pict>" + "<v:shapetype id=\"_x0000_t75\" coordsize=\"21600,21600\" o:spt=\"75\" o:preferrelative=\"t\""+ " path=\"m@4@5l@4@11@9@11@9@5xe\" filled=\"f\" stroked=\"f\">" + - "<v:stroke joinstyle=\"miter\"/>" + + "<v:stroke joinstyle=\"miter\"/>" + "<v:formulas><v:f eqn=\"if lineDrawn pixelLineWidth 0\"/><v:f eqn=\"sum @0 1 0\"/>" + "<v:f eqn=\"sum 0 0 @1\"/><v:f eqn=\"prod @2 1 2\"/><v:f eqn=\"prod @3 21600 pixelWidth\"/>" + "<v:f eqn=\"prod @3 21600 pixelHeight\"/><v:f eqn=\"sum @0 0 1\"/><v:f eqn=\"prod @6 1 2\"/>" + - "<v:f eqn=\"prod @7 21600 pixelWidth\"/><v:f eqn=\"sum @8 21600 0\"/>" + + "<v:f eqn=\"prod @7 21600 pixelWidth\"/><v:f eqn=\"sum @8 21600 0\"/>" + "<v:f eqn=\"prod @7 21600 pixelHeight\"/><v:f eqn=\"sum @10 21600 0\"/></v:formulas>" + "<v:path o:extrusionok=\"f\" gradientshapeok=\"t\" o:connecttype=\"rect\"/>"+ "<o:lock v:ext=\"edit\" aspectratio=\"t\"/></v:shapetype>" + "<w:binData w:name=\"wordml://%s\">%s</w:binData>" + - "<v:shape id=\"_x0000_i1025\" type=\"#_x0000_t75\" style=\"width:53.25pt;height:15pt\">" + + "<v:shape id=\"_x0000_i1025\" type=\"#_x0000_t75\" style=\"width:53.25pt;height:15pt\">" + "<v:imagedata src=\"wordml://%s\" o:title=\"%s\"/></v:shape></w:pict></w:r>"; // @formatter:on @@ -98,19 +97,14 @@ public class OseeLinkBuilder { super(); } - public String getUnknownArtifactLink(String guid, IOseeBranch branch) { + public String getUnknownArtifactLink(String guid, Long branch) { String processType = "unknown"; - return getArtifactLinkWithMessage( - processType, - guid, - branch, - String.format("Invalid Link: artifact with guid:[%s] on branchUuid:[%s] does not exist", guid, - branch.getUuid())); + return getArtifactLinkWithMessage(processType, guid, branch, + String.format("Invalid Link: artifact with guid:[%s] on branchUuid:[%s] does not exist", guid, branch)); } - private String getArtifactLinkWithMessage(String processType, String guid, IOseeBranch branch, String message) { - String internalLink = - String.format("http://none/%s?guid=%s&branchUuid=%s", processType, guid, branch.getUuid()); + private String getArtifactLinkWithMessage(String processType, String guid, Long branch, String message) { + String internalLink = String.format("http://none/%s?guid=%s&branchUuid=%s", processType, guid, branch); return String.format(WORDML_LINK_FORMAT, internalLink, message); } diff --git a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordMlLinkHandler.java b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordMlLinkHandler.java index e2fc4a12953..65588fa26e3 100644 --- a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordMlLinkHandler.java +++ b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/WordMlLinkHandler.java @@ -17,7 +17,6 @@ import java.util.List; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.BranchType; import org.eclipse.osee.framework.jdk.core.text.change.ChangeSet; import org.eclipse.osee.framework.jdk.core.type.HashCollection; @@ -55,6 +54,7 @@ import com.google.common.collect.Lists; * <pre> * OSEE_LINK([artifact_guid]) * </pre> + * * <li><b>Legacy style links:</b> * * <pre> @@ -76,8 +76,8 @@ import com.google.common.collect.Lists; public class WordMlLinkHandler { private static final Matcher OSEE_LINK_PATTERN = Pattern.compile("OSEE_LINK\\((.*?)\\)", Pattern.DOTALL).matcher(""); - private static final Matcher WORDML_LINK = Pattern.compile("<w:hlink\\s+w:dest=\"(.*?)\".*?</w:hlink\\s*>", - Pattern.DOTALL).matcher(""); + private static final Matcher WORDML_LINK = + Pattern.compile("<w:hlink\\s+w:dest=\"(.*?)\".*?</w:hlink\\s*>", Pattern.DOTALL).matcher(""); private static final OseeLinkBuilder linkBuilder = new OseeLinkBuilder(); @@ -164,11 +164,11 @@ public class WordMlLinkHandler { return matchMap; } - private static List<ArtifactReadable> findArtifacts(QueryFactory queryFactory, IOseeBranch branch, List<String> guidsFromLinks) throws OseeCoreException { + private static List<ArtifactReadable> findArtifacts(QueryFactory queryFactory, Long branchId, List<String> guidsFromLinks) throws OseeCoreException { List<ArtifactReadable> arts = Lists.newLinkedList(); for (String guid : guidsFromLinks) { - ArtifactReadable art = queryFactory.fromBranch(branch.getUuid()).andGuid(guid).getResults().getOneOrNull(); + ArtifactReadable art = queryFactory.fromBranch(branchId).andGuid(guid).getResults().getOneOrNull(); if (art != null) { arts.add(art); } @@ -185,21 +185,20 @@ public class WordMlLinkHandler { } private static String modifiedContent(QueryFactory queryFactory, LinkType destLinkType, ArtifactReadable source, String original, HashCollection<String, MatchRange> matchMap, boolean isUnliking) throws OseeCoreException { - IOseeBranch branch = source.getBranch(); + Long branchId = source.getBranchUuid(); ChangeSet changeSet = new ChangeSet(original); List<ArtifactReadable> artifactsFromSearch = null; List<String> guidsFromLinks = new ArrayList<>(matchMap.keySet()); - artifactsFromSearch = findArtifacts(queryFactory, source.getBranch(), guidsFromLinks); - boolean isMergeBranch = queryFactory.branchQuery().andIds(branch).andIsOfType(BranchType.MERGE).getCount() > 0; + artifactsFromSearch = findArtifacts(queryFactory, branchId, guidsFromLinks); + boolean isMergeBranch = + queryFactory.branchQuery().andUuids(branchId).andIsOfType(BranchType.MERGE).getCount() > 0; if (guidsFromLinks.size() != artifactsFromSearch.size() && isMergeBranch) { - BranchReadable branchReadable = queryFactory.branchQuery().andIds(branch).getResults().getExactlyOne(); - BranchReadable sourceBranch = - queryFactory.branchQuery().andUuids(branchReadable.getParentBranch()).getResults().getExactlyOne(); + BranchReadable branchReadable = queryFactory.branchQuery().andUuids(branchId).getResults().getExactlyOne(); List<String> unknownGuids = getGuidsNotFound(guidsFromLinks, artifactsFromSearch); List<ArtifactReadable> union = new ArrayList<>(); - union.addAll(findArtifacts(queryFactory, sourceBranch, unknownGuids)); + union.addAll(findArtifacts(queryFactory, branchReadable.getParentBranch(), unknownGuids)); union.addAll(artifactsFromSearch); artifactsFromSearch = union; } @@ -219,7 +218,7 @@ public class WordMlLinkHandler { // Items not found for (String guid : unknownGuids) { for (MatchRange match : matchMap.getValues(guid)) { - String link = linkBuilder.getUnknownArtifactLink(guid, branch); + String link = linkBuilder.getUnknownArtifactLink(guid, branchId); changeSet.replace(match.start(), match.end(), link); } } diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/type/TransactionRecordTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/type/TransactionRecordTest.java index e615747afd1..c7434dd4f7d 100644 --- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/type/TransactionRecordTest.java +++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/type/TransactionRecordTest.java @@ -27,7 +27,7 @@ import org.junit.runners.Parameterized.Parameters; /** * Test Case for {@link TransactionRecord} - * + * * @author Megumi Telles */ @RunWith(Parameterized.class) @@ -35,7 +35,7 @@ public class TransactionRecordTest { private final TransactionRecord transaction; private final int transactionNumber; - private final int branchUuid; + private final Long branchId; private final TransactionDetailsType txType; private final String comment; @@ -43,9 +43,9 @@ public class TransactionRecordTest { private final int authorArtId; private final int commitArtId; - public TransactionRecordTest(int transactionNumber, int branchUuid, String comment, Date time, int authorArtId, int commitArtId, TransactionDetailsType txType) { + public TransactionRecordTest(int transactionNumber, Long branchId, String comment, Date time, int authorArtId, int commitArtId, TransactionDetailsType txType) { this.transactionNumber = transactionNumber; - this.branchUuid = branchUuid; + this.branchId = branchId; this.comment = comment; this.time = time; this.authorArtId = authorArtId; @@ -53,12 +53,12 @@ public class TransactionRecordTest { this.txType = txType; this.transaction = - new TransactionRecord(transactionNumber, branchUuid, comment, time, authorArtId, commitArtId, txType, null); + new TransactionRecord(transactionNumber, branchId, comment, time, authorArtId, commitArtId, txType, null); } @Test public void getBranch() { - Assert.assertEquals(branchUuid, transaction.getBranchId()); + Assert.assertEquals(branchId, transaction.getBranchId()); } @Test @@ -143,7 +143,7 @@ public class TransactionRecordTest { @Test public void testToString() { - Assert.assertEquals(transactionNumber + ":" + branchUuid, transaction.toString()); + Assert.assertEquals(transactionNumber + ":" + branchId, transaction.toString()); } @Parameters @@ -151,13 +151,13 @@ public class TransactionRecordTest { Collection<Object[]> data = new ArrayList<>(); for (int index = 1; index <= 2; index++) { int transactionNumber = index * 11; - int branchUuid = index * 9; + Long branchId = index * 9L; String comment = GUID.create(); Date time = new Date(); int authorArtId = index * 47; int commitArtId = index * 37; TransactionDetailsType txType = TransactionDetailsType.toEnum(index % TransactionDetailsType.values().length); - data.add(new Object[] {transactionNumber, branchUuid, comment, time, authorArtId, commitArtId, txType}); + data.add(new Object[] {transactionNumber, branchId, comment, time, authorArtId, commitArtId, txType}); } return data; } diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java index 7d56652321e..93b881ec2c1 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java @@ -56,7 +56,7 @@ public class TransactionRecord extends BaseIdentity<Integer> implements ITransac return branchUuid != NON_EXISTING_BRANCH; } - public long getBranchId() { + public Long getBranchId() { return branchUuid; } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java index 7482bd68eb1..6db36913314 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/BaseTransactionData.java @@ -28,7 +28,7 @@ public abstract class BaseTransactionData { int getTransactionNumber(); - long getBranchId(); + Long getBranchId(); void internalAddInsertToBatch(int insertPriority, String insertSql, Object... data); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/StoreSkynetTransactionOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/StoreSkynetTransactionOperation.java index 5aec56ac35f..54f1c45422d 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/StoreSkynetTransactionOperation.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/StoreSkynetTransactionOperation.java @@ -78,7 +78,7 @@ public final class StoreSkynetTransactionOperation extends AbstractDbTxOperation } @Override - public long getBranchId() { + public Long getBranchId() { return branch.getUuid(); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Address.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Address.java index fb7ce78c1c5..bfb34f7615a 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Address.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/utility/Address.java @@ -91,7 +91,7 @@ public final class Address implements Comparable<Address> { this.purge = purge; } - public long getBranchId() { + public Long getBranchId() { return branchUuid; } 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 29962e20060..46452d7e13d 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 @@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.core.internal.artifact; import static org.junit.Assert.assertEquals; 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; @@ -25,7 +24,6 @@ import org.eclipse.osee.framework.core.data.IAttributeType; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.DeletionFlag; -import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.GUID; import org.eclipse.osee.orcs.OrcsSession; @@ -33,8 +31,6 @@ import org.eclipse.osee.orcs.core.ds.ArtifactData; import org.eclipse.osee.orcs.core.ds.ArtifactDataFactory; import org.eclipse.osee.orcs.core.ds.AttributeData; import org.eclipse.osee.orcs.core.ds.VersionData; -import org.eclipse.osee.orcs.core.internal.artifact.ArtifactFactory.BranchProviderFactory; -import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl.BranchProvider; 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; @@ -54,7 +50,7 @@ import org.mockito.stubbing.Answer; /** * Test Case for {@link ArtifactFactory} - * + * * @author John Misinco */ public class ArtifactFactoryTest { @@ -67,20 +63,18 @@ public class ArtifactFactoryTest { @Mock private IArtifactType artifactType; @Mock private ArtifactData artifactData; @Mock private VersionData artifactVersion; - + @Mock private ArtifactDataFactory dataFactory; @Mock private AttributeFactory attributeFactory; @Mock private RelationFactory relationFactory; @Mock private ArtifactTypes artifactTypeCache; - @Mock private BranchProviderFactory branchProviderFactory; - @Mock private BranchProvider branchProvider; - + @Mock private Attribute<Object> attribute; @Mock private AttributeData attributeData; @Mock private Artifact source; @Mock private Artifact destination; @Mock private OrcsSession session; - + @Mock private ArtifactData otherArtifactData; // @formatter:on @@ -88,12 +82,13 @@ public class ArtifactFactoryTest { private ArtifactFactory artifactFactory; private List<IAttributeType> types; + private final Long BRANCH_ID = 23L; + @Before public void init() throws OseeCoreException { MockitoAnnotations.initMocks(this); - artifactFactory = new ArtifactFactory(dataFactory, attributeFactory, artifactTypeCache, branchProviderFactory); - when(branchProviderFactory.createBranchProvider(any(OrcsSession.class))).thenReturn(branchProvider); + artifactFactory = new ArtifactFactory(dataFactory, attributeFactory, artifactTypeCache); guid = GUID.create(); @@ -106,30 +101,28 @@ public class ArtifactFactoryTest { when(artifactData.getGuid()).thenReturn(guid); when(artifactData.getTypeUuid()).thenReturn(65L); when(artifactData.getVersion()).thenReturn(artifactVersion); - when(artifactVersion.getBranchId()).thenReturn(23L); - when(branch.getGuid()).thenReturn(23L); + when(artifactVersion.getBranchId()).thenReturn(BRANCH_ID); + when(source.getOrcsData()).thenReturn(artifactData); - when( - attributeFactory.copyAttribute(any(AttributeData.class), any(IOseeBranch.class), any(AttributeManager.class))).thenReturn( - attribute); + when(attributeFactory.copyAttribute(any(AttributeData.class), any(Long.class), + any(AttributeManager.class))).thenReturn(attribute); when(otherArtifactData.getLocalId()).thenReturn(45); when(otherArtifactData.getGuid()).thenReturn(guid); when(otherArtifactData.getTypeUuid()).thenReturn(65L); when(otherArtifactData.getVersion()).thenReturn(artifactVersion); - when(branchProvider.getBranch(23L)).thenReturn(branch); - when(artifactTypeCache.getByUuid(65L)).thenReturn(artifactType); + } @Test public void testCreateArtifactFromBranchTypeAndGuid() throws OseeCoreException { - when(dataFactory.create(branch, artifactType, guid)).thenReturn(artifactData); + when(dataFactory.create(BRANCH_ID, artifactType, guid)).thenReturn(artifactData); - Artifact artifact = artifactFactory.createArtifact(session, branch, artifactType, guid); + Artifact artifact = artifactFactory.createArtifact(session, BRANCH_ID, artifactType, guid); - verify(dataFactory).create(branch, artifactType, guid); + verify(dataFactory).create(BRANCH_ID, artifactType, guid); assertEquals(artifactType, artifact.getArtifactType()); assertEquals(guid, artifact.getGuid()); } @@ -137,11 +130,11 @@ public class ArtifactFactoryTest { @Test public void testCreateArtifactFromBranchTypeAndGuidAndUuid() throws OseeCoreException { long uuid = 93456L; - when(dataFactory.create(branch, artifactType, guid, uuid)).thenReturn(artifactData); + when(dataFactory.create(BRANCH_ID, artifactType, guid, uuid)).thenReturn(artifactData); - Artifact artifact = artifactFactory.createArtifact(session, branch, artifactType, guid, uuid); + Artifact artifact = artifactFactory.createArtifact(session, BRANCH_ID, artifactType, guid, uuid); - verify(dataFactory).create(branch, artifactType, guid, uuid); + verify(dataFactory).create(BRANCH_ID, artifactType, guid, uuid); assertEquals(artifactType, artifact.getArtifactType()); assertEquals(guid, artifact.getGuid()); } @@ -156,21 +149,22 @@ public class ArtifactFactoryTest { @Test public void testCopyArtifact() throws OseeCoreException { - when(source.getOrcsData()).thenReturn(artifactData); - when(dataFactory.copy(branch, artifactData)).thenReturn(otherArtifactData); + when(dataFactory.copy(BRANCH_ID, artifactData)).thenReturn(otherArtifactData); when(source.getAttributes(CoreAttributeTypes.Annotation)).thenAnswer(new ReturnAttribute(attribute)); when(attribute.getOrcsData()).thenReturn(attributeData); - when(artifactTypeCache.isValidAttributeType(artifactType, branch, CoreAttributeTypes.Annotation)).thenReturn(true); + + when(artifactTypeCache.isValidAttributeType(eq(artifactType), any(IOseeBranch.class), + eq(CoreAttributeTypes.Annotation))).thenReturn(true); ArgumentCaptor<Artifact> implCapture = ArgumentCaptor.forClass(Artifact.class); - Artifact actual = artifactFactory.copyArtifact(session, source, types, branch); + Artifact actual = artifactFactory.copyArtifact(session, source, types, BRANCH_ID); verify(source, times(0)).getAttributes(CoreAttributeTypes.RelationOrder); verify(source, times(0)).getAttributes(CoreAttributeTypes.City); verify(source, times(1)).getAttributes(CoreAttributeTypes.Annotation); - verify(attributeFactory).copyAttribute(eq(attributeData), eq(branch), implCapture.capture()); + verify(attributeFactory).copyAttribute(eq(attributeData), eq(BRANCH_ID), implCapture.capture()); Assert.assertTrue(implCapture.getValue().isLoaded()); Assert.assertTrue(actual == implCapture.getValue()); @@ -178,44 +172,40 @@ public class ArtifactFactoryTest { @Test public void testIntroduceArtifact() throws OseeCoreException { - Branch otherBranch = mock(Branch.class); - - when(source.getBranch()).thenReturn(otherBranch); - when(source.getOrcsData()).thenReturn(artifactData); - - when(dataFactory.introduce(branch, artifactData)).thenReturn(otherArtifactData); + when(dataFactory.introduce(BRANCH_ID, artifactData)).thenReturn(otherArtifactData); when(source.getExistingAttributeTypes()).thenAnswer(new ReturnExistingTypes(types)); when(source.getAttributes(DeletionFlag.INCLUDE_DELETED)).thenAnswer(new ReturnAttribute(attribute)); when(attribute.getOrcsData()).thenReturn(attributeData); - when(artifactTypeCache.isValidAttributeType(artifactType, branch, CoreAttributeTypes.Annotation)).thenReturn(true); + when(artifactTypeCache.isValidAttributeType(artifactType, branch, CoreAttributeTypes.Annotation)).thenReturn( + true); when(attribute.getAttributeType()).thenReturn(CoreAttributeTypes.Annotation); when(destination.isAttributeTypeValid(CoreAttributeTypes.Annotation)).thenReturn(true); - Artifact actual = artifactFactory.introduceArtifact(session, source, destination, branch); + Artifact actual = artifactFactory.introduceArtifact(session, source, destination, BRANCH_ID); - verify(attributeFactory).introduceAttribute(eq(attributeData), eq(branch), eq(destination)); + verify(attributeFactory).introduceAttribute(eq(attributeData), eq(BRANCH_ID), eq(destination)); Assert.assertTrue(actual == destination); } @Test public void testClone() throws OseeCoreException { - when(source.getOrcsData()).thenReturn(artifactData); - when(dataFactory.copy(branch, artifactData)).thenReturn(otherArtifactData); + when(dataFactory.copy(BRANCH_ID, artifactData)).thenReturn(otherArtifactData); when(source.getExistingAttributeTypes()).thenAnswer(new ReturnExistingTypes(types)); when(source.getAttributes(CoreAttributeTypes.Annotation)).thenAnswer(new ReturnAttribute(attribute)); when(attribute.getOrcsData()).thenReturn(attributeData); - when(artifactTypeCache.isValidAttributeType(artifactType, branch, CoreAttributeTypes.Annotation)).thenReturn(true); + when(artifactTypeCache.isValidAttributeType(eq(artifactType), any(IOseeBranch.class), + eq(CoreAttributeTypes.Annotation))).thenReturn(true); ArgumentCaptor<Artifact> implCapture = ArgumentCaptor.forClass(Artifact.class); - Artifact actual = artifactFactory.copyArtifact(session, source, types, branch); + Artifact actual = artifactFactory.copyArtifact(session, source, types, BRANCH_ID); verify(source, times(0)).getAttributes(CoreAttributeTypes.RelationOrder); verify(source, times(0)).getAttributes(CoreAttributeTypes.City); verify(source, times(1)).getAttributes(CoreAttributeTypes.Annotation); - verify(attributeFactory).copyAttribute(eq(attributeData), eq(branch), implCapture.capture()); + verify(attributeFactory).copyAttribute(eq(attributeData), eq(BRANCH_ID), implCapture.capture()); Assert.assertTrue(implCapture.getValue().isLoaded()); Assert.assertTrue(actual == implCapture.getValue()); } 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 8122cd167da..f203f4666ee 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.AttributeData; 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.artifact.ArtifactImpl.BranchProvider; import org.eclipse.osee.orcs.core.internal.graph.GraphData; import org.eclipse.osee.orcs.data.ArtifactTypes; import org.eclipse.osee.orcs.data.BranchReadable; @@ -59,12 +58,11 @@ public class ArtifactTest { @Mock private ArtifactData artifactData; @Mock private AttributeFactory attributeFactory; @Mock private ArtifactTypes types; - @Mock private BranchProvider branchProvider; @Mock private VersionData version; @Mock private AttributeData attributeData; @Mock private BranchReadable branch; - + @SuppressWarnings("rawtypes") @Mock private Attribute attribute; @SuppressWarnings("rawtypes") @@ -73,7 +71,7 @@ public class ArtifactTest { @Mock private Attribute deleted; @SuppressWarnings("rawtypes") @Mock private Attribute differentType; - + @Mock private GraphData graph; // @formatter:on @@ -85,18 +83,18 @@ public class ArtifactTest { @Before public void init() throws OseeCoreException { MockitoAnnotations.initMocks(this); - artifact = new ArtifactImpl(types, artifactData, attributeFactory, branchProvider); + artifact = new ArtifactImpl(types, artifactData, attributeFactory); artifact.setGraph(graph); - when(types.isValidAttributeType(any(IArtifactType.class), any(Branch.class), any(IAttributeType.class))).thenReturn( - true); + when( + types.isValidAttributeType(any(IArtifactType.class), any(Branch.class), any(IAttributeType.class))).thenReturn( + true); when(attributeFactory.getMaxOccurrenceLimit(any(IAttributeType.class))).thenReturn(1); when(attributeFactory.createAttribute(any(AttributeManager.class), any(AttributeData.class))).thenReturn( attribute); - when( - attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class), - any(IAttributeType.class))).thenReturn(attribute); + when(attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class), + any(IAttributeType.class))).thenReturn(attribute); when(attribute.getOrcsData()).thenReturn(attributeData); when(artifactData.getGuid()).thenReturn(guid); @@ -104,7 +102,6 @@ public class ArtifactTest { when(artifactData.getTypeUuid()).thenReturn(artifactType.getGuid()); when(artifactData.getLocalId()).thenReturn(0); when(version.getBranchId()).thenReturn(55L); - when(branchProvider.getBranch(55L)).thenReturn(branch); when(deleted.isDeleted()).thenReturn(true); when(notDeleted.getOrcsData()).thenReturn(attributeData); @@ -201,9 +198,8 @@ public class ArtifactTest { public void testSetName() throws OseeCoreException { Attribute attr = mock(Attribute.class); when(attr.getOrcsData()).thenReturn(attributeData); - when( - attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class), - eq(CoreAttributeTypes.Name))).thenReturn(attr); + when(attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class), + eq(CoreAttributeTypes.Name))).thenReturn(attr); artifact.setName("test"); verify(attr).setFromString("test"); } @@ -273,13 +269,13 @@ public class ArtifactTest { @Test public void testIsAttributeTypeValid() throws OseeCoreException { artifact.isAttributeTypeValid(CoreAttributeTypes.Afha); - verify(types).isValidAttributeType(artifactType, branch, CoreAttributeTypes.Afha); + verify(types).isValidAttributeType(eq(artifactType), any(), eq(CoreAttributeTypes.Afha)); } @Test public void testGetValidAttributeTypes() throws OseeCoreException { artifact.getValidAttributeTypes(); - verify(types).getAttributeTypes(artifactType, branch); + verify(types).getAttributeTypes(eq(artifactType), any()); } @Test @@ -304,9 +300,8 @@ public class ArtifactTest { Attribute attr = mock(Attribute.class); when(attr.getOrcsData()).thenReturn(attributeData); - when( - attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class), - eq(CoreAttributeTypes.Name))).thenReturn(attr); + when(attributeFactory.createAttributeWithDefaults(any(AttributeManager.class), any(ArtifactData.class), + eq(CoreAttributeTypes.Name))).thenReturn(attr); when(attr.getValue()).thenReturn("test"); artifact.add(CoreAttributeTypes.Name, attr); artifact.setName("test"); @@ -454,8 +449,8 @@ public class ArtifactTest { when(attributeFactory.getMaxOccurrenceLimit(attributeType)).thenReturn(3); - when(attributeFactory.createAttributeWithDefaults(eq(artifact), any(ArtifactData.class), eq(attributeType))).thenReturn( - one, two, three); + when(attributeFactory.createAttributeWithDefaults(eq(artifact), any(ArtifactData.class), + eq(attributeType))).thenReturn(one, two, three); artifact.setAttributesFromStrings(attributeType, "one", "two", "three"); verify(one).setFromString("one"); verify(two).setFromString("two"); @@ -472,8 +467,8 @@ public class ArtifactTest { when(attributeFactory.getMaxOccurrenceLimit(attributeType)).thenReturn(3); - when(attributeFactory.createAttributeWithDefaults(eq(artifact), any(ArtifactData.class), eq(attributeType))).thenReturn( - two); + when(attributeFactory.createAttributeWithDefaults(eq(artifact), any(ArtifactData.class), + eq(attributeType))).thenReturn(two); artifact.add(attributeType, one); artifact.setAttributesFromStrings(attributeType, "1", "2"); verify(one).setFromString("1"); diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java index 3f47f1eb60a..dda26a944f6 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactoryTest.java @@ -20,7 +20,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import java.lang.ref.WeakReference; import org.eclipse.osee.framework.core.data.IAttributeType; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.enums.DeletionFlag; @@ -43,7 +42,7 @@ import org.mockito.MockitoAnnotations; /** * Test Case for {@link AttributeFactory} - * + * * @author John Misinco */ public class AttributeFactoryTest { @@ -55,10 +54,10 @@ public class AttributeFactoryTest { @Mock private AttributeClassResolver classResolver; @Mock private AttributeTypes cache; @Mock private AttributeDataFactory dataFactory; - + @Mock private AttributeData attributeData; @Mock private VersionData attrVersionData; - + @Mock private IAttributeType attributeType; @Mock private Attribute<Object> attribute; @Mock private Attribute<Object> destinationAttribute; @@ -69,7 +68,7 @@ public class AttributeFactoryTest { private AttributeFactory factory; private long expectedGuid; - private final IOseeBranch branch = CoreBranches.COMMON; + private final Long branchId = CoreBranches.COMMON.getUuid(); @Before public void init() throws OseeCoreException { @@ -142,18 +141,18 @@ public class AttributeFactoryTest { public void testCopyAttribute() throws OseeCoreException { AttributeData copiedAttributeData = mock(AttributeData.class); - when(dataFactory.copy(branch, attributeData)).thenReturn(copiedAttributeData); + when(dataFactory.copy(branchId, attributeData)).thenReturn(copiedAttributeData); when(copiedAttributeData.getTypeUuid()).thenReturn(expectedGuid); when(copiedAttributeData.getDataProxy()).thenReturn(proxy); ArgumentCaptor<ResourceNameResolver> resolverCapture = ArgumentCaptor.forClass(ResourceNameResolver.class); ArgumentCaptor<WeakReference> refCapture = ArgumentCaptor.forClass(WeakReference.class); - Attribute<Object> actual = factory.copyAttribute(attributeData, branch, container); + Attribute<Object> actual = factory.copyAttribute(attributeData, branchId, container); assertTrue(attribute == actual); - verify(dataFactory).copy(branch, attributeData); + verify(dataFactory).copy(branchId, attributeData); verify(proxy).setResolver(resolverCapture.capture()); verify(attribute).internalInitialize(eq(cache), refCapture.capture(), eq(copiedAttributeData), eq(true), @@ -167,7 +166,7 @@ public class AttributeFactoryTest { when(attributeData.getVersion()).thenReturn(attrVersionData); when(attrVersionData.isInStorage()).thenReturn(false); - Attribute<Object> actual = factory.introduceAttribute(attributeData, branch, container); + Attribute<Object> actual = factory.introduceAttribute(attributeData, branchId, container); assertNull(actual); } @@ -178,16 +177,16 @@ public class AttributeFactoryTest { when(attributeData.getVersion()).thenReturn(attrVersionData); when(attrVersionData.isInStorage()).thenReturn(true); - when(dataFactory.introduce(branch, attributeData)).thenReturn(introducedAttributeData); + when(dataFactory.introduce(branchId, attributeData)).thenReturn(introducedAttributeData); when(introducedAttributeData.getTypeUuid()).thenReturn(expectedGuid); when(introducedAttributeData.getDataProxy()).thenReturn(proxy); when(container.getAttributeById(attributeData, DeletionFlag.INCLUDE_DELETED)).thenReturn(destinationAttribute); - Attribute<Object> actual = factory.introduceAttribute(attributeData, branch, container); + Attribute<Object> actual = factory.introduceAttribute(attributeData, branchId, container); assertNotNull(actual); - verify(dataFactory).introduce(branch, attributeData); + verify(dataFactory).introduce(branchId, attributeData); assertEquals(actual, destinationAttribute); } diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/GraphUtilTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/GraphUtilTest.java index 6861f279df5..8f74bff7828 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/GraphUtilTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/GraphUtilTest.java @@ -10,11 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.internal.graph; +import static org.eclipse.osee.framework.core.enums.CoreBranches.SYSTEM_ROOT; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -27,12 +27,12 @@ import org.mockito.Mock; /** * Test Case for {@link GraphUtil} - * + * * @author Megumi Telles */ public class GraphUtilTest { - private static final IOseeBranch BRANCH = CoreBranches.COMMON; + private static final Long BRANCH_ID = CoreBranches.COMMON.getUuid(); private static final int TRANSACTION_ID = 231214214; @Rule @@ -50,26 +50,18 @@ public class GraphUtilTest { initMocks(this); provider = GraphUtil.asProvider(graph); - when(graph.getBranch()).thenReturn(BRANCH); + when(graph.getBranchUuid()).thenReturn(BRANCH_ID); when(graph.getTransaction()).thenReturn(TRANSACTION_ID); } @Test - public void testAsProviderNullBranch() throws OseeCoreException { - assertNotNull(provider); - - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("branch cannot be null - Invalid branch - can't provide graph"); - provider.getGraph(session, null, TRANSACTION_ID); - } - - @Test public void testAsProviderBranchNotSame() throws OseeCoreException { assertNotNull(provider); thrown.expect(OseeArgumentException.class); - thrown.expectMessage("Invalid branch - Graph's branch[Common] does not equals requested branch[System Root Branch]"); - provider.getGraph(session, CoreBranches.SYSTEM_ROOT, TRANSACTION_ID); + thrown.expectMessage(String.format("Invalid branch - Graph's branch[%s] does not equals requested branch[%s]", + BRANCH_ID, SYSTEM_ROOT.getUuid())); + provider.getGraph(session, SYSTEM_ROOT.getUuid(), TRANSACTION_ID); } @Test @@ -79,13 +71,14 @@ public class GraphUtilTest { int txId = 123456789; thrown.expect(OseeArgumentException.class); - thrown.expectMessage("Invalid transactionId - Graph's transactionId[231214214] does not equals requested transactionId[123456789]"); - provider.getGraph(session, BRANCH, txId); + thrown.expectMessage( + "Invalid transactionId - Graph's transactionId[231214214] does not equals requested transactionId[123456789]"); + provider.getGraph(session, BRANCH_ID, txId); } @Test public void testAsProviderGetName() throws OseeCoreException { assertNotNull(provider); - assertEquals(graph, provider.getGraph(session, BRANCH, TRANSACTION_ID)); + assertEquals(graph, provider.getGraph(session, BRANCH_ID, TRANSACTION_ID)); } } diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphBuilderImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphBuilderImplTest.java index faf49ddee05..01d3a289844 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphBuilderImplTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphBuilderImplTest.java @@ -15,7 +15,6 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.mockito.MockitoAnnotations.initMocks; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.IRelationType; import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.core.enums.CoreBranches; @@ -44,13 +43,13 @@ import org.mockito.Mock; /** * Test Case for @{link GraphBuilderImpl} - * + * * @author Megumi Telles */ public class GraphBuilderImplTest { private static final IRelationType TYPE_1 = TokenFactory.createRelationType(123456789L, "TYPE_1"); - private static final IOseeBranch BRANCH = CoreBranches.COMMON; + private static final Long BRANCH_ID = CoreBranches.COMMON.getUuid(); private static final int TRANSACTION_ID = 231214214; @Rule @@ -61,21 +60,21 @@ public class GraphBuilderImplTest { @Mock private ArtifactFactory artifactFactory; @Mock private AttributeFactory attributeFactory; @Mock private RelationFactory relationFactory; - + @Mock private OrcsSession session; @Mock private GraphProvider graphProvider; @Mock private GraphData graphData; - + @Mock private LoadDescription description; - + @Mock private ArtifactData artifactData; @Mock private AttributeData attributeData; @Mock private RelationData relationData; - + @Mock private Artifact artifact; @Mock private Artifact container; - @Mock private Relation relation; - + @Mock private Relation relation; + // @formatter:on private GraphBuilder builder; @@ -89,9 +88,9 @@ public class GraphBuilderImplTest { builder = new GraphBuilderImpl(logger, artifactFactory, attributeFactory, relationFactory, graphProvider); when(description.getSession()).thenReturn(session); - when(description.getBranch()).thenReturn(BRANCH); + when(description.getBranchId()).thenReturn(BRANCH_ID); when(description.getTransaction()).thenReturn(TRANSACTION_ID); - when(graphProvider.getGraph(session, BRANCH, TRANSACTION_ID)).thenReturn(graphData); + when(graphProvider.getGraph(session, BRANCH_ID, TRANSACTION_ID)).thenReturn(graphData); when(relationFactory.createRelationContainer()).thenReturn(adjacencies); when(relationFactory.createRelation(relationData)).thenReturn(relation); @@ -118,7 +117,7 @@ public class GraphBuilderImplTest { builder.onLoadDescription(description); builder.onLoadEnd(); - verify(description).getBranch(); + verify(description).getBranchId(); verify(description).getTransaction(); } diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphDataImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphDataImplTest.java index 879bac2eaec..02bd634e656 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphDataImplTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphDataImplTest.java @@ -59,12 +59,12 @@ public class GraphDataImplTest { @Mock private ArtifactFactory artifactFactory; @Mock private AttributeFactory attributeFactory; @Mock private RelationFactory relationFactory; - + @Mock private GraphProvider graphProvider; @Mock private GraphData graphData; - + @Mock private LoadDescription description; - + @Mock private ArtifactData artifactData; @Mock private ArtifactData artifactData1; @Mock private ArtifactData artifactData2; @@ -72,21 +72,21 @@ public class GraphDataImplTest { @Mock private AttributeData attributeData1; @Mock private AttributeData attributeData2; @Mock private RelationData relationData; - + @Mock private Artifact artifact; @Mock private Artifact artifact1; @Mock private Artifact artifact2; @Mock private Artifact container; @Mock private Artifact container1; @Mock private Artifact container2; - + @Mock private Relation relation; @Mock private Relation relation1; @Mock private Relation relation2; @Mock private Relation relation3; - + @Mock private OrcsSession session; - + // @formatter:on private GraphDataImpl graph; @@ -96,12 +96,12 @@ public class GraphDataImplTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - graph = new GraphDataImpl(session, branch, TRANSACTION_ID); + graph = new GraphDataImpl(session, branch.getUuid(), TRANSACTION_ID); } @Test - public void testGetBranch() { - assertEquals(branch, graph.getBranch()); + public void testGetBranchUuid() { + assertEquals(branch.getUuid(), graph.getBranchUuid()); } @Test @@ -112,7 +112,6 @@ public class GraphDataImplTest { @Test public void testAddNodeArtifact() throws OseeCoreException { when(artifact.getLocalId()).thenReturn(10); - when(artifact.getBranch()).thenReturn(branch); when(artifactData.getLocalId()).thenReturn(10); graph.addNode(artifact, false); @@ -123,7 +122,6 @@ public class GraphDataImplTest { @Test public void testAddNodeAttribute() throws OseeCoreException { when(container.getLocalId()).thenReturn(11); - when(container.getBranch()).thenReturn(branch); when(attributeData.getLocalId()).thenReturn(11); graph.addNode(container, false); @@ -138,11 +136,6 @@ public class GraphDataImplTest { when(container1.getLocalId()).thenReturn(30); when(container2.getLocalId()).thenReturn(31); - when(artifact1.getBranch()).thenReturn(branch); - when(artifact2.getBranch()).thenReturn(branch); - when(container1.getBranch()).thenReturn(branch); - when(container2.getBranch()).thenReturn(branch); - graph.addNode(artifact1, false); graph.addNode(artifact2, false); graph.addNode(container1, false); @@ -171,11 +164,6 @@ public class GraphDataImplTest { when(attributeData1.getLocalId()).thenReturn(30); when(attributeData2.getLocalId()).thenReturn(31); - when(artifact1.getBranch()).thenReturn(branch); - when(artifact2.getBranch()).thenReturn(branch); - when(container1.getBranch()).thenReturn(branch); - when(container2.getBranch()).thenReturn(branch); - graph.addNode(artifact1, false); graph.addNode(artifact2, false); graph.addNode(container1, false); @@ -204,11 +192,6 @@ public class GraphDataImplTest { when(attributeData1.getLocalId()).thenReturn(30); when(attributeData2.getLocalId()).thenReturn(31); - when(artifact1.getBranch()).thenReturn(branch); - when(artifact2.getBranch()).thenReturn(branch); - when(container1.getBranch()).thenReturn(branch); - when(container2.getBranch()).thenReturn(branch); - graph.addNode(artifact1, false); graph.addNode(artifact2, false); graph.addNode(container1, false); 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 index 8a38f713bc7..5c4760d76f0 100644 --- 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 @@ -34,7 +34,6 @@ import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.AttributeId; 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.enums.CoreRelationTypes; @@ -59,7 +58,7 @@ import org.mockito.stubbing.Answer; /** * Test Case for @{link ArtifactReadOnlyImpl} - * + * * @author Roberto E. Escobar */ public class ArtifactReadOnlyImplTest { @@ -70,15 +69,15 @@ public class ArtifactReadOnlyImplTest { @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 @@ -105,13 +104,13 @@ public class ArtifactReadOnlyImplTest { } @Test - public void testGetBranch() throws OseeCoreException { - when(proxiedObject.getBranch()).thenReturn(COMMON); + public void testGetBranchUuid() { + when(proxiedObject.getBranchUuid()).thenReturn(COMMON.getUuid()); - IOseeBranch actual = readOnly.getBranch(); + Long actual = readOnly.getBranchUuid(); - assertEquals(COMMON, actual); - verify(proxiedObject).getBranch(); + assertEquals(COMMON.getUuid(), actual); + verify(proxiedObject).getBranchUuid(); } @Test 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 df1e94d6e5c..687645703b2 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 @@ -29,7 +29,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.IRelationType; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; @@ -63,7 +62,7 @@ import org.mockito.stubbing.Answer; /** * Test Case for {@link RelationManagerFactory} - * + * * @author Megumi Telles */ public class RelationManagerTest { @@ -79,33 +78,32 @@ public class RelationManagerTest { @Mock private QueryFactory factory; @Mock private QueryModuleProvider provider; @Mock private ProxyProvider proxy; - + @Mock private RelationNodeLoader loader; @Mock private OrcsSession session; @Mock private GraphData graph; - @Mock private IOseeBranch branch; - + @Mock private RelationNode node1; @Mock private RelationNode node2; @Mock private RelationNode node3; @Mock private RelationNode node4; @Mock private RelationNode node5; @Mock private RelationNode node6; - + @Mock private RelationNodeAdjacencies adjancies1; @Mock private RelationNodeAdjacencies adjancies2; - + @Mock private Relation relation1; @Mock private Relation relation2; @Mock private Relation relation3; @Mock private Relation relation4; @Mock private IRelationType relationType; - + @Mock private RelationData data1; @Mock private RelationData data2; @Mock private RelationData data3; @Mock private RelationData data4; - + @Captor private ArgumentCaptor<Collection<Integer>> captor; // @formatter:on @@ -200,9 +198,8 @@ public class RelationManagerTest { when(types.getByUuid(DEFAULT_HIERARCHY.getGuid())).thenReturn(relationType); when(types.getDefaultOrderTypeGuid(DEFAULT_HIERARCHY)).thenReturn(LEXICOGRAPHICAL_DESC.getGuid()); when(types.getDefaultOrderTypeGuid(relationType)).thenReturn(LEXICOGRAPHICAL_DESC.getGuid()); - when(types.getAll()).thenReturn( - new ArrayList(Arrays.asList(CoreRelationTypes.Default_Hierarchical__Child, - CoreRelationTypes.Default_Hierarchical__Parent))); + when(types.getAll()).thenReturn(new ArrayList( + Arrays.asList(CoreRelationTypes.Default_Hierarchical__Child, CoreRelationTypes.Default_Hierarchical__Parent))); } private void setupAdjacencies(RelationNode node, Relation... relations) throws OseeCoreException { @@ -307,14 +304,14 @@ public class RelationManagerTest { @Test public void testIntroduce() throws OseeCoreException { - when( - types.isArtifactTypeAllowed(CoreRelationTypes.Default_Hierarchical__Parent, RelationSide.SIDE_A, - CoreArtifactTypes.SoftwareRequirement)).thenReturn(true); + Long branchId = 1L; + when(types.isArtifactTypeAllowed(CoreRelationTypes.Default_Hierarchical__Parent, RelationSide.SIDE_A, + CoreArtifactTypes.SoftwareRequirement)).thenReturn(true); when(types.getMultiplicity(CoreRelationTypes.Default_Hierarchical__Parent)).thenReturn( RelationTypeMultiplicity.ONE_TO_MANY); - when(relationFactory.introduce(branch, data1)).thenReturn(relation1); + when(relationFactory.introduce(branchId, data1)).thenReturn(relation1); - manager.introduce(session, branch, node2, node3); + manager.introduce(session, branchId, node2, node3); RelationNodeAdjacencies node2Adj = node2.getGraph().getAdjacencies(node2); RelationNodeAdjacencies node3Adj = node3.getGraph().getAdjacencies(node3); 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 1876a77cc01..c20915b2b5f 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 @@ -429,9 +429,6 @@ public class RelationManagerImplTest { @Test public void testRelateErrorCycle() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - thrown.expect(OseeArgumentException.class); thrown.expectMessage(String.format("Not valid to relate [%s] to itself", node1)); manager.relate(session, node1, typeAndSide1, node1); @@ -439,9 +436,6 @@ public class RelationManagerImplTest { @Test public void testRelateErrorMultiplicityInvalid() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - thrown.expect(OseeArgumentException.class); thrown.expectMessage(String.format("Not valid to relate [%s] to itself", node1)); manager.relate(session, node1, typeAndSide1, node1); @@ -449,9 +443,6 @@ public class RelationManagerImplTest { @Test public void testRelateErrorTypeInvalidNode1() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - OseeCoreException myException = new OseeCoreException("Test Type Exception"); doThrow(myException).when(validity).checkRelationTypeValid(TYPE_1, node1, SIDE_A); @@ -466,9 +457,6 @@ public class RelationManagerImplTest { @Test public void testRelateErrorTypeInvalidNode2() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - when(relationFactory.createRelation(node1, TYPE_1, node2)).thenReturn(relation1); when(container1.getResultSet(TYPE_1, INCLUDE_DELETED, node1, SIDE_A)).thenReturn(rSet1); when(rSet1.getOneOrNull()).thenReturn(relation1); @@ -487,9 +475,6 @@ public class RelationManagerImplTest { @Test public void testRelateErrorMultiplicityNode1() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - thrown.expect(OseeStateException.class); when(node1.getArtifactType()).thenReturn(artifactType1); @@ -505,9 +490,6 @@ public class RelationManagerImplTest { @Test public void testRelateErrorMultiplicityNode2() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - when(relationFactory.createRelation(node1, TYPE_1, node2)).thenReturn(relation1); when(container1.getResultSet(TYPE_1, INCLUDE_DELETED, node1, SIDE_A)).thenReturn(rSet1); when(rSet1.getOneOrNull()).thenReturn(relation1); @@ -536,9 +518,6 @@ public class RelationManagerImplTest { @Test public void testRelateWithSorting() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - when(container1.getRelation(node1, TYPE_1, node2, INCLUDE_DELETED)).thenReturn(null); when(container2.getRelation(node1, TYPE_1, node2, INCLUDE_DELETED)).thenReturn(null); @@ -564,9 +543,6 @@ public class RelationManagerImplTest { @Test public void testRelateNoSorting() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - when(container1.getRelation(node1, TYPE_1, node2, INCLUDE_DELETED)).thenReturn(null); when(container2.getRelation(node1, TYPE_1, node2, INCLUDE_DELETED)).thenReturn(null); @@ -595,9 +571,6 @@ public class RelationManagerImplTest { @Test public void testRelateWithSortingUserDefined() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - when(container1.getRelation(node1, TYPE_1, node2, INCLUDE_DELETED)).thenReturn(null); when(container2.getRelation(node1, TYPE_1, node2, INCLUDE_DELETED)).thenReturn(null); @@ -638,9 +611,6 @@ public class RelationManagerImplTest { @Test public void testAddChild() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - when(container1.getRelation(node1, DEFAULT_HIERARCHY, node2, INCLUDE_DELETED)).thenReturn(null); when(container2.getRelation(node1, DEFAULT_HIERARCHY, node2, INCLUDE_DELETED)).thenReturn(null); @@ -667,9 +637,6 @@ public class RelationManagerImplTest { @Test public void testAddChildren() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - when(container1.getRelation(node1, TYPE_1, node2, INCLUDE_DELETED)).thenReturn(null); when(container2.getRelation(node1, TYPE_1, node2, INCLUDE_DELETED)).thenReturn(null); @@ -696,9 +663,6 @@ public class RelationManagerImplTest { @Test public void testAddPreviouslyDeletedChild() throws OseeCoreException { - when(node1.getBranch()).thenReturn(COMMON); - when(node2.getBranch()).thenReturn(COMMON); - when(container1.getRelation(node1, DEFAULT_HIERARCHY, node2, INCLUDE_DELETED)).thenReturn(null); when(container2.getRelation(node1, DEFAULT_HIERARCHY, node2, INCLUDE_DELETED)).thenReturn(relation1); diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImplTest.java index 16d03c9cff2..4e921ae550d 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImplTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/relation/impl/RelationNodeLoaderImplTest.java @@ -45,12 +45,12 @@ public class RelationNodeLoaderImplTest { // @formatter:off @Mock private DataLoaderFactory dataLoaderFactory; @Mock private GraphBuilderFactory graphBuilderFactory; - + @Mock private OrcsSession session; @Mock private GraphData graph; @Mock private GraphBuilder builder; @Mock private DataLoader loader; - + @Mock private Artifact artifact; // @formatter:on @@ -66,7 +66,7 @@ public class RelationNodeLoaderImplTest { relationNode = new RelationNodeLoaderImpl(dataLoaderFactory, graphBuilderFactory); - when(graph.getBranch()).thenReturn(BRANCH); + when(graph.getBranchUuid()).thenReturn(BRANCH.getUuid()); when(graph.getTransaction()).thenReturn(TRANSACTION_ID); } @@ -74,13 +74,13 @@ public class RelationNodeLoaderImplTest { public void testLoadNodes() throws OseeCoreException { Iterable<Artifact> artifacts = Arrays.asList(artifact); - when(dataLoaderFactory.newDataLoaderFromIds(session, BRANCH, ids)).thenReturn(loader); + when(dataLoaderFactory.newDataLoaderFromIds(session, BRANCH.getUuid(), ids)).thenReturn(loader); when(graphBuilderFactory.createBuilderForGraph(graph)).thenReturn(builder); when(builder.getArtifacts()).thenReturn(artifacts); Iterable<RelationNode> actual = relationNode.loadNodes(session, graph, ids, LoadLevel.ALL); - verify(dataLoaderFactory).newDataLoaderFromIds(session, BRANCH, ids); + verify(dataLoaderFactory).newDataLoaderFromIds(session, BRANCH.getUuid(), ids); verify(graphBuilderFactory).createBuilderForGraph(graph); verify(loader).withLoadLevel(LoadLevel.ALL); 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 f0d1575ca45..bd4acc4ac67 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 @@ -73,7 +73,7 @@ import org.mockito.Mockito; /** * Test Case for {@link TransactionFactoryImpl} - * + * * @author Roberto E. Escobar */ public class TransactionBuilderImplTest { @@ -90,9 +90,9 @@ public class TransactionBuilderImplTest { @Mock private QueryFactory queryFactory; @Mock private QueryBuilder builder; @Mock private QueryModule query; - + @Mock private IOseeBranch branch; - + @Mock private ArtifactReadable expectedAuthor; @Mock private ArtifactReadable expectedDestination; @Mock private ArtifactReadable node1; @@ -103,11 +103,12 @@ public class TransactionBuilderImplTest { @Mock private AttributeReadable attrId; @SuppressWarnings("rawtypes") @Mock private Attribute attribute; - + @Mock private TxData txData; // @formatter:on private final IOseeBranch expectedBranch = CoreBranches.COMMON; + private final Long BRANCH_ID = expectedBranch.getUuid(); private TransactionBuilderImpl factory; private String guid; @@ -124,16 +125,6 @@ public class TransactionBuilderImplTest { } @Test - public void testGetBranch() { - when(factory.getBranch()).thenReturn(expectedBranch); - - IOseeBranch branch = factory.getBranch(); - - assertEquals(expectedBranch, branch); - verify(txData).getBranch(); - } - - @Test public void testGetAuthor() { when(factory.getAuthor()).thenReturn(expectedAuthor); @@ -175,40 +166,38 @@ public class TransactionBuilderImplTest { @Test public void testCopyArtifact() throws OseeCoreException { - when(expectedAuthor.getBranch()).thenReturn(expectedBranch); + when(expectedAuthor.getBranchUuid()).thenReturn(BRANCH_ID); factory.copyArtifact(expectedAuthor); - verify(txDataManager).copyArtifact(txData, expectedBranch, expectedAuthor); + verify(txDataManager).copyArtifact(txData, BRANCH_ID, expectedAuthor); } @Test public void testCopyArtifactWithList() throws OseeCoreException { Collection<? extends IAttributeType> attributesToDuplicate = Arrays.asList(Name, Annotation); - when(expectedAuthor.getBranch()).thenReturn(expectedBranch); + when(expectedAuthor.getBranchUuid()).thenReturn(BRANCH_ID); factory.copyArtifact(expectedAuthor, attributesToDuplicate); - verify(txDataManager).copyArtifact(txData, expectedBranch, expectedAuthor, attributesToDuplicate); + verify(txDataManager).copyArtifact(txData, BRANCH_ID, expectedAuthor, attributesToDuplicate); } @Test public void testIntroduceArtifactBranchException() throws OseeCoreException { - when(expectedAuthor.getBranch()).thenReturn(expectedBranch); - when(txData.getBranch()).thenReturn(expectedBranch); + when(expectedAuthor.getBranchUuid()).thenReturn(BRANCH_ID); + when(txData.getBranchId()).thenReturn(BRANCH_ID); thrown.expect(OseeArgumentException.class); - thrown.expectMessage("Source branch is same branch as transaction branch[" + expectedBranch + "]"); + thrown.expectMessage("Source branch is same branch as transaction branch[" + BRANCH_ID + "]"); factory.introduceArtifact(expectedBranch, expectedAuthor); } @Test public void testIntroduceArtifact() throws OseeCoreException { - when(expectedAuthor.getBranch()).thenReturn(expectedBranch); - when(txData.getBranch()).thenReturn(branch); - when(query.createQueryFactory(null)).thenReturn(queryFactory); - when(queryFactory.fromBranch(any(IOseeBranch.class))).thenReturn(builder); + when(queryFactory.fromBranch(any(Long.class))).thenReturn(builder); + when(queryFactory.fromBranch(branch)).thenReturn(builder); when(builder.includeDeletedArtifacts()).thenReturn(builder); when(builder.andGuid(anyString())).thenReturn(builder); @@ -218,7 +207,7 @@ public class TransactionBuilderImplTest { factory.introduceArtifact(expectedBranch, expectedAuthor); - verify(txDataManager).introduceArtifact(txData, expectedBranch, expectedAuthor, expectedAuthor); + verify(txDataManager).introduceArtifact(txData, BRANCH_ID, expectedAuthor, expectedAuthor); } @Test diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImplTest.java index 2a8ab5147c9..12636b7f967 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImplTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImplTest.java @@ -65,13 +65,6 @@ public class TransactionFactoryImplTest { } @Test - public void testNullBranch() throws OseeCoreException { - thrown.expect(OseeArgumentException.class); - thrown.expectMessage("branch cannot be null"); - factory.createTransaction(null, expectedAuthor, "my comment"); - } - - @Test public void testNullAuthor() throws OseeCoreException { thrown.expect(OseeArgumentException.class); thrown.expectMessage("author cannot be null"); @@ -96,14 +89,14 @@ public class TransactionFactoryImplTest { public void testCreateTransaction() throws OseeCoreException { String expectedComment = "This is my comment"; - when(txDataManager.createTxData(session, expectedBranch)).thenReturn(txData); + when(txDataManager.createTxData(session, expectedBranch.getUuid())).thenReturn(txData); when(txData.getAuthor()).thenReturn(expectedAuthor); - when(txData.getBranch()).thenReturn(expectedBranch); + when(txData.getBranchId()).thenReturn(expectedBranch.getUuid()); when(txData.getComment()).thenReturn(expectedComment); TransactionBuilder tx = factory.createTransaction(expectedBranch, expectedAuthor, expectedComment); assertNotNull(tx); - assertEquals(expectedBranch, tx.getBranch()); + assertEquals(expectedBranch.getUuid(), tx.getBranchId()); assertEquals(expectedAuthor, tx.getAuthor()); assertEquals(expectedComment, tx.getComment()); } 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 331e7b42768..2be71cd6d2c 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 @@ -48,7 +48,7 @@ import org.mockito.MockitoAnnotations; /** * Test Case for {@link TxCallableFactory} - * + * * @author Megumi Telles */ public class TxCallableFactoryTest { @@ -59,19 +59,19 @@ public class TxCallableFactoryTest { // @formatter:off @Mock private OrcsSession session; @Mock private Log logger; - + @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; @Mock private ArtifactReadable groupArtifact; - + @Captor private ArgumentCaptor<TransactionData> txData; // @formatter:on @@ -87,7 +87,6 @@ public class TxCallableFactoryTest { txFactory = new TxCallableFactory(logger, txDataStore, txManager); data = new TxData(session, graph); - when(graph.getBranch()).thenReturn(branch); } @SuppressWarnings({"unchecked", "rawtypes"}) @@ -129,7 +128,7 @@ public class TxCallableFactoryTest { assertFalse(data.isCommitInProgress()); TransactionData data = txData.getValue(); - assertEquals(branch, data.getBranch()); + assertEquals(branch.getUuid(), data.getBranchId()); assertEquals(userArtifact, data.getAuthor()); assertEquals("My Comment", data.getComment()); } 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 89d277b078c..55dd0947cb0 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 @@ -31,9 +31,7 @@ import java.util.Iterator; import java.util.List; import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.IAttributeType; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; -import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.OseeStateException; @@ -47,7 +45,6 @@ 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.ArtifactFactory; import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl; -import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl.BranchProvider; 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.Relation; @@ -72,7 +69,7 @@ import org.mockito.stubbing.Answer; /** * Test Case for {@link TxCallableFactory} - * + * * @author Megumi Telles */ public class TxDataManagerTest { @@ -82,16 +79,15 @@ public class TxDataManagerTest { // @formatter:off @Mock private OrcsSession session; - @Mock private IOseeBranch branch; - + @Mock private ExternalArtifactManager proxyManager; @Mock private ArtifactFactory artifactFactory; @Mock private QueryFactory queryFactory; @Mock private RelationManager relationManager; @Mock private TxDataLoader loader; - @Mock private BranchProvider provider; - + @Mock private TxData txData; + @Mock private GraphData graph; @Mock private ArtifactId artifactId1; @Mock private ArtifactId artifactId2; @@ -108,12 +104,15 @@ public class TxDataManagerTest { // @formatter:on private TxDataManager txDataManager; + private TxData txDataReal; private String guid; private final Collection<? extends IAttributeType> types = Arrays.asList(Name, Category); private String r1Guid; private String r2Guid; private String r3Guid; + private static final Long BRANCH_ID = 111L; + @Before public void init() throws OseeCoreException { MockitoAnnotations.initMocks(this); @@ -126,13 +125,12 @@ public class TxDataManagerTest { when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1); when(proxyManager.asExternalArtifact(session, artifact1)).thenReturn(readable1); - when(branch.getUuid()).thenReturn(111L); - when(provider.getBranch(111L)).thenReturn(branch); - when(txData.getSession()).thenReturn(session); - when(txData.getBranch()).thenReturn(branch); when(txData.getGraph()).thenReturn(graph); + when(graph.getBranchUuid()).thenReturn(BRANCH_ID); + txDataReal = new TxData(session, graph); + r1Guid = GUID.create(); r2Guid = GUID.create(); r3Guid = GUID.create(); @@ -145,37 +143,29 @@ public class TxDataManagerTest { 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(readable1.getBranchUuid()).thenReturn(BRANCH_ID); 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() throws OseeCoreException { - TxData newData = txDataManager.createTxData(session, branch); + TxData newData = txDataManager.createTxData(session, BRANCH_ID); assertNotNull(newData); } @Test public void testTxCommitSuccess() { - Iterable<Artifact> writeables = Arrays.asList(artifact1); List<Relation> empty = Collections.emptyList(); - when(txData.getGraph()).thenReturn(graph); - when(txData.getAllWriteables()).thenReturn(writeables); + txDataReal.add(artifact1); when(graph.getAdjacencies(artifact1)).thenReturn(adjacencies); when(adjacencies.getDirties()).thenReturn(empty); - txDataManager.txCommitSuccess(txData); - verify(txData).setTxState(TxState.COMMITTED); + txDataManager.txCommitSuccess(txDataReal); + assertEquals(TxState.COMMITTED, txDataReal.getTxState()); } @Test @@ -254,7 +244,6 @@ public class TxDataManagerTest { @Test public void testGetForWriteReadableButIsFromDifferentBranch() throws OseeCoreException { - when(readable1.getBranch()).thenReturn(CoreBranches.COMMON); when(txData.getWriteable(readable1)).thenReturn(null); when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1); when(artifactFactory.clone(session, artifact1)).thenReturn(artifact2); @@ -268,7 +257,7 @@ public class TxDataManagerTest { verify(txData).getWriteable(readable1); verify(proxyManager).asInternalArtifact(readable1); - verify(artifact1).getBranch(); + verify(artifact1).getBranchUuid(); assertEquals(artifact2, actual); } @@ -293,9 +282,6 @@ public class TxDataManagerTest { @Test public void testGetForWriteArtifactButIsFromDifferentBranch() throws OseeCoreException { - when(artifact1.getBranch()).thenReturn(CoreBranches.COMMON); - when(txData.getWriteable(readable1)).thenReturn(null); - ResultSet<Artifact> loaded = ResultSets.singleton(artifact2); when(loader.loadArtifacts(eq(session), eq(graph), anyCollectionOf(ArtifactId.class))).thenReturn(loaded); @@ -304,10 +290,9 @@ public class TxDataManagerTest { when(artifact2.getOrcsData()).thenReturn(data); when(data.isUseBackingData()).thenReturn(false); - Artifact actual = txDataManager.getForWrite(txData, artifact1); + Artifact actual = txDataManager.getForWrite(txDataReal, artifact1); - verify(txData).getWriteable(artifact1); - verify(artifact1).getBranch(); + verify(artifact1).getBranchUuid(); verify(loader).loadArtifacts(eq(session), eq(graph), idCaptor.capture()); assertEquals(artifact1, idCaptor.getValue().iterator().next()); @@ -387,9 +372,7 @@ public class TxDataManagerTest { @Test public void testCreateArtifact() throws OseeCoreException { - when(txData.isCommitInProgress()).thenReturn(false); - when(txData.getTxState()).thenReturn(TxState.NEW_TX); - when(artifactFactory.createArtifact(session, branch, DirectSoftwareRequirement, guid)).thenReturn(artifact1); + when(artifactFactory.createArtifact(session, BRANCH_ID, DirectSoftwareRequirement, guid)).thenReturn(artifact1); when(proxyManager.asExternalArtifact(session, artifact1)).thenReturn(readable1); ArtifactData data = Mockito.mock(ArtifactData.class); @@ -397,18 +380,17 @@ public class TxDataManagerTest { when(data.isUseBackingData()).thenReturn(false); ArtifactReadable actual = - txDataManager.createArtifact(txData, DirectSoftwareRequirement, "Direct SW requirement", guid); + txDataManager.createArtifact(txDataReal, DirectSoftwareRequirement, "Direct SW requirement", guid); - verify(artifactFactory).createArtifact(session, branch, DirectSoftwareRequirement, guid); + verify(artifactFactory).createArtifact(session, BRANCH_ID, DirectSoftwareRequirement, guid); assertEquals(readable1, actual); } @Test public void testCopyExisitingArtifact() throws OseeCoreException { - when(txData.isCommitInProgress()).thenReturn(false); - when(txData.getTxState()).thenReturn(TxState.NEW_TX); - when(txData.getWriteable(readable1)).thenReturn(artifact1); - when(artifactFactory.copyArtifact(session, artifact1, types, branch)).thenReturn(artifact2); + txDataReal.add(artifact1); + + when(artifactFactory.copyArtifact(session, artifact1, types, BRANCH_ID)).thenReturn(artifact2); when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2); ArtifactData data = Mockito.mock(ArtifactData.class); @@ -416,10 +398,9 @@ public class TxDataManagerTest { when(artifact2.getOrcsData()).thenReturn(data); when(data.isUseBackingData()).thenReturn(false); - ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, readable1); + ArtifactReadable actual = txDataManager.copyArtifact(txDataReal, BRANCH_ID, readable1); - verify(txData).getWriteable(readable1); - verify(artifactFactory).copyArtifact(session, artifact1, types, branch); + verify(artifactFactory).copyArtifact(session, artifact1, types, BRANCH_ID); verify(proxyManager).asExternalArtifact(session, artifact2); assertEquals(readable2, actual); @@ -427,10 +408,6 @@ public class TxDataManagerTest { @Test public void testCopyReadableArtifact() throws OseeCoreException { - when(txData.isCommitInProgress()).thenReturn(false); - when(txData.getTxState()).thenReturn(TxState.NEW_TX); - when(readable1.getBranch()).thenReturn(branch); - when(txData.getWriteable(readable1)).thenReturn(null); when(proxyManager.asInternalArtifact(readable1)).thenReturn(artifact1); ArtifactData data = Mockito.mock(ArtifactData.class); @@ -438,14 +415,13 @@ public class TxDataManagerTest { when(artifact2.getOrcsData()).thenReturn(data); when(data.isUseBackingData()).thenReturn(false); - when(artifactFactory.copyArtifact(session, artifact1, types, branch)).thenReturn(artifact2); + when(artifactFactory.copyArtifact(session, artifact1, types, BRANCH_ID)).thenReturn(artifact2); when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2); - ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, readable1); + ArtifactReadable actual = txDataManager.copyArtifact(txDataReal, BRANCH_ID, readable1); - verify(txData).getWriteable(readable1); verify(proxyManager).asInternalArtifact(readable1); - verify(artifactFactory).copyArtifact(session, artifact1, types, branch); + verify(artifactFactory).copyArtifact(session, artifact1, types, BRANCH_ID); verify(proxyManager).asExternalArtifact(session, artifact2); assertEquals(readable2, actual); @@ -458,9 +434,9 @@ public class TxDataManagerTest { ArtifactData data = Mockito.mock(ArtifactData.class); VersionData version = Mockito.mock(VersionData.class); when(data.getVersion()).thenReturn(version); - when(version.getBranchId()).thenReturn(111L); + when(version.getBranchId()).thenReturn(BRANCH_ID); - Artifact sourceArtifact = Mockito.spy(new ArtifactImpl(null, data, null, provider)); + Artifact sourceArtifact = Mockito.spy(new ArtifactImpl(null, data, null)); when(data.getGuid()).thenReturn(guid); @@ -470,27 +446,22 @@ public class TxDataManagerTest { when(artifact2.getOrcsData()).thenReturn(data); when(data.isUseBackingData()).thenReturn(false); - when(txData.isCommitInProgress()).thenReturn(false); - when(txData.getTxState()).thenReturn(TxState.NEW_TX); - when(txData.getWriteable(sourceArtifact)).thenReturn(null); - when(artifactFactory.copyArtifact(session, sourceArtifact, copyTypes, branch)).thenReturn(artifact2); + when(artifactFactory.copyArtifact(session, sourceArtifact, copyTypes, BRANCH_ID)).thenReturn(artifact2); when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2); - ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, sourceArtifact); + ArtifactReadable actual = txDataManager.copyArtifact(txDataReal, BRANCH_ID, sourceArtifact); - verify(txData).getWriteable(sourceArtifact); - verify(artifactFactory).copyArtifact(session, sourceArtifact, copyTypes, branch); + verify(artifactFactory).copyArtifact(session, sourceArtifact, copyTypes, BRANCH_ID); assertEquals(readable2, actual); } @Test public void testCopyArtifactId() throws OseeCoreException { - when(txData.isCommitInProgress()).thenReturn(false); - when(txData.getTxState()).thenReturn(TxState.NEW_TX); - when(txData.getWriteable(artifactId1)).thenReturn(artifact1); + txDataReal.add(artifact1); + when(artifact1.getExistingAttributeTypes()).thenAnswer(answerValue(types)); - when(artifactFactory.copyArtifact(session, artifact1, types, branch)).thenReturn(artifact2); + when(artifactFactory.copyArtifact(session, artifact1, types, BRANCH_ID)).thenReturn(artifact2); when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2); ArtifactData data = Mockito.mock(ArtifactData.class); @@ -498,10 +469,9 @@ public class TxDataManagerTest { when(artifact2.getOrcsData()).thenReturn(data); when(data.isUseBackingData()).thenReturn(false); - ArtifactReadable actual = txDataManager.copyArtifact(txData, branch, artifactId1); + ArtifactReadable actual = txDataManager.copyArtifact(txDataReal, BRANCH_ID, artifactId1); - verify(txData).getWriteable(artifactId1); - verify(artifactFactory).copyArtifact(session, artifact1, types, branch); + verify(artifactFactory).copyArtifact(session, artifact1, types, BRANCH_ID); verify(proxyManager).asExternalArtifact(session, artifact2); assertEquals(readable2, actual); @@ -509,13 +479,10 @@ public class TxDataManagerTest { @Test public void testIntroduceArtifact() throws OseeCoreException { - when(txData.isCommitInProgress()).thenReturn(false); - when(txData.getTxState()).thenReturn(TxState.NEW_TX); - when(txData.getBranch()).thenReturn(branch); - ResultSet<Artifact> loaded = ResultSets.singleton(artifact1); - when(loader.loadArtifacts(eq(session), eq(COMMON), anyCollectionOf(ArtifactId.class))).thenReturn(loaded); - when(artifactFactory.introduceArtifact(session, artifact1, artifact1, branch)).thenReturn(artifact2); + when(loader.loadArtifacts(eq(session), eq(COMMON.getUuid()), anyCollectionOf(ArtifactId.class))).thenReturn( + loaded); + when(artifactFactory.introduceArtifact(session, artifact1, artifact1, BRANCH_ID)).thenReturn(artifact2); when(proxyManager.asExternalArtifact(session, artifact2)).thenReturn(readable2); when(artifact1.getGraph()).thenReturn(graph); when(graph.getAdjacencies(artifact1)).thenReturn(adjacencies); @@ -525,9 +492,9 @@ public class TxDataManagerTest { when(artifact2.getOrcsData()).thenReturn(data); when(data.isUseBackingData()).thenReturn(false); - ArtifactReadable actual = txDataManager.introduceArtifact(txData, COMMON, readable1, readable2); + ArtifactReadable actual = txDataManager.introduceArtifact(txDataReal, COMMON.getUuid(), readable1, readable2); - verify(artifactFactory).introduceArtifact(session, artifact1, artifact1, branch); + verify(artifactFactory).introduceArtifact(session, artifact1, artifact1, BRANCH_ID); verify(proxyManager).asExternalArtifact(session, artifact1); assertEquals(readable1, actual); } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataFactory.java index c28e510c0a7..4b174231676 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/ArtifactDataFactory.java @@ -11,7 +11,6 @@ package org.eclipse.osee.orcs.core.ds; import org.eclipse.osee.framework.core.data.IArtifactType; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; /** @@ -19,14 +18,14 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; */ public interface ArtifactDataFactory { - ArtifactData create(IOseeBranch branch, IArtifactType artifactType, String guid) throws OseeCoreException; + ArtifactData create(Long branch, IArtifactType artifactType, String guid) throws OseeCoreException; - ArtifactData create(IOseeBranch branch, IArtifactType artifactType, String guid, long uuid) throws OseeCoreException; + ArtifactData create(Long branch, IArtifactType artifactType, String guid, long artifactId) throws OseeCoreException; - ArtifactData copy(IOseeBranch destination, ArtifactData source) throws OseeCoreException; + ArtifactData copy(Long destination, ArtifactData source) throws OseeCoreException; ArtifactData clone(ArtifactData source) throws OseeCoreException; - ArtifactData introduce(IOseeBranch destination, ArtifactData source) throws OseeCoreException; + ArtifactData introduce(Long destination, ArtifactData source) throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java index 38022538ba3..9fe5ec3eb05 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/AttributeDataFactory.java @@ -11,7 +11,6 @@ package org.eclipse.osee.orcs.core.ds; import org.eclipse.osee.framework.core.data.IAttributeType; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; /** @@ -21,10 +20,10 @@ public interface AttributeDataFactory { AttributeData create(ArtifactData parent, IAttributeType attributeType) throws OseeCoreException; - AttributeData copy(IOseeBranch destination, AttributeData orcsData) throws OseeCoreException; + AttributeData copy(Long destination, AttributeData orcsData) throws OseeCoreException; AttributeData clone(AttributeData source) throws OseeCoreException; - AttributeData introduce(IOseeBranch destination, AttributeData source) throws OseeCoreException; + AttributeData introduce(Long destination, AttributeData source) throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataLoaderFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataLoaderFactory.java index ce9107d5835..4c2bf96fd05 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataLoaderFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DataLoaderFactory.java @@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.core.ds; import java.util.Collection; import org.eclipse.osee.executor.admin.HasCancellation; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.OrcsSession; @@ -25,12 +24,12 @@ public interface DataLoaderFactory { DataLoader newDataLoader(QueryContext queryContext) throws OseeCoreException; - DataLoader newDataLoaderFromIds(OrcsSession session, IOseeBranch branch, Integer... artifactIds) throws OseeCoreException; + DataLoader newDataLoaderFromIds(OrcsSession session, Long branchId, Integer... artifactIds) throws OseeCoreException; - DataLoader newDataLoaderFromIds(OrcsSession session, IOseeBranch branch, Collection<Integer> artifactIds) throws OseeCoreException; + DataLoader newDataLoaderFromIds(OrcsSession session, Long branchId, Collection<Integer> artifactIds) throws OseeCoreException; - DataLoader newDataLoaderFromGuids(OrcsSession session, IOseeBranch branch, String... artifactGuids) throws OseeCoreException; + DataLoader newDataLoaderFromGuids(OrcsSession session, Long branchId, String... artifactGuids) throws OseeCoreException; - DataLoader newDataLoaderFromGuids(OrcsSession session, IOseeBranch branch, Collection<String> artifactGuids) throws OseeCoreException; + DataLoader newDataLoaderFromGuids(OrcsSession session, Long branchId, Collection<String> artifactGuids) throws OseeCoreException; -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDescription.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDescription.java index ec1e6b17543..60e0d246cd5 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDescription.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/LoadDescription.java @@ -10,21 +10,18 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.ds; -import org.eclipse.osee.framework.core.data.IOseeBranch; -import org.eclipse.osee.orcs.data.HasBranch; import org.eclipse.osee.orcs.data.HasSession; import org.eclipse.osee.orcs.data.HasTransaction; /** * @author Roberto E. Escobar */ -public interface LoadDescription extends HasOptions, HasSession, HasBranch, HasTransaction { - - @Override - IOseeBranch getBranch(); +public interface LoadDescription extends HasOptions, HasSession, HasTransaction { boolean isMultiBranch(); + Long getBranchId(); + ResultObjectDescription getObjectDescription(); } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java index 82289ef5b47..cc86fb2354f 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/RelationDataFactory.java @@ -11,7 +11,6 @@ package org.eclipse.osee.orcs.core.ds; import org.eclipse.osee.framework.core.data.HasLocalId; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.IRelationType; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -20,9 +19,9 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; */ public interface RelationDataFactory { - RelationData createRelationData(IRelationType relationType, IOseeBranch branch, HasLocalId<Integer> aArt, HasLocalId<Integer> bArt, String rationale) throws OseeCoreException; + RelationData createRelationData(IRelationType relationType, Long branch, HasLocalId<Integer> aArt, HasLocalId<Integer> bArt, String rationale) throws OseeCoreException; RelationData clone(RelationData source) throws OseeCoreException; - RelationData introduce(IOseeBranch branch, RelationData source) throws OseeCoreException; + RelationData introduce(Long branch, RelationData source) throws OseeCoreException; } 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 dd653107b4d..6d99e7e0243 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,12 +10,11 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.ds; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.orcs.data.ArtifactReadable; public interface TransactionData extends HasOrcsChangeSet { - IOseeBranch getBranch(); + Long getBranchId(); ArtifactReadable getAuthor(); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/VersionData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/VersionData.java index 39d947d2e3d..03a8c715564 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/VersionData.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/VersionData.java @@ -27,9 +27,9 @@ public interface VersionData extends Cloneable { void setStripeId(int stripeId); - long getBranchId(); + Long getBranchId(); - void setBranchId(long branchUuid); + void setBranchId(Long branchUuid); boolean isInStorage(); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaBranch.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaBranch.java index b0b3ee856ff..5f59b53f5ce 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaBranch.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaBranch.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.ds.criteria; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.orcs.core.ds.Criteria; @@ -22,31 +21,25 @@ import org.eclipse.osee.orcs.data.HasBranch; */ public class CriteriaBranch extends Criteria implements HasBranch, BranchCriteria { - private final IOseeBranch branch; + private final Long branchId; - public CriteriaBranch(IOseeBranch branch) { - super(); - this.branch = branch; + public CriteriaBranch(Long branchId) { + this.branchId = branchId; } @Override public void checkValid(Options options) throws OseeCoreException { - Conditions.checkNotNull(branch, "branch"); + Conditions.checkNotNull(branchId, "branch"); } @Override - public IOseeBranch getBranch() { - return branch; - } - - @Override - public long getBranchUuid() { - return branch.getUuid(); + public Long getBranchUuid() { + return branchId; } @Override public String toString() { - return "CriteriaBranch [branch=" + branch + "]"; + return "CriteriaBranch [branch=" + branchId + "]"; } }
\ No newline at end of file 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 5cafe273e9b..583867e0a03 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 @@ -35,8 +35,6 @@ import org.eclipse.osee.orcs.core.ds.DataModule; import org.eclipse.osee.orcs.core.ds.OrcsDataStore; 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.ArtifactFactory.BranchProviderFactory; -import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl.BranchProvider; 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; @@ -69,7 +67,6 @@ import org.eclipse.osee.orcs.core.internal.transaction.TxDataManager.TxDataLoade import org.eclipse.osee.orcs.core.internal.types.BranchHierarchyProvider; import org.eclipse.osee.orcs.core.internal.types.OrcsTypesModule; import org.eclipse.osee.orcs.data.ArtifactReadable; -import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.search.BranchQuery; import org.eclipse.osee.orcs.search.QueryFactory; import org.eclipse.osee.orcs.search.QueryIndexer; @@ -161,8 +158,7 @@ public class OrcsApiImpl implements OrcsApi { new AttributeFactory(resolver, module.getDataFactory(), orcsTypes.getAttributeTypes()); ArtifactFactory artifactFactory = - new ArtifactFactory(module.getDataFactory(), attributeFactory, orcsTypes.getArtifactTypes(), - new BranchProviderFactoryImpl()); + new ArtifactFactory(module.getDataFactory(), attributeFactory, orcsTypes.getArtifactTypes()); RelationFactory relationFactory = new RelationFactory(orcsTypes.getRelationTypes(), module.getDataFactory()); @@ -189,14 +185,13 @@ public class OrcsApiImpl implements OrcsApi { }; RelationNodeLoader nodeLoader = new RelationNodeLoaderImpl(module.getDataLoaderFactory(), graphBuilderFactory); - RelationManager relationManager = - RelationManagerFactory.createRelationManager(logger, orcsTypes.getRelationTypes(), relationFactory, - nodeLoader, queryModuleProvider, proxyProvider); + RelationManager relationManager = RelationManagerFactory.createRelationManager(logger, + orcsTypes.getRelationTypes(), relationFactory, nodeLoader, queryModuleProvider, proxyProvider); GraphProvider graphProvider = new GraphProvider() { @Override - public GraphData getGraph(OrcsSession session, IOseeBranch branch, int transactionId) throws OseeCoreException { + public GraphData getGraph(OrcsSession session, Long branch, int transactionId) throws OseeCoreException { return graphFactory.createGraph(session, branch, transactionId); } }; @@ -206,21 +201,19 @@ public class OrcsApiImpl implements OrcsApi { TransactionProvider txProvider = new TransactionProvider() { @Override - public int getHeadTransaction(OrcsSession session, IOseeBranch branch) { + public int getHeadTransaction(OrcsSession session, Long branch) { QueryFactory queryFactory = queryModule.createQueryFactory(session); return queryFactory.transactionQuery().andIsHead(branch).getResultsAsIds().getExactlyOne(); } }; - TxDataLoader txDataLoader = - new TxDataLoaderImpl(module.getDataLoaderFactory(), graphFactory, graphBuilderFactory, graphProvider, - txProvider); + TxDataLoader txDataLoader = new TxDataLoaderImpl(module.getDataLoaderFactory(), graphFactory, graphBuilderFactory, + graphProvider, txProvider); txDataManager = new TxDataManager(proxyManager, artifactFactory, relationManager, txDataLoader); txCallableFactory = new TxCallableFactory(logger, module.getTxDataStore(), txDataManager); - queryModule = - new QueryModule(logger, module.getQueryEngine(), graphBuilderFactory, graphProvider, - orcsTypes.getArtifactTypes(), orcsTypes.getAttributeTypes(), proxyManager); + queryModule = 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()); @@ -260,7 +253,8 @@ public class OrcsApiImpl implements OrcsApi { @SuppressWarnings("unchecked") @Override public ArtifactReadable call() throws Exception { - return getQueryFactory().fromBranch(CoreBranches.COMMON).andIds(SystemUser.OseeSystem).getResults().getExactlyOne(); + return getQueryFactory().fromBranch(CoreBranches.COMMON).andIds( + SystemUser.OseeSystem).getResults().getExactlyOne(); } }; @@ -268,8 +262,7 @@ public class OrcsApiImpl implements OrcsApi { } }; QueryFactory queryFactory = getQueryFactory(); - return new OrcsBranchImpl(logger, session, module.getBranchDataStore(), queryFactory, systemUser, - getOrcsTypes()); + return new OrcsBranchImpl(logger, session, module.getBranchDataStore(), queryFactory, systemUser, getOrcsTypes()); } @Override @@ -318,29 +311,6 @@ public class OrcsApiImpl implements OrcsApi { return new OrcsSessionImpl(sessionId); } - private class BranchProviderFactoryImpl implements BranchProviderFactory { - - @Override - public BranchProvider createBranchProvider(final OrcsSession session) { - BranchProvider provider = new BranchProvider() { - - BranchReadable cached = null; - - @Override - public BranchReadable getBranch(Long branchUuid) { - if (cached == null || !cached.getUuid().equals(branchUuid)) { - BranchQuery query = queryModule.createQueryFactory(session).branchQuery(); - cached = query.andUuids(branchUuid).getResults().getExactlyOne(); - } - return cached; - } - - }; - return provider; - } - - } - @Override public ScriptEngine getScriptEngine() { return manager.getEngineByName(ScriptEngines.ORCS_SCRIPT_ENGINE_ID); 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 cb37c782f4e..45ca55d13ca 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 @@ -15,7 +15,6 @@ import java.util.HashSet; 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.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.exception.AttributeDoesNotExist; @@ -24,7 +23,6 @@ import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.core.ds.ArtifactData; import org.eclipse.osee.orcs.core.ds.ArtifactDataFactory; import org.eclipse.osee.orcs.core.ds.AttributeData; -import org.eclipse.osee.orcs.core.internal.artifact.ArtifactImpl.BranchProvider; import org.eclipse.osee.orcs.core.internal.attribute.Attribute; import org.eclipse.osee.orcs.core.internal.attribute.AttributeFactory; import org.eclipse.osee.orcs.data.ArtifactTypes; @@ -38,43 +36,36 @@ public class ArtifactFactory { private final ArtifactDataFactory factory; private final AttributeFactory attributeFactory; private final ArtifactTypes artifactTypeCache; - private final BranchProviderFactory branchProviderFactory; - public static interface BranchProviderFactory { - BranchProvider createBranchProvider(OrcsSession session); - } - - public ArtifactFactory(ArtifactDataFactory factory, AttributeFactory attributeFactory, ArtifactTypes artifactTypeCache, BranchProviderFactory branchProviderFactory) { + public ArtifactFactory(ArtifactDataFactory factory, AttributeFactory attributeFactory, ArtifactTypes artifactTypeCache) { this.factory = factory; this.attributeFactory = attributeFactory; this.artifactTypeCache = artifactTypeCache; - this.branchProviderFactory = branchProviderFactory; } public Artifact createArtifact(final OrcsSession session, ArtifactData artifactData) throws OseeCoreException { - BranchProvider branchProvider = branchProviderFactory.createBranchProvider(session); - return new ArtifactImpl(artifactTypeCache, artifactData, attributeFactory, branchProvider); + return new ArtifactImpl(artifactTypeCache, artifactData, attributeFactory); } - public Artifact createArtifact(OrcsSession session, IOseeBranch branch, IArtifactType artifactType, String guid) throws OseeCoreException { + public Artifact createArtifact(OrcsSession session, Long branch, IArtifactType artifactType, String guid) throws OseeCoreException { ArtifactData artifactData = factory.create(branch, artifactType, guid); Artifact artifact = createArtifact(session, artifactData); artifact.setLoaded(true); return artifact; } - public Artifact createArtifact(OrcsSession session, IOseeBranch branch, IArtifactType artifactType, String guid, long uuid) throws OseeCoreException { + public Artifact createArtifact(OrcsSession session, Long branch, IArtifactType artifactType, String guid, long uuid) throws OseeCoreException { ArtifactData artifactData = factory.create(branch, artifactType, guid, uuid); Artifact artifact = createArtifact(session, artifactData); artifact.setLoaded(true); return artifact; } - public Artifact copyArtifact(OrcsSession session, Artifact source, Collection<? extends IAttributeType> types, IOseeBranch ontoBranch) throws OseeCoreException { + public Artifact copyArtifact(OrcsSession session, Artifact source, Collection<? extends IAttributeType> types, Long ontoBranch) throws OseeCoreException { ArtifactData artifactData = factory.copy(ontoBranch, source.getOrcsData()); Artifact copy = createArtifact(session, artifactData); - Collection<? extends IAttributeType> typeToCopy = getAllowedTypes(copy, types); - for (IAttributeType attributeType : typeToCopy) { + Collection<? extends IAttributeType> typesToCopy = getAllowedTypes(copy, types); + for (IAttributeType attributeType : typesToCopy) { for (AttributeReadable<?> attributeSource : source.getAttributes(attributeType)) { AttributeData data = getAttributeData(attributeSource); attributeFactory.copyAttribute(data, ontoBranch, copy); @@ -84,14 +75,14 @@ public class ArtifactFactory { return copy; } - public Artifact introduceArtifact(OrcsSession session, Artifact source, Artifact destination, IOseeBranch ontoBranch) throws OseeCoreException { + public Artifact introduceArtifact(OrcsSession session, Artifact source, Artifact destination, Long ontoBranch) throws OseeCoreException { destination = processIntroduceArtifact(session, source, destination, ontoBranch); processIntroduceAttributes(source, destination, ontoBranch); destination.setLoaded(true); return destination; } - private void processIntroduceAttributes(Artifact source, Artifact destination, IOseeBranch ontoBranch) { + private void processIntroduceAttributes(Artifact source, Artifact destination, Long ontoBranch) { Collection<Attribute<Object>> introduceAttributes = source.getAttributes(DeletionFlag.INCLUDE_DELETED); removeAttributes(source, destination); //introduce the existing attributes @@ -102,7 +93,7 @@ public class ArtifactFactory { } } - private Artifact processIntroduceArtifact(OrcsSession session, Artifact source, Artifact destination, IOseeBranch ontoBranch) { + private Artifact processIntroduceArtifact(OrcsSession session, Artifact source, Artifact destination, Long ontoBranch) { ArtifactData artifactData = factory.introduce(ontoBranch, source.getOrcsData()); destination.setOrcsData(artifactData); return destination; @@ -113,7 +104,7 @@ public class ArtifactFactory { try { introduce.getAttributeById(destAttribute); } catch (AttributeDoesNotExist ex) { - // remove new attributes + // remove new attributes destAttribute.delete(); } } 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 77e3e418336..e01fcbeee07 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 @@ -14,7 +14,7 @@ import java.util.Collection; import org.eclipse.osee.framework.core.data.ArtifactId; 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.TokenFactory; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.EditState; import org.eclipse.osee.framework.core.enums.ModificationType; @@ -36,17 +36,11 @@ public class ArtifactImpl extends AttributeManagerImpl implements Artifact { private EditState objectEditState; private ArtifactData artifactData; private GraphData graph; - private final BranchProvider branchProvider; - public static interface BranchProvider { - IOseeBranch getBranch(Long branchUuid); - } - - public ArtifactImpl(ArtifactTypes artifactTypeCache, ArtifactData artifactData, AttributeFactory attributeFactory, BranchProvider branchProvider) { + public ArtifactImpl(ArtifactTypes artifactTypeCache, ArtifactData artifactData, AttributeFactory attributeFactory) { super(artifactData.getGuid(), attributeFactory); this.artifactTypeCache = artifactTypeCache; this.artifactData = artifactData; - this.branchProvider = branchProvider; this.objectEditState = EditState.NO_CHANGE; } @@ -95,12 +89,7 @@ public class ArtifactImpl extends AttributeManagerImpl implements Artifact { } @Override - public IOseeBranch getBranch() throws OseeCoreException { - return branchProvider.getBranch(getBranchUuid()); - } - - @Override - public long getBranchUuid() { + public Long getBranchUuid() { return artifactData.getVersion().getBranchId(); } @@ -157,12 +146,13 @@ public class ArtifactImpl extends AttributeManagerImpl implements Artifact { @Override public boolean isAttributeTypeValid(IAttributeType attributeType) throws OseeCoreException { - return artifactTypeCache.isValidAttributeType(getArtifactType(), getBranch(), attributeType); + return artifactTypeCache.isValidAttributeType(getArtifactType(), TokenFactory.createBranch(getBranchUuid(), ""), + attributeType); } @Override public Collection<? extends IAttributeType> getValidAttributeTypes() throws OseeCoreException { - return artifactTypeCache.getAttributeTypes(getArtifactType(), getBranch()); + return artifactTypeCache.getAttributeTypes(getArtifactType(), TokenFactory.createBranch(getBranchUuid(), "")); } @Override @@ -222,7 +212,8 @@ 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()); + return String.format("artifact [type=[%s] guid=[%s] branch=[%s]]", getArtifactType(), getGuid(), + getBranchUuid()); } catch (OseeCoreException ex) { return Lib.exceptionToString(ex); } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java index 0d477c17c75..9357e931c79 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/attribute/AttributeFactory.java @@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.core.internal.attribute; import java.lang.ref.Reference; import java.lang.ref.WeakReference; import org.eclipse.osee.framework.core.data.IAttributeType; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.DeletionFlag; import org.eclipse.osee.framework.core.exception.AttributeDoesNotExist; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -67,10 +66,9 @@ public class AttributeFactory { return attribute; } - public <T> Attribute<T> copyAttribute(AttributeData source, IOseeBranch ontoBranch, AttributeContainer destinationContainer) throws OseeCoreException { + public <T> Attribute<T> copyAttribute(AttributeData source, Long ontoBranch, AttributeContainer destinationContainer) throws OseeCoreException { AttributeData attributeData = dataFactory.copy(ontoBranch, source); - Attribute<T> destinationAttribute = createAttribute(destinationContainer, attributeData, true, false); - return destinationAttribute; + return createAttribute(destinationContainer, attributeData, true, false); } public <T> Attribute<T> cloneAttribute(AttributeData source, AttributeContainer destinationContainer) throws OseeCoreException { @@ -79,7 +77,7 @@ public class AttributeFactory { return destinationAttribute; } - public <T> Attribute<Object> introduceAttribute(AttributeData source, IOseeBranch ontoBranch, AttributeManager destination) throws OseeCoreException { + public <T> Attribute<Object> introduceAttribute(AttributeData source, Long ontoBranch, AttributeManager destination) throws OseeCoreException { AttributeData attributeData = dataFactory.introduce(ontoBranch, source); // In order to reflect attributes they must exist in the data store Attribute<Object> destinationAttribute = null; diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphData.java index 6374c9d0fb9..8dd8a3e0601 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphData.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphData.java @@ -11,7 +11,6 @@ package org.eclipse.osee.orcs.core.internal.graph; import org.eclipse.osee.framework.core.data.HasLocalId; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.data.HasBranch; @@ -22,9 +21,6 @@ import org.eclipse.osee.orcs.data.HasTransaction; */ public interface GraphData extends HasBranch, HasTransaction { - @Override - IOseeBranch getBranch(); - <T extends GraphNode> T getNode(HasLocalId<Integer> data); <T extends GraphNode> T getNode(Integer id); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphFactory.java index bee52e3547c..c08210cd678 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphFactory.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.internal.graph; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.OrcsSession; @@ -19,6 +18,6 @@ import org.eclipse.osee.orcs.OrcsSession; */ public interface GraphFactory { - GraphData createGraph(OrcsSession session, IOseeBranch branch, int transactionId) throws OseeCoreException; + GraphData createGraph(OrcsSession session, Long branch, int transactionId) throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphProvider.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphProvider.java index d3185f6cb17..72932e71902 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphProvider.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphProvider.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.internal.graph; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.OrcsSession; @@ -19,6 +18,6 @@ import org.eclipse.osee.orcs.OrcsSession; */ public interface GraphProvider { - GraphData getGraph(OrcsSession session, IOseeBranch branch, int transactionId) throws OseeCoreException; + GraphData getGraph(OrcsSession session, Long branch, int transactionId) throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphUtil.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphUtil.java index 4c106c03f9b..9459815b38c 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphUtil.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/GraphUtil.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.internal.graph; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.orcs.OrcsSession; @@ -29,10 +28,10 @@ public final class GraphUtil { return new GraphProvider() { @Override - public GraphData getGraph(OrcsSession session, IOseeBranch branch, int transactionId) throws OseeCoreException { - Conditions.checkNotNull(branch, "branch", "Invalid branch - can't provide graph"); - Conditions.checkExpressionFailOnTrue(!Objects.equal(graph.getBranch(), branch), - "Invalid branch - Graph's branch[%s] does not equals requested branch[%s]", graph.getBranch(), branch); + public GraphData getGraph(OrcsSession session, Long branchId, int transactionId) throws OseeCoreException { + Conditions.checkExpressionFailOnTrue(!Objects.equal(graph.getBranchUuid(), branchId), + "Invalid branch - Graph's branch[%s] does not equals requested branch[%s]", graph.getBranchUuid(), + branchId); Conditions.checkExpressionFailOnTrue(!Objects.equal(graph.getTransaction(), transactionId), "Invalid transactionId - Graph's transactionId[%s] does not equals requested transactionId[%s]", graph.getTransaction(), transactionId); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphBuilderImpl.java index eb137563da0..7c9795021ef 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphBuilderImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphBuilderImpl.java @@ -67,7 +67,7 @@ public class GraphBuilderImpl extends LoadDataHandlerAdapter implements GraphBui @Override public void onLoadDescription(LoadDescription data) throws OseeCoreException { - graph = graphProvider.getGraph(data.getSession(), data.getBranch(), data.getTransaction()); + graph = graphProvider.getGraph(data.getSession(), data.getBranchId(), data.getTransaction()); Conditions.checkNotNull(graph, "graph"); }; diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphDataImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphDataImpl.java index c0068b6ce4a..e9877eab907 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphDataImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphDataImpl.java @@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.core.internal.graph.impl; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.eclipse.osee.framework.core.data.HasLocalId; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.OrcsSession; @@ -29,23 +28,18 @@ public class GraphDataImpl implements GraphData { private final Map<Integer, GraphNode> nodesById = new ConcurrentHashMap<>(); private final Map<Integer, GraphAdjacencies> adjacenciesById = new ConcurrentHashMap<>(); - private final IOseeBranch branch; + private final Long branchId; private final int txId; private final OrcsSession orcsSession; - public GraphDataImpl(OrcsSession session, IOseeBranch branch, int txId) { + public GraphDataImpl(OrcsSession session, Long branchId, int txId) { super(); this.orcsSession = session; - this.branch = branch; + this.branchId = branchId; this.txId = txId; } @Override - public IOseeBranch getBranch() { - return branch; - } - - @Override public int getTransaction() { return txId; } @@ -63,7 +57,7 @@ public class GraphDataImpl implements GraphData { @Override public void addNode(GraphNode node, boolean useBackingData) throws OseeCoreException { - boolean sameBranches = getBranchUuid() == node.getBranchUuid(); + boolean sameBranches = getBranchUuid().equals(node.getBranchUuid()); if (!sameBranches) { throw new OseeArgumentException("Invalid node added to graph. Graph[%s] Node[%s]", this, node.getExceptionString()); @@ -126,16 +120,14 @@ public class GraphDataImpl implements GraphData { @Override public String toString() { - return String.format("Graph - branch[%s] txId[%s] nodes[%s] adjacencies[%s]", getBranch(), getTransaction(), + return String.format("Graph - branch[%s] txId[%s] nodes[%s] adjacencies[%s]", getBranchUuid(), getTransaction(), nodesById.size(), adjacenciesById.size()); } @Override public int hashCode() { final int prime = 31; - int result = 1; - IOseeBranch branch = getBranch(); - result = prime * result + ((branch == null) ? 0 : branch.hashCode()); + int result = getBranchUuid().hashCode(); result = prime * result + getTransaction(); return result; } @@ -145,20 +137,11 @@ public class GraphDataImpl implements GraphData { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if (!(obj instanceof GraphData)) { return false; } GraphData other = (GraphData) obj; - IOseeBranch branch = getBranch(); - IOseeBranch otherbranch = other.getBranch(); - if (branch == null) { - if (otherbranch != null) { - return false; - } - } else if (!branch.equals(otherbranch)) { + if (!getBranchUuid().equals(other.getBranchUuid())) { return false; } if (getTransaction() != other.getTransaction()) { @@ -173,7 +156,7 @@ public class GraphDataImpl implements GraphData { } @Override - public long getBranchUuid() { - return branch.getUuid(); + public Long getBranchUuid() { + return branchId; } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphFactoryImpl.java index 25833bbb258..bc510babb46 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/graph/impl/GraphFactoryImpl.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.internal.graph.impl; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.core.internal.graph.GraphData; import org.eclipse.osee.orcs.core.internal.graph.GraphFactory; @@ -21,7 +20,7 @@ import org.eclipse.osee.orcs.core.internal.graph.GraphFactory; public class GraphFactoryImpl implements GraphFactory { @Override - public GraphData createGraph(OrcsSession session, IOseeBranch branch, int transactionId) { + public GraphData createGraph(OrcsSession session, Long branch, int transactionId) { return new GraphDataImpl(session, branch, transactionId); } 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 1dd5258bd50..b1783be87a6 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 @@ -19,7 +19,6 @@ import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.AttributeId; 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.enums.DeletionFlag; @@ -31,7 +30,6 @@ import org.eclipse.osee.framework.jdk.core.type.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.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; @@ -55,10 +53,6 @@ public class ArtifactReadOnlyImpl extends AbstractProxied<Artifact>implements Ar return relationManager; } - private GraphData getGraphData() { - return getProxiedObject().getGraph(); - } - @Override public String getGuid() { return getProxiedObject().getGuid(); @@ -80,13 +74,8 @@ public class ArtifactReadOnlyImpl extends AbstractProxied<Artifact>implements Ar } @Override - public IOseeBranch getBranch() throws OseeCoreException { - return getProxiedObject().getBranch(); - } - - @Override - public long getBranchUuid() { - return getBranch().getUuid(); + public Long getBranchUuid() { + return getProxiedObject().getBranchUuid(); } @Override 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 36a5e1a0ca4..e606de559c6 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 @@ -10,10 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.internal.relation; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.IRelationType; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.orcs.core.ds.RelationData; import org.eclipse.osee.orcs.core.ds.RelationDataFactory; import org.eclipse.osee.orcs.core.internal.relation.impl.RelationNodeAdjacencies; @@ -44,8 +42,7 @@ public class RelationFactory { public Relation createRelation(RelationNode aNode, IRelationType type, RelationNode bNode) throws OseeCoreException { OrcsConditions.checkBranch(aNode, bNode); OrcsConditions.checkRelateSelf(aNode, bNode); - IOseeBranch branch = aNode.getBranch(); - RelationData data = relationDataFactory.createRelationData(type, branch, aNode, bNode, Strings.emptyString()); + RelationData data = relationDataFactory.createRelationData(type, aNode.getBranchUuid(), aNode, bNode, ""); return createRelation(data); } @@ -54,7 +51,7 @@ public class RelationFactory { return createRelation(data); } - public Relation introduce(IOseeBranch branch, RelationData data) { + public Relation introduce(Long branch, RelationData data) { RelationData source = relationDataFactory.introduce(branch, data); return createRelation(source); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationManager.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationManager.java index c1e7361ab52..26da6bc4c85 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationManager.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/relation/RelationManager.java @@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.core.internal.relation; import java.util.Collection; import java.util.List; -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.enums.DeletionFlag; @@ -83,7 +82,7 @@ public interface RelationManager { void cloneRelations(OrcsSession session, RelationNode source, RelationNode destination) throws OseeCoreException; - void introduce(OrcsSession session, IOseeBranch branch, RelationNode source, RelationNode destination) throws OseeCoreException; + void introduce(OrcsSession session, Long branch, RelationNode source, RelationNode destination) throws OseeCoreException; /////////////////////////////////////// }
\ No newline at end of file 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 110bbc43f51..26e9325b6e9 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 @@ -32,7 +32,6 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -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; @@ -466,7 +465,7 @@ public class RelationManagerImpl implements RelationManager { } @Override - public void introduce(OrcsSession session, IOseeBranch branch, RelationNode source, RelationNode destination) throws OseeCoreException { + public void introduce(OrcsSession session, Long branch, RelationNode source, RelationNode destination) throws OseeCoreException { ensureRelationsInitialized(session, source.getGraph(), source); Collection<? extends IRelationType> validRelationTypes = getValidRelationTypes(session, destination); @@ -498,7 +497,7 @@ public class RelationManagerImpl implements RelationManager { } } - private ArtifactReadable doesRelatedArtifactExist(OrcsSession session, Relation rel, RelationNode destination, IOseeBranch branch) { + private ArtifactReadable doesRelatedArtifactExist(OrcsSession session, Relation rel, RelationNode destination, Long branch) { // need to check if the related artifact exists int artIdA = rel.getOrcsData().getArtIdA(); int artIdB = rel.getOrcsData().getArtIdB(); 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 4600d577af4..99ea71866e1 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 @@ -40,7 +40,7 @@ public class RelationNodeLoaderImpl implements RelationNodeLoader { public <T extends RelationNode> Iterable<T> loadNodes(OrcsSession session, final GraphData graph, Collection<Integer> ids, LoadLevel level) throws OseeCoreException { GraphBuilder builder = graphBuilderFactory.createBuilderForGraph(graph); - DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, graph.getBranch(), ids); + DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, graph.getBranchUuid(), ids); loader.withLoadLevel(level); loader.fromTransaction(graph.getTransaction()); loader.includeDeletedArtifacts(); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java index 876e087e658..4274dfe8061 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/QueryFactoryImpl.java @@ -54,11 +54,11 @@ public class QueryFactoryImpl implements QueryFactory { this.txCriteriaFactory = txCriteriaFactory; } - private QueryBuilder createBuilder(IOseeBranch branch) { + private QueryBuilder createBuilder(Long branchId) { Options options = OptionsUtil.createOptions(); CriteriaSet criteriaSet = new CriteriaSet(); - if (branch != null) { - criteriaSet.add(new CriteriaBranch(branch)); + if (branchId != null) { + criteriaSet.add(new CriteriaBranch(branchId)); } QueryData queryData = new QueryData(criteriaSet, options); QueryBuilder builder = new QueryBuilderImpl(queryFctry, criteriaFctry, context, queryData); @@ -77,7 +77,7 @@ public class QueryFactoryImpl implements QueryFactory { @Override public QueryBuilder fromBranch(IOseeBranch branch) throws OseeCoreException { Conditions.checkNotNull(branch, "branch"); - return createBuilder(branch); + return createBuilder(branch.getUuid()); } @Override @@ -91,12 +91,11 @@ public class QueryFactoryImpl implements QueryFactory { public QueryBuilder fromArtifacts(Collection<? extends ArtifactReadable> artifacts) throws OseeCoreException { Conditions.checkNotNullOrEmpty(artifacts, "artifacts"); ArtifactReadable artifact = artifacts.iterator().next(); - IOseeBranch branch = artifact.getBranch(); Set<String> guids = new HashSet<>(); for (ArtifactReadable art : artifacts) { guids.add(art.getGuid()); } - return fromBranch(branch).andGuids(guids); + return fromBranch(artifact.getBranchUuid()).andGuids(guids); } @Override 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 6c395d126a6..c61bcaf4030 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 @@ -59,8 +59,8 @@ public class TransactionBuilderImpl implements TransactionBuilder { } @Override - public IOseeBranch getBranch() { - return txData.getBranch(); + public Long getBranchId() { + return txData.getBranchId(); } @Override @@ -107,37 +107,45 @@ public class TransactionBuilderImpl implements TransactionBuilder { @Override public ArtifactId copyArtifact(ArtifactReadable sourceArtifact) throws OseeCoreException { - return copyArtifact(sourceArtifact.getBranch(), sourceArtifact); + return copyArtifact(sourceArtifact.getBranchUuid(), sourceArtifact); } @Override public ArtifactId copyArtifact(IOseeBranch fromBranch, ArtifactId artifactId) throws OseeCoreException { - return txManager.copyArtifact(txData, fromBranch, artifactId); + return copyArtifact(fromBranch.getUuid(), artifactId); + } + + private ArtifactId copyArtifact(Long fromBranchId, ArtifactId artifactId) throws OseeCoreException { + return txManager.copyArtifact(txData, fromBranchId, artifactId); } @Override public ArtifactId copyArtifact(ArtifactReadable sourceArtifact, Collection<? extends IAttributeType> attributesToDuplicate) throws OseeCoreException { - return copyArtifact(sourceArtifact.getBranch(), sourceArtifact, attributesToDuplicate); + return copyArtifact(sourceArtifact.getBranchUuid(), sourceArtifact, attributesToDuplicate); } @Override public ArtifactId copyArtifact(IOseeBranch fromBranch, ArtifactId artifactId, Collection<? extends IAttributeType> attributesToDuplicate) throws OseeCoreException { + return copyArtifact(fromBranch.getUuid(), artifactId, attributesToDuplicate); + } + + private ArtifactId copyArtifact(Long fromBranch, ArtifactId artifactId, Collection<? extends IAttributeType> attributesToDuplicate) throws OseeCoreException { return txManager.copyArtifact(txData, fromBranch, artifactId, attributesToDuplicate); } @Override public ArtifactId introduceArtifact(IOseeBranch fromBranch, ArtifactId sourceArtifact) throws OseeCoreException { - checkAreOnDifferentBranches(txData, fromBranch); - ArtifactReadable source = getArtifactReadable(txData.getSession(), query, fromBranch, sourceArtifact); + checkAreOnDifferentBranches(txData, fromBranch.getUuid()); + ArtifactReadable source = getArtifactReadable(txData.getSession(), query, fromBranch.getUuid(), sourceArtifact); Conditions.checkNotNull(source, "Source Artifact"); ArtifactReadable destination = - getArtifactReadable(txData.getSession(), query, txData.getBranch(), sourceArtifact); - return txManager.introduceArtifact(txData, fromBranch, source, destination); + getArtifactReadable(txData.getSession(), query, txData.getBranchId(), sourceArtifact); + return txManager.introduceArtifact(txData, fromBranch.getUuid(), source, destination); } @Override public ArtifactId replaceWithVersion(ArtifactReadable sourceArtifact, ArtifactReadable destination) throws OseeCoreException { - return txManager.replaceWithVersion(txData, sourceArtifact.getBranch(), sourceArtifact, destination); + return txManager.replaceWithVersion(txData, sourceArtifact.getBranchUuid(), sourceArtifact, destination); } @Override @@ -325,13 +333,13 @@ public class TransactionBuilderImpl implements TransactionBuilder { return tx; } - private void checkAreOnDifferentBranches(TxData txData, IOseeBranch sourceBranch) throws OseeCoreException { - boolean isOnSameBranch = txData.getBranch().equals(sourceBranch); + private void checkAreOnDifferentBranches(TxData txData, Long sourceBranch) throws OseeCoreException { + boolean isOnSameBranch = txData.getBranchId().equals(sourceBranch); Conditions.checkExpressionFailOnTrue(isOnSameBranch, "Source branch is same branch as transaction branch[%s]", - txData.getBranch()); + txData.getBranchId()); } - protected ArtifactReadable getArtifactReadable(OrcsSession session, QueryModule query, IOseeBranch branch, ArtifactId id) { + protected ArtifactReadable getArtifactReadable(OrcsSession session, QueryModule query, Long branch, ArtifactId id) { return query.createQueryFactory(session).fromBranch(branch).includeDeletedArtifacts().andGuid( id.getGuid()).getResults().getOneOrNull(); } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java index 98f54517650..6aaf382df01 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TransactionFactoryImpl.java @@ -66,8 +66,8 @@ public class TransactionFactoryImpl implements TransactionFactory { } @Override - public TransactionBuilder createTransaction(long uuid, ArtifactReadable userArtifact, String comment) throws OseeCoreException { - IOseeBranch branch = TokenFactory.createBranch(uuid, ""); + public TransactionBuilder createTransaction(Long branchId, ArtifactReadable userArtifact, String comment) throws OseeCoreException { + IOseeBranch branch = TokenFactory.createBranch(branchId, ""); return createTransaction(branch, userArtifact, comment); } @@ -77,7 +77,7 @@ public class TransactionFactoryImpl implements TransactionFactory { Conditions.checkNotNull(author, "author"); Conditions.checkNotNullOrEmpty(comment, "comment"); - TxData txData = txDataManager.createTxData(session, branch); + TxData txData = txDataManager.createTxData(session, branch.getUuid()); TransactionBuilderImpl orcsTxn = new TransactionBuilderImpl(txCallableFactory, txDataManager, txData, query); orcsTxn.setComment(comment); orcsTxn.setAuthor(author); @@ -102,7 +102,7 @@ public class TransactionFactoryImpl implements TransactionFactory { } @Override - public boolean replaceWithBaselineTxVersion(String userId, long branchId, int txId, int artId, String comment) { + public boolean replaceWithBaselineTxVersion(String userId, Long branchId, int txId, int artId, String comment) { boolean introduced = false; ArtifactReadable userReadable = queryFactory.fromBranch(CoreBranches.COMMON).andGuid(userId).getResults().getOneOrNull(); 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 7f4a14ee4e5..8fcaecfa0e1 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 @@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.core.internal.transaction; import java.util.HashMap; import java.util.Map; import org.eclipse.osee.framework.core.data.ArtifactId; -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; @@ -61,8 +60,8 @@ public class TxData implements HasSession { return session; } - public IOseeBranch getBranch() { - return graph.getBranch(); + public Long getBranchId() { + return graph.getBranchUuid(); } public GraphData getGraph() { 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 f12f462b25f..71a156e9ed8 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 @@ -14,7 +14,6 @@ import java.util.Collection; import java.util.LinkedHashSet; import java.util.Set; import org.eclipse.osee.framework.core.data.ArtifactId; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.LoadLevel; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.ResultSet; @@ -43,7 +42,7 @@ public class TxDataLoaderImpl implements TxDataLoader { private final TransactionProvider txProvider; public static interface TransactionProvider { - int getHeadTransaction(OrcsSession session, IOseeBranch branch); + int getHeadTransaction(OrcsSession session, Long branch); } public TxDataLoaderImpl(DataLoaderFactory dataLoaderFactory, GraphFactory graphFactory, GraphBuilderFactory graphBuilderFactory, GraphProvider graphProvider, TransactionProvider txProvider) { @@ -55,12 +54,12 @@ public class TxDataLoaderImpl implements TxDataLoader { this.txProvider = txProvider; } - private DataLoader createLoader(OrcsSession session, IOseeBranch branch, Collection<ArtifactId> artifactIds) throws OseeCoreException { + private DataLoader createLoader(OrcsSession session, Long branchId, Collection<ArtifactId> artifactIds) throws OseeCoreException { Set<String> ids = new LinkedHashSet<>(); for (ArtifactId artifactId : artifactIds) { ids.add(artifactId.getGuid()); } - DataLoader loader = dataLoaderFactory.newDataLoaderFromGuids(session, branch, ids); + DataLoader loader = dataLoaderFactory.newDataLoaderFromGuids(session, branchId, ids); loader.withLoadLevel(LoadLevel.ALL); loader.includeDeletedAttributes(); loader.includeDeletedRelations(); @@ -68,8 +67,8 @@ public class TxDataLoaderImpl implements TxDataLoader { } @Override - public ResultSet<Artifact> loadArtifacts(OrcsSession session, IOseeBranch branch, Collection<ArtifactId> artifactIds) throws OseeCoreException { - DataLoader loader = createLoader(session, branch, artifactIds); + public ResultSet<Artifact> loadArtifacts(OrcsSession session, Long branchId, Collection<ArtifactId> artifactIds) throws OseeCoreException { + DataLoader loader = createLoader(session, branchId, artifactIds); GraphBuilder handler = graphBuilderFactory.createGraphBuilder(graphProvider); loader.load(null, handler); return ResultSets.newResultSet(handler.getArtifacts()); @@ -77,7 +76,7 @@ public class TxDataLoaderImpl implements TxDataLoader { @Override public ResultSet<Artifact> loadArtifacts(OrcsSession session, GraphData graph, Collection<ArtifactId> artifactIds) throws OseeCoreException { - DataLoader loader = createLoader(session, graph.getBranch(), artifactIds); + DataLoader loader = createLoader(session, graph.getBranchUuid(), artifactIds); loader.fromTransaction(graph.getTransaction()); GraphBuilder handler = graphBuilderFactory.createBuilderForGraph(graph); loader.load(null, handler); @@ -85,7 +84,7 @@ public class TxDataLoaderImpl implements TxDataLoader { } @Override - public GraphData createGraph(OrcsSession session, IOseeBranch branch) throws OseeCoreException { + public GraphData createGraph(OrcsSession session, Long branch) throws OseeCoreException { int headTransaction = txProvider.getHeadTransaction(session, branch); return graphFactory.createGraph(session, branch, headTransaction); } 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 6423baea19d..15a0d84186d 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 @@ -19,7 +19,6 @@ import java.util.Set; import org.eclipse.osee.framework.core.data.ArtifactId; 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.enums.RelationSide; @@ -52,9 +51,9 @@ public class TxDataManager { public interface TxDataLoader { - GraphData createGraph(OrcsSession session, IOseeBranch branch) throws OseeCoreException; + GraphData createGraph(OrcsSession session, Long branch) throws OseeCoreException; - ResultSet<Artifact> loadArtifacts(OrcsSession session, IOseeBranch branch, Collection<ArtifactId> artifactIds) throws OseeCoreException; + ResultSet<Artifact> loadArtifacts(OrcsSession session, Long branchId, Collection<ArtifactId> artifactIds) throws OseeCoreException; ResultSet<Artifact> loadArtifacts(OrcsSession session, GraphData graph, Collection<ArtifactId> singleton) throws OseeCoreException; @@ -72,7 +71,7 @@ public class TxDataManager { this.loader = loader; } - public TxData createTxData(OrcsSession session, IOseeBranch branch) throws OseeCoreException { + public TxData createTxData(OrcsSession session, Long branch) throws OseeCoreException { GraphData graphData = loader.createGraph(session, branch); return new TxData(session, graphData); } @@ -158,7 +157,7 @@ public class TxDataManager { private boolean isFromSameStripe(TxData txData, Artifact artifact) { boolean result = false; - if (artifact != null && txData.getBranch().equals(artifact.getBranch())) { + if (artifact != null && txData.getBranchId().equals(artifact.getBranchUuid())) { int txId = txData.getGraph().getTransaction(); if (txId == artifact.getTransaction()) { result = true; @@ -183,9 +182,9 @@ public class TxDataManager { return artifact; } - private Artifact getSourceArtifact(TxData txData, IOseeBranch fromBranch, ArtifactId artifactId) throws OseeCoreException { + private Artifact getSourceArtifact(TxData txData, Long fromBranchId, ArtifactId artifactId) throws OseeCoreException { Artifact source = null; - if (txData.getBranch().equals(fromBranch)) { + if (txData.getBranchId().equals(fromBranchId)) { source = txData.getWriteable(artifactId); } @@ -193,12 +192,12 @@ public class TxDataManager { Artifact artifactSrc = null; if (artifactId instanceof Artifact) { Artifact external = (Artifact) artifactId; - if (fromBranch.equals(external.getBranch())) { + if (fromBranchId.equals(external.getBranchUuid())) { artifactSrc = external; } } else if (artifactId instanceof ArtifactReadable) { ArtifactReadable external = (ArtifactReadable) artifactId; - if (fromBranch.equals(external.getBranch())) { + if (fromBranchId.equals(external.getBranchUuid())) { artifactSrc = proxyManager.asInternalArtifact(external); } } @@ -209,7 +208,7 @@ public class TxDataManager { } if (source == null) { ResultSet<Artifact> loadArtifacts = - loader.loadArtifacts(txData.getSession(), fromBranch, singleton(artifactId)); + loader.loadArtifacts(txData.getSession(), fromBranchId, singleton(artifactId)); source = loadArtifacts.getExactlyOne(); } return source; @@ -237,7 +236,7 @@ public class TxDataManager { public ArtifactReadable createArtifact(TxData txData, IArtifactType artifactType, String name, String guid) throws OseeCoreException { checkChangesAllowed(txData); - Artifact artifact = artifactFactory.createArtifact(txData.getSession(), txData.getBranch(), artifactType, guid); + Artifact artifact = artifactFactory.createArtifact(txData.getSession(), txData.getBranchId(), artifactType, guid); artifact.setName(name); return asExternalArtifact(txData, artifact); } @@ -245,49 +244,48 @@ public class TxDataManager { public ArtifactReadable createArtifact(TxData txData, IArtifactType artifactType, String name, String guid, long uuid) throws OseeCoreException { checkChangesAllowed(txData); Artifact artifact = - artifactFactory.createArtifact(txData.getSession(), txData.getBranch(), artifactType, guid, uuid); + artifactFactory.createArtifact(txData.getSession(), txData.getBranchId(), artifactType, guid, uuid); artifact.setName(name); return asExternalArtifact(txData, artifact); } - public ArtifactReadable copyArtifact(TxData txData, IOseeBranch fromBranch, ArtifactId artifactId) throws OseeCoreException { + public ArtifactReadable copyArtifact(TxData txData, Long fromBranchId, ArtifactId artifactId) throws OseeCoreException { checkChangesAllowed(txData); - Artifact source = getSourceArtifact(txData, fromBranch, artifactId); + Artifact source = getSourceArtifact(txData, fromBranchId, artifactId); return copyArtifactHelper(txData, source, source.getExistingAttributeTypes()); } - public ArtifactReadable copyArtifact(TxData txData, IOseeBranch fromBranch, ArtifactId artifactId, Collection<? extends IAttributeType> attributesToDuplicate) throws OseeCoreException { + public ArtifactReadable copyArtifact(TxData txData, Long fromBranchId, ArtifactId artifactId, Collection<? extends IAttributeType> attributesToDuplicate) throws OseeCoreException { checkChangesAllowed(txData); - Artifact source = getSourceArtifact(txData, fromBranch, artifactId); + Artifact source = getSourceArtifact(txData, fromBranchId, artifactId); return copyArtifactHelper(txData, source, attributesToDuplicate); } private ArtifactReadable copyArtifactHelper(TxData txData, Artifact source, Collection<? extends IAttributeType> attributesToDuplicate) throws OseeCoreException { Artifact copy = - artifactFactory.copyArtifact(txData.getSession(), source, attributesToDuplicate, txData.getBranch()); + artifactFactory.copyArtifact(txData.getSession(), source, attributesToDuplicate, txData.getBranchId()); return asExternalArtifact(txData, copy); } - public ArtifactReadable introduceArtifact(TxData txData, IOseeBranch fromBranch, ArtifactReadable source, ArtifactReadable destination) throws OseeCoreException { + public ArtifactReadable introduceArtifact(TxData txData, Long fromBranchId, ArtifactReadable source, ArtifactReadable destination) throws OseeCoreException { checkChangesAllowed(txData); - Artifact src = getSourceArtifact(txData, fromBranch, source); + Artifact src = getSourceArtifact(txData, fromBranchId, source); Artifact dest = null; if (destination == null) { - dest = - artifactFactory.createArtifact(txData.getSession(), txData.getBranch(), src.getArtifactType(), - src.getGuid()); - dest.setGraph(loader.createGraph(txData.getSession(), txData.getBranch())); + dest = artifactFactory.createArtifact(txData.getSession(), txData.getBranchId(), src.getArtifactType(), + src.getGuid()); + dest.setGraph(loader.createGraph(txData.getSession(), txData.getBranchId())); } else { - dest = getSourceArtifact(txData, fromBranch, destination); + dest = getSourceArtifact(txData, fromBranchId, destination); } - artifactFactory.introduceArtifact(txData.getSession(), src, dest, txData.getBranch()); - relationManager.introduce(txData.getSession(), txData.getBranch(), src, dest); + artifactFactory.introduceArtifact(txData.getSession(), src, dest, txData.getBranchId()); + relationManager.introduce(txData.getSession(), txData.getBranchId(), src, dest); addAdjacencies(txData, dest); return asExternalArtifact(txData, dest); } - public ArtifactReadable replaceWithVersion(TxData txData, IOseeBranch fromBranch, ArtifactReadable readable, ArtifactReadable destination) throws OseeCoreException { - return introduceArtifact(txData, fromBranch, readable, destination); + public ArtifactReadable replaceWithVersion(TxData txData, Long fromBranchId, ArtifactReadable readable, ArtifactReadable destination) throws OseeCoreException { + return introduceArtifact(txData, fromBranchId, readable, destination); } private void addAdjacencies(TxData txData, Artifact dest) { @@ -410,27 +408,27 @@ public class TxDataManager { relationManager.accept(session, graph, artifact, builder); } OrcsChangeSet changeSet = builder.getChangeSet(); - return new TransactionDataImpl(txData.getBranch(), txData.getAuthor(), txData.getComment(), changeSet); + return new TransactionDataImpl(txData.getBranchId(), txData.getAuthor(), txData.getComment(), changeSet); } private static final class TransactionDataImpl implements TransactionData { - private final IOseeBranch branch; + private final Long branchId; private final ArtifactReadable author; private final String comment; private final OrcsChangeSet changeSet; - public TransactionDataImpl(IOseeBranch branch, ArtifactReadable author, String comment, OrcsChangeSet changeSet) { + public TransactionDataImpl(Long branchId, ArtifactReadable author, String comment, OrcsChangeSet changeSet) { super(); - this.branch = branch; + this.branchId = branchId; this.author = author; this.comment = comment; this.changeSet = changeSet; } @Override - public IOseeBranch getBranch() { - return branch; + public Long getBranchId() { + return branchId; } @Override @@ -450,7 +448,7 @@ public class TxDataManager { @Override public String toString() { - return "TransactionDataImpl [branch=" + branch + ", author=" + author + ", comment=" + comment + ", changeSet=" + changeSet + "]"; + return "TransactionDataImpl [branch=" + branchId + ", author=" + author + ", comment=" + comment + ", changeSet=" + changeSet + "]"; } } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/OrcsConditions.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/OrcsConditions.java index 63d42958138..b5c9c66b162 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/OrcsConditions.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/util/OrcsConditions.java @@ -47,7 +47,7 @@ public final class OrcsConditions { } public static void checkBranch(RelationNode node1, RelationNode node2) throws OseeCoreException { - boolean areEqual = node1.getBranchUuid() == node2.getBranchUuid(); + boolean areEqual = node1.getBranchUuid().equals(node2.getBranchUuid()); checkExpressionFailOnTrue(!areEqual, "Cross branch linking is not yet supported."); } diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java index b0f9e1a71dd..a441cd5b926 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/intergration/LoaderTest.java @@ -62,7 +62,7 @@ public class LoaderTest { // @formatter:off // @OsgiService private JdbcClient jdbcClient; @OsgiService private OrcsDataStore dataStore; - @Mock private LoadDataHandler builder; + @Mock private LoadDataHandler builder; @Captor private ArgumentCaptor<LoadDescription> descriptorCaptor; @Captor private ArgumentCaptor<ArtifactData> artifactCaptor; @Captor private ArgumentCaptor<AttributeData> attributeCaptor; @@ -76,6 +76,8 @@ public class LoaderTest { private HasCancellation cancellation; private DataLoaderFactory loaderFactory; + private static final Long commonBranchId = CoreBranches.COMMON.getUuid(); + @Before public void setUp() throws OseeCoreException { MockitoAnnotations.initMocks(this); @@ -102,7 +104,7 @@ public class LoaderTest { @org.junit.Test public void testLoad() throws OseeCoreException { - DataLoader loader = loaderFactory.newDataLoaderFromIds(session, CoreBranches.COMMON, 5, 6, 7); + DataLoader loader = loaderFactory.newDataLoaderFromIds(session, commonBranchId, 5, 6, 7); loader.withLoadLevel(LoadLevel.ALL); loader.load(cancellation, builder); @@ -112,7 +114,7 @@ public class LoaderTest { verify(builder).onLoadEnd(); LoadDescription descriptor = descriptorCaptor.getValue(); - assertEquals(CoreBranches.COMMON, descriptor.getBranch()); + assertEquals(commonBranchId, descriptor.getBranchId()); verify(builder, times(3)).onData(artifactCaptor.capture()); verify(builder, times(7)).onData(attributeCaptor.capture()); @@ -153,7 +155,7 @@ public class LoaderTest { @org.junit.Test public void testLoadByTypes() throws OseeCoreException { - DataLoader loader = loaderFactory.newDataLoaderFromIds(session, CoreBranches.COMMON, 5, 6, 7); + DataLoader loader = loaderFactory.newDataLoaderFromIds(session, commonBranchId, 5, 6, 7); loader.withLoadLevel(LoadLevel.ALL); loader.withAttributeTypes(Name); @@ -166,7 +168,7 @@ public class LoaderTest { verify(builder).onLoadEnd(); LoadDescription descriptor = descriptorCaptor.getValue(); - assertEquals(CoreBranches.COMMON, descriptor.getBranch()); + assertEquals(commonBranchId, descriptor.getBranchId()); verify(builder, times(3)).onData(artifactCaptor.capture()); verify(builder, times(3)).onData(attributeCaptor.capture()); @@ -178,7 +180,7 @@ public class LoaderTest { // @formatter:off verifyData(arts.next(), 5, "AkA10I4aUSDLuFNIaegA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 15L); verifyData(arts.next(), 6, "AkA10LiAPEZLR4+jdFQA", NEW, OseeTypeDefinition.getGuid(), 570L,5, -1, 16L); - verifyData(arts.next(), 7, "AkA2AcT6AXe6ivMFRhAA", NEW, Folder.getGuid(), 570L,6, -1, 43L); + verifyData(arts.next(), 7, "AkA2AcT6AXe6ivMFRhAA", NEW, Folder.getGuid(), 570L,6, -1, 43L); // @formatter:on sort(attributeCaptor.getAllValues()); @@ -202,7 +204,7 @@ public class LoaderTest { @org.junit.Test public void testLoadByIds() throws OseeCoreException { - DataLoader loader = loaderFactory.newDataLoaderFromIds(session, CoreBranches.COMMON, 5, 6, 7); + DataLoader loader = loaderFactory.newDataLoaderFromIds(session, commonBranchId, 5, 6, 7); loader.withLoadLevel(LoadLevel.ALL); loader.withAttributeIds(11, 14); @@ -215,7 +217,7 @@ public class LoaderTest { verify(builder).onLoadEnd(); LoadDescription descriptor = descriptorCaptor.getValue(); - assertEquals(CoreBranches.COMMON, descriptor.getBranch()); + assertEquals(commonBranchId, descriptor.getBranchId()); verify(builder, times(3)).onData(artifactCaptor.capture()); verify(builder, times(2)).onData(attributeCaptor.capture()); @@ -250,7 +252,7 @@ public class LoaderTest { @org.junit.Test public void testLoadByGuids() throws OseeCoreException { String[] ids = new String[] {"AkA10I4aUSDLuFNIaegA", "AkA10LiAPEZLR4+jdFQA", "AkA2AcT6AXe6ivMFRhAA"}; - DataLoader loader = loaderFactory.newDataLoaderFromGuids(session, CoreBranches.COMMON, ids); + DataLoader loader = loaderFactory.newDataLoaderFromGuids(session, commonBranchId, ids); loader.withLoadLevel(LoadLevel.ALL); loader.load(cancellation, builder); @@ -260,7 +262,7 @@ public class LoaderTest { verify(builder).onLoadEnd(); LoadDescription descriptor = descriptorCaptor.getValue(); - assertEquals(CoreBranches.COMMON, descriptor.getBranch()); + assertEquals(commonBranchId, descriptor.getBranchId()); verify(builder, times(3)).onData(artifactCaptor.capture()); verify(builder, times(7)).onData(attributeCaptor.capture()); diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java index e29d2204f8f..7318dcb8b31 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryTest.java @@ -20,7 +20,6 @@ import java.util.LinkedList; import java.util.List; import org.eclipse.osee.executor.admin.HasCancellation; import org.eclipse.osee.framework.core.enums.ModificationType; -import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.change.ChangeItem; import org.eclipse.osee.framework.core.model.change.ChangeItemUtil; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -58,8 +57,8 @@ public class MissingChangeItemFactoryTest { @Mock private DataLoaderFactory dataLoaderFactory; @Mock private DataLoader sourceDataLoader; @Mock private DataLoader destDataLoader; - @Mock private Branch sourceBranch; - @Mock private Branch destBranch; + @Mock private Long sourceBranch; + @Mock private Long destBranch; @Mock private TransactionReadable sourceTx; @Mock private TransactionReadable destTx; @Mock private OrcsSession session; @@ -100,12 +99,12 @@ public class MissingChangeItemFactoryTest { String sessionGuid = GUID.create(); when(session.getGuid()).thenReturn(sessionGuid); - when(dataLoaderFactory.newDataLoaderFromIds(any(OrcsSession.class), eq(sourceBranch), any(Collection.class))).thenReturn( - sourceDataLoader); - when(dataLoaderFactory.newDataLoaderFromIds(any(OrcsSession.class), eq(destBranch), any(Collection.class))).thenReturn( - destDataLoader); - when(sourceTx.getBranchId()).thenReturn(sourceBranch.getGuid()); - when(destTx.getBranchId()).thenReturn(destBranch.getGuid()); + when(dataLoaderFactory.newDataLoaderFromIds(any(OrcsSession.class), eq(sourceBranch), + any(Collection.class))).thenReturn(sourceDataLoader); + when(dataLoaderFactory.newDataLoaderFromIds(any(OrcsSession.class), eq(destBranch), + any(Collection.class))).thenReturn(destDataLoader); + when(sourceTx.getBranchId()).thenReturn(sourceBranch); + when(destTx.getBranchId()).thenReturn(destBranch); changeItemFactory = new MissingChangeItemFactoryImpl(dataLoaderFactory); } diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImplTest.java index fe3d1f35e17..bc1a077a8ac 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImplTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImplTest.java @@ -45,10 +45,12 @@ import org.mockito.MockitoAnnotations; /** * Test Case for {@link DataFactoryImplTest} and {@link OrcsObjectFactoryImpl} - * + * * @author Roberto E. Escobar */ public class DataFactoryImplTest { + private static final Long COMMON_ID = CoreBranches.COMMON.getUuid(); + private static final Long BRANCH_ID2 = Long.valueOf(11); @Rule public ExpectedException thrown = ExpectedException.none(); @@ -58,14 +60,14 @@ public class DataFactoryImplTest { @Mock private ProxyDataFactory proxyFactory; @Mock private IdentityLocator identityService; @Mock private ArtifactTypes artifactCache; - + @Mock private ArtifactData artData; @Mock private AttributeData attrData; @Mock private RelationData relData; @Mock private VersionData verData; @Mock private DataProxy dataProxy; @Mock private DataProxy otherDataProxy; - + @Mock private IArtifactType artifactTypeToken; //@formatter:on @@ -83,7 +85,7 @@ public class DataFactoryImplTest { dataFactory = new DataFactoryImpl(idFactory, objectFactory, artifactCache); // VERSION - when(verData.getBranchId()).thenReturn(11L); + when(verData.getBranchId()).thenReturn(BRANCH_ID2); when(verData.getGammaId()).thenReturn(222L); when(verData.getTransactionId()).thenReturn(333); when(verData.getStripeId()).thenReturn(444); @@ -133,7 +135,7 @@ public class DataFactoryImplTest { thrown.expect(OseeArgumentException.class); thrown.expectMessage("Cannot create an instance of abstract type [artifactTypeToken]"); - dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid); + dataFactory.create(COMMON_ID, artifactTypeToken, guid); } @Test @@ -147,7 +149,7 @@ public class DataFactoryImplTest { thrown.expect(OseeArgumentException.class); thrown.expectMessage("Invalid guid [123] during artifact creation [type: artifactTypeToken]"); - dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid); + dataFactory.create(COMMON_ID, artifactTypeToken, guid); } @Test @@ -157,13 +159,13 @@ public class DataFactoryImplTest { when(idFactory.getUniqueGuid(guid)).thenReturn(guid); when(idFactory.getNextArtifactId()).thenReturn(987); - ArtifactData actual = dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid); + ArtifactData actual = dataFactory.create(COMMON_ID, artifactTypeToken, guid); verify(idFactory).getUniqueGuid(guid); verify(idFactory).getNextArtifactId(); VersionData actualVer = actual.getVersion(); - assertEquals(570, actualVer.getBranchId()); + assertEquals(COMMON_ID, actualVer.getBranchId()); assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId()); @@ -186,12 +188,12 @@ public class DataFactoryImplTest { when(idFactory.getUniqueGuid(guid)).thenReturn(guid); when(idFactory.getNextArtifactId()).thenReturn(987); - ArtifactData actual = dataFactory.create(CoreBranches.COMMON, artifactTypeToken, guid); + ArtifactData actual = dataFactory.create(COMMON_ID, artifactTypeToken, guid); verify(idFactory).getUniqueGuid(guid); verify(idFactory).getNextArtifactId(); VersionData actualVer = actual.getVersion(); - assertEquals(570, actualVer.getBranchId()); + assertEquals(COMMON_ID, actualVer.getBranchId()); assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId()); @@ -217,7 +219,7 @@ public class DataFactoryImplTest { AttributeData actual = dataFactory.create(artData, attributeType); VersionData actualVer = actual.getVersion(); - assertEquals(11, actualVer.getBranchId()); + assertEquals(BRANCH_ID2, actualVer.getBranchId()); assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId()); @@ -250,11 +252,10 @@ public class DataFactoryImplTest { when(localId1.getLocalId()).thenReturn(4562); when(localId2.getLocalId()).thenReturn(9513); - RelationData actual = - dataFactory.createRelationData(relationType, CoreBranches.COMMON, localId1, localId2, "My rationale"); + RelationData actual = dataFactory.createRelationData(relationType, COMMON_ID, localId1, localId2, "My rationale"); VersionData actualVer = actual.getVersion(); - assertEquals(570, actualVer.getBranchId()); + assertEquals(COMMON_ID, actualVer.getBranchId()); assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId()); @@ -274,11 +275,11 @@ public class DataFactoryImplTest { @Test public void testIntroduceArtifactData() throws OseeCoreException { - ArtifactData actual = dataFactory.introduce(CoreBranches.COMMON, artData); + ArtifactData actual = dataFactory.introduce(COMMON_ID, artData); VersionData actualVer = actual.getVersion(); assertNotSame(verData, actualVer); - assertEquals(570, actualVer.getBranchId()); + assertEquals(COMMON_ID, actualVer.getBranchId()); assertEquals(222L, actualVer.getGammaId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId()); assertEquals(artData.getVersion().getStripeId(), actualVer.getStripeId()); @@ -295,11 +296,11 @@ public class DataFactoryImplTest { @Test public void testIntroduceAttributeData() throws OseeCoreException { - AttributeData actual = dataFactory.introduce(CoreBranches.COMMON, attrData); + AttributeData actual = dataFactory.introduce(COMMON_ID, attrData); VersionData actualVer = actual.getVersion(); assertNotSame(verData, actualVer); - assertEquals(570, actualVer.getBranchId()); + assertEquals(COMMON_ID, actualVer.getBranchId()); assertEquals(222L, actualVer.getGammaId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId()); assertEquals(attrData.getVersion().getStripeId(), actualVer.getStripeId()); @@ -328,12 +329,12 @@ public class DataFactoryImplTest { when(idFactory.getNextArtifactId()).thenReturn(987); when(idFactory.getUniqueGuid(null)).thenReturn(newGuid); - ArtifactData actual = dataFactory.copy(CoreBranches.COMMON, artData); + ArtifactData actual = dataFactory.copy(COMMON_ID, artData); verify(idFactory).getUniqueGuid(null); VersionData actualVer = actual.getVersion(); assertNotSame(verData, actualVer); - assertEquals(570, actualVer.getBranchId()); + assertEquals(COMMON_ID, actualVer.getBranchId()); assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId()); @@ -350,11 +351,11 @@ public class DataFactoryImplTest { @Test public void testCopyAttributeData() throws OseeCoreException { - AttributeData actual = dataFactory.copy(CoreBranches.COMMON, attrData); + AttributeData actual = dataFactory.copy(COMMON_ID, attrData); VersionData actualVer = actual.getVersion(); assertNotSame(verData, actualVer); - assertEquals(570, actualVer.getBranchId()); + assertEquals(COMMON_ID, actualVer.getBranchId()); assertEquals(RelationalConstants.GAMMA_SENTINEL, actualVer.getGammaId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getTransactionId()); assertEquals(RelationalConstants.TRANSACTION_SENTINEL, actualVer.getStripeId()); @@ -385,7 +386,7 @@ public class DataFactoryImplTest { assertNotSame(artData, actual); assertNotSame(verData, actualVer); - assertEquals(11, actualVer.getBranchId()); + assertEquals(BRANCH_ID2, actualVer.getBranchId()); assertEquals(222L, actualVer.getGammaId()); assertEquals(333, actualVer.getTransactionId()); assertEquals(444, actualVer.getStripeId()); @@ -410,7 +411,7 @@ public class DataFactoryImplTest { assertNotSame(attrData, actual); assertNotSame(verData, actualVer); - assertEquals(11, actualVer.getBranchId()); + assertEquals(BRANCH_ID2, actualVer.getBranchId()); assertEquals(222L, actualVer.getGammaId()); assertEquals(333, actualVer.getTransactionId()); assertEquals(444, actualVer.getStripeId()); @@ -441,7 +442,7 @@ public class DataFactoryImplTest { assertNotSame(relData, actual); assertNotSame(verData, actualVer); - assertEquals(11, actualVer.getBranchId()); + assertEquals(BRANCH_ID2, actualVer.getBranchId()); assertEquals(222L, actualVer.getGammaId()); assertEquals(333, actualVer.getTransactionId()); assertEquals(444, actualVer.getStripeId()); diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java index 5d2e9912743..1153d5bfa32 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java @@ -96,7 +96,7 @@ public class DataLoaderFactoryImplTest { private final static int EXPECTED_TX_ID = 45678; private final static int EXPECTED_HEAD_TX_ID = 50000; - private final static IOseeBranch BRANCH = CoreBranches.COMMON; + private final static Long COMMON_ID = CoreBranches.COMMON.getUuid(); private DataLoaderFactory factory; private SqlObjectLoader spyLoader; @@ -117,7 +117,7 @@ public class DataLoaderFactoryImplTest { when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */"); when(jdbcClient.getStatement()).thenReturn(chStmt); - when(jdbcClient.runPreparedQueryFetchObject(eq(-1), Matchers.anyString(), eq(BRANCH.getUuid()))).thenReturn( + when(jdbcClient.runPreparedQueryFetchObject(eq(-1), Matchers.anyString(), eq(COMMON_ID))).thenReturn( EXPECTED_HEAD_TX_ID); when(joinFactory.createArtifactJoinQuery()).thenAnswer(new Answer<ArtifactJoinQuery>() { @@ -143,7 +143,7 @@ public class DataLoaderFactoryImplTest { public void testLoadFull() throws OseeCoreException { LoadLevel expectedLoadLevel = LoadLevel.ALL; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.fromTransaction(EXPECTED_TX_ID); @@ -152,7 +152,7 @@ public class DataLoaderFactoryImplTest { dataLoader.load(cancellation, builder); // @formatter:off - verify(spyLoader, times(0)).loadHeadTransactionId(BRANCH); + verify(spyLoader, times(0)).loadHeadTransactionId(COMMON_ID); verify(spyLoader, times(1)).loadArtifacts(eq(builder), criteriaCaptor.capture(), contextCaptor.capture(), eq(200)); verify(spyLoader, times(1)).loadAttributes(eq(builder), criteriaCaptor.capture(), contextCaptor.capture(), eq(200)); verify(spyLoader, times(1)).loadRelations(eq(builder), criteriaCaptor.capture(), contextCaptor.capture(), eq(200)); @@ -171,7 +171,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); assertEquals(expectedLoadLevel, dataLoader.getLoadLevel()); @@ -193,7 +193,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.includeDeletedArtifacts(); @@ -217,7 +217,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.fromTransaction(EXPECTED_TX_ID); @@ -241,7 +241,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.transaction_id <= jart1.transaction_id AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.fromTransaction(EXPECTED_TX_ID); dataLoader.includeDeletedArtifacts(); @@ -267,7 +267,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); assertEquals(expectedLoadLevel, dataLoader.getLoadLevel()); @@ -291,7 +291,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withAttributeTypes(CoreAttributeTypes.Annotation); @@ -317,7 +317,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withAttributeTypes(CoreAttributeTypes.Annotation, CoreAttributeTypes.Category); @@ -342,7 +342,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withAttributeIds(45); @@ -367,7 +367,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withAttributeIds(45, 55); @@ -392,7 +392,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withAttributeIds(45, 55); dataLoader.withAttributeTypes(CoreAttributeTypes.Annotation, CoreAttributeTypes.Category); @@ -419,7 +419,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withAttributeIds(45); dataLoader.withAttributeTypes(CoreAttributeTypes.Annotation); @@ -445,7 +445,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.includeDeletedArtifacts(); @@ -470,7 +470,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.fromTransaction(EXPECTED_TX_ID); @@ -495,7 +495,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.transaction_id <= jart1.transaction_id AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, att1.attr_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.fromTransaction(EXPECTED_TX_ID); dataLoader.includeDeletedArtifacts(); @@ -523,7 +523,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); assertEquals(expectedLoadLevel, dataLoader.getLoadLevel()); @@ -547,7 +547,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.includeDeletedArtifacts(); @@ -572,7 +572,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withRelationTypes(CoreRelationTypes.Default_Hierarchical__Child); @@ -598,7 +598,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withRelationTypes(CoreRelationTypes.Default_Hierarchical__Child, CoreRelationTypes.Dependency__Artifact); @@ -631,7 +631,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withRelationIds(45); @@ -656,7 +656,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withRelationIds(45, 55); @@ -681,7 +681,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withRelationIds(45, 55); dataLoader.withRelationTypes(CoreRelationTypes.Default_Hierarchical__Child, @@ -715,7 +715,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current = 1 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.withRelationIds(45); dataLoader.withRelationTypes(CoreRelationTypes.Default_Hierarchical__Child); @@ -742,7 +742,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.transaction_id <= jart1.transaction_id AND txs1.mod_type != 3 AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.fromTransaction(EXPECTED_TX_ID); @@ -766,7 +766,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.includeDeletedAttributes(); dataLoader.withAttributeIds(45, 55); @@ -792,7 +792,7 @@ public class DataLoaderFactoryImplTest { " AND txs1.tx_current IN (1, 2, 3) AND txs1.branch_id = jart1.branch_id\n" + // " ORDER BY txs1.branch_id, jart1.art_id, rel1.rel_link_id, txs1.transaction_id desc"; - DataLoader dataLoader = factory.newDataLoaderFromIds(session, BRANCH, Arrays.asList(1, 2, 3)); + DataLoader dataLoader = factory.newDataLoaderFromIds(session, COMMON_ID, Arrays.asList(1, 2, 3)); dataLoader.withLoadLevel(expectedLoadLevel); dataLoader.includeDeletedRelations(); dataLoader.withRelationTypes(CoreRelationTypes.Default_Hierarchical__Child); @@ -833,7 +833,7 @@ public class DataLoaderFactoryImplTest { assertEquals(session, descriptor.getSession()); Options options = descriptor.getOptions(); - assertEquals(BRANCH, descriptor.getBranch()); + assertEquals(COMMON_ID, descriptor.getBranchId()); assertEquals(txId, descriptor.getTransaction()); assertEquals(isHeadTx, OptionsUtil.isHeadTransaction(options)); diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java index 7937b4ea4b0..1c17b67f373 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java @@ -140,7 +140,7 @@ public class ArtifactQuerySqlContextFactoryImplTest { CriteriaSet criteriaSet = new CriteriaSet(); Options options = OptionsUtil.createOptions(); - criteriaSet.add(new CriteriaBranch(CoreBranches.COMMON)); + criteriaSet.add(new CriteriaBranch(CoreBranches.COMMON.getUuid())); queryData = new QueryData(criteriaSet, options); when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */"); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java index c45042b7d61..2d735b1e15c 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java @@ -55,7 +55,7 @@ public class LoadDeltasBetweenTxsOnTheSameBranch extends AbstractDatastoreCallab this.changeItemLoader = new ChangeItemLoader(jdbcClient, changeByGammaId); } - private long getBranchId() { + private Long getBranchId() { return getEndTx().getBranchId(); } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java index 1012e137055..340b00bb6c6 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java @@ -17,8 +17,6 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.eclipse.osee.executor.admin.HasCancellation; -import org.eclipse.osee.framework.core.data.IOseeBranch; -import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.core.enums.LoadLevel; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.model.change.ChangeItem; @@ -90,7 +88,7 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory { } private Set<Integer> determineWhichArtifactsNotOnDestination(HasCancellation cancellation, OrcsSession session, Set<Integer> artIds, TransactionReadable destTx) throws OseeCoreException { - DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, getBranch(destTx), artIds); + DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, destTx.getBranchId(), artIds); final Set<Integer> missingArtIds = new LinkedHashSet<>(artIds); loader.includeDeletedArtifacts(); loader.fromTransaction(destTx.getGuid()); @@ -109,7 +107,7 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory { final Set<ChangeItem> toReturn = new LinkedHashSet<>(); final Set<RelationData> relations = new LinkedHashSet<>(); - DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, getBranch(sourceTx), missingArtIds); + DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, sourceTx.getBranchId(), missingArtIds); loader.withLoadLevel(LoadLevel.ALL); loader.includeDeletedArtifacts(); loader.fromTransaction(sourceTx.getGuid()); @@ -163,15 +161,11 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory { return toReturn; } - private IOseeBranch getBranch(TransactionReadable tx) { - return TokenFactory.createBranch(tx.getBranchId(), "Missing Change Items"); - } - private Set<ChangeItem> createExistingRelations(HasCancellation cancellation, OrcsSession session, TransactionReadable destTx, final Multimap<Integer, RelationData> relationChangesToAdd) throws OseeCoreException { final Set<ChangeItem> toReturn = new LinkedHashSet<>(); DataLoader loader = - dataLoaderFactory.newDataLoaderFromIds(session, getBranch(destTx), relationChangesToAdd.keySet()); + dataLoaderFactory.newDataLoaderFromIds(session, destTx.getBranchId(), relationChangesToAdd.keySet()); loader.fromTransaction(destTx.getGuid()); loader.load(cancellation, new LoadDataHandlerAdapter() { @@ -194,9 +188,8 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory { } private ChangeItem createArtifactChangeItem(ArtifactData data) throws OseeCoreException { - ChangeItem artChange = - ChangeItemUtil.newArtifactChange(data.getLocalId(), data.getTypeUuid(), data.getVersion().getGammaId(), - determineModType(data)); + ChangeItem artChange = ChangeItemUtil.newArtifactChange(data.getLocalId(), data.getTypeUuid(), + data.getVersion().getGammaId(), determineModType(data)); return artChange; } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java index 1425274d4ee..91695dc4f2b 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataFactoryImpl.java @@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.db.internal.loader; import org.eclipse.osee.framework.core.data.HasLocalId; 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.enums.ModificationType; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -47,13 +46,13 @@ public class DataFactoryImpl implements DataFactory { } @Override - public ArtifactData create(IOseeBranch branch, IArtifactType token, String guid) throws OseeCoreException { + public ArtifactData create(Long branch, IArtifactType token, String guid) throws OseeCoreException { return this.create(branch, token, guid, idFactory.getNextArtifactId()); } @Override - public ArtifactData create(IOseeBranch branch, IArtifactType token, String guid, long uuid) throws OseeCoreException { - Conditions.checkNotNull(branch, "branch"); + public ArtifactData create(Long branchId, IArtifactType token, String guid, long artifactId) throws OseeCoreException { + Conditions.checkNotNull(branchId, "branch"); Conditions.checkExpressionFailOnTrue(artifactCache.isAbstract(token), "Cannot create an instance of abstract type [%s]", token); @@ -64,15 +63,16 @@ public class DataFactoryImpl implements DataFactory { "Invalid guid [%s] during artifact creation [type: %s]", guidToSet, token); VersionData version = objectFactory.createDefaultVersionData(); - version.setBranchId(branch.getUuid()); + version.setBranchId(branchId); ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE; - ArtifactData artifactData = objectFactory.createArtifactData(version, (int) uuid, token, modType, guidToSet); + ArtifactData artifactData = + objectFactory.createArtifactData(version, (int) artifactId, token, modType, guidToSet); return artifactData; } @Override - public ArtifactData copy(IOseeBranch destination, ArtifactData source) throws OseeCoreException { + public ArtifactData copy(Long destination, ArtifactData source) throws OseeCoreException { ArtifactData copy = objectFactory.createCopy(source); updateDataForCopy(destination, copy); copy.setGuid(idFactory.getUniqueGuid(null)); @@ -81,7 +81,7 @@ public class DataFactoryImpl implements DataFactory { } @Override - public AttributeData introduce(IOseeBranch destination, AttributeData source) throws OseeCoreException { + public AttributeData introduce(Long destination, AttributeData source) throws OseeCoreException { AttributeData newVersion = objectFactory.createCopy(source); newVersion.setUseBackingData(true); updateDataForIntroduce(destination, newVersion); @@ -98,7 +98,7 @@ public class DataFactoryImpl implements DataFactory { } @Override - public AttributeData copy(IOseeBranch destination, AttributeData orcsData) throws OseeCoreException { + public AttributeData copy(Long destination, AttributeData orcsData) throws OseeCoreException { AttributeData copy = objectFactory.createCopy(orcsData); updateDataForCopy(destination, copy); copy.setLocalId(RelationalConstants.DEFAULT_ITEM_ID); @@ -106,7 +106,7 @@ public class DataFactoryImpl implements DataFactory { } @Override - public ArtifactData introduce(IOseeBranch destination, ArtifactData source) throws OseeCoreException { + public ArtifactData introduce(Long destination, ArtifactData source) throws OseeCoreException { ArtifactData newVersion = objectFactory.createCopy(source); newVersion.setUseBackingData(true); updateDataForIntroduce(destination, newVersion); @@ -114,9 +114,9 @@ public class DataFactoryImpl implements DataFactory { } @Override - public RelationData createRelationData(IRelationType relationType, IOseeBranch branch, HasLocalId<Integer> aArt, HasLocalId<Integer> bArt, String rationale) throws OseeCoreException { + public RelationData createRelationData(IRelationType relationType, Long branchId, HasLocalId<Integer> aArt, HasLocalId<Integer> bArt, String rationale) throws OseeCoreException { VersionData version = objectFactory.createDefaultVersionData(); - version.setBranchId(branch.getUuid()); + version.setBranchId(branchId); ModificationType modType = RelationalConstants.DEFAULT_MODIFICATION_TYPE; Integer relationId = RelationalConstants.DEFAULT_ITEM_ID; return objectFactory.createRelationData(version, relationId, relationType, modType, aArt.getLocalId(), @@ -124,7 +124,7 @@ public class DataFactoryImpl implements DataFactory { } @Override - public RelationData introduce(IOseeBranch destination, RelationData source) { + public RelationData introduce(Long destination, RelationData source) { RelationData newVersion = objectFactory.createCopy(source); newVersion.setUseBackingData(true); updateDataForIntroduce(destination, newVersion); @@ -146,9 +146,9 @@ public class DataFactoryImpl implements DataFactory { return objectFactory.createCopy(source); } - private void updateDataForCopy(IOseeBranch destination, OrcsData data) throws OseeCoreException { + private void updateDataForCopy(Long destination, OrcsData data) throws OseeCoreException { VersionData version = data.getVersion(); - version.setBranchId(destination.getUuid()); + version.setBranchId(destination); version.setTransactionId(RelationalConstants.TRANSACTION_SENTINEL); version.setStripeId(RelationalConstants.TRANSACTION_SENTINEL); version.setHistorical(false); @@ -157,9 +157,9 @@ public class DataFactoryImpl implements DataFactory { data.setModType(ModificationType.NEW); } - private void updateDataForIntroduce(IOseeBranch destination, OrcsData data) throws OseeCoreException { + private void updateDataForIntroduce(Long destination, OrcsData data) throws OseeCoreException { VersionData version = data.getVersion(); - version.setBranchId(destination.getUuid()); + version.setBranchId(destination); version.setHistorical(false); version.setTransactionId(RelationalConstants.TRANSACTION_SENTINEL); // do not clear gammaId for introduce case so we reuse the same version diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java index 7e4fcbbc3ba..e954d47c3d7 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImpl.java @@ -13,7 +13,6 @@ package org.eclipse.osee.orcs.db.internal.loader; import java.util.Arrays; import java.util.Collection; import org.eclipse.osee.executor.admin.HasCancellation; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.framework.jdk.core.util.Lib; @@ -102,27 +101,27 @@ public class DataLoaderFactoryImpl implements DataLoaderFactory { } @Override - public DataLoader newDataLoaderFromIds(OrcsSession session, IOseeBranch branch, Integer... ids) throws OseeCoreException { - return newDataLoaderFromIds(session, branch, Arrays.asList(ids)); + public DataLoader newDataLoaderFromIds(OrcsSession session, Long branchId, Integer... ids) throws OseeCoreException { + return newDataLoaderFromIds(session, branchId, Arrays.asList(ids)); } @Override - public DataLoader newDataLoaderFromIds(OrcsSession session, IOseeBranch branch, Collection<Integer> ids) throws OseeCoreException { - Conditions.checkNotNull(branch, "branch"); + public DataLoader newDataLoaderFromIds(OrcsSession session, Long branchId, Collection<Integer> ids) throws OseeCoreException { + Conditions.checkNotNull(branchId, "branch"); Options options = OptionsUtil.createOptions(); - return new DataLoaderImpl(logger, ids, options, session, branch, loader, joinFactory); + return new DataLoaderImpl(logger, ids, options, session, branchId, loader, joinFactory); } @Override - public DataLoader newDataLoaderFromGuids(OrcsSession session, IOseeBranch branch, String... guids) throws OseeCoreException { - return newDataLoaderFromGuids(session, branch, Arrays.asList(guids)); + public DataLoader newDataLoaderFromGuids(OrcsSession session, Long branchId, String... guids) throws OseeCoreException { + return newDataLoaderFromGuids(session, branchId, Arrays.asList(guids)); } @Override - public DataLoader newDataLoaderFromGuids(OrcsSession session, IOseeBranch branch, Collection<String> guids) throws OseeCoreException { - Conditions.checkNotNull(branch, "branch"); + public DataLoader newDataLoaderFromGuids(OrcsSession session, Long branchId, Collection<String> guids) throws OseeCoreException { + Conditions.checkNotNull(branchId, "branch"); Options options = OptionsUtil.createOptions(); - return new DataLoaderImpl(logger, options, session, branch, loader, guids, joinFactory); + return new DataLoaderImpl(logger, options, session, branchId, loader, guids, joinFactory); } @SuppressWarnings("unchecked") diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java index 5f64d9d5256..3f12250c59a 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderImpl.java @@ -16,7 +16,6 @@ import java.util.HashSet; import java.util.Set; import org.eclipse.osee.executor.admin.HasCancellation; 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.enums.LoadLevel; import org.eclipse.osee.framework.core.exception.OseeExceptions; @@ -51,38 +50,32 @@ public class DataLoaderImpl implements DataLoader { private final Options options; private final OrcsSession session; - private final IOseeBranch branch; + private final Long branchId; private final SqlObjectLoader sqlLoader; private final SqlJoinFactory joinFactory; - public DataLoaderImpl(Log logger, AbstractLoadExecutor loadExecutor, Options options, OrcsSession session, IOseeBranch branch, SqlObjectLoader sqlLoader, SqlJoinFactory joinFactory) { - this.logger = logger; + public DataLoaderImpl(Log logger, AbstractLoadExecutor loadExecutor, Options options, OrcsSession session, Long branchId, SqlObjectLoader sqlLoader, SqlJoinFactory joinFactory) { + this(logger, options, session, branchId, sqlLoader, joinFactory); this.loadExecutor = loadExecutor; - this.options = options; - this.session = session; - this.branch = branch; - this.sqlLoader = sqlLoader; - this.joinFactory = joinFactory; } - public DataLoaderImpl(Log logger, Collection<Integer> artifactIds, Options options, OrcsSession session, IOseeBranch branch, SqlObjectLoader sqlLoader, SqlJoinFactory joinFactory) { - this.logger = logger; - this.options = options; - this.session = session; - this.branch = branch; - this.sqlLoader = sqlLoader; - this.joinFactory = joinFactory; + public DataLoaderImpl(Log logger, Collection<Integer> artifactIds, Options options, OrcsSession session, Long branchId, SqlObjectLoader sqlLoader, SqlJoinFactory joinFactory) { + this(logger, options, session, branchId, sqlLoader, joinFactory); withArtifactIds(artifactIds); } - public DataLoaderImpl(Log logger, Options options, OrcsSession session, IOseeBranch branch, SqlObjectLoader sqlLoader, Collection<String> artifactIds, SqlJoinFactory joinFactory) { + public DataLoaderImpl(Log logger, Options options, OrcsSession session, Long branchId, SqlObjectLoader sqlLoader, Collection<String> artifactIds, SqlJoinFactory joinFactory) { + this(logger, options, session, branchId, sqlLoader, joinFactory); + withArtifactGuids(artifactIds); + } + + private DataLoaderImpl(Log logger, Options options, OrcsSession session, Long branchId, SqlObjectLoader sqlLoader, SqlJoinFactory joinFactory) { this.logger = logger; this.options = options; this.session = session; - this.branch = branch; + this.branchId = branchId; this.sqlLoader = sqlLoader; this.joinFactory = joinFactory; - withArtifactGuids(artifactIds); } public DataLoader resetToDefaults() { @@ -190,13 +183,13 @@ public class DataLoaderImpl implements DataLoader { private DataLoader withArtifactIds(Collection<Integer> artifactIds) { loadExecutor = - new LoadExecutor(sqlLoader, sqlLoader.getDatabaseService(), joinFactory, session, branch, artifactIds); + new LoadExecutor(sqlLoader, sqlLoader.getDatabaseService(), joinFactory, session, branchId, artifactIds); return this; } private DataLoader withArtifactGuids(Collection<String> artifactGuids) { - loadExecutor = - new UuidsLoadExecutor(sqlLoader, sqlLoader.getDatabaseService(), joinFactory, session, branch, artifactGuids); + loadExecutor = new UuidsLoadExecutor(sqlLoader, sqlLoader.getDatabaseService(), joinFactory, session, branchId, + artifactGuids); return this; } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java index d32b299afef..9545e1ed714 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/LoadSqlContext.java @@ -10,33 +10,24 @@ *******************************************************************************/ package org.eclipse.osee.orcs.db.internal.loader; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.core.ds.LoadContext; import org.eclipse.osee.orcs.core.ds.Options; -import org.eclipse.osee.orcs.data.HasBranch; import org.eclipse.osee.orcs.db.internal.sql.SqlContextImpl; /** * @author Roberto E. Escobar */ -public class LoadSqlContext extends SqlContextImpl implements LoadContext, HasBranch { +public class LoadSqlContext extends SqlContextImpl implements LoadContext { - private final IOseeBranch branch; + private final Long branchId; - public LoadSqlContext(OrcsSession session, Options options, IOseeBranch branch) { + public LoadSqlContext(OrcsSession session, Options options, Long branchId) { super(session, options); - this.branch = branch; + this.branchId = branchId; } - @Override - public IOseeBranch getBranch() { - return branch; - } - - @Override public long getBranchUuid() { - return branch.getUuid(); + return branchId; } - } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java index 506b9f02cf2..c6bb313b351 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/SqlObjectLoader.java @@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.db.internal.loader; import java.util.concurrent.CancellationException; import org.eclipse.osee.executor.admin.HasCancellation; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.LoadLevel; import org.eclipse.osee.framework.core.sql.OseeSql; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -192,16 +191,16 @@ public class SqlObjectLoader { protected void loadDescription(LoadDataHandler builder, final LoadSqlContext loadContext) throws OseeCoreException { OrcsSession session = loadContext.getSession(); Options options = loadContext.getOptions(); - IOseeBranch branch = loadContext.getBranch(); + Long branchId = loadContext.getBranchUuid(); int transactionLoaded; if (OptionsUtil.isHeadTransaction(options)) { - transactionLoaded = loadHeadTransactionId(branch); + transactionLoaded = loadHeadTransactionId(branchId); } else { transactionLoaded = OptionsUtil.getFromTransaction(options); } - LoadDescription description = createDescription(session, options, branch, transactionLoaded); + LoadDescription description = createDescription(session, options, branchId, transactionLoaded); builder.onLoadDescription(description); } @@ -229,10 +228,9 @@ public class SqlObjectLoader { } } - protected int loadHeadTransactionId(IOseeBranch branch) throws OseeCoreException { + protected int loadHeadTransactionId(Long branchId) throws OseeCoreException { String sql = sqlProvider.getSql(OseeSql.TX_GET_MAX_AS_LARGEST_TX); - return getDatabaseService().runPreparedQueryFetchObject(RelationalConstants.TRANSACTION_SENTINEL, sql, - branch.getUuid()); + return getDatabaseService().runPreparedQueryFetchObject(RelationalConstants.TRANSACTION_SENTINEL, sql, branchId); } protected <H> void load(AbstractLoadProcessor<H> processor, H handler, SqlContext loadContext, int fetchSize) throws OseeCoreException { @@ -283,11 +281,11 @@ public class SqlObjectLoader { return createDescription(session, options, null, -1, data); } - private static LoadDescription createDescription(final OrcsSession session, final Options options, final IOseeBranch branch, final int transactionLoaded) { - return createDescription(session, options, branch, transactionLoaded, null); + private static LoadDescription createDescription(final OrcsSession session, final Options options, final Long branchId, final int transactionLoaded) { + return createDescription(session, options, branchId, transactionLoaded, null); } - private static LoadDescription createDescription(final OrcsSession session, final Options options, final IOseeBranch branch, final int transactionLoaded, final ResultObjectDescription data) { + private static LoadDescription createDescription(final OrcsSession session, final Options options, final Long branchId, final int transactionLoaded, final ResultObjectDescription data) { return new LoadDescription() { @Override @@ -301,13 +299,8 @@ public class SqlObjectLoader { } @Override - public IOseeBranch getBranch() { - return branch; - } - - @Override - public long getBranchUuid() { - return branch.getUuid(); + public Long getBranchId() { + return branchId; } @Override @@ -317,7 +310,7 @@ public class SqlObjectLoader { @Override public boolean isMultiBranch() { - return getBranch() == null; + return getBranchId() == null; } @Override diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionDataImpl.java index 1b6a4e70b0a..54db63ebda0 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionDataImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/VersionDataImpl.java @@ -18,7 +18,7 @@ import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants; */ public class VersionDataImpl implements VersionData { - private Long branchUuid = RelationalConstants.BRANCH_SENTINEL; + private Long branchId = RelationalConstants.BRANCH_SENTINEL; private int txId = RelationalConstants.TRANSACTION_SENTINEL; private long gamma = RelationalConstants.GAMMA_SENTINEL; private boolean historical = RelationalConstants.IS_HISTORICAL_DEFAULT; @@ -59,13 +59,13 @@ public class VersionDataImpl implements VersionData { } @Override - public long getBranchId() { - return branchUuid; + public Long getBranchId() { + return branchId; } @Override - public void setBranchId(long branchUuid) { - this.branchUuid = branchUuid; + public void setBranchId(Long branchUuid) { + this.branchId = branchUuid; } @Override @@ -87,7 +87,7 @@ public class VersionDataImpl implements VersionData { public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + branchUuid.hashCode(); + result = prime * result + branchId.hashCode(); result = prime * result + (int) (gamma ^ (gamma >>> 32)); result = prime * result + (historical ? 1231 : 1237); result = prime * result + stripeId; @@ -107,7 +107,7 @@ public class VersionDataImpl implements VersionData { return false; } VersionDataImpl other = (VersionDataImpl) obj; - if (branchUuid != other.branchUuid) { + if (branchId != other.branchId) { return false; } if (gamma != other.gamma) { @@ -127,7 +127,7 @@ public class VersionDataImpl implements VersionData { @Override public String toString() { - return "Version [branchUuid=" + branchUuid + ", txId=" + txId + ", gamma=" + gamma + ", historical=" + historical + ", stripeId=" + stripeId + "]"; + return "Version [branchUuid=" + branchId + ", txId=" + txId + ", gamma=" + gamma + ", historical=" + historical + ", stripeId=" + stripeId + "]"; } @Override diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/ArtifactQueryContextLoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/ArtifactQueryContextLoadExecutor.java index 6dc8b256221..3a21c6dca13 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/ArtifactQueryContextLoadExecutor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/ArtifactQueryContextLoadExecutor.java @@ -50,7 +50,7 @@ public class ArtifactQueryContextLoadExecutor extends AbstractLoadExecutor { ArtifactJoinQuery join = createArtifactIdJoin(getJdbcClient(), cancellation, fetchSize); - LoadSqlContext loadContext = new LoadSqlContext(queryContext.getSession(), options, queryContext.getBranch()); + LoadSqlContext loadContext = new LoadSqlContext(queryContext.getSession(), options, queryContext.getBranchUuid()); getLoader().loadArtifacts(cancellation, handler, join, criteria, loadContext, fetchSize); } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java index 5e7473fa8d8..5496b2f4131 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/LoadExecutor.java @@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.db.internal.loader.executors; import java.util.Collection; import org.eclipse.osee.executor.admin.HasCancellation; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.jdbc.JdbcClient; import org.eclipse.osee.orcs.OrcsSession; @@ -33,14 +32,14 @@ public class LoadExecutor extends AbstractLoadExecutor { private final SqlJoinFactory joinFactory; private final OrcsSession session; - private final IOseeBranch branch; + private final Long branchId; private final Collection<Integer> artifactIds; - public LoadExecutor(SqlObjectLoader loader, JdbcClient jdbcClient, SqlJoinFactory joinFactory, OrcsSession session, IOseeBranch branch, Collection<Integer> artifactIds) { + public LoadExecutor(SqlObjectLoader loader, JdbcClient jdbcClient, SqlJoinFactory joinFactory, OrcsSession session, Long branchId, Collection<Integer> artifactIds) { super(loader, jdbcClient); this.joinFactory = joinFactory; this.session = session; - this.branch = branch; + this.branchId = branchId; this.artifactIds = artifactIds; } @@ -51,10 +50,10 @@ public class LoadExecutor extends AbstractLoadExecutor { ArtifactJoinQuery join = joinFactory.createArtifactJoinQuery(); Integer transactionId = OptionsUtil.getFromTransaction(options); for (Integer artId : artifactIds) { - join.add(artId, branch.getUuid(), transactionId); + join.add(artId, branchId, transactionId); } - LoadSqlContext loadContext = new LoadSqlContext(session, options, branch); + LoadSqlContext loadContext = new LoadSqlContext(session, options, branchId); int fetchSize = LoadUtil.computeFetchSize(artifactIds.size()); getLoader().loadArtifacts(cancellation, handler, join, criteria, loadContext, fetchSize); } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java index f87b27d0818..f986a19287f 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java @@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.db.internal.loader.executors; import java.util.Collection; import org.eclipse.osee.executor.admin.HasCancellation; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.jdbc.JdbcClient; @@ -39,14 +38,14 @@ public class UuidsLoadExecutor extends AbstractLoadExecutor { private final SqlJoinFactory joinFactory; private final OrcsSession session; - private final IOseeBranch branch; + private final Long branchId; private final Collection<String> artifactIds; - public UuidsLoadExecutor(SqlObjectLoader loader, JdbcClient jdbcClient, SqlJoinFactory joinFactory, OrcsSession session, IOseeBranch branch, Collection<String> artifactIds) { + public UuidsLoadExecutor(SqlObjectLoader loader, JdbcClient jdbcClient, SqlJoinFactory joinFactory, OrcsSession session, Long branchId, Collection<String> artifactIds) { super(loader, jdbcClient); this.joinFactory = joinFactory; this.session = session; - this.branch = branch; + this.branchId = branchId; this.artifactIds = artifactIds; } @@ -55,7 +54,7 @@ public class UuidsLoadExecutor extends AbstractLoadExecutor { checkCancelled(cancellation); if (!artifactIds.isEmpty()) { ArtifactJoinQuery join = createIdJoin(getJdbcClient(), options); - LoadSqlContext loadContext = new LoadSqlContext(session, options, branch); + LoadSqlContext loadContext = new LoadSqlContext(session, options, branchId); int fetchSize = LoadUtil.computeFetchSize(artifactIds.size()); getLoader().loadArtifacts(cancellation, handler, join, criteria, loadContext, fetchSize); } @@ -80,7 +79,7 @@ public class UuidsLoadExecutor extends AbstractLoadExecutor { chStmt.runPreparedQuery(artifactIds.size(), GUIDS_TO_IDS, guidJoin.getQueryId()); while (chStmt.next()) { Integer artId = chStmt.getInt("art_id"); - toReturn.add(artId, branch.getUuid(), transactionId); + toReturn.add(artId, branchId, transactionId); } } finally { Lib.close(chStmt); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java index 5d150aa195c..c655b79fea4 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContext.java @@ -10,36 +10,28 @@ *******************************************************************************/ package org.eclipse.osee.orcs.db.internal.search.engines; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.core.ds.Options; -import org.eclipse.osee.orcs.data.HasBranch; import org.eclipse.osee.orcs.db.internal.search.QuerySqlContext; /** * @author Roberto E. Escobar */ -public class ArtifactQuerySqlContext extends QuerySqlContext implements HasBranch { +public class ArtifactQuerySqlContext extends QuerySqlContext { - private final IOseeBranch branch; + private final Long branchId; - public ArtifactQuerySqlContext(OrcsSession session, IOseeBranch branch, Options options) { + public ArtifactQuerySqlContext(OrcsSession session, Long branchId, Options options) { super(session, options, ObjectQueryType.ARTIFACT); - this.branch = branch; + this.branchId = branchId; } - @Override - public IOseeBranch getBranch() { - return branch; - } - - @Override public long getBranchUuid() { - return branch.getUuid(); + return branchId; } @Override public String toString() { - return "ArtifactQuerySqlContext [branch=" + branch + "(" + super.toString() + ")]"; + return "ArtifactQuerySqlContext [branch=" + branchId + "(" + super.toString() + ")]"; } } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImpl.java index c8359870b10..3b1ac093769 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImpl.java @@ -11,7 +11,6 @@ package org.eclipse.osee.orcs.db.internal.search.engines; import java.util.List; -import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.logger.Log; @@ -71,19 +70,19 @@ public class ArtifactQuerySqlContextFactoryImpl implements QuerySqlContextFactor } private QuerySqlContext createContext(OrcsSession session, QueryData queryData) throws OseeCoreException { - IOseeBranch branch = getBranchToSearch(queryData); + Long branch = getBranchToSearch(queryData); Conditions.checkNotNull(branch, "branch"); return new ArtifactQuerySqlContext(session, branch, queryData.getOptions()); } private AbstractSqlWriter createQueryWriter(SqlContext context, QueryData queryData, QueryType queryType) throws OseeCoreException { - IOseeBranch branch = getBranchToSearch(queryData); + Long branch = getBranchToSearch(queryData); Conditions.checkNotNull(branch, "branch"); - return new ArtifactQuerySqlWriter(logger, joinFactory, sqlProvider, context, queryType, branch.getUuid()); + return new ArtifactQuerySqlWriter(logger, joinFactory, sqlProvider, context, queryType, branch); } - private IOseeBranch getBranchToSearch(QueryData queryData) throws OseeCoreException { - IOseeBranch branch = null; + private Long getBranchToSearch(QueryData queryData) throws OseeCoreException { + Long branch = null; Iterable<? extends Criteria> criterias = queryData.getAllCriteria(); Optional<? extends Criteria> item = Iterables.tryFind(criterias, new Predicate<Criteria>() { @@ -96,7 +95,7 @@ public class ArtifactQuerySqlContextFactoryImpl implements QuerySqlContextFactor }); if (item.isPresent()) { HasBranch criteria = (HasBranch) item.get(); - branch = criteria.getBranch(); + branch = criteria.getBranchUuid(); } return branch; } 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 774711ab9cb..7faa811e9a8 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 org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -75,11 +74,11 @@ 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 String comment = transactionData.getComment(); - IOseeBranch branch = transactionData.getBranch(); + Long branchId = transactionData.getBranchId(); ArtifactReadable author = transactionData.getAuthor(); OrcsChangeSet changeSet = transactionData.getChangeSet(); - Conditions.checkNotNull(branch, "branch"); + Conditions.checkNotNull(branchId, "branch"); Conditions.checkNotNull(author, "transaction author"); Conditions.checkNotNullOrEmpty(comment, "transaction comment"); TransactionResult result = null; @@ -87,11 +86,10 @@ public final class CommitTransactionDatabaseTxCallable extends AbstractDatastore process(TxWritePhaseEnum.BEFORE_TX_WRITE); - TransactionReadable txRecord = createTransactionRecord(branch, author, comment, getNextTransactionId()); + TransactionReadable txRecord = createTransactionRecord(branchId, author, comment, getNextTransactionId()); writer.write(connection, txRecord, changeSet); - Object[] params = - new Object[] {BranchState.MODIFIED.getValue(), branch.getUuid(), BranchState.CREATED.getValue()}; + Object[] params = new Object[] {BranchState.MODIFIED.getValue(), branchId, BranchState.CREATED.getValue()}; getJdbcClient().runPreparedUpdate(connection, UPDATE_BRANCH_STATE, params); result = new TransactionResultImpl(txRecord, changeSet); @@ -111,14 +109,14 @@ public final class CommitTransactionDatabaseTxCallable extends AbstractDatastore process(TxWritePhaseEnum.AFTER_TX_WRITE); } - private TransactionReadable createTransactionRecord(IOseeBranch branch, ArtifactReadable author, String comment, int transactionNumber) throws OseeCoreException { + private TransactionReadable createTransactionRecord(Long branchId, ArtifactReadable author, String comment, int transactionNumber) throws OseeCoreException { int authorArtId = author.getLocalId(); TransactionDetailsType txType = TransactionDetailsType.NonBaselined; Date transactionTime = GlobalTime.GreenwichMeanTimestamp(); TransactionDataImpl created = new TransactionDataImpl(); created.setAuthorId(authorArtId); - created.setBranchId(branch.getUuid()); + created.setBranchId(branchId); created.setComment(comment); created.setCommit(RelationalConstants.ART_ID_SENTINEL); created.setDate(transactionTime); 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 028989066b2..a6e00ad4106 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 @@ -46,7 +46,7 @@ public class ComodificationCheck implements TransactionProcessor { txData.getChangeSet().accept(checker); if (!checker.getArtifactIds().isEmpty()) { - DataLoader loader = dataLoader.newDataLoaderFromIds(session, txData.getBranch(), checker.getArtifactIds()); + DataLoader loader = dataLoader.newDataLoaderFromIds(session, txData.getBranchId(), checker.getArtifactIds()); loader.withAttributeIds(checker.getAttributeIds()); loader.withRelationIds(checker.getRelationIds()); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/Address.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/Address.java index 45e19cb3446..681b747669e 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/Address.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/util/Address.java @@ -17,7 +17,7 @@ import org.eclipse.osee.framework.core.enums.TxChange; * @author Ryan D. Brooks */ public final class Address implements Comparable<Address> { - private final long branchUuid; + private final Long branchId; private final int itemId; private final int transactionId; private final long gammaId; @@ -27,9 +27,9 @@ public final class Address implements Comparable<Address> { private TxChange correctedTxCurrent; private boolean purge; - public Address(boolean isBaseline, long branchUuid, int itemId, int transactionId, long gammaId, ModificationType modType, TxChange txCurrent) { + public Address(boolean isBaseline, Long branchId, int itemId, int transactionId, long gammaId, ModificationType modType, TxChange txCurrent) { super(); - this.branchUuid = branchUuid; + this.branchId = branchId; this.itemId = itemId; this.transactionId = transactionId; this.gammaId = gammaId; @@ -43,7 +43,7 @@ public final class Address implements Comparable<Address> { } public boolean isSimilar(Address other) { - return other != null && other.itemId == itemId && other.branchUuid == branchUuid; + return other != null && other.itemId == itemId && other.branchId == branchId; } public boolean isSameTransaction(Address other) { @@ -91,8 +91,8 @@ public final class Address implements Comparable<Address> { this.purge = purge; } - public long getBranchId() { - return branchUuid; + public Long getBranchId() { + return branchId; } public int getItemId() { @@ -125,7 +125,7 @@ public final class Address implements Comparable<Address> { @Override public String toString() { - return "Address [branchUuid=" + branchUuid + ", gammaId=" + gammaId + ", itemId=" + itemId + ", modType=" + modType + ", transactionId=" + transactionId + ", txCurrent=" + txCurrent + "]"; + return "Address [branchUuid=" + branchId + ", gammaId=" + gammaId + ", itemId=" + itemId + ", modType=" + modType + ", transactionId=" + transactionId + ", txCurrent=" + txCurrent + "]"; } @Override diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TransactionEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TransactionEndpoint.java index d5a0afe4e03..15c41b9fd19 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TransactionEndpoint.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/TransactionEndpoint.java @@ -51,5 +51,5 @@ public interface TransactionEndpoint { @PUT @Path("{user}/branch/{branch-id}/transaction/{tx-id}/artifact/{art-id}/comment/{comment}") - Response replaceWithBaselineTxVersion(@PathParam("user") String userId, @PathParam("branch-id") long branchId, @PathParam("tx-id") int txId, @PathParam("art-id") int artId, @PathParam("comment") String comment); + Response replaceWithBaselineTxVersion(@PathParam("user") String userId, @PathParam("branch-id") Long branchId, @PathParam("tx-id") int txId, @PathParam("art-id") int artId, @PathParam("comment") String comment); }
\ No newline at end of file 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 34cadcc6981..20bac1c30c6 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 @@ -78,15 +78,15 @@ public class HtmlWriter { data.put("Name", artifact.getName()); data.put("Uuid", artifact.getGuid()); data.put("Tx Id", artifact.getTransaction()); - IOseeBranch branch = artifact.getBranch(); + Long branchId = artifact.getBranchUuid(); URI uri; if (isAtEndOfPath(uriInfo.getPath(), "artifact")) { - uri = uriInfo.getAbsolutePathBuilder().path("../../{uuid}").build(branch.getUuid()); + uri = uriInfo.getAbsolutePathBuilder().path("../../{uuid}").build(branchId); } else { - uri = uriInfo.getAbsolutePathBuilder().path("../../../{uuid}").build(branch.getUuid()); + uri = uriInfo.getAbsolutePathBuilder().path("../../../{uuid}").build(branchId); } - data.put("Branch", asLink(uri.toASCIIString(), branch.getName())); + data.put("Branch", asLink(uri.toASCIIString(), "Branch " + branchId)); Collection<? extends IAttributeType> types = artifact.getExistingAttributeTypes(); for (IAttributeType type : types) { @@ -147,7 +147,8 @@ public class HtmlWriter { } private IOseeBranch getBranchFromUuid(long uuid) { - return OrcsApplication.getOrcsApi().getQueryFactory().branchQuery().andUuids(uuid).getResultsAsId().getExactlyOne(); + return OrcsApplication.getOrcsApi().getQueryFactory().branchQuery().andUuids( + uuid).getResultsAsId().getExactlyOne(); } public Map<String, Object> toData(TransactionReadable txRecord) throws OseeCoreException { diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java index 68624b14ea9..ecb3a3debe0 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java @@ -65,7 +65,7 @@ public class TransactionEndpointImpl implements TransactionEndpoint { } @Override - public Response replaceWithBaselineTxVersion(String userId, long branchId, int txId, int artId, String comment) { + public Response replaceWithBaselineTxVersion(String userId, Long branchId, int txId, int artId, String comment) { return OrcsRestUtil.asResponse(orcsApi.getTransactionFactory().replaceWithBaselineTxVersion(userId, branchId, txId, artId, comment)); } 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 48e7d032a79..6998fbdf911 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 @@ -95,6 +95,4 @@ public interface ArtifactReadable extends ArtifactId, HasLocalId<Integer>, HasBr String getRationale(IRelationTypeSide typeAndSide, ArtifactReadable readable) throws OseeCoreException; - String toStringWithId(); - } diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/HasBranch.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/HasBranch.java index 48bcd2d5a5f..9b0494c310c 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/HasBranch.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/HasBranch.java @@ -10,15 +10,9 @@ *******************************************************************************/ package org.eclipse.osee.orcs.data; -import org.eclipse.osee.framework.core.data.IOseeBranch; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; - /** * @author Roberto E. Escobar */ public interface HasBranch { - - IOseeBranch getBranch() throws OseeCoreException; - - long getBranchUuid(); + Long getBranchUuid(); } 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 35db6a34095..db97b47bc49 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 @@ -31,7 +31,7 @@ import org.eclipse.osee.orcs.data.TransactionReadable; */ public interface TransactionBuilder { - IOseeBranch getBranch(); + Long getBranchId(); Identifiable<String> getAuthor(); diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionFactory.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionFactory.java index a6ec3190517..2aba2391084 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionFactory.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/transaction/TransactionFactory.java @@ -26,7 +26,7 @@ public interface TransactionFactory { TransactionBuilder createTransaction(IOseeBranch branch, ArtifactReadable userArtifact, String comment) throws OseeCoreException; - TransactionBuilder createTransaction(long uuid, ArtifactReadable userArtifact, String comment) throws OseeCoreException; + TransactionBuilder createTransaction(Long branchId, ArtifactReadable userArtifact, String comment) throws OseeCoreException; Callable<Integer> purgeTransaction(Collection<? extends ITransaction> transactions); @@ -42,7 +42,7 @@ public interface TransactionFactory { boolean setTxComment(int txId, String comment); - boolean replaceWithBaselineTxVersion(String userId, long branchId, int txId, int artId, String comment); + boolean replaceWithBaselineTxVersion(String userId, Long branchId, int txId, int artId, String comment); boolean purgeTxs(String txIds); } diff --git a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastBranchData.java b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastBranchData.java index edf6ea718ef..dd47ddc5297 100644 --- a/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastBranchData.java +++ b/plugins/org.eclipse.osee.vcast/src/org/eclipse/osee/vcast/model/VCastBranchData.java @@ -16,15 +16,15 @@ package org.eclipse.osee.vcast.model; public class VCastBranchData { private final int id; - private final long branchUuid; + private final Long branchId; private final int resultId; private final int resultLine; private final Boolean taken; - public VCastBranchData(int id, long branchUuid, int resultId, int resultLine, Boolean taken) { + public VCastBranchData(int id, Long branchId, int resultId, int resultLine, Boolean taken) { super(); this.id = id; - this.branchUuid = branchUuid; + this.branchId = branchId; this.resultId = resultId; this.resultLine = resultLine; this.taken = taken; @@ -34,8 +34,8 @@ public class VCastBranchData { return id; } - public long getBranchId() { - return branchUuid; + public Long getBranchId() { + return branchId; } public int getResultId() { |