Added more possibilities
This commit is contained in:
parent
475c6147e2
commit
a51405c843
|
@ -6,6 +6,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.Direction;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||
|
@ -71,6 +72,18 @@ public abstract class JsonQueryERElement {
|
|||
continue;
|
||||
}
|
||||
|
||||
if(fieldName.compareTo(Relation.SOURCE_PROPERTY)==0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(fieldName.compareTo(Resource.CONSISTS_OF_PROPERTY)==0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(fieldName.compareTo(Resource.IS_RELATED_TO_PROPERTY)==0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(first) {
|
||||
first = false;
|
||||
}else {
|
||||
|
|
|
@ -31,10 +31,13 @@ public class JsonQueryIsRelatedTo extends JsonQueryERElement{
|
|||
|
||||
int size = jsonNode.size();
|
||||
if(size > 2) {
|
||||
buffer.append("SELECT FROM ( ");
|
||||
buffer.append("SELECT FROM ");
|
||||
if(entryPoint) {
|
||||
buffer.append(type);
|
||||
}else {
|
||||
buffer.append(" ( "); // Open ( SELECT
|
||||
}
|
||||
|
||||
}else {
|
||||
if(entryPoint) {
|
||||
buffer.append("SELECT FROM ");
|
||||
|
@ -57,7 +60,11 @@ public class JsonQueryIsRelatedTo extends JsonQueryERElement{
|
|||
|
||||
// Size 2 means that only '@class' and 'target'/'source' properties are present
|
||||
if(size > 2) {
|
||||
stringBuffer.append(") WHERE "); // Close ) SELECT
|
||||
if(!entryPoint) {
|
||||
stringBuffer.append(" )"); // Close ) SELECT
|
||||
}
|
||||
stringBuffer.append(" WHERE ");
|
||||
|
||||
stringBuffer = addWhereConstraint(jsonNode, buffer, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.Direction;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||
|
@ -68,6 +69,9 @@ public class JsonQueryResource extends JsonQueryERElement {
|
|||
stringBuffer = new StringBuffer();
|
||||
stringBuffer.append("SELECT FROM ");
|
||||
stringBuffer.append(type);
|
||||
if(jsonNode.has(IdentifiableElement.HEADER_PROPERTY)) {
|
||||
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// StringBuffer newBuffer = new StringBuffer();
|
||||
|
@ -82,6 +86,16 @@ public class JsonQueryResource extends JsonQueryERElement {
|
|||
// }
|
||||
}
|
||||
|
||||
|
||||
if(jsonNode.has(IdentifiableElement.HEADER_PROPERTY)) {
|
||||
StringBuffer newBuffer = new StringBuffer();
|
||||
newBuffer.append("SELECT FROM ( ");
|
||||
newBuffer.append(stringBuffer);
|
||||
newBuffer.append(") WHERE ");
|
||||
addWhereConstraint(jsonNode, newBuffer, null);
|
||||
stringBuffer = newBuffer;
|
||||
}
|
||||
|
||||
return stringBuffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
|
||||
"@class": "EService",
|
||||
"header": {
|
||||
"uuid": "0255b7ec-e3da-4071-b456-9a2907ece1db"
|
||||
},
|
||||
"consistsOf": [
|
||||
{
|
||||
"@class": "ConsistsOf",
|
||||
|
@ -31,8 +33,14 @@
|
|||
"isRelatedTo" : [
|
||||
{
|
||||
"@class": "Activates",
|
||||
"header": {
|
||||
"uuid": "d3f58e52-5346-47bc-b736-9d77a0b554ce"
|
||||
},
|
||||
"source": {
|
||||
"@class": "HostingNode",
|
||||
"header": {
|
||||
"uuid" : "5fbc1a56-d450-4f0f-85c1-9b1684581717"
|
||||
},
|
||||
"consistsOf": [
|
||||
{
|
||||
"@class": "ConsistsOf",
|
||||
|
|
Loading…
Reference in New Issue