Implementing projection
This commit is contained in:
parent
24f2ec53c1
commit
f2cf0a4f17
|
@ -247,13 +247,19 @@ public abstract class JsonQueryERElement {
|
|||
|
||||
while(iterator.hasNext()) {
|
||||
String fieldName = iterator.next();
|
||||
if(first) {
|
||||
first = false;
|
||||
}else {
|
||||
JsonNode node = objectNode.get(fieldName);
|
||||
StringBuffer evBuffer = evaluateNode(node, fieldName, fieldNamePrefix);
|
||||
|
||||
if(!first) {
|
||||
stringBuffer.append(queryLogicalOperator.getLogicalOperator());
|
||||
}
|
||||
JsonNode node = objectNode.get(fieldName);
|
||||
stringBuffer.append(evaluateNode(node, fieldName, fieldNamePrefix));
|
||||
|
||||
if(evBuffer!=null && evBuffer.length()>0) {
|
||||
if(first) {
|
||||
first = false;
|
||||
}
|
||||
stringBuffer.append(evBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,13 +268,19 @@ public abstract class JsonQueryERElement {
|
|||
Iterator<JsonNode> iterator = arrayNode.iterator();
|
||||
boolean first = true;
|
||||
while(iterator.hasNext()) {
|
||||
if(first) {
|
||||
first = false;
|
||||
}else {
|
||||
JsonNode node = iterator.next();
|
||||
StringBuffer evBuffer = evaluateNode(node, null, fieldNamePrefix);
|
||||
|
||||
if(!first) {
|
||||
stringBuffer.append(queryLogicalOperator.getLogicalOperator());
|
||||
}
|
||||
JsonNode node = iterator.next();
|
||||
stringBuffer.append(evaluateNode(node, null, fieldNamePrefix));
|
||||
|
||||
if(evBuffer!=null && evBuffer.length()>0) {
|
||||
if(first) {
|
||||
first = false;
|
||||
}
|
||||
stringBuffer.append(evBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,6 +141,25 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
|||
@Override
|
||||
protected StringBuffer getSpecificMatchQuery(List<JsonQueryERElement> childrenBreadcrumb)
|
||||
throws SchemaException, ResourceRegistryException {
|
||||
|
||||
|
||||
StringBuffer newBuffer = new StringBuffer();
|
||||
if(jsonNode.has(ConsistsOf.TARGET_PROPERTY)) {
|
||||
--size;
|
||||
JsonNode facetJsonNode = jsonNode.get(ConsistsOf.TARGET_PROPERTY);
|
||||
JsonQueryFacet jsonQueryFacet = new JsonQueryFacet(facetJsonNode);
|
||||
jsonQueryFacet.setTraverseBack(true);
|
||||
newBuffer = jsonQueryFacet.createMatchQuery(newBuffer);
|
||||
}
|
||||
|
||||
if(jsonNode.has(ConsistsOf.SOURCE_PROPERTY)) {
|
||||
--size;
|
||||
JsonNode resourceJsonNode = jsonNode.get(ConsistsOf.SOURCE_PROPERTY);
|
||||
JsonQueryResource jsonQueryResource = new JsonQueryResource(resourceJsonNode);
|
||||
jsonQueryResource.setTraverseBack(true);
|
||||
newBuffer = jsonQueryResource.createMatchQuery(newBuffer);
|
||||
}
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
if(!entryPoint) {
|
||||
|
@ -149,24 +168,19 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
|||
buffer.append("E('");
|
||||
buffer.append(type);
|
||||
buffer.append("'");
|
||||
|
||||
if(size>0) {
|
||||
alias = getAlias(true);
|
||||
buffer.append("{ where: ($matched.");
|
||||
buffer.append(alias);
|
||||
buffer.append(" == $currentMatch)");
|
||||
buffer.append(addConstraints(jsonNode, null, alias));
|
||||
buffer.append("}\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(jsonNode.has(ConsistsOf.TARGET_PROPERTY)) {
|
||||
--size;
|
||||
JsonNode facetJsonNode = jsonNode.get(ConsistsOf.TARGET_PROPERTY);
|
||||
JsonQueryFacet jsonQueryFacet = new JsonQueryFacet(facetJsonNode);
|
||||
jsonQueryFacet.setTraverseBack(true);
|
||||
buffer = jsonQueryFacet.createMatchQuery(buffer);
|
||||
}
|
||||
|
||||
if(jsonNode.has(ConsistsOf.SOURCE_PROPERTY)) {
|
||||
--size;
|
||||
JsonNode resourceJsonNode = jsonNode.get(ConsistsOf.SOURCE_PROPERTY);
|
||||
JsonQueryResource jsonQueryResource = new JsonQueryResource(resourceJsonNode);
|
||||
jsonQueryResource.setTraverseBack(true);
|
||||
buffer = jsonQueryResource.createMatchQuery(buffer);
|
||||
}
|
||||
buffer.append(newBuffer);
|
||||
|
||||
if(traverseBack) {
|
||||
buffer.append("\n\t");
|
||||
|
|
Loading…
Reference in New Issue