Added JSONPath-based logic to get DTOs for EServices and HostingNodes.
Tables completed.
This commit is contained in:
parent
69272233a7
commit
d2cbfae119
14
pom.xml
14
pom.xml
|
@ -142,12 +142,6 @@
|
|||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!--jsonpath-->
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -301,6 +295,14 @@
|
|||
<artifactId>authorization-utils</artifactId>
|
||||
<version>[2.1.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<!--jsonpath-->
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -92,6 +92,7 @@ public class InformationSystemService {
|
|||
List<Resource> 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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<Context> 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<String> resourceTypes2(@RequestParam String currentContext) {
|
||||
log.debug("Request resource types");
|
||||
|
||||
try {
|
||||
informationSystemService.setUma(createUmaToken(currentContext));
|
||||
List<Type> 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<String> resourceTypes(@RequestParam @Nullable String currentContext) {
|
||||
log.debug("Request resource types");
|
||||
|
@ -151,149 +127,24 @@ public class InformationSystemResource {
|
|||
@GetMapping("/resourceinstances")
|
||||
public ResponseEntity<String> 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<Resource> resourceImpls = new ArrayList<Resource>();
|
||||
ArrayList resultDtos = new ArrayList<>();
|
||||
|
||||
try {
|
||||
informationSystemService.setUma(createUmaToken(currentContext));
|
||||
resourceImpls = informationSystemService.getResourceInstances(resourceType);
|
||||
Iterator<Resource> 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<String, Object> 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);
|
||||
|
|
|
@ -17,7 +17,13 @@
|
|||
</rollingPolicy>
|
||||
<encoder>
|
||||
<charset>utf-8</charset>
|
||||
<Pattern>%d %-5level [%thread] %logger{0}: %msg%n</Pattern>
|
||||
<Pattern>${FILE_LOG_PATTERN}</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
@ -27,8 +33,7 @@
|
|||
</appender>
|
||||
|
||||
<root level="${logging.level.root}">
|
||||
<appender-ref ref="ASYNC"/>
|
||||
<appender-ref ref="FILE"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
<logger name="org.springframework" level="WARN"/>
|
||||
|
@ -40,8 +45,13 @@
|
|||
<!-- See https://github.com/jhipster/generator-jhipster/issues/14444 -->
|
||||
<logger name="_org.springframework.web.servlet.HandlerMapping.Mappings" level="WARN"/>
|
||||
<!-- jhipster-needle-logback-add-log - JHipster will add a new log with level -->
|
||||
|
||||
|
||||
<!-- mt: added for debugging purposes-->
|
||||
<logger name="org.gcube.fullstackapps.informationsystemmonitor.service" level="DEBUG"/>
|
||||
<logger name="org.gcube.fullstackapps.informationsystemmonitor" level="DEBUG">
|
||||
<appender-ref ref="ASYNC"/>
|
||||
</logger>
|
||||
|
||||
|
||||
|
||||
<!-- https://logback.qos.ch/manual/configuration.html#shutdownHook and https://jira.qos.ch/browse/LOGBACK-1090 -->
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -60,7 +60,10 @@
|
|||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<!--
|
||||
<jhi-table-screen></jhi-table-screen>
|
||||
-->
|
||||
<jhi-table-screen-es></jhi-table-screen-es>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -22,19 +22,19 @@
|
|||
<td mat-cell *matCellDef="let item">{{ item.status }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="lastmod">
|
||||
<ng-container matColumnDef="lastMod">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header>Last Modified</th>
|
||||
<td mat-cell *matCellDef="let item">{{ item.lastmod }}</td>
|
||||
<td mat-cell *matCellDef="let item">{{ item.lastMod }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="memavailable">
|
||||
<ng-container matColumnDef="avMemory">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>Available Memory</th>
|
||||
<td mat-cell *matCellDef="let item">{{ item.memavailable }}</td>
|
||||
<td mat-cell *matCellDef="let item">{{ item.avMemory }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="hdspace">
|
||||
<ng-container matColumnDef="hdSpace">
|
||||
<th mat-header-cell *matHeaderCellDef mat-sort-header disabled>HD Space</th>
|
||||
<td mat-cell *matCellDef="let item">{{ item.hdspace }}</td>
|
||||
<td mat-cell *matCellDef="let item">{{ item.hdSpace }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="actions">
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue