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

ongoing work...

parent dc683beb
......@@ -72,16 +72,12 @@ public class Graph_2_AQL_Mapper extends Graph_2_System_Mapper {
}
}
private QueryOperator getRoot() {
return root.getRootConcepts().get(0);
}
private String getPath(QueryOperator aConcept) {
String result;
if (aConcept.parent != null) {
result = getPath(aConcept.parent) + "/" + aConcept.getCode();
if (aConcept.type == OperatorType.ALIAS_REF) {
result = aConcept.getParameters().get(0).asPrimitive().value;
} else {
result = aConcept.getCode();
result = getPath(aConcept.parent) + "/" + aConcept.getParameters().get(0).asPrimitive().value;
}
return result;
}
......@@ -116,26 +112,27 @@ public class Graph_2_AQL_Mapper extends Graph_2_System_Mapper {
}
private String getSelect() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("SELECT ");
String result = "";
result += "SELECT ";
boolean first = true;
List<QueryOperator> concepts = root.getConceptsRecursive();
// assuming the root clause is a return
for (Expression anExp : root.getParameters()) {
QueryOperator aClause = (QueryOperator) anExp;
for (QueryOperator aConcept : aClause.getChildConcepts()) {
String path = getPath(aConcept);
QueryOperator returnOp = root.getParameters().get(1).asOperator();
for (Expression anExp : returnOp.getParameters()) {
if (anExp.isOperator()) {
QueryOperator anOp = anExp.asOperator();
String path = getPath(anOp);
if (!first) {
stringBuilder.append(", ");
result += ", ";
}
first = false;
stringBuilder.append(path);
if (aConcept.outputName != null) {
stringBuilder.append(" AS " + aConcept.outputName);
result += path;
if (anOp.outputName != null) {
result += " AS " + anOp.outputName;
}
} else {
throw new RuntimeException("not yet implemented");
}
}
return stringBuilder.toString();
return result;
}
private int countOfContainedArchetypedConcepts(QueryOperator aConcept) {
......@@ -149,11 +146,11 @@ public class Graph_2_AQL_Mapper extends Graph_2_System_Mapper {
}
private String getFrom() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("FROM ");
String nestedFrom = getFromNested(getRoot());
stringBuilder.append(nestedFrom);
return stringBuilder.toString();
String result = "FROM ";
QueryOperator rootFilter = root.getParameters().get(0).asOperator();
String nestedFrom = getFromNested(rootFilter);
result += nestedFrom;
return result;
}
private String getFromNested(QueryOperator aConcept) {
......@@ -396,9 +393,10 @@ public class Graph_2_AQL_Mapper extends Graph_2_System_Mapper {
public String visit(QueryOperator aQuery) {
initialize(aQuery);
String result = getFrom();
result = getSelect() + "\n" + result;
result += "\n" + getWhere();
String selectString = getSelect();
String fromString = getFrom();
String whereString = getWhere();
String result = selectString + "\n" + fromString + "\n" + whereString;
result = result.trim().replaceAll("\r\n", "\n");
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment