From ce8f089de80b36783dd3e4187008e1ed94d9c8a1 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Fri, 23 Jun 2023 18:01:12 +0200 Subject: [PATCH] Porting naming to allow usage of gcat from other services as library --- .../org/gcube/gcat/GCatInitializator.java | 2 +- .../impl/FacetBasedISConfigurationProxy.java | 62 ++++++++++--------- ...on => 02-get-catalogue-configuration.json} | 2 +- ...ple-facet-of-catalogue-configuration.json} | 0 src/main/resources/query/GraphOfResources.txt | 12 ++-- .../FacetBasedISConfigurationProxyTest.java | 2 +- 6 files changed, 41 insertions(+), 39 deletions(-) rename src/main/resources/query/{02-get-gcat-configuration.json => 02-get-catalogue-configuration.json} (92%) rename src/main/resources/query/{03-get-simple-facet-of-gcat-configuration.json => 03-get-simple-facet-of-catalogue-configuration.json} (100%) diff --git a/src/main/java/org/gcube/gcat/GCatInitializator.java b/src/main/java/org/gcube/gcat/GCatInitializator.java index 0641ccb..6766d42 100644 --- a/src/main/java/org/gcube/gcat/GCatInitializator.java +++ b/src/main/java/org/gcube/gcat/GCatInitializator.java @@ -64,7 +64,7 @@ public class GCatInitializator implements ApplicationManager { facetBasedISConfigurationProxy.installQueryTemplate(); initialised = true; } - facetBasedISConfigurationProxy.setGcatEServiceID(gcatEServiceID); + facetBasedISConfigurationProxy.setServiceEServiceID(gcatEServiceID); facetBasedISConfigurationProxy.createCallsForToVirtualService(); }catch (Exception e) { logger.warn("Gcat is not configured through the Facet Based IS in context {}. Please create/addToContext the expected resources ASAP. The Gcore IS will be used.", context); diff --git a/src/main/java/org/gcube/gcat/configuration/isproxies/impl/FacetBasedISConfigurationProxy.java b/src/main/java/org/gcube/gcat/configuration/isproxies/impl/FacetBasedISConfigurationProxy.java index f2544c9..529b87b 100644 --- a/src/main/java/org/gcube/gcat/configuration/isproxies/impl/FacetBasedISConfigurationProxy.java +++ b/src/main/java/org/gcube/gcat/configuration/isproxies/impl/FacetBasedISConfigurationProxy.java @@ -62,18 +62,19 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy | gcat-configuration | -// / | | -// / ---------------------- +// Configuration +// --------------------------- +// IsCustomizedBy | | +// -----------------> | catalogue-configuration | +// / | | +// / --------------------------- // EService VirtualService / // ------------ ----------------------------- // | | CallsFor | | @@ -170,11 +171,13 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy> getCallsForToVirtualService() throws Exception { ResourceRegistryQueryTemplateClient rrqtc = ResourceRegistryQueryTemplateClientFactory.create(); ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put(GCAT_ESERVICE_UUID_VARNAME, gcatEServiceID); + objectNode.put(SERVICE_ESERVICE_UUID_VARNAME, serviceEServiceID); List> callsForList = rrqtc.run(queryTemplate.getName(), objectNode); return callsForList; @@ -228,11 +230,11 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy1) { - logger.warn("There are {} instances of {} relation beetween gcat Eservice with UUID {} and the {} (catalogue-virtual-service). This is very strange because there should be only one. We are going to delete them and recreated a new one.", - callsForList.size(), CallsFor.NAME, gcatEServiceID, VirtualService.NAME); + logger.warn("There are {} instances of {} relation beetween {} Eservice with UUID {} and the {} (catalogue-virtual-service). This is very strange because there should be only one. We are going to delete them and recreated a new one.", + callsForList.size(), CallsFor.NAME, serviceName, serviceEServiceID, VirtualService.NAME); logger.trace("{} relation instances that are going to be deleted are {}", CallsFor.NAME, ElementMapper.marshal(callsForList)); deleteCallsForToVirtualService(callsForList); @@ -240,21 +242,21 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy(gcatEService, virtualService, propagationConstraint); + callsFor = new CallsForImpl(serviceEService, virtualService, propagationConstraint); callsFor = resourceRegistryPublisher.create(callsFor); }else if(size==1){ callsFor = callsForList.get(0); - logger.info("{} between {} (gcat with UUID={}) and the {} exists.\n{}", - CallsFor.NAME, EService.NAME, gcatEServiceID, VirtualService.NAME, ElementMapper.marshal(callsFor)); + logger.info("{} between {} ({} with UUID={}) and the {} exists.\n{}", + CallsFor.NAME, EService.NAME, serviceName, serviceEServiceID, VirtualService.NAME, ElementMapper.marshal(callsFor)); } return callsFor; @@ -309,13 +311,13 @@ public class FacetBasedISConfigurationProxy extends ISConfigurationProxy co = new ConsistsOfImpl<>(gcatConfiguration, configurationSimpleFacet); + Configuration configuration = queryServiceConfiguration(); + ConsistsOf co = new ConsistsOfImpl<>(configuration, configurationSimpleFacet); co = resourceRegistryPublisher.create(co); configurationSimpleFacet = co.getTarget(); setConfigurationInfoFromSimpleFacet(configurationSimpleFacet, catalogueConfiguration); diff --git a/src/main/resources/query/02-get-gcat-configuration.json b/src/main/resources/query/02-get-catalogue-configuration.json similarity index 92% rename from src/main/resources/query/02-get-gcat-configuration.json rename to src/main/resources/query/02-get-catalogue-configuration.json index 881e60a..2b92ac7 100644 --- a/src/main/resources/query/02-get-gcat-configuration.json +++ b/src/main/resources/query/02-get-catalogue-configuration.json @@ -5,7 +5,7 @@ "@class": "IsIdentifiedBy", "target": { "@class": "IdentifierFacet", - "value": "gcat-configuration" + "value": "catalogue-configuration" } } ], diff --git a/src/main/resources/query/03-get-simple-facet-of-gcat-configuration.json b/src/main/resources/query/03-get-simple-facet-of-catalogue-configuration.json similarity index 100% rename from src/main/resources/query/03-get-simple-facet-of-gcat-configuration.json rename to src/main/resources/query/03-get-simple-facet-of-catalogue-configuration.json diff --git a/src/main/resources/query/GraphOfResources.txt b/src/main/resources/query/GraphOfResources.txt index 2c24a6a..a1b5869 100644 --- a/src/main/resources/query/GraphOfResources.txt +++ b/src/main/resources/query/GraphOfResources.txt @@ -1,10 +1,10 @@ - Configuration - ---------------------- - IsCustomizedBy | | - -----------------> | gcat-configuration | - / | | - / ---------------------- + Configuration + --------------------------- + IsCustomizedBy | | + -----------------> | catalogue-configuration | + / | | + / --------------------------- EService VirtualService / ------------ ----------------------------- | | CallsFor | | diff --git a/src/test/java/org/gcube/gcat/configuration/isproxies/impl/FacetBasedISConfigurationProxyTest.java b/src/test/java/org/gcube/gcat/configuration/isproxies/impl/FacetBasedISConfigurationProxyTest.java index 429fcf0..069ebf3 100644 --- a/src/test/java/org/gcube/gcat/configuration/isproxies/impl/FacetBasedISConfigurationProxyTest.java +++ b/src/test/java/org/gcube/gcat/configuration/isproxies/impl/FacetBasedISConfigurationProxyTest.java @@ -26,7 +26,7 @@ public class FacetBasedISConfigurationProxyTest extends ContextTest { public void test() throws Exception { FacetBasedISConfigurationProxyFactory facetBasedISConfigurationProxyFactory = new FacetBasedISConfigurationProxyFactory(); FacetBasedISConfigurationProxy fbiscp = facetBasedISConfigurationProxyFactory.getInstance(); - fbiscp.setGcatEServiceID("f00bbacd-92b8-46d7-b41c-828f71a78753"); + fbiscp.setServiceEServiceID("f00bbacd-92b8-46d7-b41c-828f71a78753"); CallsFor callsFor = fbiscp.createCallsForToVirtualService(); logger.debug("Created {}", ElementMapper.marshal(callsFor));