Implementing projection
This commit is contained in:
parent
24f2ec53c1
commit
f2cf0a4f17
|
@ -247,13 +247,19 @@ public abstract class JsonQueryERElement {
|
||||||
|
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
String fieldName = iterator.next();
|
String fieldName = iterator.next();
|
||||||
if(first) {
|
JsonNode node = objectNode.get(fieldName);
|
||||||
first = false;
|
StringBuffer evBuffer = evaluateNode(node, fieldName, fieldNamePrefix);
|
||||||
}else {
|
|
||||||
|
if(!first) {
|
||||||
stringBuffer.append(queryLogicalOperator.getLogicalOperator());
|
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();
|
Iterator<JsonNode> iterator = arrayNode.iterator();
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
if(first) {
|
JsonNode node = iterator.next();
|
||||||
first = false;
|
StringBuffer evBuffer = evaluateNode(node, null, fieldNamePrefix);
|
||||||
}else {
|
|
||||||
|
if(!first) {
|
||||||
stringBuffer.append(queryLogicalOperator.getLogicalOperator());
|
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
|
@Override
|
||||||
protected StringBuffer getSpecificMatchQuery(List<JsonQueryERElement> childrenBreadcrumb)
|
protected StringBuffer getSpecificMatchQuery(List<JsonQueryERElement> childrenBreadcrumb)
|
||||||
throws SchemaException, ResourceRegistryException {
|
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();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
|
||||||
if(!entryPoint) {
|
if(!entryPoint) {
|
||||||
|
@ -149,24 +168,19 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
||||||
buffer.append("E('");
|
buffer.append("E('");
|
||||||
buffer.append(type);
|
buffer.append(type);
|
||||||
buffer.append("'");
|
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)) {
|
buffer.append(newBuffer);
|
||||||
--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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(traverseBack) {
|
if(traverseBack) {
|
||||||
buffer.append("\n\t");
|
buffer.append("\n\t");
|
||||||
|
|
Loading…
Reference in New Issue