fixing code

This commit is contained in:
Luca Frosini 2022-07-14 11:08:02 +02:00
parent acc9108ffb
commit 6d970281a4
2 changed files with 26 additions and 18 deletions

View File

@ -5,8 +5,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import org.gcube.common.scope.api.ScopeProvider; 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.ResourceRegistryClient;
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory; 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.CacheList;
import org.gcube.portlets.admin.resourcemanagement.shared.resource.UtilityResource; import org.gcube.portlets.admin.resourcemanagement.shared.resource.UtilityResource;
import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator; import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator;
@ -36,15 +38,15 @@ public class RegistryClientRequester {
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
try { try {
List<TypeDefinition> typeDefinitions = resourceRegistryClient.getSchema(Resource.class, true); List<Type> types = resourceRegistryClient.getType(Resource.class, true);
for (TypeDefinition td : typeDefinitions) { for (Type t : types) {
if (td.getName().equals("EService")) if (t.getName().equals("EService"))
retval.put("RunningInstance", UtilityResource.getSubResourcesTreeQuery(td.getName(),scope)); retval.put("RunningInstance", UtilityResource.getSubResourcesTreeQuery(t.getName(),scope));
if (td.getName().equals("Configuration")) if (t.getName().equals("Configuration"))
retval.put("GenericResource", UtilityResource.getSubResourcesTreeQuery(td.getName(),scope)); retval.put("GenericResource", UtilityResource.getSubResourcesTreeQuery(t.getName(),scope));
if (td.getName().equals("HostingNode")) if (t.getName().equals("HostingNode"))
retval.put("GHN", UtilityResource.getSubResourcesTreeQuery(td.getName(),scope)); retval.put("GHN", UtilityResource.getSubResourcesTreeQuery(t.getName(),scope));
} }

View File

@ -14,6 +14,7 @@ import org.gcube.informationsystem.model.reference.entities.Resource;
import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient; import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory; 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.AccessPointFacet;
import org.gcube.resourcemanagement.model.reference.entities.facets.MemoryFacet; import org.gcube.resourcemanagement.model.reference.entities.facets.MemoryFacet;
import org.gcube.resourcemanagement.model.reference.entities.facets.NetworkingFacet; 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.entities.resources.HostingNode;
import org.gcube.resourcemanagement.model.reference.relations.consistsof.HasPersistentMemory; 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.HasVolatileMemory;
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
import com.google.gwt.thirdparty.json.JSONArray; import com.google.gwt.thirdparty.json.JSONArray;
import com.google.gwt.thirdparty.json.JSONObject; import com.google.gwt.thirdparty.json.JSONObject;
@ -42,12 +44,16 @@ public class UtilityResource {
public static ArrayList<String> getSubResourcesTree(String entity, String scope) throws Exception{ public static ArrayList<String> getSubResourcesTree(String entity, String scope) throws Exception{
ArrayList<String> list = new ArrayList<>(); ArrayList<String> list = new ArrayList<>();
List<Resource> resources = (List<Resource>) resourceRegistryClient.getInstances(entity, true); String s = resourceRegistryClient.getInstances(entity, true);
for (Resource et : resources) { List<Resource> resources = ElementMapper.unmarshalList(Resource.class, s);
List<? extends Facet> facets = et.getIdentificationFacets();
for (Facet f : facets) { for (Resource r : resources) {
List<? extends IsIdentifiedBy> iibs = r.getConsistsOf(IsIdentifiedBy.class);
for (IsIdentifiedBy iib : iibs) {
Facet f = (Facet) iib.getTarget();
switch (entity) { switch (entity) {
/* /*
case "Software": case "Software":
@ -352,7 +358,7 @@ public class UtilityResource {
String status=""; String status="";
String ghnName=""; String ghnName="";
List<EService> eservices = (List<EService>) resourceRegistryClient.getInstances(EService.NAME,false); List<EService> eservices = (List<EService>) resourceRegistryClient.getInstances(EService.class,false);
for (EService et : eservices) { for (EService et : eservices) {
id=et.getHeader().getUUID().toString(); id=et.getHeader().getUUID().toString();
List<? extends Facet> facets = et.getIdentificationFacets(); List<? extends Facet> facets = et.getIdentificationFacets();
@ -382,8 +388,8 @@ public class UtilityResource {
ghnName=""; ghnName="";
} }
} }
if (c.getTarget() instanceof ServiceStateFacet){ if (c.getTarget() instanceof StateFacet){
ServiceStateFacet stf = (ServiceStateFacet) c.getTarget(); StateFacet stf = (StateFacet) c.getTarget();
try { try {
status=stf.getValue().toLowerCase(); status=stf.getValue().toLowerCase();
} }
@ -436,7 +442,7 @@ public class UtilityResource {
String subType=""; String subType="";
String name=""; String name="";
String description=""; String description="";
List<Configuration> econfiguration = (List<Configuration>) resourceRegistryClient.getInstances(Configuration.NAME,false); List<Configuration> econfiguration = (List<Configuration>) resourceRegistryClient.getInstances(Configuration.class,false);
for (Configuration et : econfiguration) { for (Configuration et : econfiguration) {
id=et.getHeader().getUUID().toString(); id=et.getHeader().getUUID().toString();
List<? extends Facet> facets = et.getIdentificationFacets(); List<? extends Facet> facets = et.getIdentificationFacets();
@ -505,7 +511,7 @@ public class UtilityResource {
String gcfVersion=""; String gcfVersion="";
String ghnVersion=""; String ghnVersion="";
List<HostingNode> ehosting = (List<HostingNode>) resourceRegistryClient.getInstances(HostingNode.NAME,false); List<HostingNode> ehosting = (List<HostingNode>) resourceRegistryClient.getInstances(HostingNode.class,false);
for (HostingNode eh : ehosting) { for (HostingNode eh : ehosting) {
id=eh.getHeader().getUUID().toString(); id=eh.getHeader().getUUID().toString();
lastUpdate=eh.getHeader().getLastUpdateTime().toString(); lastUpdate=eh.getHeader().getLastUpdateTime().toString();