Full refactor of JsonQuery management
This commit is contained in:
parent
b978185cd5
commit
7ce298be17
|
@ -100,7 +100,6 @@ 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);
|
||||||
entryPoint.setNoTraversal(true);
|
|
||||||
return entryPoint.analize(new StringBuffer());
|
return entryPoint.analize(new StringBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,12 @@ import org.gcube.informationsystem.resourceregistry.queries.operators.Conditiona
|
||||||
import org.gcube.informationsystem.resourceregistry.queries.operators.LogicalOperator;
|
import org.gcube.informationsystem.resourceregistry.queries.operators.LogicalOperator;
|
||||||
import org.gcube.informationsystem.resourceregistry.types.TypesCache;
|
import org.gcube.informationsystem.resourceregistry.types.TypesCache;
|
||||||
import org.gcube.informationsystem.utils.TypeUtility;
|
import org.gcube.informationsystem.utils.TypeUtility;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public abstract class JsonQueryERElement {
|
public abstract class JsonQueryERElement {
|
||||||
|
|
||||||
// private Logger logger = LoggerFactory.getLogger(this.getClass());
|
protected Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
public static void validateType(String type, AccessType requiredAccessType) throws SchemaException, ResourceRegistryException {
|
public static void validateType(String type, AccessType requiredAccessType) throws SchemaException, ResourceRegistryException {
|
||||||
AccessType accessType = TypesCache.getInstance().getCachedType(type).getAccessType();
|
AccessType accessType = TypesCache.getInstance().getCachedType(type).getAccessType();
|
||||||
|
@ -42,15 +44,23 @@ public abstract class JsonQueryERElement {
|
||||||
protected Direction direction;
|
protected Direction direction;
|
||||||
protected boolean entryPoint;
|
protected boolean entryPoint;
|
||||||
|
|
||||||
protected boolean noTraversal;
|
/**
|
||||||
|
* it indicates the number of properties in this.jsonNode
|
||||||
|
* This number is manipulated while analyzing the jsonNode
|
||||||
|
* to properly create the query.
|
||||||
|
*/
|
||||||
|
protected int size;
|
||||||
|
|
||||||
|
protected boolean traverseBack;
|
||||||
|
|
||||||
public JsonQueryERElement(JsonNode jsonQuery, AccessType accessType) throws SchemaException, ResourceRegistryException {
|
public JsonQueryERElement(JsonNode jsonQuery, AccessType accessType) throws SchemaException, ResourceRegistryException {
|
||||||
this.objectMapper = new ObjectMapper();
|
this.objectMapper = new ObjectMapper();
|
||||||
this.type = TypeUtility.getTypeName(jsonQuery);
|
this.type = TypeUtility.getTypeName(jsonQuery);
|
||||||
this.jsonNode = jsonQuery;
|
this.jsonNode = jsonQuery;
|
||||||
|
this.size = jsonNode.size();
|
||||||
this.accessType = accessType;
|
this.accessType = accessType;
|
||||||
this.entryPoint = false;
|
this.entryPoint = false;
|
||||||
this.noTraversal = false;
|
this.traverseBack = true;
|
||||||
|
|
||||||
this.fieldNamesToRemove = new HashSet<>();
|
this.fieldNamesToRemove = new HashSet<>();
|
||||||
this.fieldNamesToRemove.add(Element.TYPE_PROPERTY);
|
this.fieldNamesToRemove.add(Element.TYPE_PROPERTY);
|
||||||
|
@ -78,14 +88,15 @@ public abstract class JsonQueryERElement {
|
||||||
|
|
||||||
public void setEntryPoint(boolean entryPoint) {
|
public void setEntryPoint(boolean entryPoint) {
|
||||||
this.entryPoint = entryPoint;
|
this.entryPoint = entryPoint;
|
||||||
|
this.traverseBack = !entryPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNoTraversal() {
|
public boolean isTraverseBack() {
|
||||||
return noTraversal;
|
return traverseBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNoTraversal(boolean noTraversal) {
|
public void setTraverseBack(boolean traverseBack) {
|
||||||
this.noTraversal = noTraversal;
|
this.traverseBack = traverseBack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract StringBuffer analize(StringBuffer stringBuffer) throws SchemaNotFoundException, InvalidQueryException, SchemaException, ResourceRegistryException;
|
public abstract StringBuffer analize(StringBuffer stringBuffer) throws SchemaNotFoundException, InvalidQueryException, SchemaException, ResourceRegistryException;
|
||||||
|
|
|
@ -27,17 +27,17 @@ public class JsonQueryFacet extends JsonQueryEntity {
|
||||||
|
|
||||||
int size = jsonNode.size();
|
int size = jsonNode.size();
|
||||||
|
|
||||||
boolean noTraversalLocal = noTraversal;
|
boolean traverseBackLocal = traverseBack;
|
||||||
if(jsonNode.has(_SOURCE)) {
|
if(jsonNode.has(_SOURCE)) {
|
||||||
if(!entryPoint) {
|
if(!entryPoint) {
|
||||||
throw new InvalidQueryException(_SOURCE + " property cannot be used in a facet if it is not the entry object");
|
throw new InvalidQueryException(_SOURCE + " property cannot be used in a facet if it is not the entry object");
|
||||||
}
|
}
|
||||||
JsonNode consistsOfNode = jsonNode.get(_SOURCE);
|
JsonNode consistsOfNode = jsonNode.get(_SOURCE);
|
||||||
JsonQueryConsistsOf jsonQueryConsistsOf = new JsonQueryConsistsOf(consistsOfNode);
|
JsonQueryConsistsOf jsonQueryConsistsOf = new JsonQueryConsistsOf(consistsOfNode);
|
||||||
jsonQueryConsistsOf.setNoTraversal(noTraversal);
|
jsonQueryConsistsOf.setTraverseBack(traverseBackLocal);
|
||||||
jsonQueryConsistsOf.setDirection(Direction.OUT);
|
jsonQueryConsistsOf.setDirection(Direction.OUT);
|
||||||
stringBuffer = jsonQueryConsistsOf.analize(stringBuffer);
|
stringBuffer = jsonQueryConsistsOf.analize(stringBuffer);
|
||||||
noTraversalLocal = false;
|
traverseBackLocal = true;
|
||||||
|
|
||||||
/* Need to substract 1 from size otherwise
|
/* Need to substract 1 from size otherwise
|
||||||
* it add WHERE at the end because _in
|
* it add WHERE at the end because _in
|
||||||
|
@ -48,14 +48,14 @@ public class JsonQueryFacet extends JsonQueryEntity {
|
||||||
|
|
||||||
newBuffer.append("SELECT FROM ");
|
newBuffer.append("SELECT FROM ");
|
||||||
|
|
||||||
if(!noTraversalLocal) {
|
if(traverseBackLocal) {
|
||||||
newBuffer.append("( ");
|
newBuffer.append("( ");
|
||||||
newBuffer.append("TRAVERSE inV(\"");
|
newBuffer.append("TRAVERSE inV(\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
newBuffer.append(type);
|
newBuffer.append(type);
|
||||||
|
|
||||||
if(!noTraversalLocal) {
|
if(traverseBackLocal) {
|
||||||
newBuffer.append("\") FROM ( ");
|
newBuffer.append("\") FROM ( ");
|
||||||
newBuffer.append(stringBuffer);
|
newBuffer.append(stringBuffer);
|
||||||
newBuffer.append(")");
|
newBuffer.append(")");
|
||||||
|
|
|
@ -18,42 +18,74 @@ public class JsonQueryResource extends JsonQueryEntity {
|
||||||
|
|
||||||
public JsonQueryResource(JsonNode jsonQuery) throws SchemaException, ResourceRegistryException {
|
public JsonQueryResource(JsonNode jsonQuery) throws SchemaException, ResourceRegistryException {
|
||||||
super(jsonQuery, AccessType.RESOURCE);
|
super(jsonQuery, AccessType.RESOURCE);
|
||||||
fieldNamesToRemove.add(Resource.CONSISTS_OF_PROPERTY);
|
this.fieldNamesToRemove.add(Resource.CONSISTS_OF_PROPERTY);
|
||||||
fieldNamesToRemove.add(Resource.IS_RELATED_TO_PROPERTY);
|
this.fieldNamesToRemove.add(Resource.IS_RELATED_TO_PROPERTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBuffer createSelect(StringBuffer stringBuffer, boolean wrapInnerQuery) throws SchemaException, ResourceRegistryException {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("SELECT FROM ");
|
||||||
|
|
||||||
|
if(wrapInnerQuery) {
|
||||||
|
buffer.append("( ");
|
||||||
|
buffer.append(stringBuffer);
|
||||||
|
buffer.append(")");
|
||||||
|
}else {
|
||||||
|
buffer.append(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entryPoint || size>1) {
|
||||||
|
buffer.append(" WHERE ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size > 1) {
|
||||||
|
buffer.append(addConstraints(jsonNode, null, null));
|
||||||
|
if(entryPoint) {
|
||||||
|
buffer.append(" AND ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entryPoint) {
|
||||||
|
buffer.append(OrientDBUtility.ORIENTDB_CLASS_PROPERTY);
|
||||||
|
buffer.append(" INSTANCEOF \"");
|
||||||
|
buffer.append(type);
|
||||||
|
buffer.append("\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
boolean initFound = false;
|
|
||||||
|
|
||||||
int size = jsonNode.size();
|
boolean wrapInnerQuery = false;
|
||||||
|
|
||||||
if(!noTraversal) {
|
if(traverseBack) {
|
||||||
StringBuffer newBuffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
newBuffer.append("TRAVERSE ");
|
buffer.append("TRAVERSE ");
|
||||||
newBuffer.append(direction.name().toLowerCase());
|
buffer.append(direction.name().toLowerCase());
|
||||||
newBuffer.append("V(\"");
|
buffer.append("V(\"");
|
||||||
newBuffer.append(type);
|
buffer.append(type);
|
||||||
newBuffer.append("\") FROM ( ");
|
buffer.append("\") FROM ( ");
|
||||||
newBuffer.append(stringBuffer);
|
buffer.append(stringBuffer);
|
||||||
newBuffer.append(")");
|
buffer.append(")");
|
||||||
stringBuffer = newBuffer;
|
stringBuffer = buffer;
|
||||||
|
|
||||||
initFound = true;
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayNode isRelatedToArray = (ArrayNode) jsonNode.get(Resource.IS_RELATED_TO_PROPERTY);
|
ArrayNode isRelatedToArray = (ArrayNode) jsonNode.get(Resource.IS_RELATED_TO_PROPERTY);
|
||||||
if(isRelatedToArray!=null && isRelatedToArray.size()>0) {
|
if(isRelatedToArray!=null && isRelatedToArray.size()>0) {
|
||||||
--size;
|
--size;
|
||||||
initFound = true;
|
|
||||||
for(int i=0; i<isRelatedToArray.size(); i++) {
|
for(int i=0; i<isRelatedToArray.size(); i++) {
|
||||||
JsonNode isRelatedToJsonNode = isRelatedToArray.get(i);
|
JsonNode isRelatedToJsonNode = isRelatedToArray.get(i);
|
||||||
JsonQueryIsRelatedTo jsonQueryIsRelatedTo = new JsonQueryIsRelatedTo(isRelatedToJsonNode);
|
JsonQueryIsRelatedTo jsonQueryIsRelatedTo = new JsonQueryIsRelatedTo(isRelatedToJsonNode);
|
||||||
jsonQueryIsRelatedTo.setRequestedResourceType(type);
|
jsonQueryIsRelatedTo.setRequestedResourceType(type);
|
||||||
jsonQueryIsRelatedTo.setNoTraversal(noTraversal && i==0);
|
jsonQueryIsRelatedTo.setDirectionByJson();
|
||||||
|
jsonQueryIsRelatedTo.setTraverseBack( (!(!traverseBack) && i==0) );
|
||||||
stringBuffer = jsonQueryIsRelatedTo.analize(stringBuffer);
|
stringBuffer = jsonQueryIsRelatedTo.analize(stringBuffer);
|
||||||
}
|
}
|
||||||
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayNode consistsOfArray = (ArrayNode) jsonNode.get(Resource.CONSISTS_OF_PROPERTY);
|
ArrayNode consistsOfArray = (ArrayNode) jsonNode.get(Resource.CONSISTS_OF_PROPERTY);
|
||||||
|
@ -64,49 +96,20 @@ public class JsonQueryResource extends JsonQueryEntity {
|
||||||
JsonQueryConsistsOf jsonQueryConsistsOf = new JsonQueryConsistsOf(consistsOfJsonNode);
|
JsonQueryConsistsOf jsonQueryConsistsOf = new JsonQueryConsistsOf(consistsOfJsonNode);
|
||||||
jsonQueryConsistsOf.setRequestedResourceType(type);
|
jsonQueryConsistsOf.setRequestedResourceType(type);
|
||||||
jsonQueryConsistsOf.setDirection(Direction.IN);
|
jsonQueryConsistsOf.setDirection(Direction.IN);
|
||||||
jsonQueryConsistsOf.setNoTraversal(noTraversal && !initFound && i==0);
|
jsonQueryConsistsOf.setTraverseBack(!((!traverseBack) && !wrapInnerQuery && i==0));
|
||||||
stringBuffer = jsonQueryConsistsOf.analize(stringBuffer);
|
stringBuffer = jsonQueryConsistsOf.analize(stringBuffer);
|
||||||
}
|
}
|
||||||
initFound = true; // Must be set after the cycle and not before
|
wrapInnerQuery = true; // Must be set after the cycle and not before
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuffer newBuffer = new StringBuffer();
|
// The Resource has no other referenced ER inside
|
||||||
if(entryPoint || ((initFound && size >1) || !initFound)) {
|
if(!wrapInnerQuery) {
|
||||||
newBuffer.append("SELECT FROM ");
|
return createSelect(stringBuffer, wrapInnerQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(initFound) {
|
if(entryPoint || size>1) {
|
||||||
if(size > 1 || entryPoint){
|
return createSelect(stringBuffer, wrapInnerQuery);
|
||||||
newBuffer.append("( ");
|
|
||||||
}
|
}
|
||||||
newBuffer.append(stringBuffer);
|
|
||||||
|
|
||||||
if(size > 1 || entryPoint){
|
|
||||||
newBuffer.append(")");
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
newBuffer.append(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(size > 1 || entryPoint ) {
|
|
||||||
newBuffer.append(" WHERE ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(size > 1) {
|
|
||||||
newBuffer.append(addConstraints(jsonNode, null, null));
|
|
||||||
if(entryPoint) {
|
|
||||||
newBuffer.append(" AND ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entryPoint) {
|
|
||||||
newBuffer.append(OrientDBUtility.ORIENTDB_CLASS_PROPERTY);
|
|
||||||
newBuffer.append(" INSTANCEOF \"");
|
|
||||||
newBuffer.append(type);
|
|
||||||
newBuffer.append("\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
stringBuffer = newBuffer;
|
|
||||||
|
|
||||||
return stringBuffer;
|
return stringBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||||
import org.gcube.informationsystem.resourceregistry.queries.json.base.entities.JsonQueryFacet;
|
import org.gcube.informationsystem.resourceregistry.queries.json.base.entities.JsonQueryFacet;
|
||||||
import org.gcube.informationsystem.resourceregistry.queries.json.base.entities.JsonQueryResource;
|
import org.gcube.informationsystem.resourceregistry.queries.json.base.entities.JsonQueryResource;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
@ -29,30 +30,58 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
||||||
this.requestedResourceType = requestedResourceType;
|
this.requestedResourceType = requestedResourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected StringBuffer traverseBackToCallerResource(StringBuffer stringBuffer) {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("TRAVERSE ");
|
||||||
|
buffer.append(direction.opposite().name().toLowerCase());
|
||||||
|
buffer.append("V(\"");
|
||||||
|
buffer.append(requestedResourceType);
|
||||||
|
buffer.append("\") FROM ( "); // Open (
|
||||||
|
buffer.append(stringBuffer);
|
||||||
|
buffer.append(")"); // Close )
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StringBuffer createSelect(StringBuffer stringBuffer, boolean wrapInnerQuery) throws SchemaException, ResourceRegistryException {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("SELECT FROM ");
|
||||||
|
|
||||||
|
if(wrapInnerQuery) {
|
||||||
|
buffer.append("( ");
|
||||||
|
buffer.append(stringBuffer);
|
||||||
|
buffer.append(")");
|
||||||
|
}else {
|
||||||
|
buffer.append(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entryPoint || size>1) {
|
||||||
|
buffer.append(" WHERE ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size > 1) {
|
||||||
|
buffer.append(addConstraints(jsonNode, null, null));
|
||||||
|
if(entryPoint) {
|
||||||
|
buffer.append(" AND ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entryPoint) {
|
||||||
|
buffer.append(OrientDBUtility.ORIENTDB_CLASS_PROPERTY);
|
||||||
|
buffer.append(" INSTANCEOF \"");
|
||||||
|
buffer.append(type);
|
||||||
|
buffer.append("\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
StringBuffer consistsOfBuffer = new StringBuffer();
|
|
||||||
|
|
||||||
if(!jsonNode.has(ConsistsOf.SOURCE_PROPERTY)) {
|
boolean wrapInnerQuery = false;
|
||||||
consistsOfBuffer.append("TRAVERSE ");
|
|
||||||
consistsOfBuffer.append(direction.opposite().name().toLowerCase());
|
|
||||||
consistsOfBuffer.append("V(\"");
|
|
||||||
consistsOfBuffer.append(requestedResourceType);
|
|
||||||
consistsOfBuffer.append("\") FROM ( "); // Open ( 1
|
|
||||||
}
|
|
||||||
|
|
||||||
int size = jsonNode.size();
|
if(traverseBack) {
|
||||||
if(size > 2) {
|
|
||||||
consistsOfBuffer.append("SELECT FROM ( "); // Open ( SELECT
|
|
||||||
}
|
|
||||||
|
|
||||||
consistsOfBuffer.append("TRAVERSE ");
|
|
||||||
consistsOfBuffer.append(direction.name().toLowerCase());
|
|
||||||
consistsOfBuffer.append("E(\"");
|
|
||||||
consistsOfBuffer.append(type);
|
|
||||||
consistsOfBuffer.append("\") FROM ( "); // Open ( 2
|
|
||||||
|
|
||||||
if(!noTraversal) {
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append("TRAVERSE ");
|
buffer.append("TRAVERSE ");
|
||||||
buffer.append(direction.opposite().name().toLowerCase());
|
buffer.append(direction.opposite().name().toLowerCase());
|
||||||
|
@ -62,34 +91,49 @@ public class JsonQueryConsistsOf extends JsonQueryRelation {
|
||||||
buffer.append(stringBuffer);
|
buffer.append(stringBuffer);
|
||||||
buffer.append(")");
|
buffer.append(")");
|
||||||
stringBuffer = buffer;
|
stringBuffer = buffer;
|
||||||
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(jsonNode.has(ConsistsOf.TARGET_PROPERTY)) {
|
if(jsonNode.has(ConsistsOf.TARGET_PROPERTY)) {
|
||||||
|
--size;
|
||||||
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.setNoTraversal(noTraversal);
|
jsonQueryFacet.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
||||||
stringBuffer = jsonQueryFacet.analize(stringBuffer);
|
stringBuffer = jsonQueryFacet.analize(stringBuffer);
|
||||||
} else if(jsonNode.has(ConsistsOf.SOURCE_PROPERTY)) {
|
wrapInnerQuery = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(jsonNode.has(ConsistsOf.SOURCE_PROPERTY)) {
|
||||||
|
--size;
|
||||||
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.setNoTraversal(noTraversal);
|
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
||||||
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
||||||
|
wrapInnerQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
consistsOfBuffer.append(stringBuffer);
|
if(wrapInnerQuery) {
|
||||||
consistsOfBuffer.append(")"); // Close ) 2
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("TRAVERSE ");
|
||||||
// Size 2 means that only 'type' and 'target' properties are present
|
buffer.append(direction.name().toLowerCase());
|
||||||
if(size > 2) {
|
buffer.append("E(\"");
|
||||||
consistsOfBuffer.append(") WHERE "); // Close ) SELECT
|
buffer.append(type);
|
||||||
consistsOfBuffer.append(addConstraints(jsonNode, null, null));
|
buffer.append("\") FROM ( ");
|
||||||
|
buffer.append(stringBuffer);
|
||||||
|
buffer.append(")");
|
||||||
|
stringBuffer = buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!jsonNode.has(ConsistsOf.SOURCE_PROPERTY)) {
|
if(entryPoint || size>1) {
|
||||||
consistsOfBuffer.append(")"); // Close ) 1
|
stringBuffer = createSelect(stringBuffer, wrapInnerQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
return consistsOfBuffer;
|
if(!entryPoint && requestedResourceType!=null) {
|
||||||
|
stringBuffer = traverseBackToCallerResource(stringBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return stringBuffer;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.queries.json.base.relations;
|
package org.gcube.informationsystem.resourceregistry.queries.json.base.relations;
|
||||||
|
|
||||||
|
import javax.ws.rs.InternalServerErrorException;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.informationsystem.base.reference.AccessType;
|
import org.gcube.informationsystem.base.reference.AccessType;
|
||||||
import org.gcube.informationsystem.base.reference.Direction;
|
import org.gcube.informationsystem.base.reference.Direction;
|
||||||
|
@ -8,6 +10,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||||
import org.gcube.informationsystem.resourceregistry.queries.json.base.entities.JsonQueryResource;
|
import org.gcube.informationsystem.resourceregistry.queries.json.base.entities.JsonQueryResource;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
@ -18,6 +21,7 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
|
||||||
|
|
||||||
public JsonQueryIsRelatedTo(JsonNode jsonQuery) throws SchemaException, ResourceRegistryException {
|
public JsonQueryIsRelatedTo(JsonNode jsonQuery) throws SchemaException, ResourceRegistryException {
|
||||||
super(jsonQuery, AccessType.IS_RELATED_TO);
|
super(jsonQuery, AccessType.IS_RELATED_TO);
|
||||||
|
direction = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRequestedResourceType() {
|
public String getRequestedResourceType() {
|
||||||
|
@ -28,119 +32,162 @@ public class JsonQueryIsRelatedTo extends JsonQueryRelation {
|
||||||
this.requestedResourceType = requestedResourceType;
|
this.requestedResourceType = requestedResourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringBuffer traverseThisEdge(StringBuffer stringBuffer) throws InvalidQueryException {
|
protected StringBuffer traverseBackToCallerResource(StringBuffer stringBuffer) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("TRAVERSE ");
|
||||||
|
buffer.append(direction.opposite().name().toLowerCase());
|
||||||
|
buffer.append("V(\"");
|
||||||
|
buffer.append(requestedResourceType);
|
||||||
|
buffer.append("\") FROM ( "); // Open (
|
||||||
|
buffer.append(stringBuffer);
|
||||||
|
buffer.append(")"); // Close )
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
int size = jsonNode.size();
|
public StringBuffer createSelect(StringBuffer stringBuffer, boolean wrapInnerQuery) throws SchemaException, ResourceRegistryException {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("SELECT FROM ");
|
||||||
|
|
||||||
// Remove type from size
|
if(wrapInnerQuery) {
|
||||||
--size;
|
buffer.append("( ");
|
||||||
|
buffer.append(stringBuffer);
|
||||||
|
buffer.append(")");
|
||||||
|
}else {
|
||||||
|
buffer.append(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entryPoint || size>1) {
|
||||||
|
buffer.append(" WHERE ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(size > 1) {
|
||||||
|
buffer.append(addConstraints(jsonNode, null, null));
|
||||||
|
if(entryPoint) {
|
||||||
|
buffer.append(" AND ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entryPoint) {
|
||||||
|
buffer.append(OrientDBUtility.ORIENTDB_CLASS_PROPERTY);
|
||||||
|
buffer.append(" INSTANCEOF \"");
|
||||||
|
buffer.append(type);
|
||||||
|
buffer.append("\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDirectionByJson() throws InvalidQueryException {
|
||||||
|
if(entryPoint) {
|
||||||
|
String error = "The function JsonQueryIsRelatedTo#setDirectionByJson() cannot be called for an entry point";
|
||||||
|
logger.error(error);
|
||||||
|
throw new InternalServerErrorException(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
|
||||||
if(jsonNode.has(IsRelatedTo.SOURCE_PROPERTY)) {
|
if(jsonNode.has(IsRelatedTo.SOURCE_PROPERTY)) {
|
||||||
--size;
|
logger.trace("{} for type {} has {} property", IsRelatedTo.NAME, type, IsRelatedTo.SOURCE_PROPERTY);
|
||||||
|
direction = Direction.OUT;
|
||||||
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(jsonNode.has(IsRelatedTo.TARGET_PROPERTY)) {
|
if(jsonNode.has(IsRelatedTo.TARGET_PROPERTY)) {
|
||||||
--size;
|
if(found) {
|
||||||
}
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append(IsRelatedTo.NAME);
|
||||||
if(size > 0) {
|
buffer.append(" for type ");
|
||||||
buffer.append("SELECT FROM ");
|
|
||||||
if(noTraversal) {
|
|
||||||
buffer.append(type);
|
buffer.append(type);
|
||||||
}else {
|
buffer.append(" has both ");
|
||||||
buffer.append(" ( "); // Open ( SELECT
|
buffer.append(IsRelatedTo.SOURCE_PROPERTY);
|
||||||
|
buffer.append(" and ");
|
||||||
|
buffer.append(IsRelatedTo.TARGET_PROPERTY);
|
||||||
|
buffer.append(" property. Only entry points can have both because one is implicit from the resource containg the ");
|
||||||
|
buffer.append(IsRelatedTo.NAME);
|
||||||
|
buffer.append(" relation.");
|
||||||
|
logger.error("This part of the json query is not valid {}\n{}", jsonNode.toString(), buffer.toString());
|
||||||
|
throw new InvalidQueryException(buffer.toString());
|
||||||
}
|
}
|
||||||
|
direction = Direction.IN;
|
||||||
}else {
|
|
||||||
if(noTraversal) {
|
|
||||||
buffer.append("SELECT FROM ");
|
|
||||||
buffer.append(type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!noTraversal) {
|
|
||||||
buffer.append("TRAVERSE ");
|
|
||||||
buffer.append(direction.opposite().name().toLowerCase());
|
|
||||||
buffer.append("E(\"");
|
|
||||||
buffer.append(type);
|
|
||||||
buffer.append("\") FROM ( ");
|
|
||||||
buffer.append(stringBuffer);
|
|
||||||
buffer.append(")");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
stringBuffer = buffer;
|
|
||||||
|
|
||||||
// Size 0 means that only 'type' and 'target'/'source' properties are present
|
|
||||||
if(size > 0) {
|
|
||||||
if(!noTraversal) {
|
|
||||||
stringBuffer.append(" )"); // Close ) SELECT
|
|
||||||
}
|
|
||||||
stringBuffer.append(" WHERE ");
|
|
||||||
stringBuffer.append(addConstraints(jsonNode, null, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
return stringBuffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
public StringBuffer analize(StringBuffer stringBuffer) throws SchemaException, ResourceRegistryException {
|
||||||
|
|
||||||
JsonNode sourceJsonNode = jsonNode.get(IsRelatedTo.SOURCE_PROPERTY);
|
if(!entryPoint && direction==null) {
|
||||||
JsonNode targetJsonNode = jsonNode.get(IsRelatedTo.TARGET_PROPERTY);
|
throw new InternalServerErrorException("Caller Resource must invoke setDirectionByJson() first. This is a server bug. Please contact the administator. ");
|
||||||
|
|
||||||
JsonNode resourceJsonNode = null;
|
|
||||||
|
|
||||||
if(sourceJsonNode!=null) {
|
|
||||||
resourceJsonNode = sourceJsonNode;
|
|
||||||
direction = Direction.OUT;
|
|
||||||
} else if(targetJsonNode!=null) {
|
|
||||||
resourceJsonNode = targetJsonNode;
|
|
||||||
direction = Direction.IN;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stringBuffer = traverseThisEdge(stringBuffer);
|
boolean wrapInnerQuery = false;
|
||||||
|
|
||||||
JsonQueryResource jsonQueryResource = new JsonQueryResource(resourceJsonNode);
|
|
||||||
jsonQueryResource.setDirection(direction);
|
|
||||||
jsonQueryResource.setNoTraversal(false);
|
|
||||||
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
|
||||||
|
|
||||||
|
if(traverseBack) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
if(requestedResourceType!=null) {
|
|
||||||
buffer.append("TRAVERSE ");
|
buffer.append("TRAVERSE ");
|
||||||
buffer.append(direction.opposite().name().toLowerCase());
|
buffer.append(direction.opposite().name().toLowerCase());
|
||||||
buffer.append("V(\"");
|
|
||||||
buffer.append(requestedResourceType);
|
|
||||||
buffer.append("\") FROM ( ");
|
|
||||||
}
|
|
||||||
buffer.append("TRAVERSE ");
|
|
||||||
buffer.append(direction.name().toLowerCase());
|
|
||||||
buffer.append("E(\"");
|
buffer.append("E(\"");
|
||||||
buffer.append(type);
|
buffer.append(type);
|
||||||
buffer.append("\") FROM ( ");
|
buffer.append("\") FROM ( ");
|
||||||
buffer.append(stringBuffer);
|
buffer.append(stringBuffer);
|
||||||
buffer.append(")");
|
buffer.append(")");
|
||||||
if(requestedResourceType!=null) {
|
|
||||||
buffer.append(")");
|
|
||||||
}
|
|
||||||
stringBuffer = buffer;
|
stringBuffer = buffer;
|
||||||
|
wrapInnerQuery = true;
|
||||||
|
}
|
||||||
|
|
||||||
if(sourceJsonNode!=null && targetJsonNode!=null) {
|
Direction wrapDirection = direction;
|
||||||
// Target has still to be analised
|
|
||||||
|
|
||||||
jsonQueryResource = new JsonQueryResource(targetJsonNode);
|
if(jsonNode.has(IsRelatedTo.SOURCE_PROPERTY)) {
|
||||||
jsonQueryResource.setDirection(Direction.IN);
|
--size;
|
||||||
jsonQueryResource.setNoTraversal(false);
|
JsonNode sourceJsonNode = jsonNode.get(IsRelatedTo.SOURCE_PROPERTY);
|
||||||
|
JsonQueryResource jsonQueryResource = new JsonQueryResource(sourceJsonNode);
|
||||||
|
wrapDirection = Direction.OUT;
|
||||||
|
jsonQueryResource.setDirection(Direction.OUT);
|
||||||
|
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
||||||
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
||||||
|
wrapInnerQuery = true;
|
||||||
|
}
|
||||||
|
|
||||||
boolean noTraversalOldValue = noTraversal;
|
if(jsonNode.has(IsRelatedTo.TARGET_PROPERTY)) {
|
||||||
// It is no more and entry point for the function traverseThisEdge
|
if(jsonNode.has(IsRelatedTo.SOURCE_PROPERTY)) {
|
||||||
noTraversal = false;
|
StringBuffer buffer = new StringBuffer();
|
||||||
stringBuffer = traverseThisEdge(stringBuffer);
|
buffer.append("TRAVERSE ");
|
||||||
// Restoring entryPoint indication
|
buffer.append(wrapDirection.name().toLowerCase());
|
||||||
noTraversal = noTraversalOldValue;
|
buffer.append("E(\"");
|
||||||
|
buffer.append(type);
|
||||||
|
buffer.append("\") FROM ( ");
|
||||||
|
buffer.append(stringBuffer);
|
||||||
|
buffer.append(")");
|
||||||
|
stringBuffer = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
--size;
|
||||||
|
JsonNode targetJsonNode = jsonNode.get(IsRelatedTo.TARGET_PROPERTY);
|
||||||
|
JsonQueryResource jsonQueryResource = new JsonQueryResource(targetJsonNode);
|
||||||
|
wrapDirection = Direction.IN;
|
||||||
|
jsonQueryResource.setDirection(Direction.IN);
|
||||||
|
jsonQueryResource.setTraverseBack(!((!traverseBack) && !wrapInnerQuery));
|
||||||
|
stringBuffer = jsonQueryResource.analize(stringBuffer);
|
||||||
|
wrapInnerQuery = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(wrapInnerQuery) {
|
||||||
|
StringBuffer buffer = new StringBuffer();
|
||||||
|
buffer.append("TRAVERSE ");
|
||||||
|
buffer.append(wrapDirection.name().toLowerCase());
|
||||||
|
buffer.append("E(\"");
|
||||||
|
buffer.append(type);
|
||||||
|
buffer.append("\") FROM ( ");
|
||||||
|
buffer.append(stringBuffer);
|
||||||
|
buffer.append(")");
|
||||||
|
stringBuffer = buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entryPoint || size>1) {
|
||||||
|
stringBuffer = createSelect(stringBuffer, wrapInnerQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!entryPoint) {
|
||||||
|
stringBuffer = traverseBackToCallerResource(stringBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringBuffer;
|
return stringBuffer;
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class JsonQueryTest extends ContextTest {
|
||||||
@Test
|
@Test
|
||||||
public void testSingleCreateQuery() throws Exception {
|
public void testSingleCreateQuery() throws Exception {
|
||||||
File queriesDirectory = getQueriesDirectory();
|
File queriesDirectory = getQueriesDirectory();
|
||||||
File jsonQueryFile = new File(queriesDirectory, "query3.json");
|
File jsonQueryFile = new File(queriesDirectory, "query9.json");
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
JsonNode jsonNode = objectMapper.readTree(jsonQueryFile);
|
JsonNode jsonNode = objectMapper.readTree(jsonQueryFile);
|
||||||
logger.info("Going to test the following JSON query {}", jsonNode.toString());
|
logger.info("Going to test the following JSON query {}", jsonNode.toString());
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
TRAVERSE inE("IsIdentifiedBy") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("SoftwareFacet") FROM (
|
||||||
|
TRAVERSE outE("IsIdentifiedBy") FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM StateFacet WHERE value = "down"
|
||||||
|
)
|
||||||
|
) WHERE propagationConstraint.add = "propagate"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE name = "data-transfer-service" AND group = "DataTransfer"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE @class INSTANCEOF "EService"
|
|
@ -0,0 +1,41 @@
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("AccessPointFacet") FROM (
|
||||||
|
TRAVERSE outE("ConsistsOf") FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
TRAVERSE inE("IsIdentifiedBy") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("SoftwareFacet") FROM (
|
||||||
|
TRAVERSE outE("IsIdentifiedBy") FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("StateFacet") FROM (
|
||||||
|
TRAVERSE outE("ConsistsOf") FROM (
|
||||||
|
TRAVERSE inV("EService") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE outE("Activates") FROM (
|
||||||
|
SELECT FROM HostingNode WHERE id = "5fbc1a56-d450-4f0f-85c1-9b1684581717"
|
||||||
|
)
|
||||||
|
) WHERE id = "d3f58e52-5346-47bc-b736-9d77a0b554ce"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE value = "down"
|
||||||
|
)
|
||||||
|
) WHERE propagationConstraint.add = "propagate"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE name = "data-transfer-service" AND group = "DataTransfer"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE @class INSTANCEOF "EService"
|
|
@ -1 +1 @@
|
||||||
SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( TRAVERSE outE("Activates") FROM ( SELECT FROM ( TRAVERSE outV("HostingNode") FROM ( SELECT FROM Activates WHERE id = "d3f58e52-5346-47bc-b736-9d77a0b554ce")) WHERE id = "5fbc1a56-d450-4f0f-85c1-9b1684581717"))))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))) WHERE @class INSTANCEOF "EService"
|
SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( SELECT FROM ( TRAVERSE outE("Activates") FROM ( SELECT FROM HostingNode WHERE id = "5fbc1a56-d450-4f0f-85c1-9b1684581717")) WHERE id = "d3f58e52-5346-47bc-b736-9d77a0b554ce")))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))) WHERE @class INSTANCEOF "EService"
|
|
@ -0,0 +1,43 @@
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("AccessPointFacet") FROM (
|
||||||
|
TRAVERSE outE("ConsistsOf") FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
TRAVERSE inE("IsIdentifiedBy") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("SoftwareFacet") FROM (
|
||||||
|
TRAVERSE outE("IsIdentifiedBy") FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("StateFacet") FROM (
|
||||||
|
TRAVERSE outE("ConsistsOf") FROM (
|
||||||
|
TRAVERSE inV("EService") FROM (
|
||||||
|
TRAVERSE outE("Activates") FROM (
|
||||||
|
TRAVERSE outV("HostingNode") FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM CPUFacet WHERE vendor = "GenuineIntel"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE value = "down"
|
||||||
|
)
|
||||||
|
) WHERE propagationConstraint.add = "propagate"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE name = "data-transfer-service" AND group = "DataTransfer"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE @class INSTANCEOF "EService"
|
|
@ -1 +1 @@
|
||||||
SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( TRAVERSE outE("Activates") FROM ( TRAVERSE outV("HostingNode") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("CPUFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("HostingNode") FROM ( SELECT FROM Activates)))) WHERE vendor = "GenuineIntel"))))))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))) WHERE @class INSTANCEOF "EService"
|
SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( TRAVERSE outE("Activates") FROM ( TRAVERSE outV("HostingNode") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM CPUFacet WHERE vendor = "GenuineIntel"))))))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))) WHERE @class INSTANCEOF "EService"
|
|
@ -0,0 +1,47 @@
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("AccessPointFacet") FROM (
|
||||||
|
TRAVERSE outE("ConsistsOf") FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
TRAVERSE inE("IsIdentifiedBy") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("SoftwareFacet") FROM (
|
||||||
|
TRAVERSE outE("IsIdentifiedBy") FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("StateFacet") FROM (
|
||||||
|
TRAVERSE outE("ConsistsOf") FROM (
|
||||||
|
TRAVERSE inV("EService") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE outE("Activates") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE outV("HostingNode") FROM (
|
||||||
|
TRAVERSE inE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM CPUFacet WHERE vendor = "GenuineIntel"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE id = "5fbc1a56-d450-4f0f-85c1-9b1684581717"
|
||||||
|
)
|
||||||
|
) WHERE id = "d3f58e52-5346-47bc-b736-9d77a0b554ce"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE value = "down"
|
||||||
|
)
|
||||||
|
) WHERE propagationConstraint.add = "propagate"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE name = "data-transfer-service" AND group = "DataTransfer"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE id = "0255b7ec-e3da-4071-b456-9a2907ece1db" AND @class INSTANCEOF "EService"
|
|
@ -1 +1 @@
|
||||||
SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( TRAVERSE outE("Activates") FROM ( SELECT FROM ( TRAVERSE outV("HostingNode") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("CPUFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("HostingNode") FROM ( SELECT FROM Activates WHERE id = "d3f58e52-5346-47bc-b736-9d77a0b554ce")))) WHERE vendor = "GenuineIntel"))) WHERE id = "5fbc1a56-d450-4f0f-85c1-9b1684581717"))))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))) WHERE id = "0255b7ec-e3da-4071-b456-9a2907ece1db" AND @class INSTANCEOF "EService"
|
SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( SELECT FROM ( TRAVERSE outE("Activates") FROM ( SELECT FROM ( TRAVERSE outV("HostingNode") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM CPUFacet WHERE vendor = "GenuineIntel"))) WHERE id = "5fbc1a56-d450-4f0f-85c1-9b1684581717")) WHERE id = "d3f58e52-5346-47bc-b736-9d77a0b554ce")))) WHERE value = "down")) WHERE propagationConstraint.add = "propagate")))) WHERE name = "data-transfer-service" AND group = "DataTransfer"))))) WHERE endpoint = "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))) WHERE id = "0255b7ec-e3da-4071-b456-9a2907ece1db" AND @class INSTANCEOF "EService"
|
|
@ -0,0 +1,11 @@
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("StateFacet") FROM (
|
||||||
|
TRAVERSE outE("ConsistsOf") FROM (
|
||||||
|
SELECT FROM EService
|
||||||
|
WHERE (
|
||||||
|
(id = "aec0ef31-c735-4a4c-b2f4-57dfbd2fe925" AND metadata.createdBy <> "luca.frosini") OR
|
||||||
|
(id = "0255b7ec-e3da-4071-b456-9a2907ece1db" AND metadata.createdBy = "DataTransfer:data-transfer-service:pc-frosini.isti.cnr.it_8080")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE @class INSTANCEOF "StateFacet"
|
|
@ -0,0 +1,23 @@
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inE("CallsFor") FROM (
|
||||||
|
TRAVERSE outV("VirtualService") FROM (
|
||||||
|
TRAVERSE inE("IsIdentifiedBy") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("SoftwareFacet") FROM (
|
||||||
|
TRAVERSE outE("IsIdentifiedBy") FROM (
|
||||||
|
TRAVERSE inV("VirtualService") FROM (
|
||||||
|
TRAVERSE outE("CallsFor") FROM (
|
||||||
|
TRAVERSE outV("EService") FROM (
|
||||||
|
TRAVERSE inE("IsIdentifiedBy") FROM (
|
||||||
|
SELECT FROM SoftwareFacet WHERE group = "org.gcube.data-catalogue" AND name = "gcat"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE @class INSTANCEOF "CallsFor"
|
|
@ -1 +1 @@
|
||||||
TRAVERSE inE("CallsFor") FROM ( TRAVERSE outV("VirtualService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE inV("VirtualService") FROM ( TRAVERSE outE("CallsFor") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM CallsFor)))) WHERE group = "org.gcube.data-catalogue" AND name = "gcat"))))))) WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service")))
|
SELECT FROM ( TRAVERSE inE("CallsFor") FROM ( TRAVERSE outV("VirtualService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE inV("VirtualService") FROM ( TRAVERSE outE("CallsFor") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM SoftwareFacet WHERE group = "org.gcube.data-catalogue" AND name = "gcat"))))))) WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service")))) WHERE @class INSTANCEOF "CallsFor"
|
|
@ -0,0 +1,25 @@
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("SimpleFacet") FROM (
|
||||||
|
TRAVERSE outE("ConsistsOf") FROM (
|
||||||
|
TRAVERSE outV("Configuration") FROM (
|
||||||
|
TRAVERSE inE("IsIdentifiedBy") FROM (
|
||||||
|
SELECT FROM (
|
||||||
|
TRAVERSE inV("IdentifierFacet") FROM (
|
||||||
|
TRAVERSE outE("IsIdentifiedBy") FROM (
|
||||||
|
TRAVERSE inV("Configuration") FROM (
|
||||||
|
TRAVERSE outE("IsCustomizedBy") FROM (
|
||||||
|
TRAVERSE outV("VirtualService") FROM (
|
||||||
|
TRAVERSE inE("IsIdentifiedBy") FROM (
|
||||||
|
SELECT FROM SoftwareFacet WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE value = "gcat-configuration"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) WHERE @class INSTANCEOF "SimpleFacet"
|
|
@ -1 +1 @@
|
||||||
SELECT FROM ( TRAVERSE inV("SimpleFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("Configuration") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("IdentifierFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE inV("Configuration") FROM ( TRAVERSE outE("IsCustomizedBy") FROM ( TRAVERSE outV("VirtualService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("VirtualService") FROM ( SELECT FROM IsCustomizedBy)))) WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service"))))))) WHERE value = "gcat-configuration"))))) WHERE @class INSTANCEOF "SimpleFacet"
|
SELECT FROM ( TRAVERSE inV("SimpleFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("Configuration") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("IdentifierFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE inV("Configuration") FROM ( TRAVERSE outE("IsCustomizedBy") FROM ( TRAVERSE outV("VirtualService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM SoftwareFacet WHERE group = "org.gcube.data-catalogue" AND name = "catalogue-virtual-service"))))))) WHERE value = "gcat-configuration"))))) WHERE @class INSTANCEOF "SimpleFacet"
|
Loading…
Reference in New Issue