Refs #11288: Made resource-registry more RESTful

Task-Url: https://support.d4science.org/issues/11288

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@168987 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2018-06-08 13:39:04 +00:00
parent 4cd64f8094
commit a2c4b85851
2 changed files with 28 additions and 12 deletions

View File

@ -234,14 +234,10 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
return jsonArray.toString();
}
public String reallyQuery(String relationType, String referenceType, Direction direction,
boolean polymorphic, Map<String,String> constraint) throws ResourceRegistryException {
public String reallyQuery(String relationType, String referenceType, Direction direction, boolean polymorphic,
Map<String,String> constraint) throws ResourceRegistryException {
JSONArray jsonArray = new JSONArray();
// TODO check types
/*
@ -251,8 +247,6 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
* WHERE @class='EService' // Only is not polymorphic
*/
boolean first = true;
StringBuilder selectStringBuilder = new StringBuilder("SELECT FROM (TRAVERSE ");
selectStringBuilder.append(direction.name().toLowerCase());
selectStringBuilder.append("E('");
@ -263,6 +257,7 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
selectStringBuilder.append(erType);
selectStringBuilder.append("') FROM (SELECT FROM ");
selectStringBuilder.append(referenceType);
boolean first = true;
for(String key : constraint.keySet()) {
if(first) {
selectStringBuilder.append(" WHERE ");
@ -350,7 +345,7 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
throw new ResourceRegistryException(error);
}
if(constraint==null) {
if(constraint == null) {
constraint = new HashMap<>();
}
@ -388,7 +383,7 @@ public abstract class EntityManagement<E extends Entity> extends ERManagement<E,
break;
}
if(referenceUUID!=null) {
if(referenceUUID != null) {
constraint.put(Entity.HEADER_PROPERTY + "." + Header.UUID_PROPERTY, referenceUUID.toString());
}

View File

@ -283,8 +283,29 @@ public class Access {
}
/*
* /access/query/{RESOURCE_TYPE_PATH_PART}/{RELATION_TYPE_PATH_PART}/{ENTITY_TYPE_NAME}[?reference=&polymorphic=true&direction=out]
* e.g. GET /access/query/EService/isIdentifiedBy/SoftwareFacet?reference=16032d09-3823-444e-a1ff-a67de4f350a8&polymorphic=true&direction=out
* /access/query/{RESOURCE_TYPE_NAME}/{RELATION_TYPE_NAME}/{ENTITY_TYPE_NAME}[?reference={REFERENCE_ENTITY_UUID}&polymorphic=true&direction=out]
*
* e.g.
* All the EService identified By a SoftwareFacet :
* GET /access/query/EService/isIdentifiedBy/SoftwareFacet?polymorphic=true&direction=out
*
* The Eservice identified By the SoftwareFacet with UUID 7bc997c3-d005-40ff-b9ed-c4b6a35851f1 :
* GET /access/query/EService/isIdentifiedBy/SoftwareFacet?reference=7bc997c3-d005-40ff-b9ed-c4b6a35851f1&polymorphic=true&direction=out
*
* All the Resources identified By a ContactFacet :
* GET /access/query/Resource/isIdentifiedBy/ContactFacet?polymorphic=true&direction=out
*
* All the Resources with a ContactFacet :
* /access/query/Resource/ConsistsOf/ContactFacet?polymorphic=true&direction=out
*
* All the Eservice having an incoming (IN) Hosts relation with an HostingNode (i.e. all smartgears services)
* GET /access/query/EService/Hosts/HostingNode?polymorphic=true&direction=in
*
* All the Eservice having an incoming (IN) Hosts relation (i.e. hosted by) the HostingNode with UUID
* 16032d09-3823-444e-a1ff-a67de4f350a
*
* GET /access/query/EService/hosts/HostingNode?reference=16032d09-3823-444e-a1ff-a67de4f350a8&polymorphic=true&direction=in
*
*/
@SuppressWarnings({"rawtypes"})
@GET