Commit b61bcde0 authored by Georg Fette's avatar Georg Fette
Browse files

- added subnodes in ypher query results to be able to recreate the

original data objets
parent 9877bb64
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
......@@ -528,7 +528,8 @@ public class OperatorType {
for (Expression aParam : anOp.getParameters()) {
Concept dataType = aParam.getDataType();
if (interfaceFlags.contains(InterfaceFlags.IsAggregateOp)) {
if (anOp.isContainedInReturn()) {
if (anOp.getAncestorsWithType(OperatorType.RETURN).size() > 0) {
// warum gilt das nur für Operatoren die im RETURN enthalten sind ?
if (!dataType.inheritsFrom(anOp.getModel().NUMBER)
&& !dataType.inheritsFrom(anOp.getModel().QUANTITY)
&& !dataType.inheritsFrom(anOp.getModel().DATETIME)) {
......@@ -575,7 +576,8 @@ public class OperatorType {
public List<String> getAllowedAliases(QueryOperator anOp) {
// assuming the op is an ALIAS_REF
List<String> result = new ArrayList<String>();
if (anOp.isContainedInReturn()) {
if (anOp.getAncestorsWithType(OperatorType.RETURN).size() > 0) {
// in the RETURN all aliases may be referenced
for (QueryOperator x : anOp.getRoot().getOpsRecursive()) {
if (x.alias != null) {
result.add(x.alias);
......
......@@ -32,26 +32,25 @@ public class QueryOperator extends Expression {
parameters.add(primitive);
}
public QueryOperator(QueryOperator aContainerOp, QueryOperator aParentConc, String fieldName,
Model model) {
public QueryOperator(QueryOperator aContainerOp, QueryOperator aParentConc, String fieldName, Model model) {
this(aContainerOp, aParentConc, fieldName, OperatorType.FIELD, model);
}
public QueryOperator(QueryOperator aContainerOp, QueryOperator aParentConc, String fieldName,
OperatorType opType, Model model) {
public QueryOperator(QueryOperator aContainerOp, QueryOperator aParentConc, String fieldName, OperatorType opType,
Model model) {
this(aContainerOp, opType, model);
aContainerOp.removeParameter(aParentConc);
addParameter(aParentConc);
addParameter(fieldName);
}
public QueryOperator(QueryOperator aContainerOp, QueryOperator aParentConc, String fieldName,
boolean asAlias, Model model) {
public QueryOperator(QueryOperator aContainerOp, QueryOperator aParentConc, String fieldName, boolean asAlias,
Model model) {
this(aContainerOp, aParentConc, fieldName, OperatorType.FIELD, asAlias, model);
}
public QueryOperator(QueryOperator aContainerOp, QueryOperator aParentConc, String fieldName,
OperatorType opType, boolean asAlias, Model model) {
public QueryOperator(QueryOperator aContainerOp, QueryOperator aParentConc, String fieldName, OperatorType opType,
boolean asAlias, Model model) {
this(aContainerOp, opType, model);
if (asAlias) {
QueryOperator aliasRef = new QueryOperator(OperatorType.ALIAS_REF, model);
......@@ -123,8 +122,7 @@ public class QueryOperator extends Expression {
if (myParam.isPrimitive() != hisParam.isPrimitive()) {
return false;
}
if (myParam.isPrimitive()
&& !myParam.asPrimitive().value.equals(hisParam.asPrimitive().value)) {
if (myParam.isPrimitive() && !myParam.asPrimitive().value.equals(hisParam.asPrimitive().value)) {
return false;
}
if (myParam.isOperator() && !myParam.asOperator().equalsByStructure(hisParam.asOperator())) {
......@@ -191,7 +189,7 @@ public class QueryOperator extends Expression {
result += " as " + alias;
}
if (outputName != null) {
result += " out " + outputName;
result += " out '" + outputName + "'";
}
return result;
}
......@@ -228,8 +226,7 @@ public class QueryOperator extends Expression {
if (anOp.alias != null) {
for (QueryOperator anOp2 : getRoot().getOpsRecursive()) {
if ((anOp.alias != null) && (anOp != anOp2) && anOp.alias.equals(alias)) {
addProblem(result, ProblemType.DuplicateAlias,
"alias '" + anOp.alias + "' appear multiple times");
addProblem(result, ProblemType.DuplicateAlias, "alias '" + anOp.alias + "' appear multiple times");
}
}
}
......@@ -377,8 +374,7 @@ public class QueryOperator extends Expression {
allAliasRefs.add(this);
for (QueryOperator anAliasRef : allAliasRefs) {
QueryOperator aliasParent = anAliasRef.parent;
if ((aliasParent.type == OperatorType.FIELD)
|| (aliasParent.type == OperatorType.INDEXED_FIELD)) {
if ((aliasParent.type == OperatorType.FIELD) || (aliasParent.type == OperatorType.INDEXED_FIELD)) {
String fieldName = aliasParent.getParameters().get(1).asPrimitive().value;
// if (!existingFields.contains(fieldName)) {
// there can be a multiple access on the same field without an alias,
......@@ -502,22 +498,28 @@ public class QueryOperator extends Expression {
return result;
}
public boolean isContainedInReturn() {
if (parent == null) {
return false;
public boolean hasToBeReturned() {
if (isConcept()) {
// fetch all referenciations of this concet
List<QueryOperator> aliasRefsWithAlias = getRoot().getParameters().get(1).asOperator()
.getAliasRefsWithAlias(alias);
for (QueryOperator anAliasRef : aliasRefsWithAlias) {
// check if the aliasRef is directly contained in the RETURN
if (anAliasRef.parent.type == OperatorType.RETURN) {
return true;
}
}
} else {
if (parent.type == OperatorType.RETURN) {
if (getAncestorsWithType(OperatorType.RETURN).size() > 0) {
return true;
} else {
return parent.isContainedInReturn();
}
}
return false;
}
public boolean isIterator() {
return (type == OperatorType.ITERATE) || (type == OperatorType.FIELD)
|| (type == OperatorType.COLLECT) || (type == OperatorType.FIELD_WITH_TYPE)
|| (type == OperatorType.INDEXED_FIELD);
return (type == OperatorType.ITERATE) || (type == OperatorType.FIELD) || (type == OperatorType.COLLECT)
|| (type == OperatorType.FIELD_WITH_TYPE) || (type == OperatorType.INDEXED_FIELD);
}
public String getIteratorSelector() {
......
......@@ -21,8 +21,7 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
public static String system = "Cypher";
private String[] aliasNames = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P" };
private String[] aliasNames = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P" };
private int aliasIndex;
......@@ -36,23 +35,22 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
// TODO: fill
@SuppressWarnings("unchecked")
private Set<OperatorType> infixOps = new HashSet<OperatorType>(
Arrays.asList(new OperatorType[] { OperatorType.MORE_OR_EQUAL, OperatorType.MORE,
OperatorType.LESS_OR_EQUAL, OperatorType.LESS, OperatorType.AND, OperatorType.EQUALS,
OperatorType.AFTER, OperatorType.POWER, OperatorType.ADD, OperatorType.MULTIPLY,
OperatorType.DIVIDE, OperatorType.SUBTRACT, OperatorType.MATCHES_AQL }));
private Set<OperatorType> infixOps = new HashSet<OperatorType>(Arrays.asList(new OperatorType[] {
OperatorType.MORE_OR_EQUAL, OperatorType.MORE, OperatorType.LESS_OR_EQUAL, OperatorType.LESS, OperatorType.AND,
OperatorType.EQUALS, OperatorType.AFTER, OperatorType.POWER, OperatorType.ADD, OperatorType.MULTIPLY,
OperatorType.DIVIDE, OperatorType.SUBTRACT, OperatorType.MATCHES_AQL }));
@SuppressWarnings("unchecked")
private Set<OperatorType> prefixOps = new HashSet<OperatorType>(Arrays.asList(new OperatorType[] {
OperatorType.ABS, OperatorType.ALLTRUE, OperatorType.ANYTRUE, OperatorType.AVG,
OperatorType.COUNT, OperatorType.MAX, OperatorType.MIN, OperatorType.MEDIAN,
OperatorType.CEILING, OperatorType.EXP, OperatorType.FLOOR, OperatorType.LN, OperatorType.LOG,
OperatorType.ROUND, OperatorType.TRUNCATE, OperatorType.MIN, OperatorType.MAX }));
private Set<OperatorType> prefixOps = new HashSet<OperatorType>(
Arrays.asList(new OperatorType[] { OperatorType.ABS, OperatorType.ALLTRUE, OperatorType.ANYTRUE,
OperatorType.AVG, OperatorType.COUNT, OperatorType.MAX, OperatorType.MIN, OperatorType.MEDIAN,
OperatorType.CEILING, OperatorType.EXP, OperatorType.FLOOR, OperatorType.LN, OperatorType.LOG,
OperatorType.ROUND, OperatorType.TRUNCATE, OperatorType.MIN, OperatorType.MAX }));
@SuppressWarnings("unchecked")
private Set<OperatorType> compOps = new HashSet<OperatorType>(Arrays.asList(new OperatorType[] {
OperatorType.EQUALS, OperatorType.MORE, OperatorType.MORE_OR_EQUAL, OperatorType.LESS,
OperatorType.LESS_OR_EQUAL, OperatorType.MATCHES, OperatorType.MATCHES_AQL }));
private Set<OperatorType> compOps = new HashSet<OperatorType>(
Arrays.asList(new OperatorType[] { OperatorType.EQUALS, OperatorType.MORE, OperatorType.MORE_OR_EQUAL,
OperatorType.LESS, OperatorType.LESS_OR_EQUAL, OperatorType.MATCHES, OperatorType.MATCHES_AQL }));
public Graph_2_Cypher_Mapper(Model model) {
super(model);
......@@ -130,6 +128,16 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
if (aConc.type == OperatorType.ALIAS_REF) {
QueryOperator resolveAlias = aConc.resolveAlias();
result = writeExpression(resolveAlias);
if (aConc.outputName != null) {
result += " as " + aConc.outputName;
}
if (resolveAlias.isConcept() && resolveAlias.hasToBeReturned()) {
String alias = aliases.get(resolveAlias);
String output = StringUtilsUniWue.cleanStringFromSpecialCharacters(aConc.outputName);
result += ", " + alias + "x as " + output + "x, " + alias + "p as " + output + "p, extract(r in relationships("
+ alias + "p) | type(r)) as " + output + "t, extract(n in nodes(" + alias + "p) | labels(n)) as "
+ output + "n";
}
} else if (aConc.type == OperatorType.INDEXED_FIELD) {
// the INDEXED_FIELDS are already handled in the Match via aliases
result = "";
......@@ -145,8 +153,7 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
private String writeDateTime(PrimitiveDateTime pdt) {
String result;
String yearString, monthString, dayString, hourString, minuteString, secondString,
millisecondsString;
String yearString, monthString, dayString, hourString, minuteString, secondString, millisecondsString;
yearString = pdt.year.toString();
result = yearString;
if (pdt.month != null) {
......@@ -219,6 +226,12 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
throw new RuntimeException("unexpected");
}
}
if (!((anExp.isConcept() && (anExp.asConcept().type == OperatorType.ALIAS_REF)))) {
if (anExp.outputName != null) {
String cleanedString = StringUtilsUniWue.cleanStringFromSpecialCharacters(anExp.outputName);
result += " as " + cleanedString;
}
}
return result;
}
......@@ -277,10 +290,8 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
Expression param = anOp.getParameters().get(0);
if (param.isOperator() && param.asOperator().type == OperatorType.EXISTS) {
Expression existsParam = param.asOperator().getParameters().get(0);
if (!existsParam.isOperator()
|| (existsParam.asOperator().type != OperatorType.INDEXED_FIELD)) {
throw new RuntimeException(
"unexpected. NOT EXISTS may only be used with an archetype constraint");
if (!existsParam.isOperator() || (existsParam.asOperator().type != OperatorType.INDEXED_FIELD)) {
throw new RuntimeException("unexpected. NOT EXISTS may only be used with an archetype constraint");
}
QueryOperator indexedFieldOp = existsParam.asOperator();
QueryOperator aliasRef = indexedFieldOp.getParameters().get(0).asOperator();
......@@ -288,8 +299,8 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
String relName = indexedFieldOp.getParameters().get(1).asPrimitive().value;
String targetArchetypeName = indexedFieldOp.getParameters().get(2).asPrimitive().value;
String targetTypeName = indexedFieldOp.getDataType().parent;
String result = "NOT EXISTS ((" + alias + ")-[:" + relName + "]->(:" + targetTypeName
+ "{archetype_node_id:'" + targetArchetypeName + "'}))";
String result = "NOT EXISTS ((" + alias + ")-[:" + relName + "]->(:" + targetTypeName + "{archetype_node_id:'"
+ targetArchetypeName + "'}))";
return result;
} else {
String expString = writeExpression(param);
......@@ -313,8 +324,7 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
private boolean isRelation(QueryOperator aConc, QueryOperator aPossibleRel) {
String propertyType = getPropertyType(aConc, aPossibleRel);
if (propertyType == null) {
throw new RuntimeException(
"unknown property of concept '" + aConc.getIteratorSelector() + "'");
throw new RuntimeException("unknown property of concept '" + aConc.getIteratorSelector() + "'");
}
if (propertyType.matches("^[a-z].*") || propertyType.matches("DV_TEXT")) {
return false;
......@@ -387,6 +397,9 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
String targetType = aRel.getParameters().get(1).asPrimitive().value;
String targetAlias = createAlias(aRel);
String result = "(" + sourceAlias + ")-[*]->(" + targetAlias + ":" + targetType + ")";
if (aRel.hasToBeReturned()) {
result += ", " + targetAlias + "p = (" + targetAlias + ")-[*]->(" + targetAlias + "x)";
}
return result;
}
......@@ -428,8 +441,7 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
private List<String> writeSelectIndexForRoot(QueryOperator aRoot) {
List<String> result = new ArrayList<String>();
List<QueryOperator> opsRecursiveWithType = aRoot
.getOpsRecursiveWithType(OperatorType.INDEXED_FIELD);
List<QueryOperator> opsRecursiveWithType = aRoot.getOpsRecursiveWithType(OperatorType.INDEXED_FIELD);
for (QueryOperator aSelect : opsRecursiveWithType) {
if (!isTypeRelationWithNot(aSelect)) {
String sourceAlias = aliases.get(aSelect);
......@@ -443,8 +455,7 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
private List<String> writeContainsType(QueryOperator anOp) {
List<String> result = new ArrayList<String>();
List<QueryOperator> opsRecursiveWithType = anOp
.getOpsRecursiveWithType(OperatorType.CONTAINS_TYPE);
List<QueryOperator> opsRecursiveWithType = anOp.getOpsRecursiveWithType(OperatorType.CONTAINS_TYPE);
for (QueryOperator aSelect : opsRecursiveWithType) {
if (aSelect.getParameters().size() > 2) {
String sourceAlias = aliases.get(aSelect);
......@@ -458,16 +469,13 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
private String writeReturn() {
state = CypherPart.RETURN;
String result = "\nRETURN\n\t";
boolean first = true;
List<String> returnExpStrings = new ArrayList<String>();
QueryOperator returnOp = query.getParameters().get(1).asOperator();
for (Expression anExp : returnOp.getParameters()) {
if (!first) {
result += ", ";
} else {
first = false;
}
result += writeExpression(anExp);
String expString = writeExpression(anExp);
returnExpStrings.add(expString);
}
result += StringUtilsUniWue.concat(returnExpStrings, ", ");
return result;
}
......@@ -484,6 +492,9 @@ public class Graph_2_Cypher_Mapper extends Graph_2_System_Mapper {
}
String alias = createAlias(aConc);
result += "(" + alias + ":" + aConc.getIteratorSelector() + ")";
if (aConc.hasToBeReturned()) {
result += ", " + alias + "p = (" + alias + ")-[*]->(" + alias + "x)";
}
}
for (QueryOperator aConc : rootConcepts) {
List<String> relationsStrings = writeRelations(aConc);
......
......@@ -8,6 +8,7 @@ import java.util.Set;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.RuleContext;
import org.antlr.v4.runtime.tree.ErrorNodeImpl;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.TerminalNode;
......@@ -88,13 +89,15 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
return false;
}
AqlParser aqlParser;
public QueryOperator parse(String aqlQueryString) throws QueryParseException {
clear();
query = new QueryOperator(OperatorType.QUERY, getModel());
ANTLRInputStream antlrInputStream = new ANTLRInputStream(aqlQueryString);
Lexer aqlLexer = new AqlLexer(antlrInputStream);
CommonTokenStream commonTokenStream = new CommonTokenStream(aqlLexer);
AqlParser aqlParser = new AqlParser(commonTokenStream);
aqlParser = new AqlParser(commonTokenStream);
QueryExprContext parseTree = aqlParser.query().queryExpr();
boolean containsErrors = containsErrors(parseTree);
if (containsErrors) {
......@@ -152,8 +155,7 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
}
}
private QueryOperator getOutmostClauseDefiningAllAliases(Set<String> usedAliases,
QueryOperator currentClause) {
private QueryOperator getOutmostClauseDefiningAllAliases(Set<String> usedAliases, QueryOperator currentClause) {
for (QueryOperator aChildClause : currentClause.getOperators()) {
if (usedAliases.contains(aChildClause.alias)) {
Set<String> reducedAliases = new HashSet<String>(usedAliases);
......@@ -411,11 +413,22 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
return thisOp;
}
private boolean isInSelect(RuleContext aConc) {
if (aConc instanceof SelectContext) {
return true;
} else if (aConc.parent != null) {
return isInSelect(aConc.parent);
} else {
return false;
}
}
private void visitIdentifiedPath(IdentifiedPathContext ctx) {
QueryOperator lastOp = currentOp;
String prettyPrint = prettyPrint(ctx);
TerminalNode identifier = ctx.IDENTIFIER();
String text = identifier.getText();
outString += text;
currentOp = addAliasRef(currentOp, text);
lastPathElem = currentOp;
PredicateContext predicate = ctx.predicate();
......@@ -426,6 +439,10 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
if (currentExternalAlias != null) {
lastPathElem.outputName = currentExternalAlias;
currentExternalAlias = null;
} else {
if (isInSelect(ctx)) {
currentOp.outputName = outString;
}
}
// TODO: remove unselected elements from the result
currentOp = lastOp;
......@@ -447,11 +464,9 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
if (nodePredicateOr != null) {
List<NodePredicateAndContext> nodePredicateAnds = nodePredicateOr.nodePredicateAnd();
for (NodePredicateAndContext anAndContext : nodePredicateAnds) {
List<NodePredicateComparableContext> nodePredicateComparable = anAndContext
.nodePredicateComparable();
List<NodePredicateComparableContext> nodePredicateComparable = anAndContext.nodePredicateComparable();
if (nodePredicateComparable.size() == 1) {
NodePredicateComparableContext nodePredicateComparableContext = nodePredicateComparable
.get(0);
NodePredicateComparableContext nodePredicateComparableContext = nodePredicateComparable.get(0);
String result = nodePredicateComparableContext.getText();
// don't take any expressions
if (!result.matches(".*[=<>].*")) {
......@@ -470,33 +485,37 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
String singleNodePredicateComparableName = getSingleNodePredicateComparableName(ctx);
QueryOperator fieldOp;
if (singleNodePredicateComparableName != null) {
// if (singleNodePredicateComparableName.matches("openEHR-EHR-.*")) {
// fieldOp = insertOp(OperatorType.FIELD);
// fieldOp.addParameter(text);
// QueryOperator filter = insertOp(OperatorType.FILTER);
// String newAliasName = getNewAliasName();
// fieldOp.alias = newAliasName;
// QueryOperator equals = addOp(OperatorType.EQUALS);
// QueryOperator archetypeIDField = addOp(OperatorType.FIELD);
// addAliasRef(archetypeIDField, newAliasName);
// archetypeIDField.addParameter("archetype_node_id");
// equals.addParameter(singleNodePredicateComparableName);
// lastPathElem = filter;
// } else {
// fieldOp = insertOp(OperatorType.INDEXED_FIELD);
// fieldOp.addParameter(text);
// fieldOp.addParameter(singleNodePredicateComparableName);
// }
// if (singleNodePredicateComparableName.matches("openEHR-EHR-.*")) {
// fieldOp = insertOp(OperatorType.FIELD);
// fieldOp.addParameter(text);
// QueryOperator filter = insertOp(OperatorType.FILTER);
// String newAliasName = getNewAliasName();
// fieldOp.alias = newAliasName;
// QueryOperator equals = addOp(OperatorType.EQUALS);
// QueryOperator archetypeIDField = addOp(OperatorType.FIELD);
// addAliasRef(archetypeIDField, newAliasName);
// archetypeIDField.addParameter("archetype_node_id");
// equals.addParameter(singleNodePredicateComparableName);
// lastPathElem = filter;
// } else {
// fieldOp = insertOp(OperatorType.INDEXED_FIELD);
// fieldOp.addParameter(text);
// fieldOp.addParameter(singleNodePredicateComparableName);
// }
fieldOp = insertOp(OperatorType.INDEXED_FIELD);
fieldOp.addParameter(text);
fieldOp.addParameter(singleNodePredicateComparableName);
outString += "/" + text + "[" + singleNodePredicateComparableName + "]";
} else {
fieldOp = insertOp(OperatorType.FIELD);
fieldOp.addParameter(text);
fieldOp.addParameter(text);
outString += "/" + text;
}
lastPathElem = fieldOp;
}
private String outString;
private void visitSelectExpr(SelectExprContext ctx) {
String prettyPrint = prettyPrint(ctx);
TerminalNode as = ctx.AS();
......@@ -510,6 +529,7 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
}
IdentifiedPathContext identifiedPath = ctx.identifiedPath();
if (identifiedPath != null) {
outString = "";
visitIdentifiedPath(identifiedPath);
}
SelectExprContext selectExpr = ctx.selectExpr();
......@@ -591,8 +611,7 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
}
if (or != null) {
if (and != null) {
throw new RuntimeException(
"there cannot be an OR and an AND in the same containsExpression");
throw new RuntimeException("there cannot be an OR and an AND in the same containsExpression");
}
addOp(OperatorType.OR);
throw new RuntimeException("not yet implemented");
......@@ -663,8 +682,7 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
currentOp = lastOp;
} else {
QueryOperator existsOp = addOp(OperatorType.EXISTS);
newConcept = new QueryOperator(existsOp, lastPathElem, text1, OperatorType.CONTAINS_TYPE,
true, getModel());
newConcept = new QueryOperator(existsOp, lastPathElem, text1, OperatorType.CONTAINS_TYPE, true, getModel());
currentOp = existsOp;
}
if (identifier.size() > 1) {
......@@ -684,8 +702,8 @@ public class AQL_2_Graph_Mapper extends System_2_Graph_Mapper {
String text3 = archetypeid.getText();
String newElemName = text1;
QueryOperator existsOp = addOp(OperatorType.EXISTS);
QueryOperator newConcept = new QueryOperator(existsOp, lastPathElem, text1,
OperatorType.CONTAINS_TYPE, true, getModel());
QueryOperator newConcept = new QueryOperator(existsOp, lastPathElem, text1, OperatorType.CONTAINS_TYPE, true,
getModel());
if (text3 != null) {
newConcept.addParameter(text3);
}
......
......@@ -27,7 +27,7 @@ public class Test_AQL_2_Cypher {
initialize();
QueryManager queryManager = new QueryManager();
for (MultiQuery aMultiQuery : queryManager.queries) {
if (aMultiQuery.name.equals("query_AQL_2_Cypher_not1")) {
if (aMultiQuery.name.equals("query_AQL_2_Cypher_2Attrs_ReturnAttrs")) {
processQuery(aMultiQuery);
}
}
......
......@@ -30,15 +30,15 @@ QUERY(
)
)
),
RETURN(ALIAS_REF('e'))
RETURN(ALIAS_REF('e') out 'e')
)
*Cypher
MATCH
(A:EHR), (A)-[*]->(B:CLUSTER), (B)-[:items]->(C:ELEMENT)
(A:EHR), Ap = (A)-[*]->(Ax), (A)-[*]->(B:CLUSTER), (B)-[:items]->(C:ELEMENT)
WHERE
C.value.value = 'Natrium_g_dl' AND
C.archetype_node_id = 'at0024' AND
B.archetype_node_id = 'openEHR-EHR-CLUSTER.laboratory_test_analyte_dvquantity.v1'
RETURN
A
A as e, Ax as ex, Ap as ep, extract(r in relationships(Ap) | type(r)) as et, extract(n in nodes(Ap) | labels(n)) as en
......@@ -21,14 +21,14 @@ QUERY(
) as b)
)
),
RETURN(ALIAS_REF('e'))
RETURN(ALIAS_REF('e') out 'e')
)
*Cypher
MATCH
(A:EHR), (A)-[*]->(B:OBSERVATION), (A)-[*]->(C:OBSERVATION)
WHERE
B.archetype_node_id = 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1' AND
C.archetype_node_id = 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1'
MATCH
(A:EHR), Ap = (A)-[*]->(Ax), (A)-[*]->(B:OBSERVATION), (A)-[*]->(C:OBSERVATION)
WHERE
B.archetype_node_id = 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1' AND
C.archetype_node_id = 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1'
RETURN
A
A as e, Ax as ex, Ap as ep, extract(r in relationships(Ap) | type(r)) as et, extract(n in nodes(Ap) | labels(n)) as en
\ No newline at end of file
......@@ -29,7 +29,7 @@ QUERY(
'at0024'
),
'value'
),
) out 'a/items[at0024]/value',
FIELD(
INDEXED_FIELD(
ALIAS_REF('b'),
......@@ -37,7 +37,7 @@ QUERY(
'at0024'
),
'value'
)
) out 'b/items[at0024]/value'
)
)
......@@ -50,4 +50,4 @@ WHERE
D.archetype_node_id = 'at0024' AND
E.archetype_node_id = 'at0024'
RETURN