diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/EntityManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/EntityManagement.java index 2dc8e3e..e90642e 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/EntityManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/EntityManagement.java @@ -524,8 +524,13 @@ public abstract class EntityManagement */ } + + /* public String reallyQuery(String relationType, String referenceType, UUID referenceUUID, ODirection direction, boolean polymorphic, Map constraint, boolean includeRelationInResult) throws ResourceRegistryException { + */ + public String reallyQuery(String relationType, String referenceType, UUID referenceUUID, ODirection direction, + boolean polymorphic, Map constraint) throws ResourceRegistryException { ObjectMapper objectMapper = new ObjectMapper(); ArrayNode arrayNode = objectMapper.createArrayNode(); @@ -651,6 +656,7 @@ public abstract class EntityManagement continue; } + /* JsonNode jsonNode; if(includeRelationInResult) { RelationManagement relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(), @@ -659,8 +665,10 @@ public abstract class EntityManagement }else { jsonNode = entityManagement.serializeAsJsonNode(); } + */ + JsonNode node = entityManagement.serializeAsJsonNode(); - arrayNode.add(jsonNode); + arrayNode.add(node); } catch(ResourceRegistryException e) { logger.error("Unable to correctly serialize {}. It will be excluded from results. {}", vertex.toString(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE); @@ -782,8 +790,12 @@ public abstract class EntityManagement } } + /* public String query(String relationType, String referenceType, UUID referenceUUID, ODirection direction, boolean polymorphic, Map constraint, boolean includeRelationInResult) throws ResourceRegistryException { + */ + public String query(String relationType, String referenceType, UUID referenceUUID, ODirection direction, + boolean polymorphic, Map constraint) throws ResourceRegistryException { ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal(); try { @@ -844,7 +856,8 @@ public abstract class EntityManagement break; } - return reallyQuery(relationType, referenceType, referenceUUID, direction, polymorphic, constraint, includeRelationInResult); + // return reallyQuery(relationType, referenceType, referenceUUID, direction, polymorphic, constraint, includeRelationInResult); + return reallyQuery(relationType, referenceType, referenceUUID, direction, polymorphic, constraint); } catch(ResourceRegistryException e) { throw e; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java index 83b171a..bdd3a9e 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java @@ -284,7 +284,7 @@ public class Access extends BaseRest { @QueryParam(AccessPath._REFERENCE_PARAM) String reference, @QueryParam(AccessPath._POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic, @QueryParam(AccessPath._DIRECTION_PARAM) @DefaultValue("out") String direction, - @QueryParam(AccessPath._INCLUDE_RELATION_PARAM) @DefaultValue("false") Boolean includeRelation, + /*@QueryParam(AccessPath._INCLUDE_RELATION_PARAM) @DefaultValue("false") Boolean includeRelation,*/ @Context UriInfo uriInfo) throws ResourceRegistryException { logger.info("Requested {} instances having a(n) {} ({}={}} with {} ({}={}. Complete Request is {})", resourcetype, relationType, @@ -315,9 +315,11 @@ public class Access extends BaseRest { case AccessPath._REFERENCE_PARAM: break; + /* case AccessPath._INCLUDE_RELATION_PARAM: break; - + */ + case "gcube-token": break; @@ -346,7 +348,7 @@ public class Access extends BaseRest { } return ((ResourceManagement) erManagement).query(relationType, referenceType, refereceUUID, directionEnum, - polymorphic, constraint, includeRelation); + polymorphic, constraint); /*, includeRelation*/ } String error = String.format("%s is not a %s type", resourcetype, Resource.NAME); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/MultiContextTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/MultiContextTest.java index 69bc507..d00e0ae 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/MultiContextTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/MultiContextTest.java @@ -157,7 +157,7 @@ public class MultiContextTest extends ERManagementTest { // resourceManagement.setUUID(resourceUUID); String ret = resourceManagement.query(IsRelatedTo.NAME, resourceType, resourceUUID, oDirection, true, - new HashMap<>(), true); + new HashMap<>()); List isRelatedToList = ElementMapper.unmarshalList(IsRelatedTo.class, ret); return isRelatedToList; } diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/query/QueryTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/query/QueryTest.java index f1cfda9..a718c9c 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/query/QueryTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/query/QueryTest.java @@ -166,72 +166,62 @@ public class QueryTest extends ERManagementTest { ResourceManagement resourceManagement = new ResourceManagement(); resourceManagement.setElementType(Service.NAME); - boolean includeRelation = false; - /* Getting Hosting Node */ String json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, true, - null, includeRelation); + null); List resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 1); Resource resource = resourceList.get(0); Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID) == 0); - json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, true, null, - includeRelation); + json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, true, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 1); resource = resourceList.get(0); Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID) == 0); - json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, true, null, - includeRelation); + json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, true, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); - json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, false, null, - includeRelation); + json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, false, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); - json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, false, null, - includeRelation); + json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, false, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); - json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, false, null, - includeRelation); + json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, false, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); /* END Getting Hosting Node */ /* Getting EService */ json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, true, - null, includeRelation); + null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 1); Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID) == 0); - json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, true, null, - includeRelation); + json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, true, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); - json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, true, null, - includeRelation); + json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, true, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 1); Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID) == 0); json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, false, - null, includeRelation); + null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, false, - null, includeRelation); + null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); - json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, false, null, - includeRelation); + json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, false, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); /* END Getting HostingNode */ @@ -242,13 +232,13 @@ public class QueryTest extends ERManagementTest { /* EService --ConsistsOf--> SoftwareFacet */ try { json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, - ODirection.BOTH, true, null, includeRelation); + ODirection.BOTH, true, null); } catch (InvalidQueryException e) { // Ok expected } json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, - true, null, includeRelation); + true, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 1); resource = resourceList.get(0); @@ -258,7 +248,7 @@ public class QueryTest extends ERManagementTest { try { json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN, - true, null, includeRelation); + true, null); throw new Exception("Expected InvalidQueryException"); } catch (InvalidQueryException e) { // Ok expected @@ -266,20 +256,20 @@ public class QueryTest extends ERManagementTest { try { json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, - ODirection.BOTH, false, null, includeRelation); + ODirection.BOTH, false, null); throw new Exception("Expected InvalidQueryException"); } catch (InvalidQueryException e) { // Ok expected } json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, - false, null, includeRelation); + false, null); resourceList = ElementMapper.unmarshalList(Resource.class, json); Assert.assertTrue(resourceList.size() == 0); try { json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN, - false, null, includeRelation); + false, null); throw new Exception("Expected InvalidQueryException"); } catch (InvalidQueryException e) { // Ok expected @@ -307,13 +297,11 @@ public class QueryTest extends ERManagementTest { @SuppressWarnings("rawtypes") ElementManagement erManagement = ElementManagementUtility.getERManagement(type); - - boolean includeRelation = false; if (erManagement instanceof ResourceManagement) { boolean[] booleans = new boolean[] {true, false}; for(boolean bool : booleans) { - String ret = ((ResourceManagement) erManagement).query(relationType, facetType, null, ODirection.OUT, bool, constraint, includeRelation); + String ret = ((ResourceManagement) erManagement).query(relationType, facetType, null, ODirection.OUT, bool, constraint); logger.debug("Result of query for {}polymorphic {} --{}--> {} with constaint {} is {}", bool ? "" : "NOT ", type, relationType, facetType, constraint, ret); } @@ -389,8 +377,6 @@ public class QueryTest extends ERManagementTest { Configuration expected = createdConfigurations.get(i); UUID expectedUUID = expected.getHeader().getUUID(); - boolean includeRelation = false; - for(Boolean polymorphic : polymorphics) { @@ -404,7 +390,7 @@ public class QueryTest extends ERManagementTest { resourceType, relationType, referenceType, constraint); String ret = resourceManagement.query(relationType, referenceType, refereceUUID, directionEnum, - polymorphic, constraint, includeRelation); + polymorphic, constraint); List list = ElementMapper.unmarshalList(Configuration.class, ret); Assert.assertTrue(list.size()==expectedSize); @@ -430,7 +416,7 @@ public class QueryTest extends ERManagementTest { parentResourceType, relationType, referenceType, constraint); String retPolimorphic = parentResourceManagement.query(relationType, referenceType, refereceUUID, directionEnum, - polymorphic, constraint, includeRelation); + polymorphic, constraint); List listPolimorphic = ElementMapper.unmarshalList(ConfigurationTemplate.class, retPolimorphic); Assert.assertTrue(listPolimorphic.size()==expectedSize);