diff --git a/pom.xml b/pom.xml index 5f89254..810e03a 100644 --- a/pom.xml +++ b/pom.xml @@ -142,12 +142,6 @@ pom import - - - com.jayway.jsonpath - json-path - 2.4.0 - @@ -301,6 +295,14 @@ authorization-utils [2.1.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + com.jayway.jsonpath + json-path + 2.4.0 + + + diff --git a/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/InformationSystemService.java b/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/InformationSystemService.java index d4514d0..1a1bac5 100644 --- a/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/InformationSystemService.java +++ b/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/InformationSystemService.java @@ -92,6 +92,7 @@ public class InformationSystemService { List instancesAsObject; log.debug("getResourceInstances : [currentCtx=]",currentCtx); ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx); + resourceRegistryClient.setIncludeMeta(true); String instances = resourceRegistryClient.getInstances(resourceType, false); instancesAsObject = ElementMapper.unmarshalList(Resource.class, instances); return instancesAsObject; diff --git a/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/dto/EServiceDTO.java b/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/dto/EServiceDTO.java index a5e3f1b..3c9d1fe 100644 --- a/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/dto/EServiceDTO.java +++ b/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/dto/EServiceDTO.java @@ -10,9 +10,11 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class EServiceDTO { private String id; + private String lastMod; private String name; - private String classe; + private String artifact; private String version; + private String group; private String status; private String endpoint; } diff --git a/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/dto/HostingNodeDTO.java b/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/dto/HostingNodeDTO.java index 4d5db22..409d1f6 100644 --- a/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/dto/HostingNodeDTO.java +++ b/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/service/dto/HostingNodeDTO.java @@ -10,9 +10,9 @@ import lombok.NoArgsConstructor; @NoArgsConstructor public class HostingNodeDTO { private String id; + private String lastMod; private String name; private String status; - private String lastMod; private String avMemory; private String hdSpace; } diff --git a/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/web/rest/InformationSystemResource.java b/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/web/rest/InformationSystemResource.java index 0482f4a..988fa9c 100644 --- a/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/web/rest/InformationSystemResource.java +++ b/src/main/java/org/gcube/fullstackapps/informationsystemmonitor/web/rest/InformationSystemResource.java @@ -49,7 +49,7 @@ import tech.jhipster.web.util.HeaderUtil; @RequiredArgsConstructor public class InformationSystemResource { - private final Logger log = LoggerFactory.getLogger(InformationSystemResource.class); + private static final Logger log = LoggerFactory.getLogger(InformationSystemResource.class); @Value("${jhipster.clientApp.name}") private String applicationName; @@ -71,11 +71,6 @@ public class InformationSystemResource { try { informationSystemService.setUma(createUmaToken(currentContext)); List contexts = informationSystemService.getAllContext(currentContext); - /* - for(Context c : contexts) { - c.getID(); - c.getName(); - }*/ String sc = ElementMapper.marshal(contexts); return ResponseEntity.ok().body(sc); } catch (Exception e) { @@ -86,25 +81,6 @@ public class InformationSystemResource { } - /* - @GetMapping("/resourcetypes") - public ResponseEntity resourceTypes2(@RequestParam String currentContext) { - log.debug("Request resource types"); - - try { - informationSystemService.setUma(createUmaToken(currentContext)); - List resTypes = informationSystemService.getResourceTypes(); - String sc = ElementMapper.marshal(resTypes); - return ResponseEntity.ok().body(sc); - } catch (Exception e) { - log.error(e.getLocalizedMessage(), e); - return ResponseEntity.noContent() - .headers(HeaderUtil.createAlert(applicationName, e.getLocalizedMessage(), "")).build(); - } - } - */ - - @GetMapping("/resourcetypes") public ResponseEntity resourceTypes(@RequestParam @Nullable String currentContext) { log.debug("Request resource types"); @@ -151,149 +127,24 @@ public class InformationSystemResource { @GetMapping("/resourceinstances") public ResponseEntity resourceInstances(@RequestParam @Nullable String currentContext, @RequestParam String resourceType) { log.debug("Request resource instances"); - - ArrayList resultDtos = new ArrayList<>(); + DTOResourceBuilder dtoBuilder = new DTOResourceBuilder(resourceType); //String instancesAsJson = ""; List resourceImpls = new ArrayList(); + ArrayList resultDtos = new ArrayList<>(); + try { informationSystemService.setUma(createUmaToken(currentContext)); resourceImpls = informationSystemService.getResourceInstances(resourceType); - Iterator it = resourceImpls.iterator(); - while (it.hasNext()) { - Resource curr = it.next(); - - + for(Resource resImpl: resourceImpls) { + String jsonResource = ElementMapper.marshal(resImpl); + dtoBuilder.setJson(jsonResource); + resultDtos.add(dtoBuilder.build()); } }catch(Exception e) { - + log.error("ERROR WHILE FILLING RESOURCEIMPL DTO"); e.printStackTrace(); } - - try { - - String instancesAsJson = ElementMapper.marshal(resourceImpls); - - ArrayNode arrayNode = (ArrayNode) ElementMapper.getObjectMapper().readTree(instancesAsJson); - for(JsonNode node : arrayNode) { - String id = node.get(ConsistsOf.ID_PROPERTY).asText(); - Map resProperties = new HashMap<>(); - - ArrayNode consistsOfArray = (ArrayNode) node.get(Resource.CONSISTS_OF_PROPERTY); - for(JsonNode consistOfNode : consistsOfArray) { - - JsonNode targetFacetNode = consistOfNode.get(ConsistsOf.TARGET_PROPERTY); - String campoErrore = ""; - //TODO: per ogni nodo, aprire i sottonodi: consistsOf (vedere type)-> target (vedere type) -> attributi - switch (resourceType) { - - case Constants.RES_TYPE_HOSTINGNODE: - - HostingNodeDTO hnDto = new HostingNodeDTO(); - - hnDto.setId(id); - - try { - - /* - ID - $.id - - DOMAINNAME, HOSTNAME, ecc. - $..consistsOf[?(@.target)][?(@.expectedtype=='NetworkingFacet')].[domainName,hostName] - OPPURE: - $..consistsOf[?(@.expectedtype=='IsIdentifiedBy')][?(@.expectedtype=='NetworkingFacet')].[domainName,hostName] - - DATI MEMORIA - $..consistsOf[?(@.type=='ConsistsOf' && @.expectedtype=="HasPersistentMemory" )].target.[expectedtype,unit,size,used] - - STATUS - $..consistsOf[?(@.target)][?(@.expectedtype=='StateFacet')].[value] - - HD SPACE - $..consistsOf[?(@.expectedtype=='HasVolatileMemory')].target.[size,unit] - - - LAST UPDATED - $..consistsOf[?(@.target)][?(@.expectedtype=='EventFacet')].[(@.length-1)] - - - */ - - - /* - campoErrore = "lastUpdateTime"; - String lastUpdateTime = node.get(Resource.METADATA_PROPERTY).get(Metadata.LAST_UPDATE_TIME_PROPERTY).asText(); - //resProperties.put("Last Modified", lastUpdateTime); - hnDto.setLastMod(lastUpdateTime); - */ - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_ID_BY) && isInstanceOf(targetFacetNode, Constants.FACET_NETWORKING)) { - //resProperties.put("NH_name", targetFacetNode.get("hostName").asText()); - hnDto.setName(targetFacetNode.get("hostName").asText()); - campoErrore = "hostName"; - } - - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_CONS_OF) && isInstanceOf(targetFacetNode, Constants.FACET_STATE)) { - //resProperties.put("NH_status", targetFacetNode.get("value").asText()); - hnDto.setStatus(targetFacetNode.get("value").asText()); - campoErrore = "status"; - } - - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_VOL_MEM) && isInstanceOf(targetFacetNode, Constants.FACET_MEMORY)) { - String availableMemory = targetFacetNode.get("size").asText(); - //resProperties.put("NH_avMemory", availableMemory); - hnDto.setAvMemory(availableMemory); - campoErrore = "av memory"; - - } - - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_PERS_MEM) && isInstanceOf(targetFacetNode, Constants.FACET_MEMORY)) { - String diskSpace = targetFacetNode.get("size").asText(); - hnDto.setHdSpace(diskSpace); - campoErrore = "hd space"; - } - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - log.error("campoErrore......."+campoErrore); - } - - resultDtos.add(hnDto); - - break; - - case Constants.RES_TYPE_ESERVICE: - - EServiceDTO esDto = new EServiceDTO(); - - esDto.setId(id); - - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_CONS_OF) && isInstanceOf(targetFacetNode, Constants.FACET_SOFTWARE)) { - resProperties.put("ES_class", targetFacetNode.get("group").asText()); - } - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_CONS_OF) && isInstanceOf(targetFacetNode, Constants.FACET_SOFTWARE)) { - resProperties.put("ES_name", targetFacetNode.get("name").asText()); - } - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_CONS_OF) && isInstanceOf(targetFacetNode, Constants.FACET_SOFTWARE)) { - resProperties.put("ES_version", targetFacetNode.get("version").asText()); - } - //status - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_CONS_OF) && isInstanceOf(targetFacetNode, Constants.FACET_STATE)) { - resProperties.put("ES_status", targetFacetNode.get("value").asText()); - } - //endpoint - if(isInstanceOf(consistOfNode, Constants.INSTOF_TYPE_CONS_OF) && isInstanceOf(targetFacetNode, Constants.FACET_ACCESSPOINT)) { - resProperties.put("ES_endpoint", targetFacetNode.get("endpoint").asText()); - } - resultDtos.add(esDto); - break; - - default: - break; - } - - } - } ObjectMapper objectMapper = new ObjectMapper(); String sc = objectMapper.writeValueAsString(resultDtos); return ResponseEntity.ok().body(sc); diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 3f442ec..e4f68ac 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -17,7 +17,13 @@ utf-8 - %d %-5level [%thread] %logger{0}: %msg%n + ${FILE_LOG_PATTERN} + + + + + + ${CONSOLE_LOG_PATTERN} @@ -27,8 +33,7 @@ - - + @@ -40,8 +45,13 @@ + + - + + + + diff --git a/src/main/webapp/app/app.module.ts b/src/main/webapp/app/app.module.ts index 7f94ea1..30253a5 100644 --- a/src/main/webapp/app/app.module.ts +++ b/src/main/webapp/app/app.module.ts @@ -29,7 +29,6 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { RawjsonPaneComponent } from './rawjson-pane/rawjson-pane.component'; import { ClipboardModule } from '@angular/cdk/clipboard'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { TableScreenComponent } from './table-screen/table-screen.component'; @NgModule({ imports: [ diff --git a/src/main/webapp/app/home/home.component.html b/src/main/webapp/app/home/home.component.html index 88ef40e..eb2a2e7 100644 --- a/src/main/webapp/app/home/home.component.html +++ b/src/main/webapp/app/home/home.component.html @@ -60,7 +60,10 @@ + + diff --git a/src/main/webapp/app/home/home.module.ts b/src/main/webapp/app/home/home.module.ts index eb34b9c..feebd39 100644 --- a/src/main/webapp/app/home/home.module.ts +++ b/src/main/webapp/app/home/home.module.ts @@ -12,6 +12,7 @@ import { MatTabsModule } from '@angular/material/tabs'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { MatSelectFilterModule } from 'mat-select-filter'; import { TableScreenModule } from 'app/table-screen/table-screen.module'; +import { TableScreenEsModule } from 'app/table-screen-es/table-screen-es.module'; @NgModule({ imports: [SharedModule, @@ -23,7 +24,8 @@ import { TableScreenModule } from 'app/table-screen/table-screen.module'; MatTabsModule, BrowserAnimationsModule, MatSelectFilterModule, - TableScreenModule + TableScreenModule, + TableScreenEsModule ], declarations: [HomeComponent], schemas:[CUSTOM_ELEMENTS_SCHEMA] diff --git a/src/main/webapp/app/services/i-e-service.ts b/src/main/webapp/app/services/i-e-service.ts index a54d467..18ba961 100644 --- a/src/main/webapp/app/services/i-e-service.ts +++ b/src/main/webapp/app/services/i-e-service.ts @@ -1,8 +1,11 @@ export interface IEService { - name: string; id: string; - classe: string; + lastMod: string; + name: string; + artifact: string; version: string; + group: string status: string; endpoint: string; -} + +} \ No newline at end of file diff --git a/src/main/webapp/app/services/i-hosting-node.ts b/src/main/webapp/app/services/i-hosting-node.ts index 635c0b6..bd147ec 100644 --- a/src/main/webapp/app/services/i-hosting-node.ts +++ b/src/main/webapp/app/services/i-hosting-node.ts @@ -3,7 +3,7 @@ export interface IHostingNode { name: string; id: string; status: string; - lastmod: string; - memavailable: string; - hdspace: string; + lastMod: string; + avMemory: string; + hdSpace: string; } diff --git a/src/main/webapp/app/table-screen/table-screen.component.html b/src/main/webapp/app/table-screen/table-screen.component.html index 33acb6c..79c9f12 100644 --- a/src/main/webapp/app/table-screen/table-screen.component.html +++ b/src/main/webapp/app/table-screen/table-screen.component.html @@ -22,19 +22,19 @@ {{ item.status }} - + Last Modified - {{ item.lastmod }} + {{ item.lastMod }} - + Available Memory - {{ item.memavailable }} + {{ item.avMemory }} - + HD Space - {{ item.hdspace }} + {{ item.hdSpace }} diff --git a/src/main/webapp/app/table-screen/table-screen.component.ts b/src/main/webapp/app/table-screen/table-screen.component.ts index 0972ffb..e167697 100644 --- a/src/main/webapp/app/table-screen/table-screen.component.ts +++ b/src/main/webapp/app/table-screen/table-screen.component.ts @@ -31,7 +31,7 @@ import { ResourcesImplService } from 'app/services/resources-impl.service'; export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges { //NB 'actions' CI DEVE ESSERE, altrimenti la tabella non viene visualizzata - displayedColumns: string[] = ['name', 'id', 'status', 'lastmod', 'memavailable', 'hdspace', 'actions']; + displayedColumns: string[] = ['name', 'id', 'status', 'lastMod', 'avMemory', 'hdSpace', 'actions']; dataFromService: IHostingNode[]; dataSource = new MatTableDataSource(); tableDetail: IHostingNode;