Added methods to create match query
This commit is contained in:
parent
816c7693dc
commit
46cb4f0975
|
@ -100,7 +100,7 @@ public class JsonQuery {
|
||||||
public StringBuffer createQuery() throws SchemaException, InvalidQueryException, ResourceRegistryException {
|
public StringBuffer createQuery() throws SchemaException, InvalidQueryException, ResourceRegistryException {
|
||||||
entryPoint = getJsonQueryERElement(jsonQuery);
|
entryPoint = getJsonQueryERElement(jsonQuery);
|
||||||
entryPoint.setEntryPoint(true);
|
entryPoint.setEntryPoint(true);
|
||||||
return entryPoint.analize(new StringBuffer());
|
return entryPoint.createQuery(new StringBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String query() throws InvalidQueryException, ResourceRegistryException {
|
public String query() throws InvalidQueryException, ResourceRegistryException {
|
||||||
|
|
|
@ -99,8 +99,13 @@ public abstract class JsonQueryERElement {
|
||||||
this.traverseBack = traverseBack;
|
this.traverseBack = traverseBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract StringBuffer analize(StringBuffer stringBuffer) throws SchemaNotFoundException, InvalidQueryException, SchemaException, ResourceRegistryException;
|
public StringBuffer createQuery(StringBuffer stringBuffer) throws SchemaNotFoundException, InvalidQueryException, SchemaException, ResourceRegistryException {
|
||||||
|
return createTraversalQuery(stringBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract StringBuffer createTraversalQuery(StringBuffer stringBuffer) throws SchemaNotFoundException, InvalidQueryException, SchemaException, ResourceRegistryException;
|
||||||
|
|
||||||
|
protected abstract StringBuffer createMatchQuery(StringBuffer stringBuffer) throws SchemaNotFoundException, InvalidQueryException, SchemaException, ResourceRegistryException;
|
||||||
|
|
||||||
protected StringBuffer addConstraints(JsonNode jsonNode, LogicalOperator queryLogicalOperator, String fieldNamePrefix) throws InvalidQueryException {
|
protected StringBuffer addConstraints(JsonNode jsonNode, LogicalOperator queryLogicalOperator, String fieldNamePrefix) throws InvalidQueryException {
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
StringBuffer stringBuffer = new StringBuffer();
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class JsonQueryFacet extends JsonQueryEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
public StringBuffer createTraversalQuery(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
StringBuffer newBuffer = new StringBuffer();
|
StringBuffer newBuffer = new StringBuffer();
|
||||||
|
|
||||||
int size = jsonNode.size();
|
int size = jsonNode.size();
|
||||||
|
@ -36,7 +36,7 @@ public class JsonQueryFacet extends JsonQueryEntity {
|
||||||
JsonQueryConsistsOf jsonQueryConsistsOf = new JsonQueryConsistsOf(consistsOfNode);
|
JsonQueryConsistsOf jsonQueryConsistsOf = new JsonQueryConsistsOf(consistsOfNode);
|
||||||
jsonQueryConsistsOf.setTraverseBack(traverseBackLocal);
|
jsonQueryConsistsOf.setTraverseBack(traverseBackLocal);
|
||||||
jsonQueryConsistsOf.setDirection(Direction.OUT);
|
jsonQueryConsistsOf.setDirection(Direction.OUT);
|
||||||
stringBuffer = jsonQueryConsistsOf.analize(stringBuffer);
|
stringBuffer = jsonQueryConsistsOf.createTraversalQuery(stringBuffer);
|
||||||
traverseBackLocal = true;
|
traverseBackLocal = true;
|
||||||
|
|
||||||
/* Need to substract 1 from size otherwise
|
/* Need to substract 1 from size otherwise
|
||||||
|
@ -88,5 +88,9 @@ public class JsonQueryFacet extends JsonQueryEntity {
|
||||||
return newBuffer;
|
return newBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StringBuffer createMatchQuery(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class JsonQueryResource extends JsonQueryEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
public StringBuffer createTraversalQuery(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
|
|
||||||
boolean wrapInnerQuery = false;
|
boolean wrapInnerQuery = false;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class JsonQueryResource extends JsonQueryEntity {
|
||||||
jsonQueryIsRelatedTo.setRequestedResourceType(type);
|
jsonQueryIsRelatedTo.setRequestedResourceType(type);
|
||||||
jsonQueryIsRelatedTo.setDirectionByJson();
|
jsonQueryIsRelatedTo.setDirectionByJson();
|
||||||
jsonQueryIsRelatedTo.setTraverseBack( (!(!traverseBack) && i==0) );
|
jsonQueryIsRelatedTo.setTraverseBack( (!(!traverseBack) && i==0) );
|
||||||
stringBuffer = jsonQueryIsRelatedTo.analize(stringBuffer);
|
stringBuffer = jsonQueryIsRelatedTo.createTraversalQuery(stringBuffer);
|
||||||
}
|
}
|
||||||
wrapInnerQuery = true;
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public class JsonQueryResource extends JsonQueryEntity {
|
||||||
jsonQueryConsistsOf.setRequestedResourceType(type);
|
jsonQueryConsistsOf.setRequestedResourceType(type);
|
||||||
jsonQueryConsistsOf.setDirection(Direction.IN);
|
jsonQueryConsistsOf.setDirection(Direction.IN);
|
||||||
jsonQueryConsistsOf.setTraverseBack(!((!traverseBack) && !wrapInnerQuery && i==0));
|
jsonQueryConsistsOf.setTraverseBack(!((!traverseBack) && !wrapInnerQuery && i==0));
|
||||||
stringBuffer = jsonQueryConsistsOf.analize(stringBuffer);
|
stringBuffer = jsonQueryConsistsOf.createTraversalQuery(stringBuffer);
|
||||||
}
|
}
|
||||||
wrapInnerQuery = true; // Must be set after the cycle and not before
|
wrapInnerQuery = true; // Must be set after the cycle and not before
|
||||||
}
|
}
|
||||||
|
@ -114,4 +114,9 @@ public class JsonQueryResource extends JsonQueryEntity {
|
||||||
return stringBuffer;
|
return stringBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StringBuffer createMatchQuery(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
public StringBuffer createTraversalQuery(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
|
|
||||||
boolean wrapInnerQuery = false;
|
boolean wrapInnerQuery = false;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
||||||
JsonNode facetJsonNode = jsonNode.get(ConsistsOf.TARGET_PROPERTY);
|
JsonNode facetJsonNode = jsonNode.get(ConsistsOf.TARGET_PROPERTY);
|
||||||
JsonQueryFacet jsonQueryFacet = new JsonQueryFacet(facetJsonNode);
|
JsonQueryFacet jsonQueryFacet = new JsonQueryFacet(facetJsonNode);
|
||||||
jsonQueryFacet.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
jsonQueryFacet.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
||||||
stringBuffer = jsonQueryFacet.analize(stringBuffer);
|
stringBuffer = jsonQueryFacet.createTraversalQuery(stringBuffer);
|
||||||
wrapInnerQuery = true;
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
||||||
JsonNode resourceJsonNode = jsonNode.get(ConsistsOf.SOURCE_PROPERTY);
|
JsonNode resourceJsonNode = jsonNode.get(ConsistsOf.SOURCE_PROPERTY);
|
||||||
JsonQueryResource jsonQueryResource = new JsonQueryResource(resourceJsonNode);
|
JsonQueryResource jsonQueryResource = new JsonQueryResource(resourceJsonNode);
|
||||||
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
||||||
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
stringBuffer = jsonQueryResource.createTraversalQuery(stringBuffer);
|
||||||
wrapInnerQuery = true;
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,8 +132,12 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
||||||
stringBuffer = traverseBackToCallerResource(stringBuffer);
|
stringBuffer = traverseBackToCallerResource(stringBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return stringBuffer;
|
return stringBuffer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StringBuffer createMatchQuery(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
public StringBuffer createTraversalQuery(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
|
|
||||||
if(!entryPoint && direction==null) {
|
if(!entryPoint && direction==null) {
|
||||||
throw new InternalServerErrorException("Caller Resource must invoke setDirectionByJson() first. This is a server bug. Please contact the administator. ");
|
throw new InternalServerErrorException("Caller Resource must invoke setDirectionByJson() first. This is a server bug. Please contact the administator. ");
|
||||||
|
@ -143,7 +143,7 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
|
||||||
wrapDirection = Direction.OUT;
|
wrapDirection = Direction.OUT;
|
||||||
jsonQueryResource.setDirection(Direction.OUT);
|
jsonQueryResource.setDirection(Direction.OUT);
|
||||||
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
||||||
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
stringBuffer = jsonQueryResource.createTraversalQuery(stringBuffer);
|
||||||
wrapInnerQuery = true;
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
|
||||||
wrapDirection = Direction.IN;
|
wrapDirection = Direction.IN;
|
||||||
jsonQueryResource.setDirection(Direction.IN);
|
jsonQueryResource.setDirection(Direction.IN);
|
||||||
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
||||||
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
stringBuffer = jsonQueryResource.createTraversalQuery(stringBuffer);
|
||||||
wrapInnerQuery = true;
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,11 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringBuffer;
|
return stringBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StringBuffer createMatchQuery(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue