Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-11-21 19:20:30 +0000
committerAngel Avila2014-11-21 19:20:30 +0000
commit64c9287856678919697b65a55b2ab32b5b358d4c (patch)
treea67be058aeea07498f8f0a724e06153c0ad730e5 /plugins
parent97afeb67fb7ddea87428dd9ed29dfe1d62ae77af (diff)
downloadorg.eclipse.osee-64c9287856678919697b65a55b2ab32b5b358d4c.tar.gz
org.eclipse.osee-64c9287856678919697b65a55b2ab32b5b358d4c.tar.xz
org.eclipse.osee-64c9287856678919697b65a55b2ab32b5b358d4c.zip
feature[ats_ATS47363]: Adjust ORCS field level calculations
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DynamicData.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/OrcsScriptAssembler.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/JsonOutputHandler.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptAssemblerImpl.java15
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java85
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/ObjectField.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlFieldResolver.java12
-rw-r--r--plugins/org.eclipse.osee.orcs.script.dsl/src/org/eclipse/osee/orcs/script/dsl/fields/OsFieldResolverImpl.java58
8 files changed, 139 insertions, 52 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DynamicData.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DynamicData.java
index 79c0077c37..7a228fff4e 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DynamicData.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/DynamicData.java
@@ -47,7 +47,7 @@ public class DynamicData extends BaseIdentity<String> implements Named {
@Override
public String getName() {
- return isAliasValid() ? getAlias() : getGuid();
+ return isAliasValid() ? getAlias() : getFieldName();
}
public boolean hasParent() {
@@ -100,7 +100,7 @@ public class DynamicData extends BaseIdentity<String> implements Named {
put(FIELD_NAME, fieldName);
}
- public int getLevel() {
+ public Integer getLevel() {
return getObject(LEVEL);
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/OrcsScriptAssembler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/OrcsScriptAssembler.java
index bc13a1ad42..dbd31e6e31 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/OrcsScriptAssembler.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/OrcsScriptAssembler.java
@@ -53,4 +53,6 @@ public interface OrcsScriptAssembler {
void addCollect(DynamicData object, long limit);
+ int getSelectSetIndex();
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/JsonOutputHandler.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/JsonOutputHandler.java
index 30fee3e0f2..1c4d304965 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/JsonOutputHandler.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/JsonOutputHandler.java
@@ -347,7 +347,7 @@ public class JsonOutputHandler extends OrcsScriptOutputHandler {
if (data.isHidden()) {
value.append("hidden->");
}
- value.append(data.getFieldName());
+ value.append(data.getGuid());
if (data.isPrimaryKey()) {
value.append("*");
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptAssemblerImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptAssemblerImpl.java
index d657072d51..685922cec1 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptAssemblerImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptAssemblerImpl.java
@@ -256,4 +256,19 @@ public class OrcsScriptAssemblerImpl implements OrcsScriptAssembler, OrcsScriptE
return results;
}
+ @Override
+ public int getSelectSetIndex() {
+ int index = 0;
+ QueryData lastQuery = getLastQuery();
+ if (lastQuery != null) {
+ List<SelectSet> selectSets = lastQuery.getSelectSets();
+ index = selectSets.size() - 1;
+ }
+ return index;
+ }
+
+ protected LinkedList<QueryData> getQueries() {
+ return queries;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java
index 51bcd25ad7..c4ffd7ceb7 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/script/impl/OrcsScriptInterpreterImpl.java
@@ -30,6 +30,7 @@ import org.eclipse.osee.framework.core.enums.BranchType;
import org.eclipse.osee.framework.core.enums.QueryOption;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
+import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
import org.eclipse.osee.orcs.OrcsTypes;
import org.eclipse.osee.orcs.core.ds.DynamicData;
import org.eclipse.osee.orcs.core.ds.DynamicObject;
@@ -38,6 +39,7 @@ import org.eclipse.osee.orcs.core.internal.script.OrcsScriptInterpreter;
import org.eclipse.osee.orcs.script.dsl.IExpressionResolver;
import org.eclipse.osee.orcs.script.dsl.IFieldResolver;
import org.eclipse.osee.orcs.script.dsl.IFieldResolver.OsField;
+import org.eclipse.osee.orcs.script.dsl.OsFieldEnum;
import org.eclipse.osee.orcs.script.dsl.orcsScriptDsl.OrcsScript;
import org.eclipse.osee.orcs.script.dsl.orcsScriptDsl.OsArtifactIdCriteria;
import org.eclipse.osee.orcs.script.dsl.orcsScriptDsl.OsArtifactQueryAll;
@@ -194,9 +196,11 @@ public class OrcsScriptInterpreterImpl implements OrcsScriptInterpreter {
@Override
public Void caseOsCollectClause(OsCollectClause object) {
+ int startLevel = assembler.getSelectSetIndex();
+
DynamicObject parent = new DynamicObject("root", null);
- parent.setLevel(-1);
- resolveCollectExpression(object.getExpression(), parent, -1);
+ parent.setLevel(startLevel - 1);
+ resolveCollectExpression(object.getExpression(), parent, startLevel);
DynamicData data = Iterables.getFirst(parent.getChildren(), null);
data.setParent(null);
@@ -212,34 +216,59 @@ public class OrcsScriptInterpreterImpl implements OrcsScriptInterpreter {
private void resolveCollectExpression(OsCollectExpression expression, DynamicObject parent, int level) {
if (expression instanceof OsCollectAllFieldsExpression) {
for (OsField field : fieldResolver.getAllowedFields(expression)) {
- resolveOsField(field, parent);
+ resolveOsField(field, parent, level);
}
} else {
- String name = expression.getName();
DynamicData child = null;
if (expression instanceof OsCollectFieldExpression) {
OsCollectFieldExpression fieldExpr = (OsCollectFieldExpression) expression;
String alias = resolveAlias(fieldExpr.getAlias());
+ String fieldLiteral = fieldExpr.getName();
- child = new DynamicData(name, alias);
- child.setLevel(level + 1);
-
- String fieldName = fieldExpr.getName();
Set<? extends OsField> declaredFields = fieldResolver.getDeclaredFields(fieldExpr);
- for (OsField field : declaredFields) {
- if (fieldName.equals(field.getLiteral())) {
- child.setFieldName(field.getId());
- }
+ OsField field = findField(declaredFields, fieldLiteral);
+ if (field != null) {
+ child = new DynamicData(field.getId(), alias);
+ child.setFieldName(field.getLiteral());
+ child.setLevel(level);
+ } else {
+ throw new OseeStateException("unable to find field for [%s] - declared [%s]", fieldLiteral,
+ declaredFields);
}
} else if (expression instanceof OsCollectObjectExpression) {
OsCollectObjectExpression objectExpr = (OsCollectObjectExpression) expression;
String alias = resolveAlias(objectExpr.getAlias());
+ String objectType = objectExpr.getName();
+
+ String id = objectType;
+ String literal = objectType;
+
+ if ("txs".equals(objectType)) {
+ // determine whether its art_txs, attr_txs, or rel_txs
+ if (!(objectExpr.eContainer() instanceof OsCollectClause)) {
+ String value = parent.getGuid();
+ OsFieldEnum field = null;
+ if ("artifacts".equals(value)) {
+ field = OsFieldEnum.art_txs;
+ } else if ("attributes".equals(value)) {
+ field = OsFieldEnum.attr_txs;
+ } else if ("relations".equals(value)) {
+ field = OsFieldEnum.rel_txs;
+ }
+
+ if (field != null) {
+ id = field.getId();
+ literal = field.getLiteral();
+ }
+ }
+ }
- DynamicObject dynamicObject = new DynamicObject(name, alias);
- dynamicObject.setLevel(level + 1);
+ DynamicObject dynamicObject = new DynamicObject(id, alias);
+ dynamicObject.setFieldName(literal);
+ dynamicObject.setLevel(level);
for (OsCollectExpression childExpr : objectExpr.getExpressions()) {
- resolveCollectExpression(childExpr, dynamicObject, level + 1);
+ resolveCollectExpression(childExpr, dynamicObject, level);
}
child = dynamicObject;
}
@@ -249,17 +278,33 @@ public class OrcsScriptInterpreterImpl implements OrcsScriptInterpreter {
}
}
- private void resolveOsField(OsField field, DynamicObject parent) {
+ private OsField findField(Set<? extends OsField> fields, String literal) {
+ OsField found = null;
+ for (OsField field : fields) {
+ if (literal.equals(field.getLiteral())) {
+ found = field;
+ break;
+ }
+ }
+ return found;
+ }
+
+ private void resolveOsField(OsField field, DynamicObject parent, int level) {
String fieldName = field.getLiteral();
if (field.hasChildren()) {
- DynamicObject child = new DynamicObject(fieldName, null);
+ int newObjectLevel = level;
+ DynamicObject child = new DynamicObject(field.getId(), null);
+ child.setFieldName(fieldName);
+
+ child.setLevel(newObjectLevel);
for (OsField childField : field.getChildren()) {
- resolveOsField(childField, child);
+ resolveOsField(childField, child, newObjectLevel);
}
parent.addChild(child);
} else {
- DynamicData child = new DynamicData(fieldName, null);
- child.setFieldName(field.getId());
+ DynamicData child = new DynamicData(field.getId(), null);
+ child.setFieldName(fieldName);
+ child.setLevel(level);
parent.addChild(child);
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/ObjectField.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/ObjectField.java
index 0b1deeb860..9ba4d38876 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/ObjectField.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/ObjectField.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.db.internal.sql;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.google.common.base.Supplier;
@@ -30,7 +31,7 @@ public enum ObjectField {
branch_state(TableEnum.BRANCH_TABLE, "branch_state"),
branch_archive_state(TableEnum.BRANCH_TABLE, "archived"),
branch_parent_id(TableEnum.BRANCH_TABLE, "parent_branch_id"),
- branch_source_tx_id(TableEnum.BRANCH_TABLE, "parent_transaction_id"),
+ branch_parent_tx_id(TableEnum.BRANCH_TABLE, "parent_transaction_id"),
branch_baseline_tx_id(TableEnum.BRANCH_TABLE, "baseline_transaction_id"),
branch_inherit_access_control(TableEnum.BRANCH_TABLE, "inherit_access_control"),
branch_associated_art_id(TableEnum.BRANCH_TABLE, "associated_art_id"),
@@ -104,6 +105,7 @@ public enum ObjectField {
private static SetMultimap<Family, ObjectField> FAMILY_TO_FIELDS;
private static SetMultimap<Family, ObjectField> FAMILY_TO_REQUIRED_FIELDS;
+ private static Map<String, ObjectField> FIELD_BY_NAME;
private final ObjectType objectType;
private final Family family;
@@ -186,7 +188,14 @@ public enum ObjectField {
}
public static ObjectField fromString(String value) {
- return ObjectField.valueOf(value);
+ if (FIELD_BY_NAME == null) {
+ Map<String, ObjectField> fieldByName = new HashMap<String, ObjectField>();
+ for (ObjectField field : ObjectField.values()) {
+ fieldByName.put(field.name(), field);
+ }
+ FIELD_BY_NAME = fieldByName;
+ }
+ return FIELD_BY_NAME.get(value);
}
private static ObjectType objectType(ObjectField value) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlFieldResolver.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlFieldResolver.java
index 6925b1fcbb..294c9c4809 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlFieldResolver.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/SqlFieldResolver.java
@@ -156,12 +156,14 @@ public final class SqlFieldResolver {
int level = object.getLevel();
Set<ObjectField> fields = new HashSet<ObjectField>();
for (DynamicData child : object.getChildren()) {
- String fieldId = child.getFieldName();
+ String fieldId = child.getGuid();
if (fieldId != null) {
ObjectField objectField = ObjectField.fromString(fieldId);
- family = objectField.getFamily();
- fields.add(objectField);
- level = child.getLevel();
+ if (objectField != null) {
+ family = objectField.getFamily();
+ fields.add(objectField);
+ level = child.getLevel();
+ }
}
}
if (family != null && !fields.isEmpty()) {
@@ -181,7 +183,7 @@ public final class SqlFieldResolver {
}
private void processField(DynamicData data, boolean hidden) {
- String fieldId = data.getFieldName();
+ String fieldId = data.getGuid();
if (fieldId != null) {
ObjectField field = getObjectField(data);
if (field == null) {
diff --git a/plugins/org.eclipse.osee.orcs.script.dsl/src/org/eclipse/osee/orcs/script/dsl/fields/OsFieldResolverImpl.java b/plugins/org.eclipse.osee.orcs.script.dsl/src/org/eclipse/osee/orcs/script/dsl/fields/OsFieldResolverImpl.java
index 9351d14cb5..35d7254a82 100644
--- a/plugins/org.eclipse.osee.orcs.script.dsl/src/org/eclipse/osee/orcs/script/dsl/fields/OsFieldResolverImpl.java
+++ b/plugins/org.eclipse.osee.orcs.script.dsl/src/org/eclipse/osee/orcs/script/dsl/fields/OsFieldResolverImpl.java
@@ -11,7 +11,9 @@
package org.eclipse.osee.orcs.script.dsl.fields;
import java.util.Collections;
+import java.util.HashMap;
import java.util.LinkedHashSet;
+import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.eclipse.emf.ecore.EObject;
@@ -98,17 +100,36 @@ public class OsFieldResolverImpl implements IFieldResolver {
Set<? extends OsField> toReturn;
OsCollectType type = getCollectType(object);
if (type != null) {
- toReturn = getAllowedFieldsByType(type);
+ toReturn = getAllowedFieldsByType(object, type);
} else {
toReturn = Collections.<OsField> emptySet();
}
return toReturn;
}
- private Set<? extends OsField> getAllowedFieldsByType(OsCollectType type) {
- Family family = getFamily(type);
+ private Set<? extends OsField> getAllowedFieldsByType(EObject object, OsCollectType type) {
Set<? extends OsField> toReturn;
- if (family != null) {
+ if (type != null) {
+ Family family = null;
+ if (OsCollectType.TXS == type) {
+ EObject container1 = object.eContainer();
+ if (container1 != null) {
+ EObject eContainer = container1.eContainer();
+ if (eContainer instanceof OsCollectObjectExpression) {
+ String containerType = ((OsCollectObjectExpression) eContainer).getName();
+ if ("artifacts".equals(containerType)) {
+ family = Family.ARTIFACT_TX;
+ } else if ("attributes".equals(containerType)) {
+ family = Family.ATTRIBUTE_TX;
+ } else if ("relations".equals(containerType)) {
+ family = Family.RELATION_TX;
+ }
+ }
+ }
+ }
+ if (family == null) {
+ family = getFamily(type);
+ }
toReturn = OsFieldEnum.getFieldsFor(family);
} else {
toReturn = Collections.<OsField> emptySet();
@@ -185,18 +206,20 @@ public class OsFieldResolverImpl implements IFieldResolver {
String collectName = container.getName();
OsCollectType type = OsCollectType.fromString(collectName);
if (type != null) {
- Set<? extends OsField> allowed = getAllowedFieldsByType(type);
+ Set<? extends OsField> allowed = getAllowedFieldsByType(object, type);
+ Map<String, OsField> fieldMap = new HashMap<String, OsField>();
+ for (OsField item : allowed) {
+ fieldMap.put(item.getLiteral(), item);
+ }
for (OsCollectExpression expression : container.getExpressions()) {
if (expression instanceof OsCollectAllFieldsExpression) {
toReturn.addAll(allowed);
- } else if (expression instanceof OsCollectObjectExpression) {
- String fieldName = ((OsCollectObjectExpression) expression).getName();
- OsField field = getField(type, fieldName);
- toReturn.add(field);
- } else if (expression instanceof OsCollectFieldExpression) {
- OsCollectFieldExpression fieldExp = (OsCollectFieldExpression) expression;
- String fieldName = fieldExp.getName();
- OsField field = getField(type, fieldName);
+ } else if (expression instanceof OsCollectObjectExpression || expression instanceof OsCollectFieldExpression) {
+ String fieldName = expression.getName();
+ OsField field = fieldMap.get(fieldName);
+ if (field == null) {
+ field = OsFieldEnum.newField(fieldName);
+ }
toReturn.add(field);
}
}
@@ -220,13 +243,4 @@ public class OsFieldResolverImpl implements IFieldResolver {
return Sets.difference(declaredFields, allowedFields);
}
- private OsField getField(OsCollectType type, String fieldName) {
- Family family = getFamily(type);
- OsField toReturn = OsFieldEnum.getField(family, fieldName);
- if (toReturn == null) {
- toReturn = OsFieldEnum.newField(fieldName);
- }
- return toReturn;
- }
-
}

Back to the top