diff --git a/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/RegistryClientRequester.java b/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/RegistryClientRequester.java index a525d6f..4239c1f 100644 --- a/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/RegistryClientRequester.java +++ b/src/main/java/org/gcube/portlets/admin/resourcemanagement/server/RegistryClientRequester.java @@ -5,8 +5,10 @@ import java.util.HashMap; import java.util.List; import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient; import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory; +import org.gcube.informationsystem.types.reference.Type; import org.gcube.portlets.admin.resourcemanagement.shared.resource.CacheList; import org.gcube.portlets.admin.resourcemanagement.shared.resource.UtilityResource; import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator; @@ -36,15 +38,15 @@ public class RegistryClientRequester { ScopeProvider.instance.set(scope); try { - List typeDefinitions = resourceRegistryClient.getSchema(Resource.class, true); - for (TypeDefinition td : typeDefinitions) { + List types = resourceRegistryClient.getType(Resource.class, true); + for (Type t : types) { - if (td.getName().equals("EService")) - retval.put("RunningInstance", UtilityResource.getSubResourcesTreeQuery(td.getName(),scope)); - if (td.getName().equals("Configuration")) - retval.put("GenericResource", UtilityResource.getSubResourcesTreeQuery(td.getName(),scope)); - if (td.getName().equals("HostingNode")) - retval.put("GHN", UtilityResource.getSubResourcesTreeQuery(td.getName(),scope)); + if (t.getName().equals("EService")) + retval.put("RunningInstance", UtilityResource.getSubResourcesTreeQuery(t.getName(),scope)); + if (t.getName().equals("Configuration")) + retval.put("GenericResource", UtilityResource.getSubResourcesTreeQuery(t.getName(),scope)); + if (t.getName().equals("HostingNode")) + retval.put("GHN", UtilityResource.getSubResourcesTreeQuery(t.getName(),scope)); } diff --git a/src/main/java/org/gcube/portlets/admin/resourcemanagement/shared/resource/UtilityResource.java b/src/main/java/org/gcube/portlets/admin/resourcemanagement/shared/resource/UtilityResource.java index bcd1f09..6d2493b 100644 --- a/src/main/java/org/gcube/portlets/admin/resourcemanagement/shared/resource/UtilityResource.java +++ b/src/main/java/org/gcube/portlets/admin/resourcemanagement/shared/resource/UtilityResource.java @@ -14,6 +14,7 @@ import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient; import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory; +import org.gcube.informationsystem.utils.ElementMapper; import org.gcube.resourcemanagement.model.reference.entities.facets.AccessPointFacet; import org.gcube.resourcemanagement.model.reference.entities.facets.MemoryFacet; import org.gcube.resourcemanagement.model.reference.entities.facets.NetworkingFacet; @@ -25,6 +26,7 @@ import org.gcube.resourcemanagement.model.reference.entities.resources.EService; import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNode; import org.gcube.resourcemanagement.model.reference.relations.consistsof.HasPersistentMemory; import org.gcube.resourcemanagement.model.reference.relations.consistsof.HasVolatileMemory; +import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy; import com.google.gwt.thirdparty.json.JSONArray; import com.google.gwt.thirdparty.json.JSONObject; @@ -42,12 +44,16 @@ public class UtilityResource { public static ArrayList getSubResourcesTree(String entity, String scope) throws Exception{ ArrayList list = new ArrayList<>(); - List resources = (List) resourceRegistryClient.getInstances(entity, true); + String s = resourceRegistryClient.getInstances(entity, true); - for (Resource et : resources) { - List facets = et.getIdentificationFacets(); - for (Facet f : facets) { - + List resources = ElementMapper.unmarshalList(Resource.class, s); + + for (Resource r : resources) { + List iibs = r.getConsistsOf(IsIdentifiedBy.class); + for (IsIdentifiedBy iib : iibs) { + + Facet f = (Facet) iib.getTarget(); + switch (entity) { /* case "Software": @@ -352,7 +358,7 @@ public class UtilityResource { String status=""; String ghnName=""; - List eservices = (List) resourceRegistryClient.getInstances(EService.NAME,false); + List eservices = (List) resourceRegistryClient.getInstances(EService.class,false); for (EService et : eservices) { id=et.getHeader().getUUID().toString(); List facets = et.getIdentificationFacets(); @@ -382,8 +388,8 @@ public class UtilityResource { ghnName=""; } } - if (c.getTarget() instanceof ServiceStateFacet){ - ServiceStateFacet stf = (ServiceStateFacet) c.getTarget(); + if (c.getTarget() instanceof StateFacet){ + StateFacet stf = (StateFacet) c.getTarget(); try { status=stf.getValue().toLowerCase(); } @@ -436,7 +442,7 @@ public class UtilityResource { String subType=""; String name=""; String description=""; - List econfiguration = (List) resourceRegistryClient.getInstances(Configuration.NAME,false); + List econfiguration = (List) resourceRegistryClient.getInstances(Configuration.class,false); for (Configuration et : econfiguration) { id=et.getHeader().getUUID().toString(); List facets = et.getIdentificationFacets(); @@ -505,7 +511,7 @@ public class UtilityResource { String gcfVersion=""; String ghnVersion=""; - List ehosting = (List) resourceRegistryClient.getInstances(HostingNode.NAME,false); + List ehosting = (List) resourceRegistryClient.getInstances(HostingNode.class,false); for (HostingNode eh : ehosting) { id=eh.getHeader().getUUID().toString(); lastUpdate=eh.getHeader().getLastUpdateTime().toString();