diff options
69 files changed, 544 insertions, 623 deletions
diff --git a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/PopulateSawBuild2Actions.java b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/PopulateSawBuild2Actions.java index 45d44b3d716..10d5070c50c 100644 --- a/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/PopulateSawBuild2Actions.java +++ b/plugins/org.eclipse.osee.ats.client.demo/src/org/eclipse/osee/ats/client/demo/PopulateSawBuild2Actions.java @@ -350,9 +350,7 @@ public class PopulateSawBuild2Actions { throw new OseeArgumentException( new StringBuilder("Error creating working branch: ").append(result.getText()).toString()); } - AtsBranchUtil.createWorkingBranch_Create(reqTeam); - - DemoDbUtil.sleep(5000); + AtsBranchUtil.createWorkingBranch_Create(reqTeam, true); for (Artifact art : DemoDbUtil.getSoftwareRequirements(DEBUG, SoftwareRequirementStrs.Robot, reqTeam.getWorkingBranch())) { diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java index d39fda28f3a..3ac4dc8b7ea 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.ats.rest.internal.config; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import javax.ws.rs.GET; @@ -56,6 +54,8 @@ import org.eclipse.osee.orcs.OrcsApi; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.transaction.TransactionBuilder; +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; /** * @author Donald G. Dunne @@ -89,7 +89,7 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi { AtsConfiguration config = new AtsConfiguration(); configs.getConfigs().add(config); config.setName(art.getName()); - config.setUuid(art.getId()); + config.setUuid(art.getId()); config.setBranchUuid( Long.valueOf(art.getSoleAttributeValue(AtsAttributeTypes.AtsConfiguredBranch, "0L"))); config.setIsDefault(art.getSoleAttributeValue(AtsAttributeTypes.Default, false)); @@ -160,17 +160,16 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi { Conditions.checkNotNullOrEmpty(newBranchName, "newBranchName"); String userId = form.getFirst("userId"); Conditions.checkNotNullOrEmpty(userId, "UserId"); - IAtsUser user = atsServer.getUserService().getUserById(userId); + ArtifactId user = atsServer.getUserService().getUserById(userId).getStoreObject(); if (user == null) { logger.error("User by id [%s] does not exist", userId); } - ArtifactReadable userArt = atsServer.getArtifact(user); org.eclipse.osee.orcs.data.BranchReadable fromBranch = orcsApi.getQueryFactory().branchQuery().andUuids(fromBranchUuid).getResults().getExactlyOne(); // Create new baseline branch off Root Callable<BranchReadable> newBranchCallable = - orcsApi.getBranchOps().createTopLevelBranch(TokenFactory.createBranch(newBranchName), userArt); + orcsApi.getBranchOps().createTopLevelBranch(TokenFactory.createBranch(newBranchName), user); BranchReadable newBranch; try { newBranch = newBranchCallable.call(); @@ -180,16 +179,16 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi { long newBranchUuid = newBranch.getUuid(); // Introduce all ATS heading artifacts to new branch - introduceAtsHeadingArtifacts(fromBranch, newBranch, userArt); + introduceAtsHeadingArtifacts(fromBranch, newBranch, user); // Create config artifact on Common - AtsConfiguration config = createConfigArtifactOnCommon(newBranchName, userArt, newBranchUuid); + AtsConfiguration config = createConfigArtifactOnCommon(newBranchName, user, newBranchUuid); // Return new branch uuid return config; } - private void introduceAtsHeadingArtifacts(org.eclipse.osee.orcs.data.BranchReadable fromBranch, BranchReadable newBranch, ArtifactReadable userArt) { + private void introduceAtsHeadingArtifacts(org.eclipse.osee.orcs.data.BranchReadable fromBranch, BranchReadable newBranch, ArtifactId userArt) { TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(newBranch, userArt, "Add ATS Configuration"); @@ -239,7 +238,7 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi { return artifact; } - private AtsConfiguration createConfigArtifactOnCommon(String branchName, ArtifactReadable userArt, long newBranchUuid) { + private AtsConfiguration createConfigArtifactOnCommon(String branchName, ArtifactId userArt, long newBranchUuid) { TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(CoreBranches.COMMON, userArt, "Add ATS Configuration"); AtsConfiguration config = new AtsConfiguration(); diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java index 267574cf640..9f946974e8b 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java @@ -144,7 +144,7 @@ public class UpdateAtsConfiguration { } @SuppressWarnings("unchecked") - public ArtifactId getOrCreateConfigFolder(ArtifactReadable userArt, XResultData rd) { + public ArtifactId getOrCreateConfigFolder(ArtifactId userArt, XResultData rd) { ArtifactReadable configFolderArt = atsServer.getOrcsApi().getQueryFactory().fromBranch(CoreBranches.COMMON).andIds( AtsArtifactToken.ConfigFolder).getResults().getAtMostOneOrNull(); @@ -191,7 +191,7 @@ public class UpdateAtsConfiguration { } @SuppressWarnings("unchecked") - public ArtifactId getOrCreateConfigsFolder(ArtifactReadable userArt, XResultData rd) { + public ArtifactId getOrCreateConfigsFolder(ArtifactId userArt, XResultData rd) { ArtifactId configFolderArt = getOrCreateConfigFolder(userArt, rd); ArtifactId configsFolderArt = atsServer.getOrcsApi().getQueryFactory().fromBranch(CoreBranches.COMMON).andIds( AtsArtifactToken.ConfigsFolder).getResults().getAtMostOneOrNull(); diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java index 8a26dccdeed..f49702c0be7 100644 --- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java +++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java @@ -133,8 +133,9 @@ public class AtsBranchServiceImpl extends AbstractAtsBranchService { ArtifactId artifact = teamWf.getStoreObject(); if (!commitArtifactIdMap.containsKey(artifact)) { txQuery.andCommitIds(artifact.getId().intValue()); - txQuery.getResults().forEach(tx -> commitArtifactIdMap.put(artifact, new TransactionRecord(tx.getId(), - tx.getBranch(), tx.getComment(), tx.getDate(), tx.getAuthorId(), tx.getCommit(), tx.getTxType()))); + txQuery.getResults().forEach( + tx -> commitArtifactIdMap.put(artifact, new TransactionRecord(tx.getId(), tx.getBranch(), tx.getComment(), + tx.getDate(), tx.getAuthor().getId().intValue(), tx.getCommitArt().getId().intValue(), tx.getTxType()))); } Collection<TransactionRecord> transactions = commitArtifactIdMap.getValues(artifact); return transactions == null ? Collections.emptyList() : transactions; diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/internal/AtsBranchManagerUpdateListener.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/internal/AtsBranchManagerUpdateListener.java index 4831ee38bca..101cd43772e 100644 --- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/internal/AtsBranchManagerUpdateListener.java +++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/internal/AtsBranchManagerUpdateListener.java @@ -45,8 +45,9 @@ public class AtsBranchManagerUpdateListener implements IBranchEventListener { return; } try { - Artifact assocArtInCache = - ArtifactCache.getActive(BranchManager.getAssociatedArtifactId(branchEvent.getSourceBranch()), COMMON); + Integer associatedArtifact = + BranchManager.getAssociatedArtifactId(branchEvent.getSourceBranch()).getId().intValue(); + Artifact assocArtInCache = ArtifactCache.getActive(associatedArtifact, COMMON); if (assocArtInCache != null && assocArtInCache instanceof TeamWorkFlowArtifact) { TeamWorkFlowArtifact teamArt = (TeamWorkFlowArtifact) assocArtInCache; if (branchEvent.getEventType() == BranchEventType.Added) { diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/BranchStateTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/BranchStateTest.java index d3ee4e84bd5..c57e31a2a7b 100644 --- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/BranchStateTest.java +++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/BranchStateTest.java @@ -12,6 +12,7 @@ package org.eclipse.osee.client.integration.tests.integration.skynet.core; import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO; import static org.eclipse.osee.framework.core.enums.DemoBranches.SAW_Bld_1; +import static org.eclipse.osee.framework.core.enums.SystemUser.OseeSystem; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -257,8 +258,7 @@ public class BranchStateTest { checkBranchWasRebaselined(originalBranchName, workingBranch); // Check that the associated artifact remained unchanged - assertEquals((long) BranchManager.getAssociatedArtifactId(workingBranch), - SystemUser.OseeSystem.getUuid().longValue()); + assertEquals(BranchManager.getAssociatedArtifactId(workingBranch), OseeSystem); Collection<IOseeBranch> branches = BranchManager.getBranchesByName(originalBranchName); assertEquals("Check only 1 original branch", 1, branches.size()); diff --git a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/SafetyWorkflowEventHandler.java b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/SafetyWorkflowEventHandler.java index b94f7382580..45c62fe7d17 100644 --- a/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/SafetyWorkflowEventHandler.java +++ b/plugins/org.eclipse.osee.define.report/src/org/eclipse/osee/define/report/internal/wordupdate/SafetyWorkflowEventHandler.java @@ -24,6 +24,7 @@ import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow; import org.eclipse.osee.ats.api.workflow.NewActionAdapter; import org.eclipse.osee.ats.core.users.AtsCoreUsers; import org.eclipse.osee.ats.rest.IAtsServer; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; @@ -132,13 +133,13 @@ public class SafetyWorkflowEventHandler implements EventHandler { private IAtsTeamWorkflow createSafetyAction(IAtsTeamWorkflow teamWf, ArtifactReadable userArt) { IAtsTeamWorkflow teamWorkflow = null; try { - IAtsActionableItem ai = atsServer.getCache().getByUuid(AtsArtifactToken.SafetyActionableItem.getId(), - IAtsActionableItem.class); + IAtsActionableItem ai = + atsServer.getCache().getByUuid(AtsArtifactToken.SafetyActionableItem.getId(), IAtsActionableItem.class); if (ai == null) { throw new OseeCoreException("Safety Actionable Item not configured"); } - IAtsTeamDefinition teamDef = atsServer.getCache().getByUuid( - AtsArtifactToken.SafetyTeamDefinition.getId(), IAtsTeamDefinition.class); + IAtsTeamDefinition teamDef = + atsServer.getCache().getByUuid(AtsArtifactToken.SafetyTeamDefinition.getId(), IAtsTeamDefinition.class); if (teamDef == null) { throw new OseeCoreException("Safety Team Definition not configured"); } diff --git a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/integration/util/DispositionInitializer.java b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/integration/util/DispositionInitializer.java index 55c4b189e6e..f91fb60b749 100644 --- a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/integration/util/DispositionInitializer.java +++ b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/integration/util/DispositionInitializer.java @@ -52,7 +52,8 @@ public class DispositionInitializer { public void initialize() throws Exception { - orcsApi.getBranchOps().createWorkingBranch(SAW_Bld_1_FOR_DISPO, getDispositionUser(), SAW_Bld_1, null).call(); + orcsApi.getBranchOps().createWorkingBranch(SAW_Bld_1_FOR_DISPO, getDispositionUser(), SAW_Bld_1, + ArtifactId.SENTINEL).call(); // create Dispo Config Art ArtifactReadable oseeSystem = findUser(); diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java index 1f0bd6ef4a3..09f2f25a01e 100644 --- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java +++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java @@ -227,7 +227,7 @@ public class OrcsStorageImpl implements Storage { IOseeBranch branch = TokenFactory.createBranch(normalizedName); try { - getBranchFactory().createWorkingBranch(branch, author, dispoBranch, null).call(); + getBranchFactory().createWorkingBranch(branch, author, dispoBranch, ArtifactId.SENTINEL).call(); } catch (Exception ex) { throw OseeCoreException.wrap(ex); } diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java index 1ecdc0de70d..a4c61ac50b8 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Set; import java.util.function.Predicate; import org.eclipse.osee.framework.core.data.Adaptable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.enums.BranchState; @@ -38,7 +39,7 @@ public class Branch extends NamedId implements IOseeBranch, Adaptable { private TransactionRecord parentTx; private TransactionRecord baselineTx; private Branch parent; - private Integer associatedArtifactId; + private ArtifactId associatedArtifact; public Branch(Long uuid, String name, BranchType branchType, BranchState branchState, boolean isArchived, boolean inheritsAccessControl) { super(uuid, name); @@ -64,12 +65,12 @@ public class Branch extends NamedId implements IOseeBranch, Adaptable { return isArchived; } - public Integer getAssociatedArtifactId() throws OseeCoreException { - return associatedArtifactId; + public ArtifactId getAssociatedArtifactId() { + return associatedArtifact; } - public void setAssociatedArtifactId(Integer artifactId) throws OseeCoreException { - this.associatedArtifactId = artifactId; + public void setAssociatedArtifact(ArtifactId artifact) { + this.associatedArtifact = artifact; } public TransactionRecord getBaseTransaction() throws OseeCoreException { diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchFilter.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchFilter.java index ade75a6b7f1..d7588962cbc 100644 --- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchFilter.java +++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchFilter.java @@ -47,7 +47,7 @@ public class BranchFilter implements Predicate<Branch> { @Override public boolean test(Branch branch) { - if (associatedArtifact != null && !branch.getAssociatedArtifactId().equals(associatedArtifact.getArtId())) { + if (associatedArtifact != null && !branch.getAssociatedArtifactId().equals(associatedArtifact)) { return false; } if (!BranchArchivedState.fromBoolean(branch.isArchived()).matches(archivedState)) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactId.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactId.java index 8811af501cf..f4cef005eae 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactId.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/ArtifactId.java @@ -20,6 +20,8 @@ import org.eclipse.osee.framework.jdk.core.type.Identifiable; */ public interface ArtifactId extends Identifiable<String>, Id { + public static final ArtifactId SENTINEL = ArtifactId.valueOf(Id.SENTINEL); + public Long getUuid(); public static ArtifactId valueOf(String id) { diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java index 29387384be8..3f141e87e63 100644 --- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java +++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/TokenFactory.java @@ -175,18 +175,17 @@ public final class TokenFactory { } } - private static class UserToken extends NamedIdentity<String> implements IUserToken { - + private static class UserToken extends NamedId implements IUserToken { private final String userId; private final boolean active; private final boolean admin; private final String email; + private final String guid; private final boolean creationRequired; - private final long uuid; - public UserToken(long uuid, String guid, String name, String userId, boolean active, boolean admin, String email, boolean creationRequired) { - super(guid, name); - this.uuid = uuid; + public UserToken(long id, String guid, String name, String userId, boolean active, boolean admin, String email, boolean creationRequired) { + super(id, name); + this.guid = guid; this.userId = userId; this.active = active; this.admin = admin; @@ -232,7 +231,12 @@ public final class TokenFactory { @Override public Long getUuid() { - return uuid; + return getId(); + } + + @Override + public String getGuid() { + return guid; } } diff --git a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java index a4bfa3f60c9..70389af20f6 100644 --- a/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java +++ b/plugins/org.eclipse.osee.framework.jdk.core/src/org/eclipse/osee/framework/jdk/core/type/BaseId.java @@ -29,11 +29,14 @@ public class BaseId implements Id, Cloneable { @Override public boolean equals(Object obj) { if (obj instanceof Id) { - return ((Id) obj).getId().equals(id); + return id.equals(((Id) obj).getId()); } if (obj instanceof Identity<?>) { return id.equals(((Identity<?>) obj).getGuid()); } + if (obj instanceof Long) { + return id.equals(obj); + } return false; } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java index a9429bda2b8..0ac3a45af7a 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/BranchManager.java @@ -13,6 +13,7 @@ package org.eclipse.osee.framework.skynet.core.artifact; import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; import static org.eclipse.osee.framework.core.enums.CoreBranches.SYSTEM_ROOT; +import static org.eclipse.osee.framework.core.enums.SystemUser.OseeSystem; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -28,6 +29,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.osee.framework.core.client.OseeClientProperties; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TokenFactory; @@ -36,7 +38,6 @@ import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.BranchType; import org.eclipse.osee.framework.core.enums.CoreBranches; -import org.eclipse.osee.framework.core.enums.SystemUser; import org.eclipse.osee.framework.core.exception.BranchDoesNotExist; import org.eclipse.osee.framework.core.exception.MultipleBranchesExist; import org.eclipse.osee.framework.core.model.Branch; @@ -236,16 +237,16 @@ public final class BranchManager { } public static IStatus isDeleteable(Collection<Artifact> artifacts) throws OseeCoreException { - List<Integer> artIdsToCheck = new LinkedList<>(); + List<ArtifactId> artIdsToCheck = new LinkedList<>(); for (Artifact art : artifacts) { - if (art.isOnBranch(CoreBranches.COMMON_ID)) { - artIdsToCheck.add(art.getArtId()); + if (art.isOnBranch(CoreBranches.COMMON)) { + artIdsToCheck.add(art); } } if (!artIdsToCheck.isEmpty()) { for (IOseeBranch branch : getCache().getAll()) { - Integer associatedArtifactId = getAssociatedArtifactId(branch); + ArtifactId associatedArtifactId = getAssociatedArtifactId(branch); if (getState(branch) != BranchState.DELETED && artIdsToCheck.contains(associatedArtifactId)) { return new Status(IStatus.ERROR, Activator.PLUGIN_ID, String.format("Cannot delete artId [%d] because it is the associated artifact of branch [%s]", @@ -433,11 +434,11 @@ public final class BranchManager { return mergeBranch; } - public static IOseeBranch createWorkingBranch(TransactionToken parentTransactionId, String childBranchName, Artifact associatedArtifact) throws OseeCoreException { + public static IOseeBranch createWorkingBranch(TransactionToken parentTransactionId, String childBranchName, ArtifactId associatedArtifact) throws OseeCoreException { return createWorkingBranch(parentTransactionId, childBranchName, Lib.generateUuid(), associatedArtifact); } - public static IOseeBranch createWorkingBranch(TransactionToken parentTransactionId, String childBranchName, Long childBranchUuid, Artifact associatedArtifact) throws OseeCoreException { + public static IOseeBranch createWorkingBranch(TransactionToken parentTransactionId, String childBranchName, Long childBranchUuid, ArtifactId associatedArtifact) throws OseeCoreException { Conditions.notNull(childBranchUuid, "childBranchUuid"); String creationComment = String.format("New Branch from %s (%s)", getBranchName(parentTransactionId), parentTransactionId.getId()); @@ -477,10 +478,10 @@ public final class BranchManager { } public static IOseeBranch createWorkingBranch(BranchId parentBranch, String childBranchName) throws OseeCoreException { - return createWorkingBranch(parentBranch, childBranchName, UserManager.getUser(SystemUser.OseeSystem)); + return createWorkingBranch(parentBranch, childBranchName, OseeSystem); } - public static IOseeBranch createWorkingBranch(BranchId parentBranch, String childBranchName, Artifact associatedArtifact) throws OseeCoreException { + public static IOseeBranch createWorkingBranch(BranchId parentBranch, String childBranchName, ArtifactId associatedArtifact) throws OseeCoreException { Conditions.checkNotNull(parentBranch, "Parent Branch"); Conditions.checkNotNull(childBranchName, "Child Branch Name"); Conditions.checkNotNull(associatedArtifact, "Associated Artifact"); @@ -489,10 +490,10 @@ public final class BranchManager { } public static IOseeBranch createWorkingBranch(BranchId parentBranch, IOseeBranch childBranch) throws OseeCoreException { - return createWorkingBranch(parentBranch, childBranch, UserManager.getUser(SystemUser.OseeSystem)); + return createWorkingBranch(parentBranch, childBranch, OseeSystem); } - public static IOseeBranch createWorkingBranch(BranchId parentBranch, IOseeBranch childBranch, Artifact associatedArtifact) throws OseeCoreException { + public static IOseeBranch createWorkingBranch(BranchId parentBranch, IOseeBranch childBranch, ArtifactId associatedArtifact) throws OseeCoreException { TransactionToken parentTransactionId = TransactionManager.getHeadTransaction(parentBranch); return createWorkingBranch(parentTransactionId, childBranch.getName(), childBranch.getUuid(), associatedArtifact); } @@ -501,22 +502,22 @@ public final class BranchManager { * Creates a new Branch based on the most recent transaction on the parent branch. */ public static BranchId createBaselineBranch(BranchId parentBranch, IOseeBranch childBranch) throws OseeCoreException { - return createBaselineBranch(parentBranch, childBranch, UserManager.getUser(SystemUser.OseeSystem)); + return createBaselineBranch(parentBranch, childBranch, OseeSystem); } - public static BranchId createBaselineBranch(BranchId parentBranch, IOseeBranch childBranch, Artifact associatedArtifact) throws OseeCoreException { + public static BranchId createBaselineBranch(BranchId parentBranch, IOseeBranch childBranch, ArtifactId associatedArtifact) throws OseeCoreException { TransactionToken parentTransactionId = TransactionManager.getHeadTransaction(parentBranch); String creationComment = String.format("Branch Creation for %s", childBranch.getName()); return createBranch(BranchType.BASELINE, parentTransactionId, childBranch.getName(), childBranch.getUuid(), associatedArtifact, creationComment); } - private static IOseeBranch createBranch(BranchType branchType, TransactionToken parentTransaction, String branchName, long branchUuid, Artifact associatedArtifact, String creationComment) { + private static IOseeBranch createBranch(BranchType branchType, TransactionToken parentTransaction, String branchName, long branchUuid, ArtifactId associatedArtifact, String creationComment) { return createBranch(branchType, parentTransaction, branchName, branchUuid, associatedArtifact, creationComment, -1, BranchId.SENTINEL); } - private static IOseeBranch createBranch(BranchType branchType, TransactionToken parentTransaction, String branchName, long branchUuid, Artifact associatedArtifact, String creationComment, int mergeAddressingQueryId, BranchId destinationBranch) throws OseeCoreException { + private static IOseeBranch createBranch(BranchType branchType, TransactionToken parentTransaction, String branchName, long branchUuid, ArtifactId associatedArtifact, String creationComment, int mergeAddressingQueryId, BranchId destinationBranch) throws OseeCoreException { CreateBranchHttpRequestOperation operation = new CreateBranchHttpRequestOperation(branchType, parentTransaction, branchName, branchUuid, associatedArtifact, creationComment, mergeAddressingQueryId, destinationBranch); Operations.executeWorkAndCheckStatus(operation); @@ -529,7 +530,7 @@ public final class BranchManager { * @param initializeArtifacts adds common artifacts needed by most normal root branches */ public static BranchId createTopLevelBranch(IOseeBranch branch) throws OseeCoreException { - return createBaselineBranch(SYSTEM_ROOT, branch, null); + return createBaselineBranch(SYSTEM_ROOT, branch, OseeSystem); } public static BranchId createTopLevelBranch(final String branchName) throws OseeCoreException { @@ -595,28 +596,28 @@ public final class BranchManager { } public static boolean isChangeManaged(BranchId branch) throws OseeCoreException { - Integer associatedArtifactId = getAssociatedArtifactId(branch); - return associatedArtifactId > 0 && !associatedArtifactId.equals(SystemUser.OseeSystem); + ArtifactId associatedArtifactId = getAssociatedArtifactId(branch); + return associatedArtifactId.isValid() && !associatedArtifactId.equals(OseeSystem); } - public static void setAssociatedArtifactId(BranchId branch, Integer artifactId) { + public static void setAssociatedArtifactId(BranchId branch, ArtifactId artifactId) { OseeClient client = ServiceUtil.getOseeClient(); BranchEndpoint proxy = client.getBranchEndpoint(); Response response = proxy.associateBranchToArtifact(branch.getId(), artifactId); if (javax.ws.rs.core.Response.Status.OK.getStatusCode() == response.getStatus()) { - getBranch(branch).setAssociatedArtifactId(artifactId); + getBranch(branch).setAssociatedArtifact(artifactId); } } - public static Integer getAssociatedArtifactId(BranchId branch) { + public static ArtifactId getAssociatedArtifactId(BranchId branch) { return getBranch(branch).getAssociatedArtifactId(); } public static Artifact getAssociatedArtifact(BranchId branch) throws OseeCoreException { - Integer associatedArtifactId = getAssociatedArtifactId(branch); - if (associatedArtifactId == null || associatedArtifactId.equals(-1)) { - return UserManager.getUser(SystemUser.OseeSystem); + ArtifactId associatedArtifactId = getAssociatedArtifactId(branch); + if (associatedArtifactId.isInvalid()) { + return UserManager.getUser(OseeSystem); } return ArtifactQuery.getArtifactFromId(associatedArtifactId, COMMON); } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java index de87d6bb3ef..13cde7f144b 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java @@ -106,6 +106,10 @@ public class ArtifactQuery { return getArtifactFromId(new Long(artId).intValue(), branch, EXCLUDE_DELETED); } + public static Artifact getArtifactFromId(ArtifactId artId, BranchId branch) { + return getArtifactFromId(artId.getId(), branch); + } + /** * search for exactly one artifact by one its id - otherwise throw an exception * diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java index 699523bde35..fbcc451c8f7 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java @@ -21,6 +21,7 @@ import java.util.logging.Level; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.BranchState; @@ -33,7 +34,6 @@ import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.logging.OseeLog; import org.eclipse.osee.framework.messaging.event.res.AttributeEventModificationType; import org.eclipse.osee.framework.skynet.core.AccessPolicy; -import org.eclipse.osee.framework.skynet.core.User; import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache; import org.eclipse.osee.framework.skynet.core.artifact.Attribute; @@ -65,15 +65,15 @@ import org.eclipse.osee.orcs.rest.model.Transaction; * @author Ryan D. Brooks */ public final class CommitBranchHttpRequestOperation extends AbstractOperation { - private final User user; + private final ArtifactId committer; private final BranchId sourceBranch; private final BranchId destinationBranch; private final boolean isArchiveAllowed; private final boolean skipChecksAndEvents; - public CommitBranchHttpRequestOperation(User user, BranchId sourceBranch, BranchId destinationBranch, boolean isArchiveAllowed, boolean skipChecksAndEvents) { + public CommitBranchHttpRequestOperation(ArtifactId committer, BranchId sourceBranch, BranchId destinationBranch, boolean isArchiveAllowed, boolean skipChecksAndEvents) { super("Commit " + sourceBranch, Activator.PLUGIN_ID); - this.user = user; + this.committer = committer; this.sourceBranch = sourceBranch; this.destinationBranch = destinationBranch; this.isArchiveAllowed = isArchiveAllowed; @@ -93,7 +93,7 @@ public final class CommitBranchHttpRequestOperation extends AbstractOperation { BranchCommitOptions options = new BranchCommitOptions(); options.setArchive(isArchiveAllowed); - options.setCommitterId(user.getArtId()); + options.setCommitter(committer); try { Response response = proxy.commitBranch(sourceBranch.getUuid(), destinationBranch.getUuid(), options); if (Status.CREATED.getStatusCode() == response.getStatus()) { diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CreateBranchHttpRequestOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CreateBranchHttpRequestOperation.java index 8a239375f23..890af60e0fc 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CreateBranchHttpRequestOperation.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CreateBranchHttpRequestOperation.java @@ -10,28 +10,27 @@ *******************************************************************************/ package org.eclipse.osee.framework.skynet.core.httpRequests; +import static org.eclipse.osee.framework.core.enums.SystemUser.OseeSystem; import java.net.URI; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.BranchType; -import org.eclipse.osee.framework.core.enums.SystemUser; import org.eclipse.osee.framework.core.operation.AbstractOperation; 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.util.Strings; import org.eclipse.osee.framework.skynet.core.UserManager; -import org.eclipse.osee.framework.skynet.core.artifact.Artifact; import org.eclipse.osee.framework.skynet.core.artifact.BranchManager; import org.eclipse.osee.framework.skynet.core.event.OseeEventManager; import org.eclipse.osee.framework.skynet.core.event.model.BranchEvent; import org.eclipse.osee.framework.skynet.core.event.model.BranchEventType; import org.eclipse.osee.framework.skynet.core.internal.Activator; import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil; -import org.eclipse.osee.framework.skynet.core.utility.DbUtil; import org.eclipse.osee.jaxrs.client.JaxRsExceptions; import org.eclipse.osee.orcs.rest.client.OseeClient; import org.eclipse.osee.orcs.rest.model.BranchEndpoint; @@ -45,7 +44,7 @@ public final class CreateBranchHttpRequestOperation extends AbstractOperation { private final BranchType branchType; private final TransactionToken parentTransaction; private final String branchName; - private final Artifact associatedArtifact; + private final ArtifactId associatedArtifact; private final String creationComment; private final int mergeAddressingQueryId; private final BranchId destinationBranch; @@ -53,12 +52,12 @@ public final class CreateBranchHttpRequestOperation extends AbstractOperation { private boolean txCopyBranchType; private final long branchUuid; - public CreateBranchHttpRequestOperation(BranchType branchType, TransactionToken parentTransaction, String branchName, long branchUuid, Artifact associatedArtifact, String creationComment) { + public CreateBranchHttpRequestOperation(BranchType branchType, TransactionToken parentTransaction, String branchName, long branchUuid, ArtifactId associatedArtifact, String creationComment) { this(branchType, parentTransaction, branchName, branchUuid, associatedArtifact, creationComment, -1, BranchId.SENTINEL); } - public CreateBranchHttpRequestOperation(BranchType branchType, TransactionToken parentTransaction, String branchName, long branchUuid, Artifact associatedArtifact, String creationComment, int mergeAddressingQueryId, BranchId destinationBranch) { + public CreateBranchHttpRequestOperation(BranchType branchType, TransactionToken parentTransaction, String branchName, long branchUuid, ArtifactId associatedArtifact, String creationComment, int mergeAddressingQueryId, BranchId destinationBranch) { super("Create branch " + branchName, Activator.PLUGIN_ID); this.branchType = branchType; this.parentTransaction = parentTransaction; @@ -81,8 +80,8 @@ public final class CreateBranchHttpRequestOperation extends AbstractOperation { BranchEndpoint proxy = client.getBranchEndpoint(); NewBranch data = new NewBranch(); - data.setAssociatedArtifactId(getAssociatedArtifactId(associatedArtifact)); - data.setAuthorId(getAuthorId()); + data.setAssociatedArtifact(associatedArtifact.isValid() ? associatedArtifact : OseeSystem); + data.setAuthor(UserManager.getUser()); data.setBranchName(branchName); data.setBranchType(branchType); data.setCreationComment(creationComment); @@ -126,21 +125,6 @@ public final class CreateBranchHttpRequestOperation extends AbstractOperation { return toReturn; } - private static int getAssociatedArtifactId(Artifact associatedArtifact) throws OseeCoreException { - int associatedArtifactId = -1; - if (associatedArtifact == null && !DbUtil.isDbInit()) { - associatedArtifact = UserManager.getUser(SystemUser.OseeSystem); - } - if (associatedArtifact != null) { - associatedArtifactId = associatedArtifact.getArtId(); - } - return associatedArtifactId; - } - - private static int getAuthorId() throws OseeCoreException { - return UserManager.getUser().getArtId(); - } - public IOseeBranch getNewBranch() { return newBranch; } diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java index f78190a2994..dfb5e369123 100644 --- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java +++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java @@ -3,6 +3,7 @@ package org.eclipse.osee.framework.skynet.core.internal.accessors; import static org.eclipse.osee.framework.core.enums.CoreBranches.SYSTEM_ROOT; import static org.eclipse.osee.jdbc.JdbcConstants.JDBC__MAX_FETCH_SIZE; import java.util.Date; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.BranchType; @@ -70,7 +71,7 @@ public class DatabaseBranchAccessor implements IOseeDataAccessor<Branch> { BranchState branchState = BranchState.getBranchState(stmt.getInt("branch_state")); boolean isArchived = BranchArchivedState.valueOf(stmt.getInt("archived")).isArchived(); boolean inheritAccessControl = stmt.getInt("inherit_access_control") == 1; - Integer artifactId = stmt.getInt("associated_art_id"); + ArtifactId artifactId = ArtifactId.valueOf(stmt.getLong("associated_art_id")); Branch branch = cache.getById(branchId); if (branch == null) { @@ -93,7 +94,7 @@ public class DatabaseBranchAccessor implements IOseeDataAccessor<Branch> { branch.setArchived(isArchived); branch.setInheritAccessControl(inheritAccessControl); } - branch.setAssociatedArtifactId(artifactId); + branch.setAssociatedArtifact(artifactId); return branch; } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java index 1a92e02163b..9c7d94e8b2b 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/BranchCreationHandler.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.framework.ui.skynet.commandHandlers.branch; +import static org.eclipse.osee.framework.core.enums.SystemUser.OseeSystem; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -73,7 +74,7 @@ public class BranchCreationHandler extends CommandHandler { if (dialog.isChecked()) { BranchManager.createWorkingBranchFromTx(parentTransactionId, dialog.getEntry(), null); } else { - BranchManager.createWorkingBranch(parentTransactionId, dialog.getEntry(), null); + BranchManager.createWorkingBranch(parentTransactionId, dialog.getEntry(), OseeSystem); } } diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/SetAssociatedBranchArtifactHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/SetAssociatedBranchArtifactHandler.java index c9f0b1f45b7..3e3d078e7a7 100644 --- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/SetAssociatedBranchArtifactHandler.java +++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/SetAssociatedBranchArtifactHandler.java @@ -16,6 +16,7 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.osee.framework.access.AccessControlManager; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -35,12 +36,12 @@ public class SetAssociatedBranchArtifactHandler extends CommandHandler { @Override public Object executeWithException(ExecutionEvent event, IStructuredSelection selection) throws OseeCoreException { IOseeBranch selectedBranch = Handlers.getBranchesFromStructuredSelection(selection).iterator().next(); - Integer artId = BranchManager.getAssociatedArtifactId(selectedBranch); + ArtifactId artId = BranchManager.getAssociatedArtifactId(selectedBranch); EntryDialog ed = new EntryDialog("Set Associated Artifact", - "Set Associated Artifact for Branch\n\n\"" + selectedBranch.getName() + "\"" + (artId != null ? "\n\nCurrently: " + artId : "") + "\n\nEnter new Artifact Id to associate:"); - ed.setEntry(String.valueOf(artId)); + "Set Associated Artifact for Branch\n\n\"" + selectedBranch.getName() + "\"\n\nCurrently: " + artId + "\n\nEnter new Artifact Id to associate:"); + ed.setEntry(String.valueOf(artId.getId())); if (ed.open() == 0) { - Integer newArtId = Integer.parseInt(ed.getEntry()); + ArtifactId newArtId = ArtifactId.valueOf(ed.getEntry()); Artifact associatedArtifact = ArtifactQuery.getArtifactFromId(newArtId, COMMON); if (MessageDialog.openConfirm(Displays.getActiveShell(), "Set Associated Artifact", "Set Associated Artifact for Branch\n\n\"" + selectedBranch.getName() + "\"\nto\nArtifact: " + associatedArtifact)) { diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/BranchDataFactoryTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/BranchDataFactoryTest.java index a80ab3d66a1..ed92a9d90c0 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/BranchDataFactoryTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/BranchDataFactoryTest.java @@ -14,6 +14,7 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TokenFactory; @@ -23,7 +24,6 @@ import org.eclipse.osee.framework.core.enums.BranchType; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.ResultSet; -import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.data.CreateBranchData; import org.eclipse.osee.orcs.search.BranchQuery; @@ -46,22 +46,20 @@ public class BranchDataFactoryTest { @Mock private BranchQuery branchQuery; @Mock private TransactionQuery txQuery; @Mock private QueryFactory queryFactory; - @Mock private ArtifactReadable author; - @Mock private ArtifactReadable associatedArtifact; @Mock private ResultSet<TransactionToken> results; @Mock private ResultSet<BranchReadable> branchResults; @Mock private BranchReadable parentBranch; // @formatter:on - private BranchDataFactory factory; + private final ArtifactId associatedArtifact = ArtifactId.valueOf(66); + private final ArtifactId author = ArtifactId.valueOf(55); private final TransactionToken txRecord = TransactionToken.valueOf(99, parentBranch); + private BranchDataFactory factory; @Before public void init() { MockitoAnnotations.initMocks(this); - when(author.getLocalId()).thenReturn(55); - when(associatedArtifact.getLocalId()).thenReturn(66); when(queryFactory.transactionQuery()).thenReturn(txQuery); when(queryFactory.branchQuery()).thenReturn(branchQuery); factory = new BranchDataFactory(queryFactory); @@ -88,7 +86,8 @@ public class BranchDataFactoryTest { verify(txQuery).andIsHead(CoreBranches.SYSTEM_ROOT); String comment = String.format("New Branch from %s (%s)", CoreBranches.SYSTEM_ROOT.getName(), txRecord); - assertData(result, branch.getName(), branch.getId(), BranchType.BASELINE, comment, txRecord, author, null, false); + assertData(result, branch.getName(), branch.getId(), BranchType.BASELINE, comment, txRecord, author, + ArtifactId.SENTINEL, false); } @Test @@ -119,31 +118,33 @@ public class BranchDataFactoryTest { public void testDataForCopyTxBranch() throws OseeCoreException { IOseeBranch branch = TokenFactory.createBranch("testDataForCopyTxBranch"); - CreateBranchData result = factory.createCopyTxBranchData(branch, author, txRecord, null); + CreateBranchData result = factory.createCopyTxBranchData(branch, author, txRecord, ArtifactId.SENTINEL); verify(txQuery).andTxId(txRecord); verify(branchQuery).andIds(txRecord.getBranch()); String comment = String.format("Transaction %d copied from %s to create Branch %s", txRecord.getId(), parentBranch.getName(), branch.getName()); - assertData(result, branch.getName(), branch.getId(), BranchType.WORKING, comment, txRecord, author, null, true); + assertData(result, branch.getName(), branch.getId(), BranchType.WORKING, comment, txRecord, author, + ArtifactId.SENTINEL, true); } @Test public void testDataForPortBranch() throws OseeCoreException { IOseeBranch branch = TokenFactory.createBranch("testDataForPortBranch"); - CreateBranchData result = factory.createPortBranchData(branch, author, txRecord, null); + CreateBranchData result = factory.createPortBranchData(branch, author, txRecord, ArtifactId.SENTINEL); verify(txQuery).andTxId(txRecord); verify(branchQuery).andIds(txRecord.getBranch()); String comment = String.format("Transaction %d ported from %s to create Branch %s", txRecord.getId(), parentBranch.getName(), branch.getName()); - assertData(result, branch.getName(), branch.getId(), BranchType.PORT, comment, txRecord, author, null, true); + assertData(result, branch.getName(), branch.getId(), BranchType.PORT, comment, txRecord, author, + ArtifactId.SENTINEL, true); } - private static void assertData(CreateBranchData actual, String branchName, Long branchUuid, BranchType type, String comment, TransactionId fromTx, ArtifactReadable author, ArtifactReadable associatedArtifact, boolean isCopyFromTx) { + private static void assertData(CreateBranchData actual, String branchName, Long branchUuid, BranchType type, String comment, TransactionId fromTx, ArtifactId author, ArtifactId associatedArtifact, boolean isCopyFromTx) { assertEquals(branchName, actual.getName()); assertEquals(branchUuid, actual.getGuid()); @@ -154,14 +155,9 @@ public class BranchDataFactoryTest { assertEquals(-1, actual.getMergeAddressingQueryId()); assertEquals(-1L, actual.getMergeDestinationBranchId()); - assertEquals(author, actual.getUserArtifact()); - assertEquals(author.getLocalId(), actual.getUserArtifactId()); - + assertEquals(author, actual.getAuthor()); assertEquals(associatedArtifact, actual.getAssociatedArtifact()); - int assocArtId = associatedArtifact == null ? -1 : associatedArtifact.getLocalId(); - assertEquals(assocArtId, actual.getAssociatedArtifactId()); - assertEquals(isCopyFromTx, actual.isTxCopyBranchType()); } -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/BranchUtilBranchReadableTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/BranchUtilBranchReadableTest.java index 0d532183b3a..8160df48251 100644 --- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/BranchUtilBranchReadableTest.java +++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/BranchUtilBranchReadableTest.java @@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.core.internal.branch; import java.util.Arrays; import java.util.List; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchArchivedState; @@ -76,8 +77,8 @@ public class BranchUtilBranchReadableTest { } @Override - public int getAssociatedArtifactId() { - return 0; + public ArtifactId getAssociatedArtifact() { + return ArtifactId.SENTINEL; } @Override diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchData.java index 5770b2335b7..06b742f39c2 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchData.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchData.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.ds; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TransactionId; @@ -22,9 +23,9 @@ import org.eclipse.osee.framework.core.enums.BranchType; */ public interface BranchData extends IOseeBranch { - int getAssociatedArtifactId(); + ArtifactId getAssociatedArtifact(); - void setAssociatedArtifactId(int artId); + void setAssociatedArtifact(ArtifactId artId); TransactionId getBaseTransaction(); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java index 6b1d0ecd3bd..804277db094 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java @@ -13,6 +13,7 @@ package org.eclipse.osee.orcs.core.ds; import java.net.URI; import java.util.List; import java.util.concurrent.Callable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.data.TransactionToken; @@ -23,7 +24,6 @@ import org.eclipse.osee.framework.jdk.core.type.PropertyStore; import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.OrcsTypes; import org.eclipse.osee.orcs.data.ArchiveOperation; -import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.data.CreateBranchData; import org.eclipse.osee.orcs.search.ApplicabilityQuery; @@ -39,7 +39,7 @@ public interface BranchDataStore { Callable<Void> purgeBranch(OrcsSession session, BranchReadable branch); - Callable<TransactionId> commitBranch(OrcsSession session, ArtifactReadable committer, BranchReadable source, TransactionToken sourceHead, BranchReadable destination, TransactionToken destinationHead, ApplicabilityQuery applicQuery); + Callable<TransactionId> commitBranch(OrcsSession session, ArtifactId committer, BranchReadable source, TransactionToken sourceHead, BranchReadable destination, TransactionToken destinationHead, ApplicabilityQuery applicQuery); Callable<List<ChangeItem>> compareBranch(OrcsSession session, TransactionToken sourceTx, TransactionToken destinationTx, ApplicabilityQuery applicQuery); @@ -55,7 +55,7 @@ public interface BranchDataStore { Callable<Void> changeBranchName(OrcsSession session, BranchId branch, String branchName); - Callable<Void> changeBranchAssociatedArtId(OrcsSession session, BranchId branch, int assocArtId); + Callable<Void> changeBranchAssociatedArt(OrcsSession session, BranchId branch, ArtifactId assocArt); Callable<Void> archiveUnArchiveBranch(OrcsSession session, BranchId branch, ArchiveOperation op); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TxOrcsData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TxOrcsData.java index c8eab38988e..e7c46093eda 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TxOrcsData.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/TxOrcsData.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.core.ds; import java.util.Date; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.orcs.data.TransactionReadable; @@ -19,31 +20,15 @@ import org.eclipse.osee.orcs.data.TransactionReadable; */ public interface TxOrcsData extends TransactionReadable { - @Override - int getAuthorId(); - - @Override - String getComment(); - - @Override - int getCommit(); - - @Override - Date getDate(); - - @Override - TransactionDetailsType getTxType(); - - void setAuthorId(int authorId); + void setAuthor(ArtifactId author); void setBranchId(Long branchId); void setComment(String comment); - void setCommit(int commitId); + void setCommitArt(ArtifactId commitArt); void setDate(Date date); void setTxType(TransactionDetailsType type); - }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxArtifactGuids.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxArtifactIds.java index 2936a2a8a06..6ce60e24ff0 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxArtifactGuids.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/criteria/CriteriaTxArtifactIds.java @@ -10,46 +10,50 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.ds.criteria; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; +import org.eclipse.osee.framework.core.data.ArtifactId; 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.GUID; import org.eclipse.osee.orcs.core.ds.Criteria; import org.eclipse.osee.orcs.core.ds.Options; /** * @author Roberto E. Escobar */ -public class CriteriaTxArtifactGuids extends Criteria implements TxCriteria { +public class CriteriaTxArtifactIds extends Criteria implements TxCriteria { - private final Collection<String> artifactGuids; + private final Collection<ArtifactId> artifactIds; + private final ArtifactId artifactId; - public CriteriaTxArtifactGuids(Collection<String> artifactGuids) { - super(); - this.artifactGuids = artifactGuids; + public CriteriaTxArtifactIds(ArtifactId artifactId) { + this.artifactId = artifactId; + this.artifactIds = null; + } + + public CriteriaTxArtifactIds(Collection<ArtifactId> artifactIds) { + this.artifactIds = artifactIds; + this.artifactId = null; } @Override public void checkValid(Options options) throws OseeCoreException { - Conditions.checkNotNullOrEmpty(artifactGuids, "artifact guids"); - List<String> invalids = new ArrayList<>(); - for (String guid : artifactGuids) { - if (!GUID.isValid(guid)) { - invalids.add(guid); - } - } - Conditions.checkExpressionFailOnTrue(!invalids.isEmpty(), "Invalid Guids - %s", invalids); + Conditions.checkNotNullOrEmpty(artifactIds, "artifact ids"); } - public Collection<String> getIds() { - return artifactGuids; + public Collection<ArtifactId> getIds() { + return artifactIds; + } + + public ArtifactId getId() { + return artifactId; } @Override public String toString() { - return "CriteriaArtifactGuids [artifactGuids=" + artifactGuids + "]"; + return "CriteriaTxArtifactIds [" + artifactIds + "]"; } -} + public boolean hasMultiple() { + return artifactId == null; + } +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java index 05e41c328b3..52a82cc8343 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/OrcsBranchImpl.java @@ -13,6 +13,7 @@ package org.eclipse.osee.orcs.core.internal; import java.net.URI; import java.util.List; import java.util.concurrent.Callable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TransactionId; @@ -83,7 +84,7 @@ public class OrcsBranchImpl implements OrcsBranch { } @Override - public Callable<TransactionToken> commitBranch(ArtifactReadable committer, BranchId source, BranchId destination) { + public Callable<TransactionToken> commitBranch(ArtifactId committer, BranchId source, BranchId destination) { return new CommitBranchCallable(logger, session, branchStore, queryFactory, committer, source, destination); } @@ -118,14 +119,14 @@ public class OrcsBranchImpl implements OrcsBranch { } @Override - public Callable<Void> associateBranchToArtifact(BranchId branch, ArtifactReadable associatedArtifact) { + public Callable<Void> associateBranchToArtifact(BranchId branch, ArtifactId associatedArtifact) { Conditions.checkNotNull(associatedArtifact, "associatedArtifact"); - return branchStore.changeBranchAssociatedArtId(session, branch, associatedArtifact.getLocalId()); + return branchStore.changeBranchAssociatedArt(session, branch, associatedArtifact); } @Override public Callable<Void> unassociateBranch(BranchId branch) { - return branchStore.changeBranchAssociatedArtId(session, branch, -1); + return branchStore.changeBranchAssociatedArt(session, branch, ArtifactId.SENTINEL); } @Override @@ -144,34 +145,34 @@ public class OrcsBranchImpl implements OrcsBranch { } @Override - public Callable<BranchReadable> createTopLevelBranch(IOseeBranch branch, ArtifactReadable author) throws OseeCoreException { + public Callable<BranchReadable> createTopLevelBranch(IOseeBranch branch, ArtifactId author) throws OseeCoreException { CreateBranchData branchData = branchDataFactory.createTopLevelBranchData(branch, author); return createBranch(branchData); } @Override - public Callable<BranchReadable> createBaselineBranch(IOseeBranch branch, ArtifactReadable author, IOseeBranch parent, ArtifactReadable associatedArtifact) throws OseeCoreException { + public Callable<BranchReadable> createBaselineBranch(IOseeBranch branch, ArtifactId author, IOseeBranch parent, ArtifactId associatedArtifact) throws OseeCoreException { CreateBranchData branchData = branchDataFactory.createBaselineBranchData(branch, author, parent, associatedArtifact); return createBranch(branchData); } @Override - public Callable<BranchReadable> createWorkingBranch(IOseeBranch branch, ArtifactReadable author, IOseeBranch parent, ArtifactReadable associatedArtifact) throws OseeCoreException { + public Callable<BranchReadable> createWorkingBranch(IOseeBranch branch, ArtifactId author, IOseeBranch parent, ArtifactId associatedArtifact) throws OseeCoreException { CreateBranchData branchData = branchDataFactory.createWorkingBranchData(branch, author, parent, associatedArtifact); return createBranch(branchData); } @Override - public Callable<BranchReadable> createCopyTxBranch(IOseeBranch branch, ArtifactReadable author, TransactionId fromTransaction, ArtifactReadable associatedArtifact) throws OseeCoreException { + public Callable<BranchReadable> createCopyTxBranch(IOseeBranch branch, ArtifactId author, TransactionId fromTransaction, ArtifactId associatedArtifact) throws OseeCoreException { CreateBranchData branchData = branchDataFactory.createCopyTxBranchData(branch, author, fromTransaction, associatedArtifact); return createBranch(branchData); } @Override - public Callable<BranchReadable> createPortBranch(IOseeBranch branch, ArtifactReadable author, TransactionId fromTransaction, ArtifactReadable associatedArtifact) throws OseeCoreException { + public Callable<BranchReadable> createPortBranch(IOseeBranch branch, ArtifactId author, TransactionId fromTransaction, ArtifactId associatedArtifact) throws OseeCoreException { CreateBranchData branchData = branchDataFactory.createPortBranchData(branch, author, fromTransaction, associatedArtifact); return createBranch(branchData); diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/BranchDataFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/BranchDataFactory.java index a0fcef45ba7..8e8c3ce0fb3 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/BranchDataFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/BranchDataFactory.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.orcs.core.internal.branch; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TransactionId; @@ -17,7 +18,6 @@ import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.BranchType; import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.CreateBranchData; import org.eclipse.osee.orcs.search.BranchQuery; import org.eclipse.osee.orcs.search.QueryFactory; @@ -34,34 +34,34 @@ public class BranchDataFactory { this.queryFactory = queryFactory; } - public CreateBranchData createTopLevelBranchData(IOseeBranch branch, ArtifactReadable author) { - return createBranchData(branch, author, CoreBranches.SYSTEM_ROOT, null, BranchType.BASELINE); + public CreateBranchData createTopLevelBranchData(IOseeBranch branch, ArtifactId author) { + return createBranchData(branch, author, CoreBranches.SYSTEM_ROOT, ArtifactId.SENTINEL, BranchType.BASELINE); } - public CreateBranchData createBaselineBranchData(IOseeBranch branch, ArtifactReadable author, IOseeBranch parent, ArtifactReadable associatedArtifact) { + public CreateBranchData createBaselineBranchData(IOseeBranch branch, ArtifactId author, IOseeBranch parent, ArtifactId associatedArtifact) { return createBranchData(branch, author, parent, associatedArtifact, BranchType.BASELINE); } - public CreateBranchData createWorkingBranchData(IOseeBranch branch, ArtifactReadable author, IOseeBranch parent, ArtifactReadable associatedArtifact) { + public CreateBranchData createWorkingBranchData(IOseeBranch branch, ArtifactId author, IOseeBranch parent, ArtifactId associatedArtifact) { return createBranchData(branch, author, parent, associatedArtifact, BranchType.WORKING); } - private CreateBranchData createBranchData(IOseeBranch branch, ArtifactReadable author, IOseeBranch parent, ArtifactReadable associatedArtifact, BranchType branchType) { + private CreateBranchData createBranchData(IOseeBranch branch, ArtifactId author, IOseeBranch parent, ArtifactId associatedArtifact, BranchType branchType) { TransactionQuery txQuery = queryFactory.transactionQuery(); TransactionId fromTx = txQuery.andIsHead(parent).getTokens().getExactlyOne(); String creationComment = String.format("New Branch from %s (%s)", parent.getName(), fromTx); return createBranchData(branch, parent, branchType, creationComment, fromTx, author, associatedArtifact, false); } - public CreateBranchData createCopyTxBranchData(IOseeBranch branch, ArtifactReadable author, TransactionId fromTransaction, ArtifactReadable associatedArtifact) throws OseeCoreException { + public CreateBranchData createCopyTxBranchData(IOseeBranch branch, ArtifactId author, TransactionId fromTransaction, ArtifactId associatedArtifact) throws OseeCoreException { return createBranchData(branch, author, fromTransaction, associatedArtifact, BranchType.WORKING, "copied"); } - public CreateBranchData createPortBranchData(IOseeBranch branch, ArtifactReadable author, TransactionId fromTransaction, ArtifactReadable associatedArtifact) throws OseeCoreException { + public CreateBranchData createPortBranchData(IOseeBranch branch, ArtifactId author, TransactionId fromTransaction, ArtifactId associatedArtifact) throws OseeCoreException { return createBranchData(branch, author, fromTransaction, associatedArtifact, BranchType.PORT, "ported"); } - private CreateBranchData createBranchData(IOseeBranch branch, ArtifactReadable author, TransactionId fromTransaction, ArtifactReadable associatedArtifact, BranchType branchType, String verb) { + private CreateBranchData createBranchData(IOseeBranch branch, ArtifactId author, TransactionId fromTransaction, ArtifactId associatedArtifact, BranchType branchType, String verb) { TransactionQuery txQuery = queryFactory.transactionQuery(); BranchQuery branchQuery = queryFactory.branchQuery(); TransactionToken fromTx = txQuery.andTxId(fromTransaction).getTokens().getExactlyOne(); @@ -72,7 +72,7 @@ public class BranchDataFactory { return createBranchData(branch, parent, branchType, creationComment, fromTx, author, associatedArtifact, true); } - private CreateBranchData createBranchData(IOseeBranch branch, BranchId parent, BranchType branchType, String creationComment, TransactionId sysRootHeadTx, ArtifactReadable author, ArtifactReadable associatedArtifact, boolean bCopyTx) { + private CreateBranchData createBranchData(IOseeBranch branch, BranchId parent, BranchType branchType, String creationComment, TransactionId sysRootHeadTx, ArtifactId author, ArtifactId associatedArtifact, boolean bCopyTx) { CreateBranchData createData = new CreateBranchData(); createData.setUuid(branch.getUuid()); createData.setName(branch.getName()); @@ -82,11 +82,10 @@ public class BranchDataFactory { createData.setBranchType(branchType); createData.setCreationComment(creationComment); createData.setFromTransaction(sysRootHeadTx); - createData.setUserArtifact(author); + createData.setAuthor(author); createData.setAssociatedArtifact(associatedArtifact); createData.setTxCopyBranchType(bCopyTx); createData.setParentBranch(parent); return createData; } - -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java index c58cc9d29e4..ee0cb79fde1 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CommitBranchCallable.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.core.internal.branch; import java.util.concurrent.Callable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.data.TransactionToken; @@ -18,18 +19,17 @@ import org.eclipse.osee.framework.jdk.core.util.Conditions; import org.eclipse.osee.logger.Log; import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.core.ds.BranchDataStore; -import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.search.QueryFactory; public class CommitBranchCallable extends AbstractBranchCallable<TransactionToken> { - private final ArtifactReadable committer; + private final ArtifactId committer; private final BranchId source; private final BranchId destination; private final QueryFactory queryFactory; - public CommitBranchCallable(Log logger, OrcsSession session, BranchDataStore branchStore, QueryFactory queryFactory, ArtifactReadable committer, BranchId source, BranchId destination) { + public CommitBranchCallable(Log logger, OrcsSession session, BranchDataStore branchStore, QueryFactory queryFactory, ArtifactId committer, BranchId source, BranchId destination) { super(logger, session, branchStore); this.committer = committer; this.source = source; diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java index dbd804e6cac..8756751e0df 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TransactionCriteriaFactory.java @@ -11,9 +11,7 @@ package org.eclipse.osee.orcs.core.internal.search; import java.sql.Timestamp; -import java.util.ArrayList; import java.util.Collection; -import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.orcs.core.ds.Criteria; @@ -22,7 +20,6 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaAuthorIds; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaCommitIds; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaDateRange; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaDateWithOperator; -import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxArtifactGuids; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxBranchIds; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxComment; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxGetHead; @@ -78,14 +75,6 @@ public class TransactionCriteriaFactory { return new CriteriaAuthorIds(ids); } - public Criteria newByArtifactId(Collection<ArtifactId> ids) { - ArrayList<String> theGuids = new ArrayList<>(ids.size()); - for (ArtifactId id : ids) { - theGuids.add(id.getGuid()); - } - return new CriteriaTxArtifactGuids(theGuids); - } - public Criteria newByCommitId(Collection<Integer> ids) { return new CriteriaCommitIds(ids); } diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java index 643bd5ae77b..b266fe24962 100644 --- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java +++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/search/TxQueryBuilderImpl.java @@ -24,6 +24,7 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.core.ds.Criteria; import org.eclipse.osee.orcs.core.ds.Options; import org.eclipse.osee.orcs.core.ds.QueryData; +import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxArtifactIds; import org.eclipse.osee.orcs.search.Operator; import org.eclipse.osee.orcs.search.TxQueryBuilder; @@ -147,8 +148,7 @@ public class TxQueryBuilderImpl<T> implements TxQueryBuilder<T> { @Override public T andAuthorLocalIds(Collection<ArtifactId> ids) throws OseeCoreException { - Criteria criteria = criteriaFactory.newByArtifactId(ids); - return addAndCheck(queryData, criteria); + return addAndCheck(queryData, new CriteriaTxArtifactIds(ids)); } @Override diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java index 33899956c0e..c15b542269e 100644 --- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java +++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderTest.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map.Entry; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.RelationalConstants; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.ModificationType; @@ -71,9 +72,9 @@ public class TxSqlBuilderTest { private static final TransactionId EXPECTED_TX = TransactionId.valueOf(10000); private static final TransactionId LOADED_TX_ID = TransactionId.valueOf(567); - private static final int EXPECTED_COMMIT_ID = 46; + private static final ArtifactId EXPECTED_COMMIT_ART = ArtifactId.valueOf(46); private static final long EXPECTED_BRANCH_ID = 65L; - private static final int EXPECTED_AUTHOR_ID = 89; + private static final ArtifactId EXPECTED_AUTHOR = ArtifactId.valueOf(89); private static final String EXPECTED_COMMENT = "My comment"; private static final TransactionDetailsType EXPECTED_TX_TYPE = TransactionDetailsType.Baselined; private static final Date EXPECTED_TX_TIME = new Date(); @@ -141,10 +142,10 @@ public class TxSqlBuilderTest { relData.setArtIdB(B_ART_ID); relData.setRationale(RATIONALE); - tx.setAuthorId(EXPECTED_AUTHOR_ID); + tx.setAuthor(EXPECTED_AUTHOR); tx.setBranchId(EXPECTED_BRANCH_ID); tx.setComment(EXPECTED_COMMENT); - tx.setCommit(EXPECTED_COMMIT_ID); + tx.setCommitArt(EXPECTED_COMMIT_ART); tx.setDate(EXPECTED_TX_TIME); tx.setTxType(EXPECTED_TX_TYPE); @@ -184,7 +185,7 @@ public class TxSqlBuilderTest { assertEquals(EXPECTED_TX, data[index++]); assertEquals(EXPECTED_COMMENT, data[index++]); assertEquals(EXPECTED_TX_TIME, data[index++]); - assertEquals(EXPECTED_AUTHOR_ID, data[index++]); + assertEquals(EXPECTED_AUTHOR, data[index++]); assertEquals(EXPECTED_BRANCH_ID, data[index++]); assertEquals(EXPECTED_TX_TYPE.getId(), data[index++]); } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java index eda7c920536..b7be7afe1b7 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java @@ -14,6 +14,7 @@ import java.net.URI; import java.util.List; import java.util.concurrent.Callable; import org.eclipse.osee.executor.admin.ExecutorAdmin; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.data.TransactionToken; @@ -30,7 +31,6 @@ import org.eclipse.osee.orcs.core.SystemPreferences; import org.eclipse.osee.orcs.core.ds.BranchDataStore; import org.eclipse.osee.orcs.core.ds.DataLoaderFactory; import org.eclipse.osee.orcs.data.ArchiveOperation; -import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.data.CreateBranchData; import org.eclipse.osee.orcs.db.internal.IdentityManager; @@ -90,7 +90,7 @@ public class BranchModule { } @Override - public Callable<TransactionId> commitBranch(OrcsSession session, ArtifactReadable committer, BranchReadable source, TransactionToken sourceHead, BranchReadable destination, TransactionToken destinationHead, ApplicabilityQuery applicQuery) { + public Callable<TransactionId> commitBranch(OrcsSession session, ArtifactId committer, BranchReadable source, TransactionToken sourceHead, BranchReadable destination, TransactionToken destinationHead, ApplicabilityQuery applicQuery) { return new CommitBranchDatabaseCallable(logger, session, jdbcClient, joinFactory, idManager, committer, source, sourceHead, destination, destinationHead, missingChangeItemFactory, applicQuery); } @@ -143,8 +143,8 @@ public class BranchModule { } @Override - public Callable<Void> changeBranchAssociatedArtId(OrcsSession session, BranchId branch, int assocArtId) { - return ChangeBranchFieldCallable.newAssocArtId(logger, session, jdbcClient, branch, assocArtId); + public Callable<Void> changeBranchAssociatedArt(OrcsSession session, BranchId branch, ArtifactId assocArt) { + return ChangeBranchFieldCallable.newAssocArtId(logger, session, jdbcClient, branch, assocArt); } @Override diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java index 69b8592d325..59840a25e1d 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java @@ -75,7 +75,7 @@ public final class BranchCopyTxCallable extends JdbcTransaction { String creationComment = branchData.getCreationComment(); jdbcClient.runPreparedUpdate(connection, INSERT_TX_DETAILS, branchData.getUuid(), nextTransactionId, - creationComment, timestamp, branchData.getUserArtifactId(), TransactionDetailsType.NonBaselined.getId()); + creationComment, timestamp, branchData.getAuthor(), TransactionDetailsType.NonBaselined.getId()); populateTransaction(0.30, connection, nextTransactionId, branchData.getParentBranch(), branchData.getSavedTransaction()); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/ChangeBranchFieldCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/ChangeBranchFieldCallable.java index a73e5a4b39e..1eee3ab9267 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/ChangeBranchFieldCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/ChangeBranchFieldCallable.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.db.internal.callable; import java.util.concurrent.Callable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.BranchType; @@ -64,7 +65,7 @@ public class ChangeBranchFieldCallable extends AbstractDatastoreTxCallable<Void> return new ChangeBranchFieldCallable(logger, session, jdbcClient, branch, "branch_name", branchName); } - public static Callable<Void> newAssocArtId(Log logger, OrcsSession session, JdbcClient jdbcClient, BranchId branch, int associatedArtId) { - return new ChangeBranchFieldCallable(logger, session, jdbcClient, branch, "associated_art_id", associatedArtId); + public static Callable<Void> newAssocArtId(Log logger, OrcsSession session, JdbcClient jdbcClient, BranchId branch, ArtifactId associatedArt) { + return new ChangeBranchFieldCallable(logger, session, jdbcClient, branch, "associated_art_id", associatedArt); } } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseCallable.java index c4e8c1cd90d..9addbdd7d46 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseCallable.java @@ -14,6 +14,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import org.eclipse.osee.executor.admin.CancellableCallable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.data.TransactionToken; @@ -22,7 +23,6 @@ import org.eclipse.osee.framework.core.model.change.ChangeItem; import org.eclipse.osee.jdbc.JdbcClient; import org.eclipse.osee.logger.Log; import org.eclipse.osee.orcs.OrcsSession; -import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.db.internal.IdentityManager; import org.eclipse.osee.orcs.db.internal.change.ComputeNetChangeCallable; @@ -38,7 +38,7 @@ public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<Tran private final SqlJoinFactory joinFactory; private final IdentityManager idManager; - private final ArtifactReadable committer; + private final ArtifactId committer; private final TransactionToken sourceHead; private final BranchReadable source; private final TransactionToken destinationHead; @@ -51,7 +51,7 @@ public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<Tran private static final String SELECT_MERGE_BRANCH_HEAD_TX = "select max(transaction_id) from osee_tx_details where branch_id = ?"; - public CommitBranchDatabaseCallable(Log logger, OrcsSession session, JdbcClient service, SqlJoinFactory joinFactory, IdentityManager idManager, ArtifactReadable committer, BranchReadable source, TransactionToken sourceHead, BranchReadable destination, TransactionToken destinationHead, MissingChangeItemFactory missingChangeItemFactory, ApplicabilityQuery applicQuery) { + public CommitBranchDatabaseCallable(Log logger, OrcsSession session, JdbcClient service, SqlJoinFactory joinFactory, IdentityManager idManager, ArtifactId committer, BranchReadable source, TransactionToken sourceHead, BranchReadable destination, TransactionToken destinationHead, MissingChangeItemFactory missingChangeItemFactory, ApplicabilityQuery applicQuery) { super(logger, session, service); this.joinFactory = joinFactory; this.idManager = idManager; @@ -64,10 +64,6 @@ public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<Tran this.applicQuery = applicQuery; } - private int getUserArtId() { - return committer != null ? committer.getLocalId() : -1; - } - private List<ChangeItem> callComputeChanges(BranchId mergeBranch) throws Exception { TransactionId mergeTxId = getJdbcClient().fetch(TransactionId.SENTINEL, SELECT_MERGE_BRANCH_HEAD_TX, mergeBranch); @@ -100,7 +96,7 @@ public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<Tran List<ChangeItem> changes = callComputeChanges(mergeBranch); CancellableCallable<TransactionId> commitCallable = new CommitBranchDatabaseTxCallable(getLogger(), getSession(), - getJdbcClient(), joinFactory, idManager, getUserArtId(), source, destination, mergeBranch, changes); + getJdbcClient(), joinFactory, idManager, committer, source, destination, mergeBranch, changes); TransactionId newTx = callAndCheckForCancel(commitCallable); return newTx; diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java index d0535c19c30..682d2404d7f 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java @@ -14,6 +14,7 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import org.eclipse.osee.framework.core.data.ApplicabilityToken; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchState; @@ -59,17 +60,17 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< private final SqlJoinFactory joinFactory; private final IdentityManager idManager; - private final int userArtId; + private final ArtifactId committer; private final BranchReadable sourceBranch; private final BranchReadable destinationBranch; private final BranchId mergeBranch; private final List<ChangeItem> changes; - public CommitBranchDatabaseTxCallable(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, IdentityManager idManager, int userArtId, BranchReadable sourceBranch, BranchReadable destinationBranch, BranchId mergeBranch, List<ChangeItem> changes) { + public CommitBranchDatabaseTxCallable(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, IdentityManager idManager, ArtifactId committer, BranchReadable sourceBranch, BranchReadable destinationBranch, BranchId mergeBranch, List<ChangeItem> changes) { super(logger, session, jdbcClient); this.joinFactory = joinFactory; this.idManager = idManager; - this.userArtId = userArtId; + this.committer = committer; this.sourceBranch = sourceBranch; this.destinationBranch = destinationBranch; this.mergeBranch = mergeBranch; @@ -87,7 +88,7 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< TransactionId newTx = null; try { - newTx = addCommitTransactionToDatabase(userArtId, connection); + newTx = addCommitTransactionToDatabase(committer, connection); updatePreviousCurrentsOnDestinationBranch(connection); insertCommitAddressing(newTx, connection); @@ -143,7 +144,7 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< updater.updateTxNotCurrents(); } - private TransactionId addCommitTransactionToDatabase(int userArtId, JdbcConnection connection) throws OseeCoreException { + private TransactionId addCommitTransactionToDatabase(ArtifactId committer, JdbcConnection connection) throws OseeCoreException { TransactionId newTransactionNumber = idManager.getNextTransactionId(); Timestamp timestamp = GlobalTime.GreenwichMeanTimestamp(); @@ -151,7 +152,7 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< getJdbcClient().runPreparedUpdate(connection, INSERT_COMMIT_TRANSACTION, TransactionDetailsType.NonBaselined.getId(), destinationBranch.getUuid(), newTransactionNumber, comment, - timestamp, userArtId, sourceBranch.getAssociatedArtifactId()); + timestamp, committer, sourceBranch.getAssociatedArtifact()); return newTransactionNumber; } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java index a816a4233a8..6731126b893 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java @@ -14,6 +14,7 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchArchivedState; @@ -114,13 +115,13 @@ public class CreateBranchDatabaseTxCallable extends JdbcTransaction { destinationBranch); } } else if (!newBranchData.getBranchType().isSystemRootBranch()) { - int associatedArtifactId = newBranchData.getAssociatedArtifactId(); + ArtifactId associatedArtifactId = newBranchData.getAssociatedArtifact(); // this checks to see if there are any branches that aren't either DELETED or REBASELINED with the same artifact ID - if (associatedArtifactId > -1 && !SystemUser.OseeSystem.getUuid().equals((long) associatedArtifactId)) { + if (associatedArtifactId.isValid() && !SystemUser.OseeSystem.equals(associatedArtifactId)) { int count = jdbcClient.fetch(connection, 0, "SELECT (1) FROM osee_branch WHERE associated_art_id = ? AND branch_state NOT IN (?, ?)", - newBranchData.getAssociatedArtifactId(), BranchState.DELETED.getValue(), + newBranchData.getAssociatedArtifact(), BranchState.DELETED.getValue(), BranchState.REBASELINED.getValue()); if (count > 0) { // the PORT branch type is a special case, a PORT branch can have the same associated artifact @@ -130,7 +131,7 @@ public class CreateBranchDatabaseTxCallable extends JdbcTransaction { int portcount = jdbcClient.fetch(connection, 0, "SELECT (1) FROM osee_branch WHERE associated_art_id = ? AND branch_state NOT IN (?, ?) AND branch_type = ?", - newBranchData.getAssociatedArtifactId(), BranchState.DELETED.getValue(), + newBranchData.getAssociatedArtifact(), BranchState.DELETED.getValue(), BranchState.REBASELINED.getValue(), BranchType.PORT.getValue()); if (portcount > 0) { throw new OseeStateException("Existing port branch creation detected for [%s]", @@ -183,7 +184,7 @@ public class CreateBranchDatabaseTxCallable extends JdbcTransaction { parentBranch, sourceTx, BranchArchivedState.UNARCHIVED.getValue(), - newBranchData.getAssociatedArtifactId(), + newBranchData.getAssociatedArtifact(), newBranchData.getBranchType().getValue(), BranchState.CREATED.getValue(), nextTransactionId, @@ -192,12 +193,12 @@ public class CreateBranchDatabaseTxCallable extends JdbcTransaction { jdbcClient.runPreparedUpdate(connection, INSERT_BRANCH, toInsert); if (inheritAccessControl != 0) { - copyAccessRules(newBranchData.getUserArtifactId(), parentBranch, uuid); + copyAccessRules(newBranchData.getAuthor(), parentBranch, uuid); } nextTransactionId = tobeTransactionId; jdbcClient.runPreparedUpdate(connection, INSERT_TX_DETAILS, uuid, nextTransactionId, - newBranchData.getCreationComment(), timestamp, newBranchData.getUserArtifactId(), + newBranchData.getCreationComment(), timestamp, newBranchData.getAuthor(), TransactionDetailsType.Baselined.getId()); if (needsUpdate) { @@ -256,15 +257,15 @@ public class CreateBranchDatabaseTxCallable extends JdbcTransaction { } } - private void copyAccessRules(int userArtId, BranchId parentBranch, Long branchUuid) { + private void copyAccessRules(ArtifactId author, BranchId parentBranch, Long branchUuid) { int lock = PermissionEnum.LOCK.getPermId(); int deny = PermissionEnum.DENY.getPermId(); List<Object[]> data = new ArrayList<>(); jdbcClient.runQuery(stmt -> { int permissionId = stmt.getInt("permission_id"); - int priviledgeId = stmt.getInt("privilege_entity_id"); - if (priviledgeId == userArtId && permissionId < lock && permissionId != deny) { + Long priviledgeId = stmt.getLong("privilege_entity_id"); + if (author.equals(priviledgeId) && permissionId < lock && permissionId != deny) { permissionId = lock; } data.add(new Object[] {permissionId, priviledgeId, branchUuid}); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/BranchDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/BranchDataImpl.java index f8b1cfb128f..daf81a450fa 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/BranchDataImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/BranchDataImpl.java @@ -10,8 +10,8 @@ *******************************************************************************/ package org.eclipse.osee.orcs.db.internal.loader.data; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.RelationalConstants; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.core.enums.BranchState; @@ -24,7 +24,7 @@ import org.eclipse.osee.orcs.data.BranchReadable; * @author Roberto E. Escobar */ public class BranchDataImpl extends NamedId implements BranchData, BranchReadable { - private int associatedArtifactId = RelationalConstants.ART_ID_SENTINEL; + private ArtifactId associatedArtifact = ArtifactId.SENTINEL; private TransactionId baseTransaction = TransactionId.SENTINEL; private TransactionId sourceTransaction = TransactionId.SENTINEL; private BranchId parentBranch = BranchId.SENTINEL; @@ -38,13 +38,13 @@ public class BranchDataImpl extends NamedId implements BranchData, BranchReadabl } @Override - public int getAssociatedArtifactId() { - return associatedArtifactId; + public ArtifactId getAssociatedArtifact() { + return associatedArtifact; } @Override - public void setAssociatedArtifactId(int artId) { - associatedArtifactId = artId; + public void setAssociatedArtifact(ArtifactId associatedArtifact) { + this.associatedArtifact = associatedArtifact; } @Override diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/BranchObjectFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/BranchObjectFactory.java index 17f8a1776bc..716ee54b34d 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/BranchObjectFactory.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/BranchObjectFactory.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.orcs.db.internal.loader.data; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchArchivedState; @@ -23,7 +24,7 @@ import org.eclipse.osee.orcs.core.ds.BranchData; */ public interface BranchObjectFactory extends OrcsDataFactory { - BranchData createBranchData(Long branchUuid, BranchType branchType, String name, BranchId parentBranch, TransactionId baseTransaction, TransactionId sourceTransaction, BranchArchivedState archiveState, BranchState branchState, int associatedArtifactId, boolean inheritAccessControl) throws OseeCoreException; + BranchData createBranchData(Long branchUuid, BranchType branchType, String name, BranchId parentBranch, TransactionId baseTransaction, TransactionId sourceTransaction, BranchArchivedState archiveState, BranchState branchState, ArtifactId associatedArtifact, boolean inheritAccessControl) throws OseeCoreException; BranchData createCopy(BranchData source) throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java index 267bc0807aa..d044d760ef2 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/OrcsObjectFactoryImpl.java @@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.db.internal.loader.data; import java.util.Date; import org.eclipse.osee.framework.core.data.ApplicabilityId; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IArtifactType; import org.eclipse.osee.framework.core.data.IAttributeType; @@ -194,10 +195,10 @@ public class OrcsObjectFactoryImpl implements OrcsObjectFactory { } @Override - public BranchData createBranchData(Long branchUuid, BranchType branchType, String name, BranchId parentBranch, TransactionId baseTransaction, TransactionId sourceTransaction, BranchArchivedState archiveState, BranchState branchState, int associatedArtifactId, boolean inheritAccessControl) { + public BranchData createBranchData(Long branchUuid, BranchType branchType, String name, BranchId parentBranch, TransactionId baseTransaction, TransactionId sourceTransaction, BranchArchivedState archiveState, BranchState branchState, ArtifactId associatedArtifact, boolean inheritAccessControl) { BranchData data = new BranchDataImpl(branchUuid, name); data.setArchiveState(archiveState); - data.setAssociatedArtifactId(associatedArtifactId); + data.setAssociatedArtifact(associatedArtifact); data.setBaseTransaction(baseTransaction); data.setBranchState(branchState); data.setBranchType(branchType); @@ -211,25 +212,25 @@ public class OrcsObjectFactoryImpl implements OrcsObjectFactory { public BranchData createCopy(BranchData source) { return createBranchData(source.getId(), source.getBranchType(), source.getName(), source.getParentBranch(), source.getBaseTransaction(), source.getSourceTransaction(), source.getArchiveState(), source.getBranchState(), - source.getAssociatedArtifactId(), source.isInheritAccessControl()); + source.getAssociatedArtifact(), source.isInheritAccessControl()); } @Override - public TxOrcsData createTxData(Long localId, TransactionDetailsType type, Date date, String comment, Long branchId, int authorId, int commitId) { + public TxOrcsData createTxData(Long localId, TransactionDetailsType type, Date date, String comment, Long branchId, ArtifactId author, ArtifactId commitArt) { TxOrcsData data = new TransactionDataImpl(localId); data.setTxType(type); data.setDate(date); data.setComment(comment); data.setBranchId(branchId); - data.setAuthorId(authorId); - data.setCommit(commitId); + data.setAuthor(author); + data.setCommitArt(commitArt); return data; } @Override public TxOrcsData createCopy(TxOrcsData source) { return createTxData(source.getId(), source.getTxType(), source.getDate(), source.getComment(), - source.getBranchId(), source.getAuthorId(), source.getCommit()); + source.getBranchId(), source.getAuthor(), source.getCommitArt()); } @Override diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionDataImpl.java index 84a829430d0..1d78dea6324 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionDataImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionDataImpl.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.db.internal.loader.data; import java.util.Date; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.RelationalConstants; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; @@ -22,10 +23,10 @@ import org.eclipse.osee.orcs.core.ds.TxOrcsData; */ public class TransactionDataImpl extends BaseId implements TxOrcsData { - private int authorId = RelationalConstants.ART_ID_SENTINEL; + private ArtifactId authorId = ArtifactId.SENTINEL; private Long branchId = BranchId.SENTINEL.getId(); private String comment = RelationalConstants.DEFAULT_COMMENT; - private int commitId = RelationalConstants.ART_ID_SENTINEL; + private ArtifactId commitId = ArtifactId.SENTINEL; private TransactionDetailsType type = TransactionDetailsType.INVALID; private Date date; @@ -34,7 +35,7 @@ public class TransactionDataImpl extends BaseId implements TxOrcsData { } @Override - public int getAuthorId() { + public ArtifactId getAuthor() { return authorId; } @@ -49,7 +50,7 @@ public class TransactionDataImpl extends BaseId implements TxOrcsData { } @Override - public int getCommit() { + public ArtifactId getCommitArt() { return commitId; } @@ -64,8 +65,8 @@ public class TransactionDataImpl extends BaseId implements TxOrcsData { } @Override - public void setAuthorId(int authorId) { - this.authorId = authorId; + public void setAuthor(ArtifactId author) { + this.authorId = author; } @Override @@ -79,8 +80,8 @@ public class TransactionDataImpl extends BaseId implements TxOrcsData { } @Override - public void setCommit(int commitId) { - this.commitId = commitId; + public void setCommitArt(ArtifactId commitArt) { + this.commitId = commitArt; } @Override diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionObjectFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionObjectFactory.java index ac1b27fad9a..40db842b073 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionObjectFactory.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionObjectFactory.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.db.internal.loader.data; import java.util.Date; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.core.ds.TxOrcsData; @@ -20,7 +21,7 @@ import org.eclipse.osee.orcs.core.ds.TxOrcsData; */ public interface TransactionObjectFactory extends OrcsDataFactory { - TxOrcsData createTxData(Long localId, TransactionDetailsType type, Date date, String comment, Long branchId, int authorId, int commitId) throws OseeCoreException; + TxOrcsData createTxData(Long localId, TransactionDetailsType type, Date date, String comment, Long branchId, ArtifactId author, ArtifactId commitArt) throws OseeCoreException; TxOrcsData createCopy(TxOrcsData source) throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/BranchLoadProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/BranchLoadProcessor.java index 6df82a2f4f2..95b2767ee11 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/BranchLoadProcessor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/BranchLoadProcessor.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.orcs.db.internal.loader.processor; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.core.data.TransactionId; @@ -43,7 +44,7 @@ public class BranchLoadProcessor extends LoadProcessor<BranchData, BranchObjectF BranchId parentBranchId = TokenFactory.createBranch(chStmt.getLong("parent_branch_id")); TransactionId sourceTx = TransactionId.valueOf(chStmt.getLong("parent_transaction_id")); TransactionId baseTx = TransactionId.valueOf(chStmt.getLong("baseline_transaction_id")); - int assocArtId = chStmt.getInt("associated_art_id"); + ArtifactId assocArtId = ArtifactId.valueOf(chStmt.getLong("associated_art_id")); boolean inheritAccessControl = chStmt.getInt("inherit_access_control") != 0; return factory.createBranchData(branchUuid, branchType, branchName, parentBranchId, baseTx, sourceTx, diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/TransactionLoadProcessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/TransactionLoadProcessor.java index 8639f3a0324..d6eadad3e13 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/TransactionLoadProcessor.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/processor/TransactionLoadProcessor.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.db.internal.loader.processor; import java.util.Date; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.jdbc.JdbcStatement; @@ -34,8 +35,8 @@ public class TransactionLoadProcessor extends LoadProcessor<TxOrcsData, Transact TransactionDetailsType type = TransactionDetailsType.toEnum(chStmt.getInt("tx_type")); String comment = chStmt.getString("osee_comment"); Date date = chStmt.getTimestamp("time"); - int authorId = chStmt.getInt("author"); - int commitId = chStmt.getInt("commit_art_id"); + ArtifactId authorId = ArtifactId.valueOf(chStmt.getLong("author")); + ArtifactId commitId = ArtifactId.valueOf(chStmt.getLong("commit_art_id")); return factory.createTxData(localId, type, date, comment, branchUuid, authorId, commitId); } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java index fc04765f232..21e8ce32d5e 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/SqlHandlerFactoryUtil.java @@ -43,7 +43,7 @@ import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeFollow; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeNotExists; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeSideExists; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaRelationTypeSideNotExists; -import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxArtifactGuids; +import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxArtifactIds; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxBranchIds; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxComment; import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxGetHead; @@ -138,7 +138,7 @@ public final class SqlHandlerFactoryUtil { handleMap.put(CriteriaDateWithOperator.class, TxDateWithOperatorSqlHandler.class); handleMap.put(CriteriaDateRange.class, TxDateRangeSqlHandler.class); handleMap.put(CriteriaAuthorIds.class, TxAuthorIdsSqlHandler.class); - handleMap.put(CriteriaTxArtifactGuids.class, TxArtifactGuidSqlHandler.class); + handleMap.put(CriteriaTxArtifactIds.class, TxArtifactIdSqlHandler.class); handleMap.put(CriteriaCommitIds.class, TxCommitArtIdSqlHandler.class); handleMap.put(CriteriaTxGetHead.class, TxGetHeadSqlHandler.class); handleMap.put(CriteriaTxGetPrior.class, TxGetPriorSqlHandler.class); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxArtifactGuidSqlHandler.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxArtifactIdSqlHandler.java index 3b31214986f..fabee5ac8c5 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxArtifactGuidSqlHandler.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/handlers/TxArtifactIdSqlHandler.java @@ -12,8 +12,9 @@ package org.eclipse.osee.orcs.db.internal.search.handlers; import java.util.Collection; import java.util.List; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; -import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxArtifactGuids; +import org.eclipse.osee.orcs.core.ds.criteria.CriteriaTxArtifactIds; import org.eclipse.osee.orcs.db.internal.sql.AbstractSqlWriter; import org.eclipse.osee.orcs.db.internal.sql.SqlHandler; import org.eclipse.osee.orcs.db.internal.sql.TableEnum; @@ -22,24 +23,24 @@ import org.eclipse.osee.orcs.db.internal.sql.join.AbstractJoinQuery; /** * @author Roberto E. Escobar */ -public class TxArtifactGuidSqlHandler extends SqlHandler<CriteriaTxArtifactGuids> { +public class TxArtifactIdSqlHandler extends SqlHandler<CriteriaTxArtifactIds> { - private CriteriaTxArtifactGuids criteria; + private CriteriaTxArtifactIds criteria; private String txdAlias; private String artAlias; - private String jguidAlias; + private String jIdAlias; private AbstractJoinQuery joinQuery; @Override - public void setData(CriteriaTxArtifactGuids criteria) { + public void setData(CriteriaTxArtifactIds criteria) { this.criteria = criteria; } @Override public void addTables(AbstractSqlWriter writer) { - if (criteria.getIds().size() > 1) { - jguidAlias = writer.addTable(TableEnum.CHAR_JOIN_TABLE); + if (criteria.hasMultiple()) { + jIdAlias = writer.addTable(TableEnum.ID_JOIN_TABLE); } List<String> aliases = writer.getAliases(TableEnum.TX_DETAILS_TABLE); if (aliases.isEmpty()) { @@ -57,20 +58,20 @@ public class TxArtifactGuidSqlHandler extends SqlHandler<CriteriaTxArtifactGuids @Override public boolean addPredicates(AbstractSqlWriter writer) throws OseeCoreException { - Collection<String> ids = criteria.getIds(); - if (ids.size() > 1) { - joinQuery = writer.writeCharJoin(ids); + Collection<ArtifactId> ids = criteria.getIds(); + if (criteria.hasMultiple()) { + joinQuery = writer.writeJoin(ids); writer.write(artAlias); - writer.write(".guid = "); - writer.write(jguidAlias); + writer.write(".art_id = "); + writer.write(jIdAlias); writer.write(".id AND "); - writer.write(jguidAlias); + writer.write(jIdAlias); writer.write(".query_id = ?"); writer.addParameter(joinQuery.getQueryId()); } else { writer.write(artAlias); - writer.write(".guid = ?"); - writer.addParameter(ids.iterator().next()); + writer.write(".art_id = ?"); + writer.addParameter(criteria.getId()); } writer.write(" AND "); writer.write(artAlias); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java index 20923944cf3..318f0eb0b2b 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java @@ -16,6 +16,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; import org.eclipse.osee.framework.core.sql.OseeSql; +import org.eclipse.osee.framework.jdk.core.type.Id; import org.eclipse.osee.framework.jdk.core.type.Identifiable; import org.eclipse.osee.framework.jdk.core.type.Identity; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -343,6 +344,15 @@ public abstract class AbstractSqlWriter implements HasOptions { return joinQuery; } + public IdJoinQuery writeJoin(Collection<? extends Id> ids) { + IdJoinQuery joinQuery = joinFactory.createIdJoinQuery(); + for (Id id : ids) { + joinQuery.add(id.getId()); + } + addJoin(joinQuery); + return joinQuery; + } + public IdJoinQuery writeIdentifiableJoin(Collection<? extends Identifiable<Long>> ids) { IdJoinQuery joinQuery = joinFactory.createIdJoinQuery(); for (Identity<Long> id : ids) { 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 f26a5bf416e..f930d43718b 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 @@ -12,7 +12,6 @@ package org.eclipse.osee.orcs.db.internal.transaction; import java.util.Date; import org.eclipse.osee.framework.core.data.ArtifactId; -import org.eclipse.osee.framework.core.data.RelationalConstants; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; @@ -116,10 +115,10 @@ public final class CommitTransactionDatabaseTxCallable extends AbstractDatastore Date transactionTime = GlobalTime.GreenwichMeanTimestamp(); TransactionDataImpl created = new TransactionDataImpl(transaction.getId()); - created.setAuthorId(author.getUuid().intValue()); + created.setAuthor(author); created.setBranchId(branchId); created.setComment(comment); - created.setCommit(RelationalConstants.ART_ID_SENTINEL); + created.setCommitArt(ArtifactId.SENTINEL); created.setDate(transactionTime); created.setTxType(txType); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java index 862d0cc67de..2eb654ff9f6 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/TxSqlBuilderImpl.java @@ -92,7 +92,7 @@ public class TxSqlBuilderImpl implements OrcsVisitor, TxSqlBuilder { dataItemInserts = new HashCollection<>(); txNotCurrentsJoin = new HashMap<>(); - addRow(SqlOrderEnum.TXS_DETAIL, txId, tx.getComment(), tx.getDate(), tx.getAuthorId(), tx.getBranchId(), + addRow(SqlOrderEnum.TXS_DETAIL, txId, tx.getComment(), tx.getDate(), tx.getAuthor(), tx.getBranchId(), tx.getTxType().getId()); changeSet.accept(this); } diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java index de3875fc5f4..d7406c461d8 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java @@ -11,8 +11,8 @@ package org.eclipse.osee.orcs.rest.model; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; -import org.eclipse.osee.framework.core.data.RelationalConstants; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.core.enums.BranchState; @@ -23,14 +23,11 @@ import org.eclipse.osee.framework.core.enums.BranchType; */ @XmlRootElement public class Branch { - - private static final int DEFAULT_INT = -1; - private long branchUuid; private String name; private BranchId parentBranch; - private int associatedArtifactId = DEFAULT_INT; + private ArtifactId associatedArtifact = ArtifactId.SENTINEL; private TransactionId baseTransaction = TransactionId.SENTINEL; private TransactionId sourceTransaction = TransactionId.SENTINEL; @@ -59,12 +56,12 @@ public class Branch { this.name = name; } - public int getAssociatedArtifactId() { - return associatedArtifactId; + public ArtifactId getAssociatedArtifact() { + return associatedArtifact; } - public void setAssociatedArtifactId(int artId) { - associatedArtifactId = artId; + public void setAssociatedArtifact(ArtifactId associatedArtifact) { + this.associatedArtifact = associatedArtifact; } public TransactionId getBaseTransactionId() { @@ -151,7 +148,7 @@ public class Branch { @Override public String toString() { - return "Branch [branchUuid=" + getBranchUuid() + ", name=" + name + ", parentBranchUuid=" + getParentBranch() + ", associatedArtifactId=" + associatedArtifactId + ", baseTransaction=" + baseTransaction + ", sourceTransaction=" + sourceTransaction + ", archiveState=" + archiveState + ", branchState=" + branchState + ", branchType=" + branchType + ", inheritAccessControl=" + inheritAccessControl + "]"; + return "Branch [branchUuid=" + getBranchUuid() + ", name=" + name + ", parentBranchUuid=" + getParentBranch() + ", associatedArtifactId=" + associatedArtifact + ", baseTransaction=" + baseTransaction + ", sourceTransaction=" + sourceTransaction + ", archiveState=" + archiveState + ", branchState=" + branchState + ", branchType=" + branchType + ", inheritAccessControl=" + inheritAccessControl + "]"; } } diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchCommitOptions.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchCommitOptions.java index e52653ec648..aee81000bbc 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchCommitOptions.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchCommitOptions.java @@ -11,24 +11,22 @@ package org.eclipse.osee.orcs.rest.model; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.framework.core.data.ArtifactId; /** * @author Roberto E. Escobar */ @XmlRootElement public class BranchCommitOptions { - - private static final int DEFAULT_COMMITTER_ID = -1; - - private int committerId = DEFAULT_COMMITTER_ID; + private ArtifactId committer = ArtifactId.SENTINEL; private boolean archive; - public int getCommitterId() { - return committerId; + public ArtifactId getCommitter() { + return committer; } - public void setCommitterId(int committerId) { - this.committerId = committerId; + public void setCommitter(ArtifactId committer) { + this.committer = committer; } public boolean isArchive() { @@ -38,5 +36,4 @@ public class BranchCommitOptions { public void setArchive(boolean archive) { this.archive = archive; } - -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java index b43f0f61124..56b716cd19f 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java @@ -23,6 +23,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.BranchType; import org.eclipse.osee.framework.core.model.change.CompareResults; @@ -155,7 +156,7 @@ public interface BranchEndpoint { @PUT @Path("{branch-uuid}/associated-artifact/{art-id}") - Response associateBranchToArtifact(@PathParam("branch-uuid") long branchUuid, @PathParam("art-id") int artifactId); + Response associateBranchToArtifact(@PathParam("branch-uuid") long branchUuid, @PathParam("art-id") ArtifactId artifact); @PUT @Path("{branch-uuid}/txs/{tx-id}/comment/{tx-comment}") diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/NewBranch.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/NewBranch.java index 51c8120082a..7d766270a15 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/NewBranch.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/NewBranch.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.orcs.rest.model; -import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchType; @@ -18,25 +18,18 @@ import org.eclipse.osee.framework.core.enums.BranchType; /** * @author Roberto E. Escobar */ -@XmlRootElement public class NewBranch { - private String branchName; private BranchId parentBranch; - private int associatedArtifactId; + private ArtifactId associatedArtifact; private BranchType branchType; - - private int authorId; + private ArtifactId author; private TransactionId sourceTransaction; private String creationComment; private int mergeAddressingQueryId; private long mergeDestinationBranchId; private boolean txCopyBranchType; - public NewBranch() { - super(); - } - public String getBranchName() { return branchName; } @@ -45,16 +38,16 @@ public class NewBranch { return parentBranch; } - public int getAssociatedArtifactId() { - return associatedArtifactId; + public ArtifactId getAssociatedArtifact() { + return associatedArtifact; } public BranchType getBranchType() { return branchType; } - public int getAuthorId() { - return authorId; + public ArtifactId getAuthor() { + return author; } public TransactionId getSourceTransaction() { @@ -85,16 +78,16 @@ public class NewBranch { this.parentBranch = parentBranch; } - public void setAssociatedArtifactId(int associatedArtifactId) { - this.associatedArtifactId = associatedArtifactId; + public void setAssociatedArtifact(ArtifactId associatedArtifact) { + this.associatedArtifact = associatedArtifact; } public void setBranchType(BranchType branchType) { this.branchType = branchType; } - public void setAuthorId(int authorId) { - this.authorId = authorId; + public void setAuthor(ArtifactId author) { + this.author = author; } public void setSourceTransactionId(TransactionId sourceTransaction) { @@ -119,7 +112,6 @@ public class NewBranch { @Override public String toString() { - return "NewBranch [branchName=" + branchName + ", parentBranchId=" + parentBranch + ", associatedArtifactId=" + associatedArtifactId + ", branchType=" + branchType + ", authorId=" + authorId + ", sourceTransactionId=" + sourceTransaction + ", creationComment=" + creationComment + ", mergeAddressingQueryId=" + mergeAddressingQueryId + ", mergeDestinationBranchId=" + mergeDestinationBranchId + ", txCopyBranchType=" + txCopyBranchType + "]"; + return "NewBranch [branchName=" + branchName + ", parentBranchId=" + parentBranch + ", associatedArtifactId=" + associatedArtifact + ", branchType=" + branchType + ", authorId=" + author + ", sourceTransactionId=" + sourceTransaction + ", creationComment=" + creationComment + ", mergeAddressingQueryId=" + mergeAddressingQueryId + ", mergeDestinationBranchId=" + mergeDestinationBranchId + ", txCopyBranchType=" + txCopyBranchType + "]"; } - -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java index 92f11450981..f4f90022a52 100644 --- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java +++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java @@ -10,9 +10,9 @@ *******************************************************************************/ package org.eclipse.osee.orcs.rest.model; -import static org.eclipse.osee.framework.core.data.TransactionId.SENTINEL; import java.util.Date; import javax.xml.bind.annotation.XmlRootElement; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; @@ -27,8 +27,8 @@ public class Transaction { private TransactionDetailsType txType; private String comment; private Date timestamp; - private int authorId; - private int commitArtId; + private ArtifactId author; + private ArtifactId commitArtId; public TransactionId getTxId() { return txId; @@ -70,25 +70,24 @@ public class Transaction { this.timestamp = timestamp; } - public int getAuthorId() { - return authorId; + public ArtifactId getAuthor() { + return author; } - public void setAuthorId(int authorId) { - this.authorId = authorId; + public void setAuthor(ArtifactId author) { + this.author = author; } - public int getCommitArtId() { + public ArtifactId getCommitArt() { return commitArtId; } - public void setCommitArtId(int commitArtId) { + public void setCommitArt(ArtifactId commitArtId) { this.commitArtId = commitArtId; } @Override public String toString() { - return "Transaction [txId=" + getTxId() + ", branchUuid=" + branchUuid + ", txType=" + txType + ", comment=" + comment + ", timestamp=" + timestamp + ", authorArtId=" + authorId + ", commitArtId=" + commitArtId + "]"; + return "Transaction [txId=" + getTxId() + ", branchUuid=" + branchUuid + ", txType=" + txType + ", comment=" + comment + ", timestamp=" + timestamp + ", authorArtId=" + author + ", commitArtId=" + commitArtId + "]"; } - -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java index c445bd265a2..e56c21bf681 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.rest.internal; -import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON_ID; import static org.eclipse.osee.framework.jdk.core.util.Compare.isDifferent; import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asBranch; import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asBranches; @@ -37,6 +36,7 @@ import javax.ws.rs.core.UriBuilder; import javax.ws.rs.core.UriInfo; import org.eclipse.osee.activity.api.Activity; import org.eclipse.osee.activity.api.ActivityLog; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TokenFactory; @@ -138,14 +138,6 @@ public class BranchEndpointImpl implements BranchEndpoint { return orcsApi.getBranchOps(); } - private ArtifactReadable getArtifactById(Long branchId, int id) { - ArtifactReadable artifact = null; - if (id > 0) { - artifact = newQuery().fromBranch(branchId).andUuid(id).getResults().getExactlyOne(); - } - return artifact; - } - private BranchReadable getBranchById(long branchUuid) { ResultSet<BranchReadable> results = newBranchQuery().andUuids(branchUuid)// .includeArchived()// @@ -299,8 +291,8 @@ public class BranchEndpointImpl implements BranchEndpoint { createData.setBranchType(data.getBranchType()); createData.setCreationComment(data.getCreationComment()); - createData.setUserArtifact(getArtifactById(COMMON_ID, data.getAuthorId())); - createData.setAssociatedArtifact(getArtifactById(COMMON_ID, data.getAssociatedArtifactId())); + createData.setAuthor(data.getAuthor()); + createData.setAssociatedArtifact(data.getAssociatedArtifact()); createData.setFromTransaction(data.getSourceTransaction()); createData.setParentBranch(data.getParentBranch()); @@ -358,8 +350,7 @@ public class BranchEndpointImpl implements BranchEndpoint { BranchReadable srcBranch = getBranchById(branchUuid); BranchReadable destBranch = getBranchById(destinationBranchUuid); - ArtifactReadable committer = getArtifactById(COMMON_ID, options.getCommitterId()); - Callable<TransactionToken> op = getBranchOps().commitBranch(committer, srcBranch, destBranch); + Callable<TransactionToken> op = getBranchOps().commitBranch(options.getCommitter(), srcBranch, destBranch); TransactionToken tx = executeCallable(op); if (options.isArchive()) { @@ -650,20 +641,19 @@ public class BranchEndpointImpl implements BranchEndpoint { } @Override - public Response associateBranchToArtifact(long branchUuid, int artifactId) { + public Response associateBranchToArtifact(long branchUuid, ArtifactId artifact) { BranchReadable branch = getBranchById(branchUuid); boolean modified = false; - if (isDifferent(branch.getAssociatedArtifactId(), artifactId)) { + if (isDifferent(branch.getAssociatedArtifact(), artifact)) { try { activityLog.createEntry(Activity.BRANCH_OPERATION, ActivityLog.INITIAL_STATUS, String.format( "Branch Operation Associate Branch to Artifact {branchUUID: %s prevArt: %s newArt: %s accountId: %s serverId: %s clientId: %s}", - branchUuid, branch.getAssociatedArtifactId(), artifactId, RestUtil.getAccountId(httpHeaders), + branchUuid, branch.getAssociatedArtifact(), artifact, RestUtil.getAccountId(httpHeaders), RestUtil.getServerId(httpHeaders), RestUtil.getClientId(httpHeaders))); } catch (OseeCoreException ex) { OseeLog.log(ActivityLog.class, OseeLevel.SEVERE_POPUP, ex); } - ArtifactReadable artifact = newQuery().fromBranch(COMMON_ID).andUuid(artifactId).getResults().getExactlyOne(); Callable<?> op = getBranchOps().associateBranchToArtifact(branch, artifact); executeCallable(op); modified = true; @@ -745,7 +735,7 @@ public class BranchEndpointImpl implements BranchEndpoint { public Response unassociateBranch(long branchUuid) { BranchReadable branch = getBranchById(branchUuid); boolean modified = false; - if (branch.getAssociatedArtifactId() != -1) { + if (branch.getAssociatedArtifact().isValid()) { Callable<?> op = getBranchOps().unassociateBranch(branch); executeCallable(op); modified = true; 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 5787b23eb4e..fa9409209fc 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 @@ -158,7 +158,7 @@ public class HtmlWriter { data.put("TxType", txRecord.getTxType()); data.put("Date", txRecord.getDate()); data.put("Comment", txRecord.getComment()); - data.put("Author", txRecord.getAuthorId()); + data.put("Author", txRecord.getAuthor()); IOseeBranch branch = getBranchFromId(txRecord.getBranch()); URI uri; diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java index 797073da4bb..d7fe5ea1d2b 100644 --- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java +++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java @@ -70,7 +70,7 @@ public final class OrcsRestUtil { public static Branch asBranch(BranchReadable src) { Branch data = new Branch(); data.setArchiveState(src.getArchiveState()); - data.setAssociatedArtifactId(src.getAssociatedArtifactId()); + data.setAssociatedArtifact(src.getAssociatedArtifact()); data.setBaseTransactionId(src.getBaseTransaction()); data.setBranchState(src.getBranchState()); data.setBranchType(src.getBranchType()); @@ -85,10 +85,10 @@ public final class OrcsRestUtil { public static Transaction asTransaction(TransactionReadable tx) { Transaction data = new Transaction(); data.setTxId(tx); - data.setAuthorId(tx.getAuthorId()); + data.setAuthor(tx.getAuthor()); data.setBranchUuid(tx.getBranchId()); data.setComment(tx.getComment()); - data.setCommitArtId(tx.getCommit()); + data.setCommitArt(tx.getCommitArt()); data.setTimeStamp(tx.getDate()); data.setTxType(tx.getTxType()); return data; diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchQueryTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchQueryTest.java index 726c17ef72a..786db459c96 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchQueryTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchQueryTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TokenFactory; @@ -90,11 +91,11 @@ public class OrcsBranchQueryTest { List<BranchReadable> list = results.getList(); // list, IOseeBranch, BranchType, BranchState, isArchived, parentId, baseTx, sourceTx, assocArtId - assertBranch(list, SYSTEM_ROOT, BranchType.SYSTEM_ROOT, MODIFIED, false, BranchId.SENTINEL, -1); - assertBranch(list, SAW_Bld_1, BASELINE, MODIFIED, false, SYSTEM_ROOT, -1); - assertBranch(list, CIS_Bld_1, BASELINE, MODIFIED, false, SYSTEM_ROOT, -1); - assertBranch(list, SAW_Bld_2, BASELINE, MODIFIED, false, SAW_Bld_1, 11); - assertBranch(list, COMMON, BASELINE, MODIFIED, false, SYSTEM_ROOT, -1); + assertBranch(list, SYSTEM_ROOT, BranchType.SYSTEM_ROOT, MODIFIED, false, BranchId.SENTINEL, ArtifactId.SENTINEL); + assertBranch(list, SAW_Bld_1, BASELINE, MODIFIED, false, SYSTEM_ROOT, ArtifactId.SENTINEL); + assertBranch(list, CIS_Bld_1, BASELINE, MODIFIED, false, SYSTEM_ROOT, ArtifactId.SENTINEL); + assertBranch(list, SAW_Bld_2, BASELINE, MODIFIED, false, SAW_Bld_1, SystemUser.OseeSystem); + assertBranch(list, COMMON, BASELINE, MODIFIED, false, SYSTEM_ROOT, ArtifactId.SENTINEL); } @Test @@ -295,7 +296,7 @@ public class OrcsBranchQueryTest { private IOseeBranch createBranch(IOseeBranch parent, IOseeBranch uuid) throws Exception { ArtifactReadable author = getSystemUser(); - return getBranchOps().createWorkingBranch(uuid, author, parent, null).call(); + return getBranchOps().createWorkingBranch(uuid, author, parent, ArtifactId.SENTINEL).call(); } @SuppressWarnings("unchecked") @@ -307,19 +308,14 @@ public class OrcsBranchQueryTest { return orcsApi.getBranchOps(); } - private static void assertBranch(List<BranchReadable> list, IOseeBranch token, BranchType type, BranchState state, boolean isArchived, BranchId parent, int assocArtId) { - BranchReadable found = null; - for (BranchReadable branch : list) { - if (branch.getId().equals(token.getId())) { - found = branch; - break; - } - } - Assert.assertNotNull(found); - assertBranch(found, token.getName(), token.getGuid(), type, state, isArchived, parent, assocArtId); + private static void assertBranch(List<BranchReadable> list, IOseeBranch token, BranchType type, BranchState state, boolean isArchived, BranchId parent, ArtifactId associatedArtifact) { + int index = list.indexOf(token); + Assert.assertNotEquals(index, -1); + assertBranch(list.get(index), token.getName(), token.getGuid(), type, state, isArchived, parent, + associatedArtifact); } - private static void assertBranch(BranchReadable actual, String name, Long localId, BranchType type, BranchState state, boolean isArchived, BranchId parent, int assocArtId) { + private static void assertBranch(BranchReadable actual, String name, Long localId, BranchType type, BranchState state, boolean isArchived, BranchId parent, ArtifactId associatedArtifact) { assertEquals(name, actual.getName()); assertEquals(localId, actual.getUuid()); @@ -327,6 +323,6 @@ public class OrcsBranchQueryTest { assertEquals(state, actual.getBranchState()); assertEquals(isArchived, actual.getArchiveState().isArchived()); assertEquals(parent, actual.getParentBranch()); - assertEquals(assocArtId, actual.getAssociatedArtifactId()); + assertEquals(associatedArtifact, actual.getAssociatedArtifact()); } } diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java index cd10a2e8a89..c2e1a91b137 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsBranchTest.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.orcs.api; +import static org.eclipse.osee.framework.core.data.ArtifactId.SENTINEL; import static org.eclipse.osee.orcs.OrcsIntegrationRule.integrationRule; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -31,7 +32,6 @@ import org.eclipse.osee.framework.core.enums.CoreBranches; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.enums.SystemUser; import org.eclipse.osee.framework.core.model.change.ChangeItem; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.OrcsApi; import org.eclipse.osee.orcs.OrcsBranch; import org.eclipse.osee.orcs.data.ArtifactReadable; @@ -81,10 +81,10 @@ public class OrcsBranchTest { // set up the initial branch IOseeBranch branch = TokenFactory.createBranch("PriorBranch"); - ArtifactReadable author = getSystemUser(); + ArtifactId author = SystemUser.OseeSystem; TransactionId tx = TransactionId.valueOf(SOURCE_TX_ID); - Callable<BranchReadable> callable = branchOps.createCopyTxBranch(branch, author, tx, null); + Callable<BranchReadable> callable = branchOps.createCopyTxBranch(branch, author, tx, ArtifactId.SENTINEL); assertNotNull(callable); BranchReadable priorBranch = callable.call(); @@ -108,7 +108,8 @@ public class OrcsBranchTest { IOseeBranch postbranch = TokenFactory.createBranch("PostBranch"); TransactionId tx1 = TransactionId.valueOf(CHANGED_TX_ID); - Callable<BranchReadable> postCallable = branchOps.createCopyTxBranch(postbranch, author, tx1, null); + Callable<BranchReadable> postCallable = + branchOps.createCopyTxBranch(postbranch, author, tx1, ArtifactId.SENTINEL); assertNotNull(postCallable); BranchReadable postBranch = postCallable.call(); @@ -133,10 +134,10 @@ public class OrcsBranchTest { // create the branch with the copied transaction IOseeBranch branch = TokenFactory.createBranch("CopiedBranch"); - ArtifactReadable author = getSystemUser(); + ArtifactId author = SystemUser.OseeSystem; TransactionId tx = TransactionId.valueOf(SOURCE_TX_ID); - Callable<BranchReadable> callableBranch = branchOps.createCopyTxBranch(branch, author, tx, null); + Callable<BranchReadable> callableBranch = branchOps.createCopyTxBranch(branch, author, tx, ArtifactId.SENTINEL); // the new branch will contain two transactions - these should have the same change report as the original branch BranchReadable postBranch = callableBranch.call(); @@ -148,8 +149,7 @@ public class OrcsBranchTest { @Test public void testCommitBranchMissingArtifactsOnDestination() throws Exception { - ArtifactReadable author = - query.fromBranch(CoreBranches.COMMON).andNameEquals("OSEE System").getResults().getExactlyOne(); + ArtifactId author = SystemUser.OseeSystem; // set up the initial branch IOseeBranch branch = TokenFactory.createBranch("BaseBranch"); @@ -163,7 +163,8 @@ public class OrcsBranchTest { // create working branch off of base to make some changes // set up the child branch IOseeBranch branchName = TokenFactory.createBranch("ChildBranch"); - Callable<BranchReadable> callableChildBranch = branchOps.createWorkingBranch(branchName, author, base, null); + Callable<BranchReadable> callableChildBranch = + branchOps.createWorkingBranch(branchName, author, base, ArtifactId.SENTINEL); BranchReadable childBranch = callableChildBranch.call(); @@ -183,7 +184,7 @@ public class OrcsBranchTest { IOseeBranch commonName = TokenFactory.createBranch("ChildFromCommonBranch"); Callable<BranchReadable> callableBranchFromCommon = - branchOps.createWorkingBranch(commonName, author, CoreBranches.COMMON, null); + branchOps.createWorkingBranch(commonName, author, CoreBranches.COMMON, ArtifactId.SENTINEL); BranchReadable commonChildBranch = callableBranchFromCommon.call(); branchOps.commitBranch(author, childBranch, commonChildBranch).call(); @@ -198,50 +199,50 @@ public class OrcsBranchTest { IOseeBranch branch = TokenFactory.createBranch(branchName); - branchOps.createBaselineBranch(branch, getSystemUser(), CoreBranches.SYSTEM_ROOT, null).call(); + branchOps.createBaselineBranch(branch, SystemUser.OseeSystem, CoreBranches.SYSTEM_ROOT, SENTINEL).call(); BranchReadable actual = getBranch(branch); Long id = actual.getUuid(); - assertBranch(actual, id, branchName, BranchState.CREATED, BranchType.BASELINE, -1); + assertBranch(actual, id, branchName, BranchState.CREATED, BranchType.BASELINE, SENTINEL); branchName = "another-name"; branchOps.changeBranchName(branch, branchName).call(); actual = getBranch(branch); - assertBranch(actual, id, branchName, BranchState.CREATED, BranchType.BASELINE, -1); + assertBranch(actual, id, branchName, BranchState.CREATED, BranchType.BASELINE, SENTINEL); BranchState branchState = BranchState.DELETED; branchOps.changeBranchState(branch, branchState).call(); actual = getBranch(branch); - assertBranch(actual, id, branchName, branchState, BranchType.BASELINE, -1); + assertBranch(actual, id, branchName, branchState, BranchType.BASELINE, SENTINEL); BranchType branchType = BranchType.WORKING; branchOps.changeBranchType(branch, branchType).call(); actual = getBranch(branch); - assertBranch(actual, id, branchName, branchState, branchType, -1); + assertBranch(actual, id, branchName, branchState, branchType, SENTINEL); - ArtifactReadable assocArtifact = getSystemUser(); + ArtifactId assocArtifact = SystemUser.OseeSystem; branchOps.associateBranchToArtifact(branch, assocArtifact).call(); actual = getBranch(branch); - assertBranch(actual, id, branchName, branchState, branchType, assocArtifact.getLocalId()); + assertBranch(actual, id, branchName, branchState, branchType, assocArtifact); branchOps.unassociateBranch(branch).call(); actual = getBranch(branch); - assertBranch(actual, id, branchName, branchState, branchType, -1); + assertBranch(actual, id, branchName, branchState, branchType, SENTINEL); } - private void assertBranch(BranchReadable branch, Long id, String name, BranchState state, BranchType type, int assocArtId) { + private void assertBranch(BranchReadable branch, Long id, String name, BranchState state, BranchType type, ArtifactId assocArtId) { assertEquals(id, branch.getGuid()); assertEquals(id, branch.getUuid()); assertEquals(name, branch.getName()); assertEquals(state, branch.getBranchState()); assertEquals(type, branch.getBranchType()); - assertEquals(assocArtId, branch.getAssociatedArtifactId()); + assertEquals(assocArtId, branch.getAssociatedArtifact()); } private BranchReadable getBranch(BranchId branch) { @@ -269,9 +270,4 @@ public class OrcsBranchTest { Collections.sort(newItems); assertEquals(priorItems, newItems); } - - private ArtifactReadable getSystemUser() throws OseeCoreException { - return query.fromBranch(CoreBranches.COMMON).andIds(SystemUser.OseeSystem).getResults().getExactlyOne(); - } - -} +}
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsPortingTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsPortingTest.java index 9e06f263f9a..40421b6cce4 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsPortingTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsPortingTest.java @@ -58,30 +58,26 @@ public class OrcsPortingTest { private QueryFactory query; private TransactionFactory txFactory; private final String branchString = "CopiedTxBranch"; - - private ArtifactReadable author; + private final ArtifactId author = SystemUser.OseeSystem; @Before public void setUp() throws Exception { branchApi = orcsApi.getBranchOps(); query = orcsApi.getQueryFactory(); txFactory = orcsApi.getTransactionFactory(); - - author = query.fromBranch(CoreBranches.COMMON).andIds(SystemUser.OseeSystem).getResults().getExactlyOne(); } @Test public void testCreateBranch() throws Exception { String artifactGuid = GUID.create(); - String assocArtifactGuid = GUID.create(); - setupAssociatedArtifact(assocArtifactGuid); + ArtifactId assocaitedArt = setupAssociatedArtifact(); TransactionToken mainBranchTx = createBaselineBranchAndArtifacts(artifactGuid); IOseeBranch branch = TokenFactory.createBranch(mainBranchTx.getBranchId(), "testCreateBranch"); TransactionId transactionToCopy = createWorkingBranchChanges(branch, artifactGuid); - BranchId copyTxBranch = createCopyFromTransactionBranch(transactionToCopy, assocArtifactGuid); + BranchId copyTxBranch = createCopyFromTransactionBranch(transactionToCopy, assocaitedArt); TransactionToken finalTx = commitToDestinationBranch(copyTxBranch); // now check to make sure everything is as expected @@ -115,19 +111,18 @@ public class OrcsPortingTest { String artifactGuid = GUID.create(); String differentGuid = GUID.create(); - String assocArtifactGuid = GUID.create(); - setupAssociatedArtifact(assocArtifactGuid); + ArtifactId assocaitedArt = setupAssociatedArtifact(); TransactionId mainBranchTx = createBaselineBranchAndArtifacts(artifactGuid); TransactionId differentBranchTx = createBaselineBranchAndArtifacts(differentGuid); - BranchId copyTxBranch = createCopyFromTransactionBranch(mainBranchTx, assocArtifactGuid); + BranchId copyTxBranch = createCopyFromTransactionBranch(mainBranchTx, assocaitedArt); assertNotNull(copyTxBranch); // There should only be one Port Branch per associated artifact. Expecting an exception thrown.expect(OseeCoreException.class); thrown.expectMessage(String.format("Existing port branch creation detected for [%s]", branchString)); - createCopyFromTransactionBranch(differentBranchTx, assocArtifactGuid); + createCopyFromTransactionBranch(differentBranchTx, assocaitedArt); fail(); // should never get here due to thrown exception } @@ -149,19 +144,20 @@ public class OrcsPortingTest { return tx2.commit(); } - private void setupAssociatedArtifact(String associatedArtifactGuid) throws Exception { + private ArtifactId setupAssociatedArtifact() throws Exception { TransactionBuilder tx = txFactory.createTransaction(CoreBranches.COMMON, author, "setup associated artifact"); // normally the associated artifact would be a work flow, // but since that is an ATS construct, we are just using a requirement - tx.createArtifact(CoreArtifactTypes.Requirement, "AssociatedArtifact", associatedArtifactGuid); + ArtifactId assocaitedArt = tx.createArtifact(CoreArtifactTypes.Requirement, "AssociatedArtifact"); tx.commit(); + return assocaitedArt; } private TransactionId createWorkingBranchChanges(IOseeBranch parentBranch, String artifactToModifyGuid) throws Exception { // set up the child branch to copy to IOseeBranch childBranch = TokenFactory.createBranch("childBranch"); - branchApi.createWorkingBranch(childBranch, author, parentBranch, null).call(); + branchApi.createWorkingBranch(childBranch, author, parentBranch, ArtifactId.SENTINEL).call(); TransactionBuilder tx3 = txFactory.createTransaction(childBranch, author, "update second requirement"); ArtifactReadable readableReq2 = @@ -191,14 +187,14 @@ public class OrcsPortingTest { return transactionToCopy; } - private BranchId createCopyFromTransactionBranch(TransactionId transactionToCopy, String assocArtifactGuid) throws Exception { + private BranchId createCopyFromTransactionBranch(TransactionId transactionToCopy, ArtifactId assocaitedArt) throws Exception { // create the branch with the copied transaction IOseeBranch branch = TokenFactory.createBranch(branchString); // get the setup associated artifact - this is for a later test to make sure the branch is not duplicated // there should only be one port branch per associated artifact ArtifactReadable readableReq = - query.fromBranch(CoreBranches.COMMON).andGuid(assocArtifactGuid).getResults().getExactlyOne(); + query.fromBranch(CoreBranches.COMMON).andIds(assocaitedArt).getResults().getExactlyOne(); assertNotNull(readableReq); // the new branch will contain two transactions - diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java index 053eefc096e..81c6d8283d5 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsQueryTest.java @@ -30,8 +30,8 @@ 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.CoreArtifactTokens; import org.eclipse.osee.framework.core.data.TransactionId; +import org.eclipse.osee.framework.core.enums.CoreArtifactTokens; import org.eclipse.osee.framework.core.enums.CoreArtifactTypes; import org.eclipse.osee.framework.core.enums.CoreAttributeTypes; import org.eclipse.osee.framework.core.enums.CoreRelationTypes; @@ -81,7 +81,7 @@ public class OrcsQueryTest { private OrcsBranch branchApi; private TransactionFactory txFactory; private QueryFactory factory; - private static ArtifactReadable author; + private final ArtifactId author = SystemUser.OseeSystem; @Before public void setup() { @@ -467,7 +467,7 @@ public class OrcsQueryTest { // Add a child ArtifactReadable parent = results.iterator().next().getParent(); - TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(SAW_Bld_2, getAuthor(), "FollowTest"); + TransactionBuilder tx = orcsApi.getTransactionFactory().createTransaction(SAW_Bld_2, author, "FollowTest"); ArtifactId child = tx.createArtifact(CoreArtifactTypes.SoftwareRequirement, "Dummy Robot"); tx.relate(parent, CoreRelationTypes.Default_Hierarchical__Child, child); TransactionId commitTx = tx.commit(); @@ -490,13 +490,6 @@ public class OrcsQueryTest { assertEquals("Robot collaboration", iterator.next()); } - private ArtifactReadable getAuthor() { - if (author == null) { - author = factory.fromBranch(COMMON_ID).andIds(SystemUser.OseeSystem).getResults().getExactlyOne(); - } - return author; - } - @Test public void testRelatedTo() { // do a query on branch @@ -505,7 +498,7 @@ public class OrcsQueryTest { .andIsOfType(CoreArtifactTypes.SoftwareRequirement).getResults().getExactlyOne(); // create a tx on branch - TransactionBuilder tx = txFactory.createTransaction(SAW_Bld_2, getAuthor(), "Simple Tx"); + TransactionBuilder tx = txFactory.createTransaction(SAW_Bld_2, author, "Simple Tx"); tx.createArtifact(CoreArtifactTypes.Folder, "Just a Folder"); tx.commit(); @@ -525,8 +518,8 @@ public class OrcsQueryTest { .andIsOfType(CoreArtifactTypes.SoftwareRequirement).getResults().getExactlyOne(); // create a tx on branch - TransactionBuilder tx1 = txFactory.createTransaction(SAW_Bld_2, getAuthor(), "Simple Tx1"); - TransactionBuilder tx2 = txFactory.createTransaction(SAW_Bld_2, getAuthor(), "Simple Tx2"); + TransactionBuilder tx1 = txFactory.createTransaction(SAW_Bld_2, author, "Simple Tx1"); + TransactionBuilder tx2 = txFactory.createTransaction(SAW_Bld_2, author, "Simple Tx2"); ArtifactId folder = tx1.createArtifact(CoreArtifactTypes.Folder, "Just a Folder"); tx1.commit(); @@ -553,7 +546,6 @@ public class OrcsQueryTest { } private BranchReadable setupNameEqualsArtifacts() throws Exception { - getAuthor(); IOseeBranch branchToken = TokenFactory.createBranch("TestAndNameEquals"); BranchReadable branch = branchApi.createTopLevelBranch(branchToken, author).call(); TransactionBuilder tx = txFactory.createTransaction(branch, author, "add folders"); diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java index 0e954c66d01..0d9cbbfc505 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTransactionTest.java @@ -13,12 +13,12 @@ package org.eclipse.osee.orcs.api; import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.Component; import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.GeneralDocument; import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; -import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON_ID; import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Child; import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Default_Hierarchical__Parent; import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Dependency__Artifact; import static org.eclipse.osee.framework.core.enums.CoreRelationTypes.Dependency__Dependency; import static org.eclipse.osee.framework.core.enums.RelationOrderBaseTypes.LEXICOGRAPHICAL_DESC; +import static org.eclipse.osee.framework.core.enums.SystemUser.OseeSystem; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -33,6 +33,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.concurrent.Callable; import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TokenFactory; import org.eclipse.osee.framework.core.data.TransactionId; @@ -87,7 +88,7 @@ public class OrcsTransactionTest { private OrcsApi orcsApi; private TransactionFactory txFactory; - private ArtifactReadable userArtifact; + private final ArtifactId userArtifact = OseeSystem; private OrcsBranch orcsBranch; private QueryFactory query; @@ -101,7 +102,6 @@ public class OrcsTransactionTest { txFactory = orcsApi.getTransactionFactory(); orcsBranch = orcsApi.getBranchOps(); query = orcsApi.getQueryFactory(); - userArtifact = getSystemUser(); } @AfterClass @@ -122,7 +122,7 @@ public class OrcsTransactionTest { tx.commit(); ResultSet<ArtifactReadable> results = - query.fromBranch(COMMON_ID).andIsOfType(CoreArtifactTypes.SoftwareRequirementPlainText).getResults(); + query.fromBranch(COMMON).andIsOfType(CoreArtifactTypes.SoftwareRequirementPlainText).getResults(); Optional<ArtifactReadable> item = Iterables.tryFind(results, new Predicate<ArtifactReadable>() { @Override @@ -150,9 +150,9 @@ public class OrcsTransactionTest { query.branchQuery(); TransactionQuery transactionQuery = query.transactionQuery(); - TransactionReadable previousTx = transactionQuery.andIsHead(COMMON_ID).getResults().getExactlyOne(); + TransactionReadable previousTx = transactionQuery.andIsHead(COMMON).getResults().getExactlyOne(); - TransactionBuilder tx = txFactory.createTransaction(COMMON_ID, userArtifact, comment); + TransactionBuilder tx = txFactory.createTransaction(COMMON, userArtifact, comment); ArtifactId artifactId = tx.createArtifact(CoreArtifactTypes.Folder, expectedName); @@ -162,14 +162,14 @@ public class OrcsTransactionTest { TransactionReadable newTx = tx.commit(); assertFalse(tx.isCommitInProgress()); - TransactionReadable newHeadTx = transactionQuery.andIsHead(COMMON_ID).getResults().getExactlyOne(); + TransactionReadable newHeadTx = transactionQuery.andIsHead(COMMON).getResults().getExactlyOne(); assertEquals(newTx, newHeadTx); TransactionReadable newTxReadable = transactionQuery.andTxId(newTx).getResults().getExactlyOne(); - checkTransaction(previousTx, newTxReadable, COMMON_ID, comment, userArtifact); + checkTransaction(previousTx, newTxReadable, COMMON, comment, userArtifact); - ResultSet<ArtifactReadable> result = query.fromBranch(COMMON_ID).andIds(artifactId).getResults(); + ResultSet<ArtifactReadable> result = query.fromBranch(COMMON).andIds(artifactId).getResults(); ArtifactReadable artifact = result.getExactlyOne(); @@ -189,9 +189,9 @@ public class OrcsTransactionTest { query.branchQuery(); TransactionQuery transactionQuery = query.transactionQuery(); - transactionQuery.andIsHead(COMMON_ID).getResults().getExactlyOne(); + transactionQuery.andIsHead(COMMON).getResults().getExactlyOne(); - TransactionBuilder tx = txFactory.createTransaction(COMMON_ID, userArtifact, comment); + TransactionBuilder tx = txFactory.createTransaction(COMMON, userArtifact, comment); ArtifactId artifactId = tx.createArtifact(CoreArtifactTypes.SubsystemRequirementHTML, expectedName); @@ -201,7 +201,7 @@ public class OrcsTransactionTest { tx.commit(); - ArtifactReadable artifactReadable = query.fromBranch(COMMON_ID).andIds(artifactId).getResults().getExactlyOne(); + ArtifactReadable artifactReadable = query.fromBranch(COMMON).andIds(artifactId).getResults().getExactlyOne(); assertEquals(expectedName, artifactReadable.getName()); assertEquals(expectedQualifaction, artifactReadable.getSoleAttributeAsString(CoreAttributeTypes.QualificationMethod)); @@ -210,13 +210,13 @@ public class OrcsTransactionTest { @Test public void testCopyArtifact() throws Exception { - ArtifactReadable user = query.fromBranch(COMMON_ID).andIds(SystemUser.Anonymous).getResults().getExactlyOne(); + ArtifactReadable user = query.fromBranch(COMMON).andIds(SystemUser.Anonymous).getResults().getExactlyOne(); // duplicate on same branch TransactionBuilder transaction1 = createTx(); ArtifactId duplicate = transaction1.copyArtifact(user); transaction1.commit(); - ArtifactReadable userDup = query.fromBranch(COMMON_ID).andIds(duplicate).getResults().getExactlyOne(); + ArtifactReadable userDup = query.fromBranch(COMMON).andIds(duplicate).getResults().getExactlyOne(); assertNotSame(SystemUser.Anonymous.getGuid(), userDup.getGuid()); assertEquals(SystemUser.Anonymous.getName(), userDup.getName()); @@ -239,7 +239,7 @@ public class OrcsTransactionTest { @Test public void testIntroduceArtifact() throws Exception { - ArtifactReadable user = query.fromBranch(COMMON_ID).andIds(SystemUser.Anonymous).getResults().getExactlyOne(); + ArtifactReadable user = query.fromBranch(COMMON).andIds(SystemUser.Anonymous).getResults().getExactlyOne(); IOseeBranch branchToken = TokenFactory.createBranch("IntroduceArtifact tests"); BranchReadable topLevelBranch = orcsBranch.createTopLevelBranch(branchToken, userArtifact).call(); @@ -256,7 +256,7 @@ public class OrcsTransactionTest { @Test public void testIntroduceOnSameBranch() throws OseeCoreException { - ArtifactReadable user = query.fromBranch(COMMON_ID).andIds(SystemUser.Anonymous).getResults().getExactlyOne(); + ArtifactReadable user = query.fromBranch(COMMON).andIds(SystemUser.Anonymous).getResults().getExactlyOne(); TransactionBuilder tx = createTx(); @@ -266,7 +266,7 @@ public class OrcsTransactionTest { @Test public void testReadAfterWrite() throws OseeCoreException { - QueryBuilder queryBuilder = query.fromBranch(COMMON_ID).andIds(SystemUser.OseeSystem); + QueryBuilder queryBuilder = query.fromBranch(COMMON).andIds(OseeSystem); ArtifactReadable oseeSystem = queryBuilder.getResults().getExactlyOne(); @@ -276,7 +276,7 @@ public class OrcsTransactionTest { ArtifactReadable newGuest = queryBuilder.getResults().getExactlyOne(); - assertEquals(SystemUser.OseeSystem.getName(), oseeSystem.getName()); + assertEquals(OseeSystem.getName(), oseeSystem.getName()); assertEquals("Test", newGuest.getName()); } @@ -286,13 +286,13 @@ public class OrcsTransactionTest { ArtifactId artifact = tx.createArtifact(CoreArtifactTypes.AccessControlModel, "deleteMe"); tx.commit(); - ArtifactReadable toDelete = query.fromBranch(COMMON_ID).andIds(artifact).getResults().getExactlyOne(); + ArtifactReadable toDelete = query.fromBranch(COMMON).andIds(artifact).getResults().getExactlyOne(); - tx = txFactory.createTransaction(COMMON_ID, userArtifact, testName.getMethodName()); + tx = txFactory.createTransaction(COMMON, userArtifact, testName.getMethodName()); tx.deleteArtifact(toDelete); tx.commit(); - toDelete = query.fromBranch(COMMON_ID).andIds(artifact).includeDeletedArtifacts().getResults().getOneOrNull(); + toDelete = query.fromBranch(COMMON).andIds(artifact).includeDeletedArtifacts().getResults().getOneOrNull(); assertNotNull(toDelete); assertTrue(toDelete.isDeleted()); } @@ -309,31 +309,31 @@ public class OrcsTransactionTest { tx.deleteAttributes(artifact, CoreAttributeTypes.GeneralStringData); tx.commit(); - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.andExists(CoreAttributeTypes.GeneralStringData); builder.andIds(artifact); ResultSet<ArtifactReadable> artifacts = builder.getResults(); assertEquals(0, artifacts.size()); - builder = query.fromBranch(COMMON_ID); + builder = query.fromBranch(COMMON); builder.andExists(CoreAttributeTypes.GeneralStringData); builder.andIds(artifact); builder.includeDeletedAttributes(); artifacts = builder.getResults(); assertEquals(1, artifacts.size()); - builder = query.fromBranch(COMMON_ID); + builder = query.fromBranch(COMMON); builder.andExists(CoreAttributeTypes.Annotation); builder.andIds(artifact); builder.includeDeletedAttributes(); artifacts = builder.getResults(); assertEquals(0, artifacts.size()); - ArtifactReadable toDelete = query.fromBranch(COMMON_ID).andIds(artifact).getResults().getExactlyOne(); + ArtifactReadable toDelete = query.fromBranch(COMMON).andIds(artifact).getResults().getExactlyOne(); tx = createTx(); tx.deleteArtifact(toDelete); tx.commit(); - toDelete = query.fromBranch(COMMON_ID).andIds(artifact).includeDeletedArtifacts().getResults().getOneOrNull(); + toDelete = query.fromBranch(COMMON).andIds(artifact).includeDeletedArtifacts().getResults().getOneOrNull(); assertNotNull(toDelete); assertTrue(toDelete.isDeleted()); @@ -348,29 +348,29 @@ public class OrcsTransactionTest { ArtifactId artifact2 = tx.createArtifact(CoreArtifactTypes.Folder, "deleteThisFolder"); tx.createAttribute(artifact2, CoreAttributeTypes.Annotation, "annotation"); tx.relate(artifact2, Default_Hierarchical__Parent, artifact1); - TransactionId tx1 = tx.commit(); + TransactionId tx1 = tx.commit(); artifactsZero = artifact1; artifactsOne = artifact2; tx = createTx(); tx.deleteAttributes(artifact1, CoreAttributeTypes.GeneralStringData); - TransactionId tx2 = tx.commit(); + TransactionId tx2 = tx.commit(); - ArtifactReadable toDelete = query.fromBranch(COMMON_ID).andIds(artifact1).getResults().getExactlyOne(); + ArtifactReadable toDelete = query.fromBranch(COMMON).andIds(artifact1).getResults().getExactlyOne(); tx = createTx(); tx.deleteArtifact(toDelete); tx.deleteAttributes(artifact2, CoreAttributeTypes.Annotation); tx.unrelate(artifact2, Default_Hierarchical__Parent, artifact1); - TransactionId tx3 = tx.commit(); + TransactionId tx3 = tx.commit(); - toDelete = query.fromBranch(COMMON_ID).andIds(artifact2).getResults().getExactlyOne(); + toDelete = query.fromBranch(COMMON).andIds(artifact2).getResults().getExactlyOne(); tx = createTx(); tx.deleteArtifact(toDelete); - TransactionId tx4 = tx.commit(); + TransactionId tx4 = tx.commit(); - toDelete = query.fromBranch(COMMON_ID).andIds(artifact1).includeDeletedArtifacts().getResults().getOneOrNull(); + toDelete = query.fromBranch(COMMON).andIds(artifact1).includeDeletedArtifacts().getResults().getOneOrNull(); assertNotNull(toDelete); assertTrue(toDelete.isDeleted()); toReturn = new TransactionId[] {tx1, tx2, tx3, tx4}; @@ -378,7 +378,7 @@ public class OrcsTransactionTest { } artifacts[0] = artifactsZero; artifacts[1] = artifactsOne; - return toReturn; + return toReturn; } @Test @@ -388,7 +388,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[0]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact1, artifact2); @@ -403,7 +403,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[2]); builder.andIds(artifact1, artifact2); ResultSet<ArtifactReadable> artifacts = builder.getResults(); @@ -417,7 +417,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[1]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact1, artifact2); @@ -434,7 +434,7 @@ public class OrcsTransactionTest { ArtifactId[] theArtifacts = {null, null}; TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[1]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact1); @@ -448,7 +448,7 @@ public class OrcsTransactionTest { ArtifactId[] theArtifacts = {null, null}; TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[1]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact1); @@ -464,7 +464,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[1]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact2, artifact1); @@ -480,7 +480,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[2]); builder.andIds(artifact1, artifact2); ResultSet<ArtifactReadable> artifacts = builder.getResults(); @@ -494,7 +494,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[2]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact1, artifact2); @@ -510,7 +510,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[2]); builder.andExists(CoreAttributeTypes.PublishInline, CoreAttributeTypes.Annotation); builder.andIds(artifact1, artifact2); @@ -526,7 +526,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[1]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact2, artifact1); @@ -538,7 +538,7 @@ public class OrcsTransactionTest { if (!artifact1Actual.equals(artifact2)) { artifact1Actual = iter.next(); } - builder = query.fromBranch(COMMON_ID); + builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[1]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact1, artifact2); @@ -556,7 +556,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[1]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact2, artifact1); @@ -568,7 +568,7 @@ public class OrcsTransactionTest { if (!artifact1Actual.equals(artifact2)) { artifact1Actual = iter.next(); } - builder = query.fromBranch(COMMON_ID); + builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[2]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact1, artifact2); @@ -586,7 +586,7 @@ public class OrcsTransactionTest { TransactionId[] transactions = setupHistory(theArtifacts); ArtifactId artifact1 = theArtifacts[0]; ArtifactId artifact2 = theArtifacts[1]; - QueryBuilder builder = query.fromBranch(COMMON_ID); + QueryBuilder builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[1]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact2, artifact1); @@ -598,7 +598,7 @@ public class OrcsTransactionTest { if (!artifact1Actual.equals(artifact2)) { artifact1Actual = iter.next(); } - builder = query.fromBranch(COMMON_ID); + builder = query.fromBranch(COMMON); builder.fromTransaction(transactions[2]); builder.andExists(CoreAttributeTypes.GeneralStringData, CoreAttributeTypes.Annotation); builder.andIds(artifact1, artifact2); @@ -642,7 +642,7 @@ public class OrcsTransactionTest { String guid = tx.createArtifact(CoreArtifactTypes.Component, "A component").getGuid(); TransactionId startingTx = tx.commit(); - ArtifactReadable artifact = query.fromBranch(COMMON_ID).andGuid(guid).getResults().getExactlyOne(); + ArtifactReadable artifact = query.fromBranch(COMMON).andGuid(guid).getResults().getExactlyOne(); assertEquals(startingTx, artifact.getTransaction()); TransactionBuilder tx2 = createTx(); @@ -651,7 +651,7 @@ public class OrcsTransactionTest { assertFalse(startingTx.equals(lastTx)); - ArtifactReadable currentArtifact = query.fromBranch(COMMON_ID).andGuid(guid).getResults().getExactlyOne(); + ArtifactReadable currentArtifact = query.fromBranch(COMMON).andGuid(guid).getResults().getExactlyOne(); assertEquals(lastTx, currentArtifact.getTransaction()); } @@ -663,7 +663,7 @@ public class OrcsTransactionTest { tx1.relate(art1, CoreRelationTypes.Users_User, art2); tx1.commit(); - ArtifactReadable artifact = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactReadable artifact = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); assertEquals("A component", artifact.getName()); ResultSet<ArtifactReadable> related = artifact.getRelated(CoreRelationTypes.Users_User); @@ -692,7 +692,7 @@ public class OrcsTransactionTest { tx1.addChildren(art1, art2, art3); TransactionId tx1Id = tx1.commit(); - QueryBuilder art1Query = query.fromBranch(COMMON_ID).andIds(art1); + QueryBuilder art1Query = query.fromBranch(COMMON).andIds(art1); ArtifactReadable artifact = art1Query.getResults().getExactlyOne(); assertEquals("A component", artifact.getName()); @@ -733,7 +733,7 @@ public class OrcsTransactionTest { tx1.addChildren(art1, art2); tx1.commit(); - ArtifactReadable artifact1 = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactReadable artifact1 = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); assertEquals("A component", artifact1.getName()); ResultSet<ArtifactReadable> children = artifact1.getChildren(); @@ -750,7 +750,7 @@ public class OrcsTransactionTest { tx2.setRelations(art1, Default_Hierarchical__Child, Arrays.asList(art3, art4)); tx2.commit(); - artifact1 = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + artifact1 = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); assertEquals("A component", artifact1.getName()); children = artifact1.getChildren(); @@ -769,7 +769,7 @@ public class OrcsTransactionTest { assertEquals(art3, artifact3); assertEquals(art4, artifact4); - artifact2 = query.fromBranch(COMMON_ID).andIds(art2).getResults().getExactlyOne(); + artifact2 = query.fromBranch(COMMON).andIds(art2).getResults().getExactlyOne(); assertEquals("B component", artifact2.getName()); assertNull(artifact2.getParent()); assertEquals(art2, artifact2); @@ -787,7 +787,7 @@ public class OrcsTransactionTest { tx2.addChildren(art1, art2, art3); tx2.commit(); - ArtifactReadable artifact1 = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactReadable artifact1 = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); assertEquals("A component", artifact1.getName()); ResultSet<ArtifactReadable> children = artifact1.getChildren(); @@ -820,7 +820,7 @@ public class OrcsTransactionTest { tx1.commit(); - ArtifactReadable artifact = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactReadable artifact = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); assertEquals("A component", artifact.getName()); ResultSet<ArtifactReadable> children = artifact.getChildren(); @@ -847,7 +847,7 @@ public class OrcsTransactionTest { tx1.relate(art1, Dependency__Dependency, art4); tx1.commit(); - ArtifactReadable artifact4 = query.fromBranch(COMMON_ID).andIds(art4).getResults().getExactlyOne(); + ArtifactReadable artifact4 = query.fromBranch(COMMON).andIds(art4).getResults().getExactlyOne(); assertEquals(art4, artifact4); ArtifactReadable artifact1 = artifact4.getRelated(CoreRelationTypes.Dependency__Artifact).getExactlyOne(); @@ -862,7 +862,7 @@ public class OrcsTransactionTest { tx2.unrelate(art1, Default_Hierarchical__Child, art2); tx2.commit(); - artifact4 = query.fromBranch(COMMON_ID).andIds(art4).getResults().getExactlyOne(); + artifact4 = query.fromBranch(COMMON).andIds(art4).getResults().getExactlyOne(); assertEquals(art4, artifact4); artifact1 = artifact4.getRelated(CoreRelationTypes.Dependency__Artifact).getExactlyOne(); @@ -883,7 +883,7 @@ public class OrcsTransactionTest { tx1.relate(art1, Dependency__Dependency, art4); tx1.commit(); - ArtifactReadable artifact4 = query.fromBranch(COMMON_ID).andIds(art4).getResults().getExactlyOne(); + ArtifactReadable artifact4 = query.fromBranch(COMMON).andIds(art4).getResults().getExactlyOne(); assertEquals(art4, artifact4); ArtifactReadable artifact1 = artifact4.getRelated(Dependency__Artifact).getExactlyOne(); @@ -898,7 +898,7 @@ public class OrcsTransactionTest { tx2.unrelateFromAll(Default_Hierarchical__Parent, art1); tx2.commit(); - artifact4 = query.fromBranch(COMMON_ID).andIds(art4).getResults().getExactlyOne(); + artifact4 = query.fromBranch(COMMON).andIds(art4).getResults().getExactlyOne(); assertEquals(art4, artifact4); artifact1 = artifact4.getRelated(Dependency__Artifact).getExactlyOne(); @@ -914,18 +914,18 @@ public class OrcsTransactionTest { ArtifactId art1 = tx1.createArtifact(Component, "orig name"); TransactionId rec1 = tx1.commit(); assertNotNull(rec1); - art1 = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + art1 = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); assertEquals("orig name", art1.getName()); // change name - ArtifactId art2 = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactId art2 = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); TransactionBuilder tx2 = createTx(); tx2.setName(art2, "new name"); TransactionId rec2 = tx2.commit(); assertNotNull(rec2); // verify that change only exists on new stripe? - ArtifactId art3 = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactId art3 = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); assertEquals("orig name", art1.getName()); // this should be same name cause we didn't re-query it and the tx didn't change the model? assertEquals("orig name", art2.getName()); @@ -951,7 +951,7 @@ public class OrcsTransactionTest { TransactionId rec1 = tx1.commit(); assertNotNull(rec1); - artifact4 = query.fromBranch(COMMON_ID).andIds(art4).getResults().getExactlyOne(); + artifact4 = query.fromBranch(COMMON).andIds(art4).getResults().getExactlyOne(); assertEquals(art4, artifact4); artifact1 = artifact4.getRelated(Dependency__Artifact).getExactlyOne(); @@ -966,14 +966,14 @@ public class OrcsTransactionTest { TransactionId rec2 = tx2.commit(); assertNotNull(rec2); - artifact1 = query.fromBranch(COMMON_ID).andUuid( - art1.getUuid()).includeDeletedArtifacts().getResults().getAtMostOneOrNull(); + artifact1 = + query.fromBranch(COMMON).andUuid(art1.getUuid()).includeDeletedArtifacts().getResults().getAtMostOneOrNull(); assertNotNull(artifact1); - artifact2 = query.fromBranch(COMMON_ID).andUuid(art2.getUuid()).getResults().getAtMostOneOrNull(); + artifact2 = query.fromBranch(COMMON).andUuid(art2.getUuid()).getResults().getAtMostOneOrNull(); assertNotNull(artifact2); - artifact3 = query.fromBranch(COMMON_ID).andUuid(art3.getUuid()).getResults().getAtMostOneOrNull(); + artifact3 = query.fromBranch(COMMON).andUuid(art3.getUuid()).getResults().getAtMostOneOrNull(); assertNotNull(artifact3); - artifact4 = query.fromBranch(COMMON_ID).andUuid(art4.getUuid()).getResults().getAtMostOneOrNull(); + artifact4 = query.fromBranch(COMMON).andUuid(art4.getUuid()).getResults().getAtMostOneOrNull(); assertNotNull(artifact4); assertEquals(true, artifact1.getChildren().isEmpty()); @@ -1008,13 +1008,13 @@ public class OrcsTransactionTest { tx.setSoleAttributeFromString(art1, CoreAttributeTypes.Annotation, "write5"); TransactionId lastTx = tx.commit(); - ArtifactReadable art = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactReadable art = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); ResultSet<? extends AttributeReadable<Object>> attributes = art.getAttributes(CoreAttributeTypes.Annotation); assertEquals(1, attributes.size()); assertEquals("write5", attributes.getExactlyOne().getValue()); - QueryBuilder builder = query.fromBranch(COMMON_ID).fromTransaction(lastTx).andIds(art1); + QueryBuilder builder = query.fromBranch(COMMON).fromTransaction(lastTx).andIds(art1); ResultSet<ArtifactReadable> results = builder.getResults(); art = results.getExactlyOne(); attributes = art.getAttributes(CoreAttributeTypes.Annotation); @@ -1046,7 +1046,7 @@ public class OrcsTransactionTest { tx.setRationale(art1, CoreRelationTypes.Users_User, art2, "rationale5"); TransactionId lastTx = tx.commit(); - ArtifactReadable art = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactReadable art = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); ResultSet<ArtifactReadable> related = art.getRelated(CoreRelationTypes.Users_User); assertEquals(1, related.size()); ArtifactReadable other = related.getExactlyOne(); @@ -1054,7 +1054,7 @@ public class OrcsTransactionTest { assertEquals("rationale5", rationale); - art = query.fromBranch(COMMON_ID).fromTransaction(lastTx).andIds(art1).getResults().getExactlyOne(); + art = query.fromBranch(COMMON).fromTransaction(lastTx).andIds(art1).getResults().getExactlyOne(); related = art.getRelated(CoreRelationTypes.Users_User); assertEquals(1, related.size()); other = related.getExactlyOne(); @@ -1071,7 +1071,7 @@ public class OrcsTransactionTest { tx.relate(art1, CoreRelationTypes.Users_User, art2, "rationale1"); tx.commit(); - ArtifactReadable art = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + ArtifactReadable art = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); ArtifactReadable otherSide = art.getRelated(CoreRelationTypes.Users_User).getExactlyOne(); assertEquals(true, art.areRelated(CoreRelationTypes.Users_User, otherSide)); @@ -1079,7 +1079,7 @@ public class OrcsTransactionTest { tx.unrelate(art1, CoreRelationTypes.Users_User, art2); tx.commit(); - art = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + art = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); ResultSet<ArtifactReadable> otherSideResults = art.getRelated(CoreRelationTypes.Users_User); assertEquals(true, otherSideResults.isEmpty()); @@ -1087,7 +1087,7 @@ public class OrcsTransactionTest { tx.relate(art1, CoreRelationTypes.Users_User, art2); tx.commit(); - art = query.fromBranch(COMMON_ID).andIds(art1).getResults().getExactlyOne(); + art = query.fromBranch(COMMON).andIds(art1).getResults().getExactlyOne(); otherSide = art.getRelated(CoreRelationTypes.Users_User).getExactlyOne(); assertEquals(true, art.areRelated(CoreRelationTypes.Users_User, otherSide)); } @@ -1129,21 +1129,16 @@ public class OrcsTransactionTest { } private TransactionBuilder createTx() throws OseeCoreException { - return txFactory.createTransaction(COMMON_ID, userArtifact, testName.getMethodName()); + return txFactory.createTransaction(COMMON, userArtifact, testName.getMethodName()); } - private ArtifactReadable getSystemUser() throws OseeCoreException { - return query.fromBranch(COMMON_ID).andIds(SystemUser.OseeSystem).getResults().getExactlyOne(); - } - - private void checkTransaction(TransactionReadable previousTx, TransactionReadable newTx, Long branchId, String comment, ArtifactReadable user) throws OseeCoreException { + private void checkTransaction(TransactionReadable previousTx, TransactionReadable newTx, BranchId branchId, String comment, ArtifactId user) throws OseeCoreException { assertTrue(previousTx.isOlderThan(newTx)); assertEquals(comment, newTx.getComment()); assertEquals(branchId, newTx.getBranchId()); assertEquals(TransactionDetailsType.NonBaselined, newTx.getTxType()); - assertEquals(user.getLocalId().intValue(), newTx.getAuthorId()); - assertEquals(0, newTx.getCommit()); + assertEquals(user, newTx.getAuthor()); + assertEquals(newTx.getCommitArt(), 0L); assertTrue(previousTx.getDate().before(newTx.getDate())); } - }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java index d4af1a84b0a..76791f5ce2a 100644 --- a/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java +++ b/plugins/org.eclipse.osee.orcs.test/src/org/eclipse/osee/orcs/api/OrcsTxQueryTest.java @@ -10,8 +10,12 @@ *******************************************************************************/ package org.eclipse.osee.orcs.api; +import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON; +import static org.eclipse.osee.framework.core.enums.CoreBranches.SYSTEM_ROOT; import static org.eclipse.osee.framework.core.enums.DemoBranches.CIS_Bld_1; import static org.eclipse.osee.framework.core.enums.DemoBranches.SAW_Bld_1; +import static org.eclipse.osee.framework.core.enums.DemoBranches.SAW_Bld_2; +import static org.eclipse.osee.framework.core.enums.SystemUser.OseeSystem; import static org.eclipse.osee.framework.core.enums.TransactionDetailsType.Baselined; import static org.eclipse.osee.framework.core.enums.TransactionDetailsType.NonBaselined; import static org.eclipse.osee.orcs.OrcsIntegrationRule.integrationRule; @@ -26,9 +30,8 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; import org.eclipse.osee.framework.core.data.ArtifactId; +import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; -import org.eclipse.osee.framework.core.enums.CoreBranches; -import org.eclipse.osee.framework.core.enums.SystemUser; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; @@ -64,8 +67,7 @@ public class OrcsTxQueryTest { private final static DateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); private QueryFactory factory; - private final Long OseeSystemId = SystemUser.OseeSystem.getId(); - private final Long JoeSmithId = Long.valueOf(61106791); + private final ArtifactId JoeSmith = ArtifactId.valueOf(61106791); private final Long CommonBranchHeadTransaction = 117L; private final String CommonBranchTransComment = "Create new Agile Feature Group"; private final int NumberCommonTransactions = 77; @@ -83,10 +85,8 @@ public class OrcsTxQueryTest { assertEquals(CommonBranchHeadTransaction, Long.valueOf(results.size())); List<TransactionReadable> transactions = results.getList(); - assertTx(transactions, Long.valueOf(4), Baselined, "Branch Creation for Common", 570, OseeSystemId, - Long.valueOf(0)); - assertTx(transactions, Long.valueOf(5), NonBaselined, "Add Types to Common Branch", 570, OseeSystemId, - Long.valueOf(0)); + assertTx(transactions, Long.valueOf(4), Baselined, "Branch Creation for Common", COMMON, OseeSystem); + assertTx(transactions, Long.valueOf(5), NonBaselined, "Add Types to Common Branch", COMMON, OseeSystem); } @Test @@ -114,8 +114,8 @@ public class OrcsTxQueryTest { TransactionReadable actual = query.getResults().getExactlyOne(); assertEquals(1, query.getCount()); - assertTx(Arrays.asList(actual), Long.valueOf(26), Baselined, "Branch Creation for SAW_Bld_1", 3, OseeSystemId, - Long.valueOf(0)); + assertTx(Arrays.asList(actual), Long.valueOf(26), Baselined, "Branch Creation for SAW_Bld_1", SAW_Bld_1, + OseeSystem); assertEquals(Long.valueOf(26), query.getResultsAsIds().getExactlyOne()); } @@ -141,16 +141,11 @@ public class OrcsTxQueryTest { assertEquals(8, query.getCount()); List<TransactionReadable> transactions = results.getList(); - assertTx(transactions, Long.valueOf(1), Baselined, "System Root Branch Creation", 1, OseeSystemId, - Long.valueOf(0)); - assertTx(transactions, Long.valueOf(4), Baselined, "Branch Creation for Common", 570, OseeSystemId, - Long.valueOf(0)); - assertTx(transactions, Long.valueOf(26), Baselined, "Branch Creation for SAW_Bld_1", 3, OseeSystemId, - Long.valueOf(0)); - assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", 4, OseeSystemId, - Long.valueOf(0)); - assertTx(transactions, Long.valueOf(66), Baselined, "Branch Creation for SAW_Bld_2", 5, JoeSmithId, - Long.valueOf(0)); + assertTx(transactions, Long.valueOf(1), Baselined, "System Root Branch Creation", SYSTEM_ROOT, OseeSystem); + assertTx(transactions, Long.valueOf(4), Baselined, "Branch Creation for Common", COMMON, OseeSystem); + assertTx(transactions, Long.valueOf(26), Baselined, "Branch Creation for SAW_Bld_1", SAW_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(66), Baselined, "Branch Creation for SAW_Bld_2", SAW_Bld_2, JoeSmith); } @Test @@ -163,10 +158,8 @@ public class OrcsTxQueryTest { assertEquals(4, query.getCount()); List<TransactionReadable> transactions = results.getList(); - assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", 4, OseeSystemId, - Long.valueOf(0)); - assertTx(transactions, Long.valueOf(66), Baselined, "Branch Creation for SAW_Bld_2", 5, JoeSmithId, - Long.valueOf(0)); + assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(66), Baselined, "Branch Creation for SAW_Bld_2", SAW_Bld_2, JoeSmith); } @@ -181,14 +174,14 @@ public class OrcsTxQueryTest { List<TransactionReadable> transactions = results.getList(); //@formatter:off - assertTx(transactions, Long.valueOf(26), Baselined, "Branch Creation for SAW_Bld_1", 3, OseeSystemId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(27), NonBaselined, "DemoDatabaseConfig", 3, OseeSystemId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", 4, OseeSystemId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(29), NonBaselined, "DemoDatabaseConfig", 4,OseeSystemId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(62), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", 3, JoeSmithId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(63), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", 3, JoeSmithId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(64), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", 3, JoeSmithId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(65), NonBaselined, "Populate Demo DB - Create Traceability", 3, JoeSmithId, Long.valueOf(0)); + assertTx(transactions, Long.valueOf(26), Baselined, "Branch Creation for SAW_Bld_1", SAW_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(27), NonBaselined, "DemoDatabaseConfig", SAW_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(29), NonBaselined, "DemoDatabaseConfig", CIS_Bld_1,OseeSystem); + assertTx(transactions, Long.valueOf(62), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(63), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(64), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, Long.valueOf(65), NonBaselined, "Populate Demo DB - Create Traceability", SAW_Bld_1, JoeSmith); //@formatter:on } @@ -244,7 +237,7 @@ public class OrcsTxQueryTest { public void testGetEQIdOperators() throws OseeCoreException { TransactionQuery query = factory.transactionQuery(); query.andTxId(Operator.EQUAL, 21); - query.andBranch(CoreBranches.COMMON); + query.andBranch(COMMON); ResultSet<TransactionReadable> results = query.getResults(); assertEquals(1, results.size()); @@ -253,7 +246,7 @@ public class OrcsTxQueryTest { query = factory.transactionQuery(); query.andTxId(Operator.NOT_EQUAL, 10); - query.andBranch(CoreBranches.COMMON); + query.andBranch(COMMON); results = query.getResults(); transactions = results.getList(); @@ -321,42 +314,41 @@ public class OrcsTxQueryTest { @Test public void testGetAuthorId() throws Exception { TransactionQuery query = factory.transactionQuery(); - query.andAuthorIds(OseeSystemId.intValue()); + query.andAuthorLocalIds(OseeSystem); ResultSet<TransactionReadable> results = query.getResults(); assertEquals(72, results.size()); assertEquals(72, query.getCount()); List<TransactionReadable> transactions = results.getList(); - assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", 4, OseeSystemId, - Long.valueOf(0)); + assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, OseeSystem); query = factory.transactionQuery(); - query.andAuthorIds(OseeSystemId.intValue(), JoeSmithId.intValue()); + query.andAuthorLocalIds(OseeSystem, JoeSmith); results = query.getResults(); assertEquals(117, results.size()); assertEquals(117, query.getCount()); transactions = results.getList(); //@formatter:off - assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", 4, OseeSystemId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(62), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", 3, JoeSmithId, Long.valueOf(0)); - assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, 570, OseeSystemId, Long.valueOf(0)); + assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(62), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, COMMON, OseeSystem); //@formatter:on query = factory.transactionQuery(); - ArrayList<Integer> list = new ArrayList<>(2); - list.add(OseeSystemId.intValue()); - list.add(JoeSmithId.intValue()); - query.andAuthorIds(list); + ArrayList<ArtifactId> list = new ArrayList<>(2); + list.add(OseeSystem); + list.add(JoeSmith); + query.andAuthorLocalIds(list); results = query.getResults(); assertEquals(117, results.size()); assertEquals(117, query.getCount()); transactions = results.getList(); //@formatter:off - assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", 4, OseeSystemId, Long.valueOf(0)); - assertTx(transactions, Long.valueOf(62), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", 3, JoeSmithId, Long.valueOf(0)); - assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, 570, OseeSystemId, Long.valueOf(0)); + assertTx(transactions, Long.valueOf(28), Baselined, "Branch Creation for CIS_Bld_1", CIS_Bld_1, OseeSystem); + assertTx(transactions, Long.valueOf(62), NonBaselined, "ArtifactImportOperationFactory: Artifact Import Wizard transaction", SAW_Bld_1, JoeSmith); + assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, COMMON, OseeSystem); //@formatter:on } @@ -376,7 +368,7 @@ public class OrcsTxQueryTest { assertTxExists(transactions, Long.valueOf(5)); query = factory.transactionQuery(); - query.andCommitIds(OseeSystemId.intValue(), 1); + query.andCommitIds(OseeSystem.getId().intValue(), 1); results = query.getResults(); assertEquals(0, results.size()); assertEquals(0, query.getCount()); @@ -394,7 +386,7 @@ public class OrcsTxQueryTest { * null not allowed in multiple argument case -- throws OseeArgumentException */ query = factory.transactionQuery(); - query.andCommitIds(null, OseeSystemId.intValue(), 1); + query.andCommitIds(null, OseeSystem.getId().intValue(), 1); results = query.getResults(); } @@ -413,25 +405,24 @@ public class OrcsTxQueryTest { @Test public void testGetHead2() throws Exception { TransactionQuery query = factory.transactionQuery(); - query.andIsHead(CoreBranches.COMMON); + query.andIsHead(COMMON); ResultSet<TransactionReadable> results = query.getResults(); assertEquals(1, query.getCount()); assertEquals(1, results.size()); List<TransactionReadable> transactions = results.getList(); - assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, 570, OseeSystemId, - Long.valueOf(0L)); + assertTx(transactions, CommonBranchHeadTransaction, NonBaselined, CommonBranchTransComment, COMMON, OseeSystem); } @Test public void testAuthorLocal() throws Exception { QueryFactory branchFactory = orcsApi.getQueryFactory(); - QueryBuilder branchQuery = branchFactory.fromBranch(CoreBranches.COMMON); + QueryBuilder branchQuery = branchFactory.fromBranch(COMMON); /********************************************************* * Only valid user is Joe Smith */ - branchQuery.andUuids(Arrays.asList(Long.valueOf(JoeSmithId))); + branchQuery.andUuid(JoeSmith.getId()); ResultSet<ArtifactReadable> userIds = branchQuery.getResults(); Iterator<ArtifactReadable> itUsers = userIds.iterator(); ArtifactId joeArt = itUsers.next(); @@ -452,7 +443,7 @@ public class OrcsTxQueryTest { @Test public void testMultifield() throws Exception { TransactionQuery query = factory.transactionQuery(); - query.andAuthorIds(OseeSystemId.intValue()); + query.andAuthorLocalIds(OseeSystem); query.andIs(Baselined); query.andCommentPattern("Branch Creation for.*"); ResultSet<TransactionReadable> results = query.getResults(); @@ -480,16 +471,16 @@ public class OrcsTxQueryTest { assertEquals(Long.valueOf(CommonBranchHeadTransaction - 1), ids.next()); } - private static void assertTx(List<TransactionReadable> transactions, Long localId, TransactionDetailsType type, String comment, long branchUuid, Long authorId, Long commitId) { + private static void assertTx(List<TransactionReadable> transactions, Long localId, TransactionDetailsType type, String comment, BranchId branch, ArtifactId author) { TransactionReadable transaction = getTransaction(transactions, localId); assertEquals(localId, transaction.getId()); assertEquals(type, transaction.getTxType()); assertNotNull(DATE_FORMATTER.format(transaction.getDate())); assertEquals(comment, transaction.getComment()); - assertEquals(authorId.intValue(), transaction.getAuthorId()); - assertEquals((Long) branchUuid, transaction.getBranchId()); - assertEquals(commitId.intValue(), transaction.getCommit()); + assertEquals(author, transaction.getAuthor()); + assertEquals(branch, transaction.getBranchId()); + assertTrue(transaction.getCommitArt().isInvalid()); } private void assertTxExists(List<TransactionReadable> transactions, Long localId) { diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java index 996d3928540..8e71f6dbb52 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/OrcsBranch.java @@ -13,6 +13,7 @@ package org.eclipse.osee.orcs; import java.net.URI; import java.util.List; import java.util.concurrent.Callable; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TransactionId; @@ -20,10 +21,8 @@ import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.BranchType; import org.eclipse.osee.framework.core.model.change.ChangeItem; -import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.framework.jdk.core.type.PropertyStore; import org.eclipse.osee.orcs.data.ArchiveOperation; -import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.data.CreateBranchData; @@ -47,15 +46,15 @@ public interface OrcsBranch { // branch state // assoc art id - Callable<BranchReadable> createTopLevelBranch(IOseeBranch branch, ArtifactReadable author) throws OseeCoreException; + Callable<BranchReadable> createTopLevelBranch(IOseeBranch branch, ArtifactId author); - Callable<BranchReadable> createBaselineBranch(IOseeBranch branch, ArtifactReadable author, IOseeBranch parent, ArtifactReadable associatedArtifact) throws OseeCoreException; + Callable<BranchReadable> createBaselineBranch(IOseeBranch branch, ArtifactId author, IOseeBranch parent, ArtifactId associatedArtifact); - Callable<BranchReadable> createWorkingBranch(IOseeBranch branch, ArtifactReadable author, IOseeBranch parent, ArtifactReadable associatedArtifact) throws OseeCoreException; + Callable<BranchReadable> createWorkingBranch(IOseeBranch branch, ArtifactId author, IOseeBranch parent, ArtifactId associatedArtifact); - Callable<BranchReadable> createCopyTxBranch(IOseeBranch branch, ArtifactReadable author, TransactionId fromTransaction, ArtifactReadable associatedArtifact) throws OseeCoreException; + Callable<BranchReadable> createCopyTxBranch(IOseeBranch branch, ArtifactId author, TransactionId fromTransaction, ArtifactId associatedArtifact); - Callable<BranchReadable> createPortBranch(IOseeBranch branch, ArtifactReadable author, TransactionId fromTransaction, ArtifactReadable associatedArtifact) throws OseeCoreException; + Callable<BranchReadable> createPortBranch(IOseeBranch branch, ArtifactId author, TransactionId fromTransaction, ArtifactId associatedArtifact); ///////////////////////////////////////////////////////////////////////// @@ -65,7 +64,7 @@ public interface OrcsBranch { Callable<Void> changeBranchName(BranchId branch, String name); - Callable<Void> associateBranchToArtifact(BranchId branch, ArtifactReadable associatedArtifact); + Callable<Void> associateBranchToArtifact(BranchId branch, ArtifactId associatedArtifact); Callable<Void> unassociateBranch(BranchId branch); @@ -79,11 +78,11 @@ public interface OrcsBranch { Callable<List<BranchId>> purgeBranch(BranchId branch, boolean recurse); - Callable<TransactionToken> commitBranch(ArtifactReadable committer, BranchId source, BranchId destination); + Callable<TransactionToken> commitBranch(ArtifactId committer, BranchId source, BranchId destination); Callable<List<ChangeItem>> compareBranch(TransactionToken sourceTx, TransactionToken destinationTx); - Callable<List<ChangeItem>> compareBranch(BranchId branch) throws OseeCoreException; + Callable<List<ChangeItem>> compareBranch(BranchId branch); Callable<URI> exportBranch(List<? extends BranchId> branches, PropertyStore options, String exportName); diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/BranchReadable.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/BranchReadable.java index b6767e55f37..5453e16b0de 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/BranchReadable.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/BranchReadable.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.orcs.data; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TransactionId; @@ -31,7 +32,7 @@ public interface BranchReadable extends IOseeBranch { boolean hasParentBranch(); // These get Id method might change - int getAssociatedArtifactId(); + ArtifactId getAssociatedArtifact(); TransactionId getBaseTransaction(); diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/CreateBranchData.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/CreateBranchData.java index 1d183cb9c46..9fc7901b638 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/CreateBranchData.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/CreateBranchData.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.osee.orcs.data; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchType; @@ -22,8 +23,6 @@ import org.eclipse.osee.framework.jdk.core.util.Lib; * @author Roberto E. Escobar */ public class CreateBranchData implements Identifiable<Long> { - - private static final int NULL_ARTIFACT_ID = -1; private final long MERGE_DESTINATION_BRANCH_ID = -1; // only used on merge branches private final int MERGE_ADDRESSING_QUERY_ID = -1; // only used on merge branches @@ -33,8 +32,8 @@ public class CreateBranchData implements Identifiable<Long> { private String creationComment; private TransactionId fromTransaction; private TransactionId savedTransaction; - private ArtifactReadable associatedArtifact; - private ArtifactReadable userArtifact; + private ArtifactId associatedArtifact; + private ArtifactId author; // Merge Branch Legacy Support private int mergeAddressingQueryId = MERGE_ADDRESSING_QUERY_ID; @@ -56,20 +55,8 @@ public class CreateBranchData implements Identifiable<Long> { return branchUuid; } - public int getAssociatedArtifactId() { - int result = NULL_ARTIFACT_ID; - if (associatedArtifact != null) { - result = associatedArtifact.getLocalId(); - } - return result; - } - - public Integer getUserArtifactId() { - int result = NULL_ARTIFACT_ID; - if (userArtifact != null) { - result = userArtifact.getLocalId(); - } - return result; + public ArtifactId getAssociatedArtifact() { + return associatedArtifact; } @Override @@ -113,19 +100,15 @@ public class CreateBranchData implements Identifiable<Long> { this.savedTransaction = priorTransaction; } - public ArtifactReadable getUserArtifact() { - return userArtifact; - } - - public void setUserArtifact(ArtifactReadable userArtifact) { - this.userArtifact = userArtifact; + public ArtifactId getAuthor() { + return author; } - public ArtifactReadable getAssociatedArtifact() { - return associatedArtifact; + public void setAuthor(ArtifactId author) { + this.author = author; } - public void setAssociatedArtifact(ArtifactReadable associatedArtifact) { + public void setAssociatedArtifact(ArtifactId associatedArtifact) { this.associatedArtifact = associatedArtifact; } @@ -168,7 +151,7 @@ public class CreateBranchData implements Identifiable<Long> { @Override public String toString() { - return "CreateBranchData [branchUuid=" + branchUuid + ", branchName=" + branchName + ", branchType=" + branchType + ", creationComment=" + creationComment + ", fromTransaction=" + fromTransaction + ", associatedArtifact=" + associatedArtifact + ", userArtifact=" + userArtifact + ", mergeAddressingQueryId=" + mergeAddressingQueryId + ", destinationBranchId=" + mergeDestinationBranchId + "]"; + return "CreateBranchData [branchUuid=" + branchUuid + ", branchName=" + branchName + ", branchType=" + branchType + ", creationComment=" + creationComment + ", fromTransaction=" + fromTransaction + ", associatedArtifact=" + associatedArtifact + ", userArtifact=" + author + ", mergeAddressingQueryId=" + mergeAddressingQueryId + ", destinationBranchId=" + mergeDestinationBranchId + "]"; } public long getUuid() { diff --git a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/TransactionReadable.java b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/TransactionReadable.java index 5edbe598b78..7dcb6489e87 100644 --- a/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/TransactionReadable.java +++ b/plugins/org.eclipse.osee.orcs/src/org/eclipse/osee/orcs/data/TransactionReadable.java @@ -11,6 +11,7 @@ package org.eclipse.osee.orcs.data; import java.util.Date; +import org.eclipse.osee.framework.core.data.ArtifactId; import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; @@ -25,8 +26,8 @@ public interface TransactionReadable extends TransactionToken { String getComment(); - int getAuthorId(); + ArtifactId getAuthor(); - int getCommit(); + ArtifactId getCommitArt(); }
\ No newline at end of file |