Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2017-07-29 13:07:07 -0400
committerRyan D. Brooks2017-08-16 10:34:00 -0400
commit77caf6710e37c86faccb6e5f1acbfb8fb5f07e1b (patch)
treeb6aa0f39bc9836b11f08cfeca4ae943d3b7fe344
parent354ecd4dbbacacd1abc09a7c90846abaa699a385 (diff)
downloadorg.eclipse.osee-77caf6710e37c86faccb6e5f1acbfb8fb5f07e1b.tar.gz
org.eclipse.osee-77caf6710e37c86faccb6e5f1acbfb8fb5f07e1b.tar.xz
org.eclipse.osee-77caf6710e37c86faccb6e5f1acbfb8fb5f07e1b.zip
refactor: Use ArtifactId in ArtifactLoader
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java77
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/MergeManagerTest.java11
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java134
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java62
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java7
5 files changed, 90 insertions, 201 deletions
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java
index a51ae56160..ed3aaa3954 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/ArtifactLoaderTest.java
@@ -22,10 +22,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.osee.client.integration.tests.integration.skynet.core.utils.TestUtil;
import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule;
import org.eclipse.osee.client.test.framework.OseeLogMonitorRule;
@@ -35,17 +31,10 @@ import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
-import org.eclipse.osee.framework.core.enums.LoadLevel;
-import org.eclipse.osee.framework.core.operation.IOperation;
-import org.eclipse.osee.framework.core.operation.OperationLogger;
-import org.eclipse.osee.framework.core.operation.Operations;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
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.ArtifactLoader;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactPersistenceManager;
-import org.eclipse.osee.framework.skynet.core.artifact.LoadType;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
@@ -178,70 +167,6 @@ public class ArtifactLoaderTest {
}
- @Test(timeout = 5000)
- public void testLoadingNonExistingArtifactMultipleTimes() throws InterruptedException {
- final List<Integer> artIds = new LinkedList<>();
- artIds.add(Integer.MAX_VALUE);
- artIds.add(Integer.MIN_VALUE);
- Job job1 = Operations.executeAsJob(new IOperation() {
-
- @Override
- public String getName() {
- return "Job1";
- }
-
- @Override
- public IStatus run(SubMonitor subMonitor) {
- List<Artifact> artifacts;
- try {
- artifacts = ArtifactLoader.loadArtifactIds(artIds, CoreBranches.COMMON, LoadLevel.ALL,
- LoadType.RELOAD_CACHE, DeletionFlag.EXCLUDE_DELETED);
- Assert.assertTrue(artifacts.isEmpty());
- } catch (OseeCoreException ex) {
- // do nothing
- }
-
- return Status.OK_STATUS;
- }
-
- @Override
- public OperationLogger getLogger() {
- return null;
- }
- }, true);
-
- Job job2 = Operations.executeAsJob(new IOperation() {
-
- @Override
- public String getName() {
- return "Job2";
- }
-
- @Override
- public IStatus run(SubMonitor subMonitor) {
- List<Artifact> artifacts;
- try {
- artifacts = ArtifactLoader.loadArtifactIds(artIds, CoreBranches.COMMON, LoadLevel.ALL,
- LoadType.RELOAD_CACHE, DeletionFlag.EXCLUDE_DELETED);
- Assert.assertTrue(artifacts.isEmpty());
- } catch (OseeCoreException ex) {
- // do nothing
- }
-
- return Status.OK_STATUS;
- }
-
- @Override
- public OperationLogger getLogger() {
- return null;
- }
- }, true);
-
- job1.join();
- job2.join();
-
- }
-
private final class MultiThreadCallable implements Callable<String> {
private final String guid;
@@ -279,4 +204,4 @@ public class ArtifactLoaderTest {
return new Thread(target, "Loading Thread: " + ++threadCount);
}
}
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/MergeManagerTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/MergeManagerTest.java
index 76bb017f9c..6fa06538ec 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/MergeManagerTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/skynet/core/MergeManagerTest.java
@@ -22,8 +22,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule;
import org.eclipse.osee.client.test.framework.OseeLogMonitorRule;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
-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.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
@@ -88,9 +88,6 @@ public class MergeManagerTest {
@After
public void tearDown() throws OseeCoreException {
- Artifact artOnWorking = ArtifactQuery.getArtifactFromId(NewArtifactToken, workingBranch);
- Operations.executeWorkAndCheckStatus(new PurgeArtifacts(Collections.singleton(artOnWorking)));
-
BranchManager.purgeBranch(workingBranch);
}
@@ -115,7 +112,7 @@ public class MergeManagerTest {
// Shouldn't be allowed to commit
boolean committed =
CommitHandler.commitBranch(new ConflictManagerExternal(SAW_Bld_2, workingBranch), false, true);
- assertTrue("Branch Committed while in Rebaseline In Progress", !committed);
+ assertFalse("Branch Committed while in Rebaseline In Progress", committed);
assertTrue("An additional Merge Branch was created", BranchManager.getMergeBranches(workingBranch).size() == 1);
// Abandon
@@ -211,10 +208,6 @@ public class MergeManagerTest {
assertTrue("Branch was not committed into new, rebaselined working branch", committed);
// Clean up this test
- // Purge art from new Updated Branch
- Artifact artOnSaw2 = ArtifactQuery.getArtifactFromId(NewArtifactToken, SAW_Bld_2);
- Artifact artOnUpdateBranch = ArtifactQuery.getArtifactFromId(NewArtifactToken, branchForUpdate);
- Operations.executeWorkAndCheckStatus(new PurgeArtifacts(Arrays.asList(artOnSaw2, artOnUpdateBranch)));
BranchManager.purgeBranch(branchForUpdate);
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
index dc06864ee8..f8768d7f5d 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
@@ -19,10 +19,12 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import org.eclipse.osee.framework.core.data.ApplicabilityId;
import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.data.ArtifactTypeId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.TransactionId;
@@ -34,8 +36,8 @@ import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.sql.OseeSql;
import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
+import org.eclipse.osee.framework.jdk.core.type.Id;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.internal.Activator;
@@ -50,14 +52,14 @@ import org.eclipse.osee.jdbc.JdbcStatement;
*/
public final class ArtifactLoader {
- private static final CompositeKeyHashMap<Integer, Long, ReentrantLock> loadingActiveMap =
- new CompositeKeyHashMap<Integer, Long, ReentrantLock>(1000, true);
+ private static final ConcurrentHashMap<ArtifactToken, ReentrantLock> loadingActiveMap =
+ new ConcurrentHashMap<>(1000);
/**
* (re)loads the artifacts selected by sql and then returns them in a list
*/
public static List<Artifact> getArtifacts(String sql, Object[] queryParameters, int artifactCountEstimate, LoadLevel loadLevel, LoadType reload, ISearchConfirmer confirmer, TransactionRecord transactionId, DeletionFlag allowDeleted, boolean isArchived) throws OseeCoreException {
- List<Pair<ArtifactId, BranchId>> toLoad = selectArtifacts(sql, queryParameters, artifactCountEstimate);
+ List<ArtifactToken> toLoad = selectArtifacts(sql, queryParameters, artifactCountEstimate);
List<Artifact> artifacts =
loadSelectedArtifacts(toLoad, loadLevel, reload, allowDeleted, transactionId, isArchived);
@@ -67,32 +69,20 @@ public final class ArtifactLoader {
return new LinkedList<Artifact>(artifacts);
}
- public static List<Artifact> loadArtifactIds(Collection<Integer> artIds, BranchId branch, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted) {
- return loadArtifactIds(artIds, branch, loadLevel, reload, allowDeleted, TransactionId.SENTINEL);
- }
-
- public static List<Artifact> loadArtifactIds(Collection<Integer> artIds, BranchId branch, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted, TransactionId transactionId) {
- List<ArtifactId> artifacts = new ArrayList<>();
- for (Integer artId : artIds) {
- artifacts.add(ArtifactId.valueOf(artId));
- }
- return loadArtifacts(artifacts, branch, loadLevel, reload, allowDeleted, transactionId);
- }
-
public static List<Artifact> loadArtifacts(Collection<? extends ArtifactId> artIds, BranchId branch, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted) {
return loadArtifacts(artIds, branch, loadLevel, reload, allowDeleted, TransactionId.SENTINEL);
}
public static List<Artifact> loadArtifacts(Collection<? extends ArtifactId> artIds, BranchId branch, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted, TransactionId transactionId) {
- List<Pair<ArtifactId, BranchId>> toLoad = new LinkedList<>();
+ List<ArtifactToken> toLoad = new LinkedList<>();
for (ArtifactId artId : new HashSet<>(artIds)) {
- toLoad.add(new Pair<ArtifactId, BranchId>(artId, branch));
+ toLoad.add(ArtifactToken.valueOf(artId, branch));
}
return loadSelectedArtifacts(toLoad, loadLevel, reload, allowDeleted, transactionId,
BranchManager.isArchived(branch));
}
- private static List<Artifact> loadSelectedArtifacts(List<Pair<ArtifactId, BranchId>> toLoad, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted, TransactionId transactionId, boolean isArchived) throws OseeCoreException {
+ private static List<Artifact> loadSelectedArtifacts(List<ArtifactToken> toLoad, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted, TransactionId transactionId, boolean isArchived) throws OseeCoreException {
Set<Artifact> artifacts = new LinkedHashSet<>();
if (transactionId.isValid()) {
loadArtifacts(toLoad, loadLevel, transactionId, reload, allowDeleted, artifacts, isArchived);
@@ -102,28 +92,24 @@ public final class ArtifactLoader {
return new LinkedList<Artifact>(artifacts);
}
- private static void loadActiveArtifacts(List<Pair<ArtifactId, BranchId>> toLoad, Set<Artifact> artifacts, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted, boolean isArchived) throws OseeCoreException {
+ private static void loadActiveArtifacts(List<ArtifactToken> toLoad, Set<Artifact> artifacts, LoadLevel loadLevel, LoadType reload, DeletionFlag allowDeleted, boolean isArchived) throws OseeCoreException {
if (!toLoad.isEmpty()) {
int numRequested = toLoad.size();
- Iterator<Pair<ArtifactId, BranchId>> iterator = toLoad.iterator();
- CompositeKeyHashMap<Integer, Long, ReentrantLock> locks =
- new CompositeKeyHashMap<Integer, Long, ReentrantLock>();
+ Iterator<ArtifactToken> iterator = toLoad.iterator();
+ ConcurrentHashMap<ArtifactToken, ReentrantLock> locks = new ConcurrentHashMap<>();
while (iterator.hasNext()) {
- Pair<ArtifactId, BranchId> next = iterator.next();
- ArtifactId artId = next.getFirst();
- BranchId branch = next.getSecond();
+ ArtifactToken artifact = iterator.next();
Artifact active = null;
if (reload == LoadType.INCLUDE_CACHE) {
synchronized (ArtifactCache.class) {
- active = ArtifactCache.getActive(artId, branch);
+ active = ArtifactCache.getActive(artifact);
}
}
- boolean doNotLoad =
- determineIfIShouldLoad(artifacts, allowDeleted, locks, artId.getId().intValue(), branch.getId(), active);
+ boolean doNotLoad = determineIfIShouldLoad(artifacts, allowDeleted, locks, artifact, active);
if (doNotLoad) {
iterator.remove();
@@ -136,11 +122,9 @@ public final class ArtifactLoader {
} finally {
// remove and unlock locks this thread created but didn't load
if (artifacts.size() != numRequested) {
- for (Pair<ArtifactId, BranchId> loadPair : toLoad) {
- Integer artId = loadPair.getFirst().getId().intValue();
- Long branchUuid = loadPair.getSecond().getId();
- removeAndUnlock(artId, branchUuid);
- locks.removeAndGet(artId, branchUuid);
+ for (ArtifactToken artifact : toLoad) {
+ removeAndUnlock(artifact);
+ locks.remove(artifact);
}
}
}
@@ -148,30 +132,30 @@ public final class ArtifactLoader {
}
}
- private static void removeAndUnlock(Integer artId, Long branchUuid) {
+ private static void removeAndUnlock(ArtifactToken artifact) {
ReentrantLock lock = null;
synchronized (loadingActiveMap) {
- lock = loadingActiveMap.removeAndGet(artId, branchUuid);
+ lock = loadingActiveMap.remove(artifact);
}
if (lock != null && lock.isLocked()) {
lock.unlock();
}
}
- private static boolean determineIfIShouldLoad(Set<Artifact> artifacts, DeletionFlag allowDeleted, CompositeKeyHashMap<Integer, Long, ReentrantLock> locks, Integer artId, Long branchUuid, Artifact active) {
+ private static boolean determineIfIShouldLoad(Set<Artifact> artifacts, DeletionFlag allowDeleted, ConcurrentHashMap<ArtifactToken, ReentrantLock> locks, ArtifactToken artifact, Artifact active) {
boolean doNotLoad = false;
//not in the cache
if (active == null) {
synchronized (loadingActiveMap) {
- ReentrantLock lock = loadingActiveMap.get(artId, branchUuid);
+ ReentrantLock lock = loadingActiveMap.get(artifact);
// this thread should load the artifact
if (lock == null) {
lock = new ReentrantLock();
lock.lock();
- loadingActiveMap.put(artId, branchUuid, lock);
+ loadingActiveMap.put(artifact, lock);
} else {
// another thread is loading the artifact, do not load it
- locks.put(artId, branchUuid, lock);
+ locks.put(artifact, lock);
doNotLoad = true;
}
}
@@ -185,15 +169,15 @@ public final class ArtifactLoader {
return doNotLoad;
}
- private static void processLocks(CompositeKeyHashMap<Integer, Long, ReentrantLock> locks, Set<Artifact> artifacts) {
- Iterator<Entry<Pair<Integer, Long>, ReentrantLock>> iterator = locks.entrySet().iterator();
+ private static void processLocks(ConcurrentHashMap<ArtifactToken, ReentrantLock> locks, Set<Artifact> artifacts) {
+ Iterator<Entry<ArtifactToken, ReentrantLock>> iterator = locks.entrySet().iterator();
while (iterator.hasNext()) {
- Entry<Pair<Integer, Long>, ReentrantLock> entry = iterator.next();
- ArtifactId artId = ArtifactId.valueOf(entry.getKey().getFirst());
- BranchId branch = BranchId.valueOf(entry.getKey().getSecond());
- entry.getValue().lock();
- entry.getValue().unlock();
- Artifact active = ArtifactCache.getActive(artId, branch);
+ Entry<ArtifactToken, ReentrantLock> entry = iterator.next();
+ ArtifactToken artifact = entry.getKey();
+ ReentrantLock lock = entry.getValue();
+ lock.lock();
+ lock.unlock();
+ Artifact active = ArtifactCache.getActive(artifact);
if (active != null) {
artifacts.add(active);
}
@@ -222,16 +206,16 @@ public final class ArtifactLoader {
sql = ServiceUtil.getSql(sqlKey);
chStmt.runPreparedQuery(fetchSize, sql, queryId);
- int previousArtId = -1;
- long previousBranchId = -1;
+ ArtifactId previousArtId = ArtifactId.SENTINEL;
+ BranchId previousBranchId = BranchId.SENTINEL;
Long previousViewId = -1L;
while (chStmt.next()) {
- int artId = chStmt.getInt("id2");
- long branchUuid = chStmt.getLong("branch_id");
+ ArtifactId artId = ArtifactId.valueOf(chStmt.getLong("id2"));
+ BranchId branch = BranchId.valueOf(chStmt.getLong("branch_id"));
Long viewId = chStmt.getLong("id4");
// assumption: sql is returning rows ordered by branch_id, art_id, transaction_id in descending order
- if (previousArtId != artId || previousBranchId != branchUuid || !previousViewId.equals(viewId)) {
+ if (previousArtId.notEqual(artId) || previousBranchId.notEqual(branch) || !previousViewId.equals(viewId)) {
// assumption: sql is returning unwanted deleted artifacts only in the historical case
if (!historical || allowDeleted == DeletionFlag.INCLUDE_DELETED || ModificationType.getMod(
chStmt.getInt("mod_type")) != ModificationType.DELETED) {
@@ -240,7 +224,7 @@ public final class ArtifactLoader {
}
}
previousArtId = artId;
- previousBranchId = branchUuid;
+ previousBranchId = branch;
previousViewId = viewId;
}
} catch (OseeDataStoreException ex) {
@@ -261,12 +245,13 @@ public final class ArtifactLoader {
* @param artifacts
* @param locks
*/
- private static void loadArtifacts(List<Pair<ArtifactId, BranchId>> toLoad, LoadLevel loadLevel, TransactionId transactionId, LoadType reload, DeletionFlag allowDeleted, Set<Artifact> artifacts, boolean isArchived) throws OseeCoreException {
+ private static void loadArtifacts(List<ArtifactToken> toLoad, LoadLevel loadLevel, TransactionId transactionId, LoadType reload, DeletionFlag allowDeleted, Set<Artifact> artifacts, boolean isArchived) throws OseeCoreException {
if (toLoad != null && !toLoad.isEmpty()) {
Id4JoinQuery joinQuery = JoinUtility.createId4JoinQuery();
- for (Pair<ArtifactId, BranchId> pair : toLoad) {
- joinQuery.add(pair.getSecond(), pair.getFirst(), transactionId, pair.getSecond().getViewId());
+ for (ArtifactToken artifact : toLoad) {
+ BranchId branch = artifact.getBranch();
+ joinQuery.add(branch, artifact, transactionId, branch.getViewId());
}
loadArtifacts(artifacts, joinQuery, loadLevel, null, reload, transactionId, allowDeleted, isArchived);
}
@@ -312,8 +297,7 @@ public final class ArtifactLoader {
try {
chStmt.runPreparedQuery(artifactCountEstimate, sql, queryParameters);
while (chStmt.next()) {
- int artId = chStmt.getInt("art_id");
- toLoad.add(ArtifactId.valueOf(artId));
+ toLoad.add(ArtifactId.valueOf(chStmt.getLong("art_id")));
}
} finally {
chStmt.close();
@@ -327,26 +311,17 @@ public final class ArtifactLoader {
/**
* Determines the artIds and branchUuids of artifacts to load based on sql and queryParameters
*/
- public static List<Pair<ArtifactId, BranchId>> selectArtifacts(String sql, Object[] queryParameters, int artifactCountEstimate) throws OseeCoreException {
- JdbcStatement chStmt = ConnectionHandler.getStatement();
+ public static List<ArtifactToken> selectArtifacts(String sql, Object[] queryParameters, int artifactCountEstimate) throws OseeCoreException {
long time = System.currentTimeMillis();
+ List<ArtifactToken> toLoad = new LinkedList<>();
- List<Pair<ArtifactId, BranchId>> toLoad = new LinkedList<>();
+ ConnectionHandler.getJdbcClient().runQuery(
+ stmt -> toLoad.add(ArtifactToken.valueOf(stmt.getLong("art_id"), BranchId.valueOf(stmt.getLong("branch_id")))),
+ artifactCountEstimate, sql, queryParameters);
- try {
- chStmt.runPreparedQuery(artifactCountEstimate, sql, queryParameters);
- while (chStmt.next()) {
- int artId = chStmt.getInt("art_id");
- long branchUuid = chStmt.getLong("branch_id");
- toLoad.add(new Pair<>(ArtifactId.valueOf(artId), BranchId.valueOf(branchUuid)));
- }
- } finally {
- chStmt.close();
- }
OseeLog.logf(Activator.class, Level.FINE, "Artifact Selection Time [%s], [%d] artifacts selected",
Lib.getElapseString(time), toLoad.size());
return toLoad;
- // processList(queryId, toLoad, artifacts, insertParameters, transactionId, reload, locks);
}
/**
@@ -399,14 +374,11 @@ public final class ArtifactLoader {
}
}
boolean historical = transactionId.isValid();
- long key2;
-
- CompositeKeyHashMap<Integer, Long, Artifact> tempCache =
- new CompositeKeyHashMap<Integer, Long, Artifact>(artifacts.size(), true);
+ CompositeKeyHashMap<ArtifactId, Id, Artifact> tempCache = new CompositeKeyHashMap<>(artifacts.size(), true);
for (Artifact artifact : artifacts) {
- key2 = historical ? transactionId.getId() : artifact.getBranchId();
- tempCache.put(artifact.getArtId(), key2, artifact);
+ Id key2 = historical ? transactionId : artifact.getBranch();
+ tempCache.put(artifact, key2, artifact);
}
AttributeLoader.loadAttributeData(queryId, tempCache, historical, allowDeleted, loadLevel, isArchived);
@@ -414,10 +386,8 @@ public final class ArtifactLoader {
if (!historical) {
for (Artifact artifact : artifacts) {
- key2 = artifact.getBranchId();
- removeAndUnlock(artifact.getArtId(), key2);
+ removeAndUnlock(artifact);
}
}
}
-
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java
index 94c977593a..7ebdb609f3 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java
@@ -14,11 +14,14 @@ import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED
import static org.eclipse.osee.framework.core.enums.LoadLevel.ARTIFACT_DATA;
import static org.eclipse.osee.framework.core.enums.LoadLevel.RELATION_DATA;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import org.eclipse.osee.framework.core.data.ApplicabilityId;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.AttributeId;
import org.eclipse.osee.framework.core.data.AttributeTypeId;
+import org.eclipse.osee.framework.core.data.BranchId;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.LoadLevel;
@@ -26,6 +29,7 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.sql.OseeSql;
import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
+import org.eclipse.osee.framework.jdk.core.type.Id;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -39,7 +43,7 @@ import org.eclipse.osee.jdbc.JdbcStatement;
*/
public class AttributeLoader {
- static void loadAttributeData(int queryId, CompositeKeyHashMap<Integer, Long, Artifact> tempCache, boolean historical, DeletionFlag allowDeletedArtifacts, LoadLevel loadLevel, boolean isArchived) throws OseeCoreException {
+ static void loadAttributeData(int queryId, CompositeKeyHashMap<ArtifactId, Id, Artifact> tempCache, boolean historical, DeletionFlag allowDeletedArtifacts, LoadLevel loadLevel, boolean isArchived) throws OseeCoreException {
if (loadLevel == ARTIFACT_DATA || loadLevel == RELATION_DATA) {
return;
}
@@ -77,15 +81,15 @@ public class AttributeLoader {
}
private static final class AttrData {
- public int artifactId = -1;
- public long branchUuid = -1;
- public int attrId = -1;
+ public ArtifactId artifactId = ArtifactId.SENTINEL;
+ public BranchId branch = BranchId.SENTINEL;
+ public AttributeId attrId = AttributeId.SENTINEL;
public int gammaId = -1;
- public int modType = -1;
+ public ModificationType modType;
public Long transactionId = -1L;
public AttributeTypeId attributeType = AttributeTypeId.SENTINEL;
public Object value = "";
- public int stripeId = -1;
+ public TransactionId stripeId = TransactionId.SENTINEL;
public String uri = "";
public ApplicabilityId applicabilityId = ApplicabilityId.BASE;
@@ -94,11 +98,11 @@ public class AttributeLoader {
}
public AttrData(JdbcStatement chStmt, boolean historical) throws OseeCoreException {
- artifactId = chStmt.getInt("art_id");
- branchUuid = chStmt.getLong("id1");
- attrId = chStmt.getInt("attr_id");
+ artifactId = ArtifactId.valueOf(chStmt.getLong("art_id"));
+ branch = BranchId.valueOf(chStmt.getLong("id1"));
+ attrId = AttributeId.valueOf(chStmt.getLong("attr_id"));
gammaId = chStmt.getInt("gamma_id");
- modType = chStmt.getInt("mod_type");
+ modType = ModificationType.getMod(chStmt.getInt("mod_type"));
transactionId = chStmt.getLong("transaction_id");
attributeType = AttributeTypeId.valueOf(chStmt.getLong("attr_type_id"));
@@ -123,28 +127,29 @@ public class AttributeLoader {
}
if (historical) {
- stripeId = chStmt.getInt("stripe_transaction_id");
+ stripeId = TransactionId.valueOf(chStmt.getLong("stripe_transaction_id"));
}
uri = chStmt.getString("uri");
applicabilityId = ApplicabilityId.valueOf(chStmt.getLong("app_id"));
}
public static boolean isDifferentArtifact(AttrData previous, AttrData current) {
- return current.branchUuid != previous.branchUuid || current.artifactId != previous.artifactId;
+ return current.branch.notEqual(previous.branch) || current.artifactId.notEqual(previous.artifactId);
}
public static boolean multipleVersionsExist(AttrData current, AttrData previous) {
- return current.attrId == previous.attrId && current.branchUuid == previous.branchUuid && current.artifactId == previous.artifactId;
+ return current.attrId.equals(previous.attrId) && current.branch.equals(
+ previous.branch) && current.artifactId.equals(previous.artifactId);
}
}
- private static Artifact getArtifact(AttrData current, boolean historical, CompositeKeyHashMap<Integer, Long, Artifact> tempCache) {
+ private static Artifact getArtifact(AttrData current, boolean historical, CompositeKeyHashMap<ArtifactId, Id, Artifact> tempCache) {
Artifact artifact = null;
- long key2 = historical ? current.stripeId : current.branchUuid;
+ Id key2 = historical ? current.stripeId : current.branch;
artifact = tempCache.get(current.artifactId, key2);
if (artifact == null) {
- OseeLog.logf(ArtifactLoader.class, Level.WARNING, "Orphaned attribute id [%d] for artifact id[%d] branch[%d]",
- current.attrId, current.artifactId, current.branchUuid);
+ OseeLog.logf(ArtifactLoader.class, Level.WARNING, "Orphaned attribute id [%s] for artifact id[%s] branch[%s]",
+ current.attrId, current.artifactId, current.branch);
}
return artifact;
}
@@ -153,7 +158,7 @@ public class AttributeLoader {
if (artifact == null) {
return; // If the artifact is null, it means the attributes are orphaned.
}
- List<Long> transactionNumbers = new ArrayList<>();
+ Long maxTransaction = Id.SENTINEL;
AttrData previous = new AttrData();
synchronized (artifact) {
if (!artifact.isAttributesLoaded()) {
@@ -162,11 +167,13 @@ public class AttributeLoader {
handleMultipleVersions(previous, current, historical);
} else {
loadAttribute(artifact, current, previous);
- transactionNumbers.add(current.transactionId);
+ if (current.transactionId > maxTransaction) {
+ maxTransaction = current.transactionId;
+ }
}
previous = current;
}
- setLastAttributePersistTransaction(artifact, transactionNumbers);
+ artifact.setTransactionId(TransactionToken.valueOf(maxTransaction, artifact.getBranch()));
artifact.meetMinimumAttributeCounts(false);
}
}
@@ -177,21 +184,16 @@ public class AttributeLoader {
// transaction is used first due to sorting on the query
if (!historical) {
OseeLog.logf(ArtifactLoader.class, Level.WARNING,
-
- "multiple attribute version for attribute id [%d] artifact id[%d] branch[%d] previousGammaId[%s] currentGammaId[%s] previousModType[%s] currentModType[%s]",
- current.attrId, current.artifactId, current.branchUuid, previous.gammaId, current.gammaId, previous.modType,
+ "multiple attribute version for attribute id [%s] artifact id[%s] branch[%s] previousGammaId[%s] currentGammaId[%s] previousModType[%s] currentModType[%s]",
+ current.attrId, current.artifactId, current.branch, previous.gammaId, current.gammaId, previous.modType,
current.modType);
}
}
private static void loadAttribute(Artifact artifact, AttrData current, AttrData previous) throws OseeCoreException {
boolean markDirty = false;
- artifact.internalInitializeAttribute(current.attributeType, current.attrId, current.gammaId,
- ModificationType.getMod(current.modType), current.applicabilityId, markDirty, current.value, current.uri);
- }
-
- private static void setLastAttributePersistTransaction(Artifact artifact, List<Long> transactionNumbers) {
- artifact.setTransactionId(TransactionToken.valueOf(Collections.max(transactionNumbers), artifact.getBranch()));
+ artifact.internalInitializeAttribute(current.attributeType, current.attrId, current.gammaId, current.modType,
+ current.applicabilityId, markDirty, current.value, current.uri);
}
private static String getSql(DeletionFlag allowDeletedArtifacts, LoadLevel loadLevel, boolean historical, boolean isArchived) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
index 74a2f7fa39..b9c251403a 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQueryBuilder.java
@@ -296,8 +296,7 @@ public class ArtifactQueryBuilder {
return java.util.Collections.emptyList();
}
- List<Artifact> artifactsFromServerIds = loadArtifactsFromServerIds(reload);
- return artifactsFromServerIds;
+ return loadArtifactsFromServerIds(reload);
}
public List<ArtifactId> selectArtifacts(int artifactCountEstimate) throws OseeCoreException {
@@ -347,7 +346,7 @@ public class ArtifactQueryBuilder {
}
if (artifactId.isValid()) {
message.append(" with id \"");
- message.append(artifactId);
+ message.append(artifactId.getIdString());
message.append("\"");
}
if (guid != null) {
@@ -361,7 +360,7 @@ public class ArtifactQueryBuilder {
message.append("\"");
}
message.append(" on branch \"");
- message.append(branch.getIdString());
+ message.append(branch);
message.append("\"");
return message.toString();
}

Back to the top