Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2017-07-21 11:05:39 -0400
committerRyan Brooks2017-07-26 14:33:32 -0400
commit8af038cdaed76f60484b44770b6a226411341c1e (patch)
treed16aec3954ee43b54bb79d5fa64fdf9840aaf7d0
parent57e180699158cb2515e349a4ebcc66772d62454e (diff)
downloadorg.eclipse.osee-8af038cdaed76f60484b44770b6a226411341c1e.tar.gz
org.eclipse.osee-8af038cdaed76f60484b44770b6a226411341c1e.tar.xz
org.eclipse.osee-8af038cdaed76f60484b44770b6a226411341c1e.zip
refactor: Use ArtifactId in ArtifactQuery.checkArtifactFromId
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java29
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/OseeGroup.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java14
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java3
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java8
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java2
6 files changed, 29 insertions, 33 deletions
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
index e111ad03f9..7e46367e12 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactQueryTest.java
@@ -15,17 +15,16 @@ import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import static org.eclipse.osee.framework.core.enums.DemoBranches.SAW_Bld_1;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule;
import org.eclipse.osee.client.test.framework.OseeLogMonitorRule;
import org.eclipse.osee.client.test.framework.TestInfo;
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.TransactionToken;
import org.eclipse.osee.framework.core.enums.BranchType;
@@ -90,7 +89,7 @@ public class ArtifactQueryTest {
newArtifact.deleteAndPersist();
try {
- Artifact ret = ArtifactQuery.checkArtifactFromId(newArtifact.getUuid(), COMMON);
+ Artifact ret = ArtifactQuery.checkArtifactFromId(newArtifact, COMMON);
Assert.assertNull(ret);
} catch (ArtifactDoesNotExist ex) {
Assert.fail("ArtifactQuery should never throw ArtifactDoesNotExist with QueryType.CHECK");
@@ -212,23 +211,22 @@ public class ArtifactQueryTest {
Assert.assertEquals(artifact1, artifacts.iterator().next());
}
+ private TransactionToken createArtifactFortestQueryById(List<ArtifactId> newIdsInOrder, BranchId branch) {
+ Artifact created = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch);
+ created.persist(testInfo.getTestName());
+ ArtifactCache.deCache(created);
+ newIdsInOrder.add(created);
+ return TransactionManager.getHeadTransaction(branch);
+ }
+
@Test
public void testQueryById() throws OseeCoreException {
BranchId branch = BranchManager.createTopLevelBranch(testInfo.getTestName() + " branch");
AccessControlManager.setPermission(UserManager.getUser(DemoUsers.Joe_Smith), branch, PermissionEnum.FULLACCESS);
- List<Integer> newIdsInOrder = new LinkedList<>();
- Map<Integer, TransactionToken> idToTxId = new HashMap<>();
- //create 3 artifacts, decache them
- for (int i = 0; i < 2; i++) {
- Artifact created = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Folder, branch);
- created.persist(testInfo.getTestName());
- ArtifactCache.deCache(created);
- newIdsInOrder.add(created.getArtId());
- TransactionToken tx = TransactionManager.getHeadTransaction(branch);
- idToTxId.put(created.getArtId(), tx);
- }
-
+ List<ArtifactId> newIdsInOrder = new LinkedList<>();
+ createArtifactFortestQueryById(newIdsInOrder, branch);
+ TransactionToken beforeDelete = createArtifactFortestQueryById(newIdsInOrder, branch);
Assert.assertEquals(2, newIdsInOrder.size());
//create a new tx deleting the first created
@@ -242,7 +240,6 @@ public class ArtifactQueryTest {
Assert.assertNotNull(toCheck);
ArtifactCache.deCache(toCheck);
- TransactionToken beforeDelete = idToTxId.get(newIdsInOrder.get(1));
Assert.assertNotNull(
ArtifactQuery.checkHistoricalArtifactFromId(firstCreated, beforeDelete, DeletionFlag.EXCLUDE_DELETED));
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/OseeGroup.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/OseeGroup.java
index 9ac19beb41..24af8aa44b 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/OseeGroup.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/OseeGroup.java
@@ -14,8 +14,8 @@ import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
import java.util.HashMap;
import java.util.Map;
-import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.ArtifactToken;
+import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.enums.CoreArtifactTokens;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -96,7 +96,7 @@ public class OseeGroup {
}
private Artifact getOrCreateGroupArtifact(ArtifactToken token) throws OseeCoreException {
- Artifact groupArtifact = ArtifactQuery.checkArtifactFromId(token.getUuid().intValue(), COMMON, EXCLUDE_DELETED);
+ Artifact groupArtifact = ArtifactQuery.getArtifactOrNull(token, EXCLUDE_DELETED);
if (groupArtifact == null) {
Artifact userGroupsFolder = getOrCreateUserGroupsFolder(COMMON);
groupArtifact = ArtifactTypeManager.addArtifact(token, COMMON);
@@ -106,7 +106,7 @@ public class OseeGroup {
}
private Artifact getOrCreateUserGroupsFolder(BranchId branch) throws OseeCoreException {
- Artifact usersGroupFolder = ArtifactQuery.checkArtifactFromId(CoreArtifactTokens.UserGroups.getUuid(), branch);
+ Artifact usersGroupFolder = ArtifactQuery.checkArtifactFromId(CoreArtifactTokens.UserGroups, branch);
if (usersGroupFolder == null) {
Artifact root = OseeSystemArtifacts.getDefaultHierarchyRootArtifact(branch);
if (root.hasChild(CoreArtifactTokens.UserGroups.getName())) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
index f31211b4ef..2dad2c9485 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ChangeArtifactType.java
@@ -23,9 +23,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.ArtifactTypeId;
import org.eclipse.osee.framework.core.data.AttributeTypeId;
import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.data.GammaId;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IRelationType;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
@@ -66,7 +68,7 @@ public class ChangeArtifactType {
private final Set<EventBasicGuidArtifact> artifactChanges = new HashSet<>();
private final List<Artifact> modifiedArtifacts = new ArrayList<>();
private static final IStatus promptStatus = new Status(IStatus.WARNING, Activator.PLUGIN_ID, 257, "", null);
- private final Map<Integer, Integer> gammaToArtId = new HashMap<>();
+ private final Map<GammaId, ArtifactId> gammaToArtId = new HashMap<>();
public static void changeArtifactType(Collection<? extends Artifact> inputArtifacts, ArtifactTypeId newArtifactTypeToken, boolean prompt) throws OseeCoreException {
@@ -137,9 +139,9 @@ public class ChangeArtifactType {
gammaJoin.getQueryId(), branchJoin.getQueryId(), TxChange.CURRENT.getValue());
while (chStmt.next()) {
- int gammaId = chStmt.getInt("gamma_id");
+ GammaId gammaId = GammaId.valueOf(chStmt.getLong("gamma_id"));
BranchId branch = BranchId.valueOf(chStmt.getLong("branch_id"));
- int artId = gammaToArtId.get(gammaId);
+ ArtifactId artId = gammaToArtId.get(gammaId);
Artifact artifact = ArtifactQuery.checkArtifactFromId(artId, branch, DeletionFlag.EXCLUDE_DELETED);
if (artifact != null) {
deleteInvalidAttributes(artifact, newArtifactType);
@@ -275,9 +277,9 @@ public class ChangeArtifactType {
IdJoinQuery gammaJoin = JoinUtility.createIdJoinQuery();
Consumer<JdbcStatement> consumer = stmt -> {
- Integer artId = stmt.getInt("art_id");
- Long gammaId = stmt.getLong("gamma_id");
- gammaToArtId.put(gammaId.intValue(), artId);
+ ArtifactId artId = ArtifactId.valueOf(stmt.getLong("art_id"));
+ GammaId gammaId = GammaId.valueOf(stmt.getLong("gamma_id"));
+ gammaToArtId.put(gammaId, artId);
gammaJoin.add(gammaId);
};
ConnectionHandler.getJdbcClient().runQuery(consumer,
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
index a5f2b1abea..ab264e1a5a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/PurgeArtifacts.java
@@ -14,6 +14,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.IOseeBranch;
@@ -173,7 +174,7 @@ public class PurgeArtifacts extends AbstractDbTxOperation {
}
private void getArtifactViloation(JdbcStatement stmt) {
- Long artId = stmt.getLong("art_id");
+ ArtifactId artId = ArtifactId.valueOf(stmt.getLong("art_id"));
Long branchId = stmt.getLong("branch_id");
if (recurseChildrenBranches) {
BranchId branch = BranchId.valueOf(branchId);
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 2992d5849f..3aeae0f1bf 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
@@ -150,8 +150,8 @@ public class ArtifactQuery {
* @param allowDeleted whether to return the artifact even if it has been deleted
* @return one artifact by one its id if it exists, otherwise null
*/
- public static Artifact checkArtifactFromId(int artifactId, BranchId branch, DeletionFlag allowDeleted) throws OseeCoreException {
- return getOrCheckArtifactFromId(ArtifactId.valueOf(artifactId), branch, allowDeleted, QueryType.CHECK);
+ public static Artifact checkArtifactFromId(ArtifactId artifactId, BranchId branch, DeletionFlag allowDeleted) throws OseeCoreException {
+ return getOrCheckArtifactFromId(artifactId, branch, allowDeleted, QueryType.CHECK);
}
/**
@@ -171,10 +171,6 @@ public class ArtifactQuery {
* @param artifactId of the desired artifact
* @return one artifact by its guid if it exists, otherwise null
*/
- public static Artifact checkArtifactFromId(long uuid, BranchId branch) throws OseeCoreException {
- return getOrCheckArtifactFromId(ArtifactId.valueOf(uuid), branch, EXCLUDE_DELETED, QueryType.CHECK);
- }
-
public static Artifact checkArtifactFromId(ArtifactId artifactId, BranchId branch) {
return getOrCheckArtifactFromId(artifactId, branch, EXCLUDE_DELETED, QueryType.CHECK);
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java
index 3aeabec282..b7d328fa2c 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/explorer/ArtifactExplorer.java
@@ -346,7 +346,7 @@ public class ArtifactExplorer extends GenericViewPart implements IArtifactExplor
if (!BranchManager.isArchived(branch) || AccessControlManager.isOseeAdmin()) {
Artifact previousArtifact =
- ArtifactQuery.checkArtifactFromId(Long.valueOf(memento.getString(ROOT_UUID)), branch);
+ ArtifactQuery.checkArtifactFromId(ArtifactId.valueOf(memento.getString(ROOT_UUID)), branch);
if (previousArtifact != null) {
explore(previousArtifact);
} else {

Back to the top