Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrschmitt2010-05-26 22:31:30 +0000
committerrschmitt2010-05-26 22:31:30 +0000
commit2676235f8004e052d45ce6e0953e1ac54391d9ed (patch)
treed01c3620dcab29527ce82d92dc00ff69aea61e64 /plugins/org.eclipse.osee.framework.skynet.core
parenta51f9d007caa56a4eb569f3a7288db92cea021d0 (diff)
downloadorg.eclipse.osee-2676235f8004e052d45ce6e0953e1ac54391d9ed.tar.gz
org.eclipse.osee-2676235f8004e052d45ce6e0953e1ac54391d9ed.tar.xz
org.eclipse.osee-2676235f8004e052d45ce6e0953e1ac54391d9ed.zip
AttributeLoader changes pursuant to code review
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/AttributeLoader.java135
1 files changed, 66 insertions, 69 deletions
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 7f057c4e14f..fd435301627 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,16 +14,16 @@ import static org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoad.RELAT
import static org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoad.SHALLOW;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.client.ClientSessionManager;
-import org.eclipse.osee.framework.core.enums.ModificationType;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import java.util.List;
+import java.util.logging.Level;
+import org.eclipse.osee.framework.core.client.ClientSessionManager;
+import org.eclipse.osee.framework.core.data.IAttributeType;
+import org.eclipse.osee.framework.core.enums.ModificationType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
-import org.eclipse.osee.framework.core.model.AttributeType;
-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.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.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.attribute.AttributeTypeManager;
@@ -31,25 +31,40 @@ import org.eclipse.osee.framework.skynet.core.attribute.BooleanAttribute;
import org.eclipse.osee.framework.skynet.core.attribute.EnumeratedAttribute;
/**
- * @author Ryan Schmitt
- */
-public class AttributeLoader {
- private static boolean historical = false;
+ * @author Ryan Schmitt
+ */
+public class AttributeLoader {
- private static String getSql(boolean allowDeletedArtifacts, ArtifactLoad loadLevel) throws OseeCoreException {
- OseeSql sqlKey;
- if (historical) {
- sqlKey = OseeSql.LOAD_HISTORICAL_ATTRIBUTES;
- } else if (loadLevel == ArtifactLoad.ALL_CURRENT) {
- sqlKey = OseeSql.LOAD_ALL_CURRENT_ATTRIBUTES;
- } else if (allowDeletedArtifacts) {
- sqlKey = OseeSql.LOAD_CURRENT_ATTRIBUTES_WITH_DELETED;
- } else {
- sqlKey = OseeSql.LOAD_CURRENT_ATTRIBUTES;
+ static void loadAttributeData(int queryId, Collection<Artifact> artifacts, boolean historical, boolean allowDeletedArtifacts, ArtifactLoad loadLevel) throws OseeCoreException {
+ if (loadLevel == SHALLOW || loadLevel == RELATION) {
+ return;
}
- String sql = ClientSessionManager.getSql(sqlKey);
- return sql;
+ IOseeStatement chStmt = ConnectionHandler.getStatement();
+ try {
+ String sql = getSql(allowDeletedArtifacts, loadLevel, historical);
+ chStmt.runPreparedQuery(artifacts.size() * 8, sql, queryId);
+
+ Artifact currentArtifact = null;
+ AttrData previousAttr = new AttrData();
+ List<AttrData> currentAttributes = new ArrayList<AttrData>();
+
+ while (chStmt.next()) {
+ AttrData nextAttr = new AttrData(chStmt, historical);
+
+ if (AttrData.isDifferentArtifact(previousAttr, nextAttr)) {
+ loadAttributesFor(currentArtifact, currentAttributes, historical);
+ currentAttributes.clear();
+ currentArtifact = getArtifact(nextAttr, historical);
+ }
+
+ currentAttributes.add(nextAttr);
+ previousAttr = nextAttr;
+ }
+ loadAttributesFor(currentArtifact, currentAttributes, historical);
+ } finally {
+ chStmt.close();
+ }
}
private static final class AttrData {
@@ -84,48 +99,15 @@ public class AttributeLoader {
}
public static boolean isDifferentArtifact(AttrData previous, AttrData current) {
- return (current.branchId != previous.branchId || current.artifactId != previous.artifactId);
+ return current.branchId != previous.branchId || current.artifactId != previous.artifactId;
}
public static boolean multipleVersionsExist(AttrData current, AttrData previous) {
- return (current.attrId == previous.attrId && current.branchId == previous.branchId && current.artifactId == previous.artifactId);
+ return current.attrId == previous.attrId && current.branchId == previous.branchId && current.artifactId == previous.artifactId;
}
}
- static void loadAttributeData(int queryId, Collection<Artifact> artifacts, boolean _historical, boolean allowDeletedArtifacts, ArtifactLoad loadLevel) throws OseeCoreException {
- if (loadLevel == SHALLOW || loadLevel == RELATION) {
- return;
- }
- historical = _historical;
-
- IOseeStatement chStmt = ConnectionHandler.getStatement();
- try {
- String sql = getSql(allowDeletedArtifacts, loadLevel);
- chStmt.runPreparedQuery(artifacts.size() * 8, sql, queryId);
-
- Artifact currentArtifact = null;
- AttrData previousAttr = new AttrData();
- List<AttrData> currentAttributes = new ArrayList<AttrData>();
-
- while (chStmt.next()) {
- AttrData nextAttr = new AttrData(chStmt, historical);
-
- if (AttrData.isDifferentArtifact(previousAttr, nextAttr)) {
- handleArtifact(currentArtifact, currentAttributes);
- currentAttributes.clear();
- currentArtifact = getArtifact(nextAttr);
- }
-
- currentAttributes.add(nextAttr);
- previousAttr = nextAttr;
- }
- handleArtifact(currentArtifact, currentAttributes);
- } finally {
- chStmt.close();
- }
- }
-
- private static Artifact getArtifact(AttrData current) {
+ private static Artifact getArtifact(AttrData current, boolean historical) {
Artifact artifact = null;
if (historical) {
artifact = ArtifactCache.getHistorical(current.artifactId, current.stripeId);
@@ -137,9 +119,9 @@ public class AttributeLoader {
"Orphaned attribute for artifact id[%d] branch[%d]", current.artifactId, current.branchId));
}
return artifact;
- }
+ }
- private static void handleArtifact(Artifact artifact, List<AttrData> attributes) throws OseeCoreException {
+ private static void loadAttributesFor(Artifact artifact, List<AttrData> attributes, boolean historical) throws OseeCoreException {
if (artifact == null) {
return; // If the artifact is null, it means the attributes are orphaned.
}
@@ -151,7 +133,7 @@ public class AttributeLoader {
if (AttrData.multipleVersionsExist(current, previous)) {
handleMultipleVersions(previous, current, historical);
} else {
- handleAttribute(artifact, current, previous);
+ loadAttribute(artifact, current, previous);
transactionNumbers.add(current.transactionId);
}
previous = current;
@@ -164,7 +146,7 @@ public class AttributeLoader {
}
private static void handleMultipleVersions(AttrData previous, AttrData current, boolean historical) {
- // Okay to skip on historical loading, because the most recent
+ // Do not warn about skipping on historical loading, because the most recent
// transaction is used first due to sorting on the query
if (!historical) {
OseeLog.log(
@@ -177,8 +159,8 @@ public class AttributeLoader {
}
}
- private static void handleAttribute(Artifact artifact, AttrData current, AttrData previous) throws OseeCoreException {
- AttributeType attributeType = AttributeTypeManager.getType(current.attrTypeId);
+ private static void loadAttribute(Artifact artifact, AttrData current, AttrData previous) throws OseeCoreException {
+ IAttributeType attributeType = AttributeTypeManager.getType(current.attrTypeId);
String value = current.value;
if (isEnumOrBoolean(attributeType)) {
value = Strings.intern(value);
@@ -188,7 +170,7 @@ public class AttributeLoader {
ModificationType.getMod(current.modType), markDirty, value, current.uri);
}
- private static boolean isEnumOrBoolean(AttributeType attributeType) throws OseeCoreException {
+ private static boolean isEnumOrBoolean(IAttributeType attributeType) throws OseeCoreException {
boolean isBooleanAttribute = AttributeTypeManager.isBaseTypeCompatible(BooleanAttribute.class, attributeType);
boolean isEnumAttribute = AttributeTypeManager.isBaseTypeCompatible(EnumeratedAttribute.class, attributeType);
return isBooleanAttribute || isEnumAttribute;
@@ -201,4 +183,19 @@ public class AttributeLoader {
}
artifact.setTransactionId(maxTransactionId);
}
-}
+
+ private static String getSql(boolean allowDeletedArtifacts, ArtifactLoad loadLevel, boolean historical) throws OseeCoreException {
+ OseeSql sqlKey;
+ if (historical) {
+ sqlKey = OseeSql.LOAD_HISTORICAL_ATTRIBUTES;
+ } else if (loadLevel == ArtifactLoad.ALL_CURRENT) {
+ sqlKey = OseeSql.LOAD_ALL_CURRENT_ATTRIBUTES;
+ } else if (allowDeletedArtifacts) {
+ sqlKey = OseeSql.LOAD_CURRENT_ATTRIBUTES_WITH_DELETED;
+ } else {
+ sqlKey = OseeSql.LOAD_CURRENT_ATTRIBUTES;
+ }
+
+ return ClientSessionManager.getSql(sqlKey);
+ }
+} \ No newline at end of file

Back to the top