Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeBuilder.java6
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeWorker.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/AttributeChangeBuilder.java21
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ChangeBuilder.java18
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/RelationChangeBuilder.java28
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java61
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java7
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java134
8 files changed, 149 insertions, 128 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeBuilder.java
index a496b081b01..536bcf2ab90 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeBuilder.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeBuilder.java
@@ -12,7 +12,6 @@ package org.eclipse.osee.framework.skynet.core.change;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
@@ -25,9 +24,4 @@ public class ArtifactChangeBuilder extends ChangeBuilder {
super(branch, artifactType, sourceGamma, artId, txDelta, modType, isHistorical);
}
- @Override
- public Change build(Branch branch) throws OseeCoreException {
- return new ArtifactChange(branch, getSourceGamma(), getArtId(), getTxDelta(), getModType(), isHistorical(),
- loadArtifact(), new ArtifactDelta(getTxDelta(), loadArtifact(), null));
- }
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeWorker.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeWorker.java
index f92ecfca15a..302d6554d25 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeWorker.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ArtifactChangeWorker.java
@@ -15,7 +15,7 @@ import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
/**
* @author Jeff C. Phillips
- * @author Wilik Karol
+ * @author Wilk Karol
*/
public class ArtifactChangeWorker implements IChangeWorker {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/AttributeChangeBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/AttributeChangeBuilder.java
index 89d84f037a9..804e53fe5f2 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/AttributeChangeBuilder.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/AttributeChangeBuilder.java
@@ -12,7 +12,6 @@ package org.eclipse.osee.framework.skynet.core.change;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
import org.eclipse.osee.framework.core.model.type.AttributeType;
@@ -44,10 +43,20 @@ public final class AttributeChangeBuilder extends ChangeBuilder {
this.wasValue = wasValue;
}
- @Override
- public Change build(Branch branch) throws OseeCoreException {
- return new AttributeChange(branch, getSourceGamma(), getArtId(), getTxDelta(), getModType(), isValue, wasValue,
- attrId, attributeType, artModType, isHistorical(), loadArtifact(), new ArtifactDelta(getTxDelta(),
- loadArtifact(), null));
+ public String getIsValue() {
+ return isValue;
}
+
+ public String getWasValue() {
+ return wasValue;
+ }
+
+ public int getAttrId() {
+ return attrId;
+ }
+
+ public AttributeType getAttributeType() {
+ return attributeType;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ChangeBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ChangeBuilder.java
index a7567c8ffcc..aa2bdfc923f 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ChangeBuilder.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/ChangeBuilder.java
@@ -11,13 +11,9 @@
package org.eclipse.osee.framework.skynet.core.change;
import org.eclipse.osee.framework.core.data.IArtifactType;
-import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
/**
* @author Jeff C. Phillips
@@ -74,18 +70,4 @@ public abstract class ChangeBuilder {
return isHistorical;
}
- protected Artifact loadArtifact() throws OseeCoreException {
- Artifact artifact;
-
- if (isHistorical()) {
- artifact =
- ArtifactQuery.getHistoricalArtifactFromId(getArtId(), getTxDelta().getEndTx(), DeletionFlag.INCLUDE_DELETED);
- } else {
- artifact = ArtifactQuery.getArtifactFromId(getArtId(), getBranch());
- }
- return artifact;
- }
-
- public abstract Change build(Branch branch) throws OseeCoreException;
-
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/RelationChangeBuilder.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/RelationChangeBuilder.java
index 26d611b35ee..b3427586a03 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/RelationChangeBuilder.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/change/RelationChangeBuilder.java
@@ -11,14 +11,10 @@
package org.eclipse.osee.framework.skynet.core.change;
import org.eclipse.osee.framework.core.data.IArtifactType;
-import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionDelta;
import org.eclipse.osee.framework.core.model.type.RelationType;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
/**
* @author Jeff C. Phillips
@@ -37,20 +33,20 @@ public class RelationChangeBuilder extends ChangeBuilder {
this.relationType = relationType;
}
- @Override
- public Change build(Branch branch) throws OseeCoreException {
- Artifact bArtifact;
+ public int getbArtId() {
+ return bArtId;
+ }
+
+ public int getRelLinkId() {
+ return relLinkId;
+ }
- if (isHistorical()) {
- bArtifact =
- ArtifactQuery.getHistoricalArtifactFromId(bArtId, getTxDelta().getEndTx(), DeletionFlag.INCLUDE_DELETED);
- } else {
- bArtifact = ArtifactQuery.getArtifactFromId(bArtId, getBranch());
- }
+ public String getRationale() {
+ return rationale;
+ }
- return new RelationChange(branch, getSourceGamma(), getArtId(), getTxDelta(), getModType(), bArtId, relLinkId,
- rationale, relationType, isHistorical(), loadArtifact(),
- new ArtifactDelta(getTxDelta(), loadArtifact(), null), bArtifact);
+ public RelationType getRelationType() {
+ return relationType;
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java
index 18ea304dce8..0cd23f35361 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeDataLoader.java
@@ -11,10 +11,10 @@
package org.eclipse.osee.framework.skynet.core.revision;
import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
@@ -39,6 +39,7 @@ import org.eclipse.osee.framework.core.model.change.RelationChangeItem;
import org.eclipse.osee.framework.core.model.type.AttributeType;
import org.eclipse.osee.framework.core.model.type.RelationType;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
@@ -79,7 +80,10 @@ public class ChangeDataLoader extends AbstractOperation {
monitor.worked(calculateWork(0.80));
} else {
monitor.setTaskName("Bulk load changed artifacts");
- Collection<Artifact> bulkLoaded = new ArrayList<Artifact>();
+
+ CompositeKeyHashMap<TransactionRecord, Integer, Artifact> bulkLoaded =
+ new CompositeKeyHashMap<TransactionRecord, Integer, Artifact>();
+
bulkLoadArtifactDeltas(monitor, bulkLoaded, changeItems);
monitor.worked(calculateWork(0.20));
@@ -88,44 +92,32 @@ public class ChangeDataLoader extends AbstractOperation {
IOseeBranch startTxBranch = txDelta.getStartTx().getBranch();
for (ChangeItem item : changeItems) {
checkForCancelledStatus(monitor);
- Change change = computeChange(startTxBranch, item);
+ Change change = computeChange(bulkLoaded, startTxBranch, item);
changes.add(change);
monitor.worked(calculateWork(workAmount));
}
}
}
- private Artifact getArtifactAtTx(int artId, TransactionRecord transaction) throws OseeCoreException {
- Artifact artifactAtTransaction = null;
- if (txDelta.areOnTheSameBranch()) {
- artifactAtTransaction = ArtifactQuery.checkHistoricalArtifactFromId(artId, transaction, INCLUDE_DELETED);
- } else {
- artifactAtTransaction = ArtifactQuery.checkArtifactFromId(artId, transaction.getBranch(), INCLUDE_DELETED);
- }
- return artifactAtTransaction;
- }
-
- private Change computeChange(IOseeBranch startTxBranch, ChangeItem item) {
+ private Change computeChange(CompositeKeyHashMap<TransactionRecord, Integer, Artifact> bulkLoaded, IOseeBranch startTxBranch, ChangeItem item) {
Change change = null;
try {
int artId = item.getArtId();
Artifact startTxArtifact;
if (txDelta.areOnTheSameBranch()) {
- startTxArtifact = getArtifactAtTx(artId, txDelta.getStartTx());
+ startTxArtifact = bulkLoaded.get(txDelta.getStartTx(), artId);
} else {
- startTxArtifact =
- ArtifactQuery.checkHistoricalArtifactFromId(artId,
- txDelta.getStartTx().getBranch().getBaseTransaction(), INCLUDE_DELETED);
+ startTxArtifact = bulkLoaded.get(txDelta.getStartTx().getBranch().getBaseTransaction(), artId);
}
Artifact endTxArtifact;
if (txDelta.areOnTheSameBranch()) {
- endTxArtifact = getArtifactAtTx(artId, txDelta.getEndTx());
+ endTxArtifact = bulkLoaded.get(txDelta.getEndTx(), artId);
} else {
- endTxArtifact = getArtifactAtTx(artId, txDelta.getStartTx());
+ endTxArtifact = bulkLoaded.get(txDelta.getStartTx(), artId);
}
ArtifactDelta artifactDelta = new ArtifactDelta(txDelta, startTxArtifact, endTxArtifact);
- change = createChangeObject(item, txDelta, startTxBranch, artifactDelta);
+ change = createChangeObject(bulkLoaded, item, txDelta, startTxBranch, artifactDelta);
change.setChangeItem(item);
} catch (Exception ex) {
@@ -135,7 +127,7 @@ public class ChangeDataLoader extends AbstractOperation {
return change;
}
- private Change createChangeObject(ChangeItem item, TransactionDelta txDelta, IOseeBranch startTxBranch, ArtifactDelta artifactDelta) throws OseeCoreException {
+ private Change createChangeObject(CompositeKeyHashMap<TransactionRecord, Integer, Artifact> bulkLoaded, ChangeItem item, TransactionDelta txDelta, IOseeBranch startTxBranch, ArtifactDelta artifactDelta) throws OseeCoreException {
Change change = null;
int itemId = item.getItemId();
@@ -178,7 +170,7 @@ public class ChangeDataLoader extends AbstractOperation {
if (txDelta.areOnTheSameBranch()) {
transaction = txDelta.getEndTx();
}
- Artifact endTxBArtifact = getArtifactAtTx(relationItem.getBArtId(), transaction);
+ Artifact endTxBArtifact = bulkLoaded.get(transaction, relationItem.getBArtId());
change =
new RelationChange(startTxBranch, itemGammaId, artId, txDelta, netModType, endTxBArtifact.getArtId(),
@@ -190,24 +182,29 @@ public class ChangeDataLoader extends AbstractOperation {
return change;
}
- private void bulkLoadArtifactDeltas(IProgressMonitor monitor, Collection<Artifact> bulkLoaded, Collection<ChangeItem> changeItems) throws OseeCoreException {
+ private void bulkLoadArtifactDeltas(IProgressMonitor monitor, CompositeKeyHashMap<TransactionRecord, Integer, Artifact> bulkLoaded, Collection<ChangeItem> changeItems) throws OseeCoreException {
checkForCancelledStatus(monitor);
Set<Integer> artIds = asArtIds(changeItems);
- if (txDelta.areOnTheSameBranch()) {
- preloadArtifacts(bulkLoaded, artIds, txDelta.getStartTx(), false);
- } else {
- // Load current artifacts by id for each branch
- preloadArtifacts(bulkLoaded, artIds, txDelta.getStartTx(), false);
+ preloadArtifacts(bulkLoaded, artIds, txDelta.getStartTx(), false);
+ if (!txDelta.getStartTx().equals(txDelta.getEndTx())) {
preloadArtifacts(bulkLoaded, artIds, txDelta.getEndTx(), false);
}
+
+ if (!txDelta.areOnTheSameBranch()) {
+ preloadArtifacts(bulkLoaded, artIds, txDelta.getStartTx().getBranch().getBaseTransaction(), true);
+ }
}
- private static void preloadArtifacts(Collection<Artifact> bulkLoaded, Collection<Integer> artIds, TransactionRecord tx, boolean isHistorical) throws OseeCoreException {
+ private static void preloadArtifacts(CompositeKeyHashMap<TransactionRecord, Integer, Artifact> bulkLoaded, Collection<Integer> artIds, TransactionRecord tx, boolean isHistorical) throws OseeCoreException {
Branch branch = BranchManager.getBranch(tx.getBranchId());
+ List<Artifact> artifacts;
if (isHistorical) {
- bulkLoaded.addAll(ArtifactQuery.getHistoricalArtifactListFromIds(artIds, tx, INCLUDE_DELETED));
+ artifacts = ArtifactQuery.getHistoricalArtifactListFromIds(artIds, tx, INCLUDE_DELETED);
} else {
- bulkLoaded.addAll(ArtifactQuery.getArtifactListFromIds(artIds, branch, INCLUDE_DELETED));
+ artifacts = ArtifactQuery.getArtifactListFromIds(artIds, branch, INCLUDE_DELETED);
+ }
+ for (Artifact artifact : artifacts) {
+ bulkLoaded.put(tx, artifact.getArtId(), artifact);
}
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
index c46c8e32dfd..47141c4673b 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
@@ -61,13 +61,6 @@ public final class ChangeManager {
}
/**
- * Acquires changes for a particular artifact without recursing through branch hierarchy
- */
- public static Collection<Change> getChangesMadeOnCurrentBranch(Artifact artifact, IProgressMonitor monitor) throws OseeCoreException {
- return revsionChangeLoader.getChangesMadeOnCurrentBranch(artifact, monitor);
- }
-
- /**
* Acquires changes for a particular artifact
*/
public static Collection<Change> getChangesPerArtifact(Artifact artifact, IProgressMonitor monitor) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
index 0ff0189c52c..860372f61e8 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
@@ -10,25 +10,36 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.revision;
-import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.osee.framework.core.client.ClientSessionManager;
+import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.database.core.ConnectionHandler;
import org.eclipse.osee.framework.database.core.IOseeStatement;
import org.eclipse.osee.framework.database.core.OseeSql;
+import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.change.ArtifactChange;
+import org.eclipse.osee.framework.skynet.core.change.ArtifactChangeBuilder;
+import org.eclipse.osee.framework.skynet.core.change.ArtifactDelta;
+import org.eclipse.osee.framework.skynet.core.change.AttributeChange;
+import org.eclipse.osee.framework.skynet.core.change.AttributeChangeBuilder;
import org.eclipse.osee.framework.skynet.core.change.Change;
import org.eclipse.osee.framework.skynet.core.change.ChangeBuilder;
+import org.eclipse.osee.framework.skynet.core.change.RelationChange;
+import org.eclipse.osee.framework.skynet.core.change.RelationChangeBuilder;
import org.eclipse.osee.framework.skynet.core.revision.acquirer.ArtifactChangeAcquirer;
import org.eclipse.osee.framework.skynet.core.revision.acquirer.AttributeChangeAcquirer;
import org.eclipse.osee.framework.skynet.core.revision.acquirer.RelationChangeAcquirer;
@@ -56,24 +67,10 @@ public final class RevisionChangeLoader {
/**
* @return Returns artifact, relation and attribute changes from a specific artifact
*/
- public Collection<Change> getChangesPerArtifact(Artifact artifact, IProgressMonitor monitor, LoadChangeType... loadChangeTypes) throws OseeCoreException {
- return getChangesPerArtifact(artifact, monitor, true, loadChangeTypes);
- }
-
- /**
- * @return Returns artifact, relation and attribute changes from a specific artifact made on the current branch only
- */
- public Collection<Change> getChangesMadeOnCurrentBranch(Artifact artifact, IProgressMonitor monitor) throws OseeCoreException {
- return getChangesPerArtifact(artifact, monitor, false, LoadChangeType.artifact, LoadChangeType.attribute,
- LoadChangeType.relation);
- }
-
- /**
- * @return Returns artifact, relation and attribute changes from a specific artifact
- */
- private Collection<Change> getChangesPerArtifact(Artifact artifact, IProgressMonitor monitor, boolean recurseThroughBranchHierarchy, LoadChangeType... loadChangeTypes) throws OseeCoreException {
+ private Collection<Change> getChangesPerArtifact(Artifact artifact, IProgressMonitor monitor, LoadChangeType... loadChangeTypes) throws OseeCoreException {
Branch branch = artifact.getFullBranch();
Set<TransactionRecord> transactionIds = new LinkedHashSet<TransactionRecord>();
+ boolean recurseThroughBranchHierarchy = true;
loadBranchTransactions(branch, artifact, transactionIds, TransactionManager.getHeadTransaction(branch),
recurseThroughBranchHierarchy);
@@ -122,23 +119,24 @@ public final class RevisionChangeLoader {
* creation.
*/
private void loadChanges(Branch sourceBranch, TransactionRecord transactionId, IProgressMonitor monitor, Artifact specificArtifact, Collection<Change> changes, LoadChangeType... loadChangeTypes) throws OseeCoreException {
- @SuppressWarnings("unused")
- //This is so weak references do not get collected from bulk loading
- Collection<Artifact> bulkLoadedArtifacts;
- ArrayList<ChangeBuilder> changeBuilders = new ArrayList<ChangeBuilder>();
-
- Set<Integer> artIds = new HashSet<Integer>();
- Set<Integer> newAndDeletedArtifactIds = new HashSet<Integer>();
- boolean historical = sourceBranch == null;
-
if (monitor == null) {
monitor = new NullProgressMonitor();
}
-
monitor.beginTask("Find Changes", 100);
+ Set<Integer> artIds = new HashSet<Integer>();
+ Set<Integer> newAndDeletedArtifactIds = new HashSet<Integer>();
+ boolean isHistorical = sourceBranch == null;
+
+ ArrayList<ChangeBuilder> changeBuilders = new ArrayList<ChangeBuilder>();
for (LoadChangeType changeType : loadChangeTypes) {
switch (changeType) {
+ case artifact:
+ ArtifactChangeAcquirer artifactChangeAcquirer =
+ new ArtifactChangeAcquirer(sourceBranch, transactionId, monitor, specificArtifact, artIds,
+ changeBuilders, newAndDeletedArtifactIds);
+ changeBuilders = artifactChangeAcquirer.acquireChanges();
+ break;
case attribute:
AttributeChangeAcquirer attributeChangeAcquirer =
new AttributeChangeAcquirer(sourceBranch, transactionId, monitor, specificArtifact, artIds,
@@ -149,33 +147,85 @@ public final class RevisionChangeLoader {
RelationChangeAcquirer relationChangeAcquirer =
new RelationChangeAcquirer(sourceBranch, transactionId, monitor, specificArtifact, artIds,
changeBuilders, newAndDeletedArtifactIds);
+
changeBuilders = relationChangeAcquirer.acquireChanges();
break;
- case artifact:
- ArtifactChangeAcquirer artifactChangeAcquirer =
- new ArtifactChangeAcquirer(sourceBranch, transactionId, monitor, specificArtifact, artIds,
- changeBuilders, newAndDeletedArtifactIds);
- changeBuilders = artifactChangeAcquirer.acquireChanges();
- break;
default:
break;
}
}
monitor.subTask("Loading Artifacts from the Database");
- Branch branch = historical ? transactionId.getBranch() : sourceBranch;
+ Branch branch = isHistorical ? transactionId.getBranch() : sourceBranch;
- if (historical) {
- bulkLoadedArtifacts = ArtifactQuery.getHistoricalArtifactListFromIds(artIds, transactionId, INCLUDE_DELETED);
- } else {
- bulkLoadedArtifacts = ArtifactQuery.getArtifactListFromIds(artIds, branch, INCLUDE_DELETED);
- }
+ Collection<Change> changesLoaded = getChanges(branch, isHistorical, changeBuilders);
+ changes.addAll(changesLoaded);
+
+ monitor.done();
+ }
- //We build the changes after the artifact loader has been run so we can take advantage of bulk loading.
+ private CompositeKeyHashMap<TransactionRecord, Integer, Artifact> getBulkLoadedArtifacts(Branch branch, boolean isHistorical, List<ChangeBuilder> changeBuilders) throws OseeCoreException {
+ HashCollection<TransactionRecord, Integer> loadMap =
+ new HashCollection<TransactionRecord, Integer>(false, HashSet.class);
for (ChangeBuilder builder : changeBuilders) {
- changes.add(builder.build(branch));
+ TransactionRecord endTx = builder.getTxDelta().getEndTx();
+ loadMap.put(endTx, builder.getArtId());
+ if (builder instanceof RelationChangeBuilder) {
+ RelationChangeBuilder relBuilder = (RelationChangeBuilder) builder;
+ loadMap.put(endTx, relBuilder.getbArtId());
+ }
}
- monitor.done();
+ CompositeKeyHashMap<TransactionRecord, Integer, Artifact> loadedMap =
+ new CompositeKeyHashMap<TransactionRecord, Integer, Artifact>();
+
+ for (Entry<TransactionRecord, Collection<Integer>> entry : loadMap.entrySet()) {
+ Collection<Artifact> artifacts;
+ if (isHistorical) {
+ artifacts =
+ ArtifactQuery.getHistoricalArtifactListFromIds(entry.getValue(), entry.getKey(),
+ DeletionFlag.INCLUDE_DELETED);
+ } else {
+ artifacts = ArtifactQuery.getArtifactListFromIds(entry.getValue(), branch, DeletionFlag.INCLUDE_DELETED);
+ }
+ for (Artifact artifact : artifacts) {
+ loadedMap.put(entry.getKey(), artifact.getArtId(), artifact);
+ }
+ }
+ return loadedMap;
+ }
+
+ private Collection<Change> getChanges(Branch branch, boolean isHistorical, List<ChangeBuilder> changeBuilders) throws OseeCoreException {
+ CompositeKeyHashMap<TransactionRecord, Integer, Artifact> loadedMap =
+ getBulkLoadedArtifacts(branch, isHistorical, changeBuilders);
+
+ Collection<Change> changes = new ArrayList<Change>();
+ for (ChangeBuilder builder : changeBuilders) {
+ Change toReturn = null;
+ Artifact changeArtifact = loadedMap.get(builder.getTxDelta().getEndTx(), builder.getArtId());
+
+ ArtifactDelta delta = new ArtifactDelta(builder.getTxDelta(), changeArtifact, null);
+ if (builder instanceof ArtifactChangeBuilder) {
+ toReturn =
+ new ArtifactChange(branch, builder.getSourceGamma(), builder.getArtId(), builder.getTxDelta(),
+ builder.getModType(), isHistorical, changeArtifact, delta);
+ } else if (builder instanceof AttributeChangeBuilder) {
+ AttributeChangeBuilder attrBuilder = (AttributeChangeBuilder) builder;
+ toReturn =
+ new AttributeChange(branch, attrBuilder.getSourceGamma(), attrBuilder.getArtId(),
+ attrBuilder.getTxDelta(), attrBuilder.getModType(), attrBuilder.getIsValue(),
+ attrBuilder.getWasValue(), attrBuilder.getAttrId(), attrBuilder.getAttributeType(),
+ attrBuilder.getArtModType(), isHistorical, changeArtifact, delta);
+ } else if (builder instanceof RelationChangeBuilder) {
+ RelationChangeBuilder relBuilder = (RelationChangeBuilder) builder;
+ Artifact bArtifact = loadedMap.get(builder.getTxDelta().getEndTx(), relBuilder.getbArtId());
+ toReturn =
+ new RelationChange(branch, builder.getSourceGamma(), builder.getArtId(), builder.getTxDelta(),
+ builder.getModType(), relBuilder.getbArtId(), relBuilder.getRelLinkId(), relBuilder.getRationale(),
+ relBuilder.getRelationType(), isHistorical, changeArtifact, delta, bArtifact);
+ }
+ changes.add(toReturn);
+ }
+ return changes;
}
} \ No newline at end of file

Back to the top