adding logic and GUIs for creation and removal of other types
This commit is contained in:
parent
2b93619117
commit
1a27b8a43e
|
@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
|
import com.jayway.jsonpath.internal.filter.ValueNode.JsonNode;
|
||||||
import com.nimbusds.jose.shaded.json.JSONUtil;
|
import com.nimbusds.jose.shaded.json.JSONUtil;
|
||||||
|
|
||||||
import net.minidev.json.JSONArray;
|
import net.minidev.json.JSONArray;
|
||||||
|
@ -402,7 +403,10 @@ public class InformationSystemService {
|
||||||
public void createResourceInstance(String jsonDescription) throws Exception {
|
public void createResourceInstance(String jsonDescription) throws Exception {
|
||||||
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||||
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create(currentCtx);
|
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create(currentCtx);
|
||||||
publisher.createResource(jsonDescription);
|
String res = publisher.createResource(jsonDescription);
|
||||||
|
System.out.println("*************RES*********");
|
||||||
|
System.out.println(res);
|
||||||
|
System.out.println("**********************");
|
||||||
}
|
}
|
||||||
|
|
||||||
//CRUD - 2
|
//CRUD - 2
|
||||||
|
|
|
@ -8,10 +8,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class EServiceDTO {
|
public class EServiceDTO extends ResourceImplDTO{
|
||||||
private String id;
|
|
||||||
private String lastMod;
|
|
||||||
private String name;
|
|
||||||
private String artifact;
|
private String artifact;
|
||||||
private String version;
|
private String version;
|
||||||
private String group;
|
private String group;
|
||||||
|
|
|
@ -8,10 +8,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class HostingNodeDTO {
|
public class HostingNodeDTO extends ResourceImplDTO{
|
||||||
private String id;
|
|
||||||
private String lastMod;
|
|
||||||
private String name;
|
|
||||||
private String status;
|
private String status;
|
||||||
private String avMemory;
|
private String avMemory;
|
||||||
private String hdSpace;
|
private String hdSpace;
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.gcube.informationsystem.service.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class ResourceImplDTO {
|
||||||
|
private String id;
|
||||||
|
private String lastMod;
|
||||||
|
private String name;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.gcube.informationsystem.service.dto;
|
||||||
|
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class VirtualMachineDTO extends ResourceImplDTO{
|
||||||
|
private String group;
|
||||||
|
private String version;
|
||||||
|
}
|
|
@ -8,10 +8,7 @@ import lombok.NoArgsConstructor;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class VirtualServiceDTO {
|
public class VirtualServiceDTO extends ResourceImplDTO{
|
||||||
private String id;
|
|
||||||
private String lastMod;
|
|
||||||
private String name;
|
|
||||||
private String group;
|
private String group;
|
||||||
private String version;
|
private String version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package org.gcube.informationsystem.service.dto.angular;
|
|
||||||
|
|
||||||
class ExtraProps{
|
|
||||||
String prop_deno;
|
|
||||||
public String getProp_deno() {
|
|
||||||
return prop_deno;
|
|
||||||
}
|
|
||||||
public void setProp_deno(String prop_deno) {
|
|
||||||
this.prop_deno = prop_deno;
|
|
||||||
}
|
|
||||||
public String getProp_val() {
|
|
||||||
return prop_val;
|
|
||||||
}
|
|
||||||
public void setProp_val(String prop_val) {
|
|
||||||
this.prop_val = prop_val;
|
|
||||||
}
|
|
||||||
public String getProp_tipo() {
|
|
||||||
return prop_tipo;
|
|
||||||
}
|
|
||||||
public void setProp_tipo(String prop_tipo) {
|
|
||||||
this.prop_tipo = prop_tipo;
|
|
||||||
}
|
|
||||||
String prop_val;
|
|
||||||
String prop_tipo;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,119 +0,0 @@
|
||||||
package org.gcube.informationsystem.service.dto.angular;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
|
|
||||||
public class VirtualServiceAngular{
|
|
||||||
String typeName;
|
|
||||||
ArrayList<FacetDescription> facets;
|
|
||||||
public String getTypeName() {
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
public void setTypeName(String typeName) {
|
|
||||||
this.typeName = typeName;
|
|
||||||
}
|
|
||||||
public ArrayList<FacetDescription> getFacets() {
|
|
||||||
return facets;
|
|
||||||
}
|
|
||||||
public void setFacets(ArrayList<FacetDescription> facets) {
|
|
||||||
this.facets = facets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FacetDescription{
|
|
||||||
//da elminare - begin
|
|
||||||
String facetName;
|
|
||||||
String max;
|
|
||||||
String min;
|
|
||||||
String facetDescription;
|
|
||||||
String relationFacet;
|
|
||||||
boolean isAdded;
|
|
||||||
boolean prop_optional;
|
|
||||||
//da elminare - end
|
|
||||||
String prop_name;
|
|
||||||
String prop_group;
|
|
||||||
String prop_description;
|
|
||||||
String prop_version;
|
|
||||||
String prop_qualifier;
|
|
||||||
ArrayList<ExtraProps> extraProps;
|
|
||||||
|
|
||||||
public String getFacetName() {
|
|
||||||
return facetName;
|
|
||||||
}
|
|
||||||
public void setFacetName(String facetName) {
|
|
||||||
this.facetName = facetName;
|
|
||||||
}
|
|
||||||
public String getMax() {
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
public void setMax(String max) {
|
|
||||||
this.max = max;
|
|
||||||
}
|
|
||||||
public String getMin() {
|
|
||||||
return min;
|
|
||||||
}
|
|
||||||
public void setMin(String min) {
|
|
||||||
this.min = min;
|
|
||||||
}
|
|
||||||
public String getFacetDescription() {
|
|
||||||
return facetDescription;
|
|
||||||
}
|
|
||||||
public void setFacetDescription(String facetDescription) {
|
|
||||||
this.facetDescription = facetDescription;
|
|
||||||
}
|
|
||||||
public String getRelationFacet() {
|
|
||||||
return relationFacet;
|
|
||||||
}
|
|
||||||
public void setRelationFacet(String relationFacet) {
|
|
||||||
this.relationFacet = relationFacet;
|
|
||||||
}
|
|
||||||
public boolean isAdded() {
|
|
||||||
return isAdded;
|
|
||||||
}
|
|
||||||
public void setAdded(boolean isAdded) {
|
|
||||||
this.isAdded = isAdded;
|
|
||||||
}
|
|
||||||
public boolean isProp_optional() {
|
|
||||||
return prop_optional;
|
|
||||||
}
|
|
||||||
public void setProp_optional(boolean prop_optional) {
|
|
||||||
this.prop_optional = prop_optional;
|
|
||||||
}
|
|
||||||
public String getProp_name() {
|
|
||||||
return prop_name;
|
|
||||||
}
|
|
||||||
public void setProp_name(String prop_name) {
|
|
||||||
this.prop_name = prop_name;
|
|
||||||
}
|
|
||||||
public String getProp_group() {
|
|
||||||
return prop_group;
|
|
||||||
}
|
|
||||||
public void setProp_group(String prop_group) {
|
|
||||||
this.prop_group = prop_group;
|
|
||||||
}
|
|
||||||
public String getProp_description() {
|
|
||||||
return prop_description;
|
|
||||||
}
|
|
||||||
public void setProp_description(String prop_description) {
|
|
||||||
this.prop_description = prop_description;
|
|
||||||
}
|
|
||||||
public String getProp_version() {
|
|
||||||
return prop_version;
|
|
||||||
}
|
|
||||||
public void setProp_version(String prop_version) {
|
|
||||||
this.prop_version = prop_version;
|
|
||||||
}
|
|
||||||
public String getProp_qualifier() {
|
|
||||||
return prop_qualifier;
|
|
||||||
}
|
|
||||||
public void setProp_qualifier(String prop_qualifier) {
|
|
||||||
this.prop_qualifier = prop_qualifier;
|
|
||||||
}
|
|
||||||
public ArrayList<ExtraProps> getExtraProps() {
|
|
||||||
return extraProps;
|
|
||||||
}
|
|
||||||
public void setExtraProps(ArrayList<ExtraProps> extraProps) {
|
|
||||||
this.extraProps = extraProps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ public final class Constants {
|
||||||
public static final String RES_TYPE_HOSTINGNODE = "HostingNode";
|
public static final String RES_TYPE_HOSTINGNODE = "HostingNode";
|
||||||
public static final String RES_TYPE_ESERVICE = "EService";
|
public static final String RES_TYPE_ESERVICE = "EService";
|
||||||
public static final String RES_TYPE_VSERVICE = "VirtualService";
|
public static final String RES_TYPE_VSERVICE = "VirtualService";
|
||||||
|
public static final String RES_TYPE_VMACHINE = "VirtualMachine";
|
||||||
|
|
||||||
|
|
||||||
public static final String FACET_NETWORKING = "NetworkingFacet";
|
public static final String FACET_NETWORKING = "NetworkingFacet";
|
||||||
|
|
|
@ -33,15 +33,15 @@ public class DTOResourceBuilder {
|
||||||
//private static String
|
//private static String
|
||||||
|
|
||||||
//hostingNodes JSONPath queries
|
//hostingNodes JSONPath queries
|
||||||
private static String HN_DOMAIN_HOST_QUERY = "$..consistsOf[?(@.expectedtype=='IsIdentifiedBy')]['target'][?(@.['expectedtype']=='NetworkingFacet')].['domainName','hostName']";
|
private static String NETWORKINGFACET_QUERY_DOMAIN = "$..consistsOf[?(@.expectedtype=='IsIdentifiedBy')]['target'][?(@.['expectedtype']=='NetworkingFacet')].['domainName','hostName']";
|
||||||
private static String HN_MEMORY_QUERY = "$..consistsOf[?(@.['type']=='ConsistsOf' && @.['expectedtype']=='HasPersistentMemory')].['target'].['expectedtype','unit','size','used']";
|
private static String PERS_MEMORY_QUERY = "$..consistsOf[?(@.['type']=='ConsistsOf' && @.['expectedtype']=='HasPersistentMemory')].['target'].['expectedtype','unit','size','used']";
|
||||||
private static String HN_STATUS_QUERY = "$..consistsOf[?(@.['target'])]*[?(@.['expectedtype']=='StateFacet')].['value']";
|
private static String STATEFACET_QUERY_STATUS = "$..consistsOf[?(@.['target'])]*[?(@.['expectedtype']=='StateFacet')].['value']";
|
||||||
private static String HN_VOL_MEMORY_QUERY = "$..consistsOf[?(@.['expectedtype']=='HasVolatileMemory')].['target'].['size','unit']";
|
private static String VOLATILE_MEMORY_QUERY = "$..consistsOf[?(@.['expectedtype']=='HasVolatileMemory')].['target'].['size','unit']";
|
||||||
|
|
||||||
//EService
|
//EService
|
||||||
private static String ES_ENDPOINT_QUERY = "$..consistsOf[*]['target'][?(@.['expectedtype']=='AccessPointFacet')].['endpoint','entryName']";
|
private static String ACCESSPOINTFACET_QUERY_ENDPOINT = "$..consistsOf[*]['target'][?(@.['expectedtype']=='AccessPointFacet')].['endpoint','entryName']";
|
||||||
private static String ES_STATUS_QUERY = "$..consistsOf[*]['target'][?(@.['expectedtype']=='StateFacet')].['value']";
|
private static String STATEFACET_QUERY_VALUE = "$..consistsOf[*]['target'][?(@.['expectedtype']=='StateFacet')].['value']";
|
||||||
private static String ES_NGV_QUERY = "$..consistsOf[*]['target'][?(@.['expectedtype']=='SoftwareFacet')].['name','group','version']";
|
private static String SOFTWAREFACET_QUERY_NAME = "$..consistsOf[*]['target'][?(@.['expectedtype']=='SoftwareFacet')].['name','group','version']";
|
||||||
|
|
||||||
//VirtualService
|
//VirtualService
|
||||||
/*
|
/*
|
||||||
|
@ -81,15 +81,15 @@ public class DTOResourceBuilder {
|
||||||
((HostingNodeDTO) dto).setLastMod(lastUpd);
|
((HostingNodeDTO) dto).setLastMod(lastUpd);
|
||||||
log.debug("2..."+lastUpd);
|
log.debug("2..."+lastUpd);
|
||||||
|
|
||||||
myLeaves = JsonPath.parse(resJson).read(HN_DOMAIN_HOST_QUERY);
|
myLeaves = JsonPath.parse(resJson).read(NETWORKINGFACET_QUERY_DOMAIN);
|
||||||
((HostingNodeDTO) dto).setName(myLeaves.get(0).get("hostName").toString());
|
((HostingNodeDTO) dto).setName(myLeaves.get(0).get("hostName").toString());
|
||||||
log.debug("3..." + myLeaves.get(0).get("hostName").toString());
|
log.debug("3..." + myLeaves.get(0).get("hostName").toString());
|
||||||
|
|
||||||
myLeaves = JsonPath.parse(resJson).read(HN_MEMORY_QUERY);
|
myLeaves = JsonPath.parse(resJson).read(PERS_MEMORY_QUERY);
|
||||||
((HostingNodeDTO) dto).setAvMemory(myLeaves.get(0).get("size").toString()+" "+myLeaves.get(0).get("unit").toString());
|
((HostingNodeDTO) dto).setAvMemory(myLeaves.get(0).get("size").toString()+" "+myLeaves.get(0).get("unit").toString());
|
||||||
log.debug("4..."+myLeaves.get(0).get("size").toString()+" "+myLeaves.get(0).get("unit").toString());
|
log.debug("4..."+myLeaves.get(0).get("size").toString()+" "+myLeaves.get(0).get("unit").toString());
|
||||||
Object status = null;
|
Object status = null;
|
||||||
status = JsonPath.parse(resJson).read(HN_STATUS_QUERY);
|
status = JsonPath.parse(resJson).read(STATEFACET_QUERY_STATUS);
|
||||||
status = status.toString().replace("[\"", "").replace("\"]", "");
|
status = status.toString().replace("[\"", "").replace("\"]", "");
|
||||||
log.debug("5..."+status);
|
log.debug("5..."+status);
|
||||||
((HostingNodeDTO) dto).setStatus(status.toString());
|
((HostingNodeDTO) dto).setStatus(status.toString());
|
||||||
|
@ -98,7 +98,7 @@ public class DTOResourceBuilder {
|
||||||
log.error("Error while building HostingNodeDTO from json");
|
log.error("Error while building HostingNodeDTO from json");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
myLeaves = JsonPath.parse(resJson).read(HN_VOL_MEMORY_QUERY);
|
myLeaves = JsonPath.parse(resJson).read(VOLATILE_MEMORY_QUERY);
|
||||||
((HostingNodeDTO) dto).setHdSpace(myLeaves.get(0).get("size").toString()+" "+myLeaves.get(0).get("unit").toString());
|
((HostingNodeDTO) dto).setHdSpace(myLeaves.get(0).get("size").toString()+" "+myLeaves.get(0).get("unit").toString());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -115,7 +115,7 @@ public class DTOResourceBuilder {
|
||||||
((EServiceDTO) dto).setLastMod(lastUpd);
|
((EServiceDTO) dto).setLastMod(lastUpd);
|
||||||
log.debug("2..."+lastUpd);
|
log.debug("2..."+lastUpd);
|
||||||
|
|
||||||
myLeaves= JsonPath.parse(resJson).read(ES_ENDPOINT_QUERY);
|
myLeaves= JsonPath.parse(resJson).read(ACCESSPOINTFACET_QUERY_ENDPOINT);
|
||||||
String ep = myLeaves.get(0).get("endpoint").toString();
|
String ep = myLeaves.get(0).get("endpoint").toString();
|
||||||
String en = myLeaves.get(0).get("entryName").toString();
|
String en = myLeaves.get(0).get("entryName").toString();
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class DTOResourceBuilder {
|
||||||
log.debug("3..."+ep);
|
log.debug("3..."+ep);
|
||||||
log.debug("3..."+en);
|
log.debug("3..."+en);
|
||||||
|
|
||||||
myLeaves = JsonPath.parse(resJson).read(ES_NGV_QUERY);
|
myLeaves = JsonPath.parse(resJson).read(SOFTWAREFACET_QUERY_NAME);
|
||||||
String name = myLeaves.get(0).get("name").toString();
|
String name = myLeaves.get(0).get("name").toString();
|
||||||
String group = myLeaves.get(0).get("group").toString();
|
String group = myLeaves.get(0).get("group").toString();
|
||||||
String version = myLeaves.get(0).get("version").toString();
|
String version = myLeaves.get(0).get("version").toString();
|
||||||
|
@ -134,7 +134,7 @@ public class DTOResourceBuilder {
|
||||||
((EServiceDTO) dto).setGroup(group);
|
((EServiceDTO) dto).setGroup(group);
|
||||||
|
|
||||||
|
|
||||||
myLeaves = JsonPath.parse(resJson).read(ES_STATUS_QUERY);
|
myLeaves = JsonPath.parse(resJson).read(STATEFACET_QUERY_VALUE);
|
||||||
String sts = myLeaves.toString().replace("[\"", "").replace("\"]", "");
|
String sts = myLeaves.toString().replace("[\"", "").replace("\"]", "");
|
||||||
log.debug("4..."+sts);
|
log.debug("4..."+sts);
|
||||||
((EServiceDTO) dto).setStatus(sts);
|
((EServiceDTO) dto).setStatus(sts);
|
||||||
|
@ -146,6 +146,33 @@ public class DTOResourceBuilder {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Constants.RES_TYPE_VMACHINE:
|
||||||
|
dto = new VirtualServiceDTO();
|
||||||
|
try {
|
||||||
|
String uid= JsonPath.parse(resJson).read(UID_QUERY);
|
||||||
|
((VirtualServiceDTO) dto).setId(uid);
|
||||||
|
log.debug("1..."+uid);
|
||||||
|
|
||||||
|
String lastUpd= JsonPath.parse(resJson).read(LAST_UPDATE_QUERY);
|
||||||
|
lastUpd = lastUpd.substring(0,lastUpd.length()-10);
|
||||||
|
((VirtualServiceDTO) dto).setLastMod(lastUpd);
|
||||||
|
log.debug("2..."+lastUpd);
|
||||||
|
|
||||||
|
//Software Facet Fields
|
||||||
|
myLeaves = JsonPath.parse(resJson).read(SOFTWAREFACET_QUERY_NAME);
|
||||||
|
String name = myLeaves.get(0).get("name").toString();
|
||||||
|
String group = myLeaves.get(0).get("group").toString();
|
||||||
|
String version = myLeaves.get(0).get("version").toString();
|
||||||
|
log.debug("3..."+myLeaves);
|
||||||
|
((VirtualServiceDTO) dto).setVersion(version);
|
||||||
|
((VirtualServiceDTO) dto).setName(name);
|
||||||
|
((VirtualServiceDTO) dto).setGroup(group);
|
||||||
|
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("Error while building VirtualServiceDTO from json");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Constants.RES_TYPE_VSERVICE:
|
case Constants.RES_TYPE_VSERVICE:
|
||||||
dto = new VirtualServiceDTO();
|
dto = new VirtualServiceDTO();
|
||||||
try {
|
try {
|
||||||
|
@ -159,7 +186,7 @@ public class DTOResourceBuilder {
|
||||||
log.debug("2..."+lastUpd);
|
log.debug("2..."+lastUpd);
|
||||||
|
|
||||||
//Software Facet Fields
|
//Software Facet Fields
|
||||||
myLeaves = JsonPath.parse(resJson).read(ES_NGV_QUERY);
|
myLeaves = JsonPath.parse(resJson).read(SOFTWAREFACET_QUERY_NAME);
|
||||||
String name = myLeaves.get(0).get("name").toString();
|
String name = myLeaves.get(0).get("name").toString();
|
||||||
String group = myLeaves.get(0).get("group").toString();
|
String group = myLeaves.get(0).get("group").toString();
|
||||||
String version = myLeaves.get(0).get("version").toString();
|
String version = myLeaves.get(0).get("version").toString();
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package org.gcube.informationsystem.web.rest;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class ExtraProp {
|
|
||||||
|
|
||||||
String prop_deno;
|
|
||||||
String prop_val;
|
|
||||||
String prop_tipo;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package org.gcube.informationsystem.web.rest;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
|
||||||
|
|
||||||
//Risorsa da inviare per la creazione
|
|
||||||
public class FacetProperties {
|
|
||||||
String type;
|
|
||||||
Map<String, Object> facetprops = new LinkedHashMap();
|
|
||||||
|
|
||||||
@JsonAnySetter
|
|
||||||
void setDetail(String key, Object value) {
|
|
||||||
facetprops.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package org.gcube.informationsystem.web.rest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||||
|
|
||||||
|
//Risorsa da inviare per la creazione
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
public class FormDataJson {
|
||||||
|
private Map<String, String> properties;
|
||||||
|
private Map<String, String> extraProperties;
|
||||||
|
public FormDataJson(){
|
||||||
|
properties = new HashMap<>();
|
||||||
|
extraProperties = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonAnySetter
|
||||||
|
public void addProperty(String property, String value){
|
||||||
|
properties.put(property, value);
|
||||||
|
}
|
||||||
|
@JsonAnySetter
|
||||||
|
public void addExtraProperty(String extraProp, String value){
|
||||||
|
properties.put(extraProp, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
class Student {
|
||||||
|
private Map<String, String> properties;
|
||||||
|
public Student(){
|
||||||
|
properties = new HashMap<>();
|
||||||
|
}
|
||||||
|
public Map<String, String> getProperties(){
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
@JsonAnySetter
|
||||||
|
public void add(String property, String value){
|
||||||
|
properties.put(property, value);
|
||||||
|
}
|
||||||
|
}*/
|
|
@ -229,7 +229,7 @@ public class InformationSystemResource {
|
||||||
}
|
}
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("ERROR WHILE FILLING RESOURCEIMPL DTO");
|
log.error("ERROR WHILE FILLING RESOURCEIMPL DTO");
|
||||||
//e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
@ -245,11 +245,6 @@ public class InformationSystemResource {
|
||||||
//CRUD - 1
|
//CRUD - 1
|
||||||
@PostMapping("/createresource")
|
@PostMapping("/createresource")
|
||||||
String createresource(@RequestParam String resourceType, @RequestBody String formData) throws Exception {
|
String createresource(@RequestParam String resourceType, @RequestBody String formData) throws Exception {
|
||||||
/*
|
|
||||||
* ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
|
||||||
UUIDUtility uuidUtil = new UUIDUtility();
|
|
||||||
return publisher.deleteResource(resourceType, uuidUtil.fromString(uuid));
|
|
||||||
*/
|
|
||||||
String currentContext = SecretManagerProvider.instance.get().getContext();
|
String currentContext = SecretManagerProvider.instance.get().getContext();
|
||||||
String result = "";
|
String result = "";
|
||||||
informationSystemService.setUma(createUmaToken(currentContext));
|
informationSystemService.setUma(createUmaToken(currentContext));
|
||||||
|
@ -260,9 +255,24 @@ public class InformationSystemResource {
|
||||||
result = publisher.createResource(formData);
|
result = publisher.createResource(formData);
|
||||||
//result = publisher.create(formData);
|
//result = publisher.create(formData);
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error("****************");
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
log.error("****************");
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//CRUD - 2
|
||||||
|
@PostMapping("/updateresource")
|
||||||
|
String updateresource(@RequestParam String resourceType, @RequestBody String formData) throws Exception {
|
||||||
|
String currentContext = SecretManagerProvider.instance.get().getContext();
|
||||||
|
String result = "";
|
||||||
|
informationSystemService.setUma(createUmaToken(currentContext));
|
||||||
|
formData = informationSystemService.createResourceInternal(resourceType, formData);
|
||||||
|
try {
|
||||||
|
ResourceRegistryPublisher publisher = ResourceRegistryPublisherFactory.create();
|
||||||
|
result = publisher.updateResource(formData);
|
||||||
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
<p> {{typeSpec.description}} </p>
|
<p> {{typeSpec.description}} </p>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
<div [formGroup]="myForm">
|
<div [formGroup]="myForm">
|
||||||
|
|
||||||
<div formArrayName="{{facetTemplate.key}}" *ngFor="let facetTemplate of fieldsMap|keyvalue;" >
|
<div formArrayName="{{facetTemplate.key}}" *ngFor="let facetTemplate of fieldsMap|keyvalue;" >
|
||||||
<div [formGroupName] ="ind" *ngFor="let fct of (getSingleFacetArray(facetTemplate.key)).controls; let ind=index;" style="border: 3px solid rgb(72, 157, 202); padding: 10px; margin: 5px;">
|
<div [formGroupName] ="ind" *ngFor="let fct of (getSingleFacetArray(facetTemplate.key)).controls; let ind=index;" style="border: 3px solid rgb(72, 157, 202); padding: 10px; margin: 5px;">
|
||||||
<mat-form-field appearance="outline" >
|
<mat-form-field appearance="outline" >
|
||||||
|
|
|
@ -64,6 +64,9 @@
|
||||||
<div *ngSwitchCase = "'HostingNode'">
|
<div *ngSwitchCase = "'HostingNode'">
|
||||||
<jhi-table-screen [typeObject]="resType" [currentCtx]="myContext"></jhi-table-screen>
|
<jhi-table-screen [typeObject]="resType" [currentCtx]="myContext"></jhi-table-screen>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngSwitchCase = "'VirtualMachine'">
|
||||||
|
<jhi-table-screen [typeObject]="resType" [currentCtx]="myContext"></jhi-table-screen>
|
||||||
|
</div>
|
||||||
<div *ngSwitchCase = "'EService'">
|
<div *ngSwitchCase = "'EService'">
|
||||||
<jhi-table-screen-es [typeObject]="resType" [currentCtx]="myContext"></jhi-table-screen-es>
|
<jhi-table-screen-es [typeObject]="resType" [currentCtx]="myContext"></jhi-table-screen-es>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
export interface IVirtualMachine {
|
||||||
|
type:string;
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
status: string;
|
||||||
|
lastMod: string;
|
||||||
|
avMemory: string;
|
||||||
|
hdSpace: string;
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import { IHostingNode } from './i-hosting-node';
|
||||||
import { IEService } from './i-e-service';
|
import { IEService } from './i-e-service';
|
||||||
import { ApplicationConfigService } from 'app/core/config/application-config.service';
|
import { ApplicationConfigService } from 'app/core/config/application-config.service';
|
||||||
import { IVirtualService } from './i-virtual-service';
|
import { IVirtualService } from './i-virtual-service';
|
||||||
|
import { IVirtualMachine } from './i-virtual-machine';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
|
@ -36,6 +37,10 @@ export class ResourcesImplService {
|
||||||
//console.debug("******GETTING HOSTING NODE*****");
|
//console.debug("******GETTING HOSTING NODE*****");
|
||||||
return this.http.get<IHostingNode[]>(resourceUrl,{params:queryParams});
|
return this.http.get<IHostingNode[]>(resourceUrl,{params:queryParams});
|
||||||
}
|
}
|
||||||
|
if(type==='VirtualMachine'){
|
||||||
|
//console.debug("******GETTING HOSTING NODE*****");
|
||||||
|
return this.http.get<IVirtualMachine[]>(resourceUrl,{params:queryParams});
|
||||||
|
}
|
||||||
if(type==='EService'){
|
if(type==='EService'){
|
||||||
return this.http.get<IEService[]>(resourceUrl,{params:queryParams});
|
return this.http.get<IEService[]>(resourceUrl,{params:queryParams});
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
class BaseFacet {
|
||||||
|
uid:string;
|
||||||
|
facetName: string;
|
||||||
|
facetDescription: string;
|
||||||
|
facetMin: string;
|
||||||
|
facetMax: string;
|
||||||
|
customProperties: CustomProperty[];
|
||||||
|
|
||||||
|
constructor(){
|
||||||
|
this.uid='';
|
||||||
|
this.facetName='';
|
||||||
|
this.facetMin='';
|
||||||
|
this.facetMax='';
|
||||||
|
this.facetDescription='';
|
||||||
|
this.customProperties = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
class CustomProperty {
|
||||||
|
name:string;
|
||||||
|
value:string;
|
||||||
|
type:string;
|
||||||
|
|
||||||
|
constructor(){
|
||||||
|
this.name='';
|
||||||
|
this.value='';
|
||||||
|
this.type='';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
class SoftwareFacet extends BaseFacet{
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
relation: string;
|
||||||
|
optional: boolean;
|
||||||
|
group: string;
|
||||||
|
qualifier:string;
|
||||||
|
version:string;
|
||||||
|
|
||||||
|
|
||||||
|
constructor(){
|
||||||
|
super();
|
||||||
|
this.relation='';
|
||||||
|
this.name='';
|
||||||
|
this.group='';
|
||||||
|
this.description='';
|
||||||
|
this.qualifier='';
|
||||||
|
this.version='';
|
||||||
|
this.optional=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,23 +0,0 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { TableScreenEsComponent } from './table-screen-es.component';
|
|
||||||
|
|
||||||
describe('TableScreenEsComponent', () => {
|
|
||||||
let component: TableScreenEsComponent;
|
|
||||||
let fixture: ComponentFixture<TableScreenEsComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ TableScreenEsComponent ]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
|
|
||||||
fixture = TestBed.createComponent(TableScreenEsComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -21,7 +21,6 @@ import { TableScreenVsComponent } from './table-screen-vs.component';
|
||||||
|
|
||||||
declarations:[TableScreenVsComponent],
|
declarations:[TableScreenVsComponent],
|
||||||
exports: [TableScreenVsComponent],
|
exports: [TableScreenVsComponent],
|
||||||
//NB: QUI VA DICHIARATO IL DIALOG DI DATAENTRY COME COMPONENT
|
|
||||||
entryComponents: [ResourceAddComponent],
|
entryComponents: [ResourceAddComponent],
|
||||||
bootstrap: [TableScreenVsComponent],
|
bootstrap: [TableScreenVsComponent],
|
||||||
})
|
})
|
||||||
|
|
|
@ -165,6 +165,7 @@ export class TableScreenComponent implements OnInit, AfterViewInit, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadTable():void{
|
reloadTable():void{
|
||||||
|
alert(this.typeObject.name)
|
||||||
this.myDataService.fetchResourceImpls(this.currentCtx.path,this.typeObject.name).subscribe(res => {
|
this.myDataService.fetchResourceImpls(this.currentCtx.path,this.typeObject.name).subscribe(res => {
|
||||||
this.dataFromService = res;
|
this.dataFromService = res;
|
||||||
this.dataSource.data = res;
|
this.dataSource.data = res;
|
||||||
|
|
Loading…
Reference in New Issue