debugging on types
This commit is contained in:
parent
f51a0a632f
commit
adfb060279
15
.classpath
15
.classpath
|
@ -31,16 +31,19 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="ignore_optional_problems" value="true"/>
|
||||||
|
<attribute name="m2e-apt" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="target/generated-sources/annotations">
|
<classpathentry kind="src" path="target/generated-sources/annotations">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="optional" value="true"/>
|
|
||||||
<attribute name="test" value="true"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,7 +7,6 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||||
import org.gcube.common.authorization.utils.secret.JWTSecret;
|
import org.gcube.common.authorization.utils.secret.JWTSecret;
|
||||||
|
@ -28,10 +27,12 @@ import org.gcube.informationsystem.service.dto.FacetTypeDTO;
|
||||||
import org.gcube.informationsystem.service.dto.ResourceTypeDTO;
|
import org.gcube.informationsystem.service.dto.ResourceTypeDTO;
|
||||||
import org.gcube.informationsystem.service.dto.ValidationObjDTO;
|
import org.gcube.informationsystem.service.dto.ValidationObjDTO;
|
||||||
import org.gcube.informationsystem.tree.Tree;
|
import org.gcube.informationsystem.tree.Tree;
|
||||||
|
import org.gcube.informationsystem.types.TypeMapper;
|
||||||
import org.gcube.informationsystem.types.impl.entities.FacetTypeImpl;
|
import org.gcube.informationsystem.types.impl.entities.FacetTypeImpl;
|
||||||
import org.gcube.informationsystem.types.impl.entities.ResourceTypeImpl;
|
|
||||||
import org.gcube.informationsystem.types.knowledge.TypeInformation;
|
import org.gcube.informationsystem.types.knowledge.TypeInformation;
|
||||||
import org.gcube.informationsystem.types.reference.Type;
|
import org.gcube.informationsystem.types.reference.Type;
|
||||||
|
import org.gcube.informationsystem.types.reference.entities.FacetType;
|
||||||
|
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
||||||
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
|
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
|
||||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||||
import org.gcube.informationsystem.utils.UUIDUtility;
|
import org.gcube.informationsystem.utils.UUIDUtility;
|
||||||
|
@ -41,9 +42,13 @@ import org.gcube.informationsystem.web.rest.TypeProperty;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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 net.minidev.json.JSONArray;
|
import net.minidev.json.JSONArray;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service class for managing InformationSystem resources.
|
* Service class for managing InformationSystem resources.
|
||||||
*/
|
*/
|
||||||
|
@ -106,36 +111,34 @@ public class InformationSystemService {
|
||||||
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||||
ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx);
|
ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx);
|
||||||
String jsonResult = resourceRegistryClient.getType(facetName, true);
|
String jsonResult = resourceRegistryClient.getType(facetName, true);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
Type type = TypeMapper.deserializeTypeDefinitions(jsonResult).get(0); //only one result
|
||||||
//resourceRegistryClient returns an array of one element
|
|
||||||
FacetTypeImpl ft = objectMapper.readValue(jsonResult, FacetTypeImpl[].class)[0];
|
|
||||||
ArrayList<FacetPropGui> propsGui = new ArrayList<FacetPropGui>();
|
|
||||||
FacetSpecDTO fsdto = new FacetSpecDTO();
|
FacetSpecDTO fsdto = new FacetSpecDTO();
|
||||||
fsdto.setName(ft.getName());
|
ArrayList<FacetPropGui> propsGui = new ArrayList<FacetPropGui>();
|
||||||
fsdto.setDescription(ft.getDescription());
|
FacetType ft = (FacetType) type;
|
||||||
|
fsdto.setName(ft.getTypeName());
|
||||||
if(ft.getProperties()!=null ) {
|
fsdto.setDescription(ft.getDescription());
|
||||||
for(PropertyDefinition pd:ft.getProperties() ) {
|
if(ft.getProperties()!=null ) {
|
||||||
try {
|
for(PropertyDefinition pd:ft.getProperties() ) {
|
||||||
FacetPropertyDTO prop = new FacetPropertyDTO();
|
try {
|
||||||
prop.setDescription(pd.getDescription());
|
FacetPropertyDTO prop = new FacetPropertyDTO();
|
||||||
prop.setMandatory(pd.isMandatory());
|
prop.setDescription(pd.getDescription());
|
||||||
//prop.setMax(pd.getMax());
|
prop.setMandatory(pd.isMandatory());
|
||||||
//prop.setMin(pd.getMin());
|
//prop.setMax(pd.getMax());
|
||||||
prop.setName(pd.getName());
|
//prop.setMin(pd.getMin());
|
||||||
prop.setNotnull(pd.isNotnull());
|
prop.setName(pd.getName());
|
||||||
prop.setPropertyType(pd.getPropertyType());
|
prop.setNotnull(pd.isNotnull());
|
||||||
//prop.setReadonly(pd.isReadonly());
|
prop.setPropertyType(pd.getPropertyType());
|
||||||
prop.setRegexp(pd.getRegexp());
|
//prop.setReadonly(pd.isReadonly());
|
||||||
prop.setType(pd.getTypeName());
|
prop.setRegexp(pd.getRegexp());
|
||||||
propsGui.add(toFacetPropGui(prop, resourceRegistryClient));
|
prop.setType(pd.getTypeName());
|
||||||
}catch(Exception e) {
|
propsGui.add(toFacetPropGui(prop, resourceRegistryClient));
|
||||||
e.printStackTrace();
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
fsdto.setGuiProps(propsGui);
|
||||||
fsdto.setGuiProps(propsGui);
|
return fsdto;
|
||||||
return fsdto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,29 +212,46 @@ public class InformationSystemService {
|
||||||
|
|
||||||
|
|
||||||
public ResourceTypeDTO getResourceType(String typeName) throws Exception {
|
public ResourceTypeDTO getResourceType(String typeName) throws Exception {
|
||||||
|
String currentCtx = null;
|
||||||
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
try {
|
||||||
|
currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("**********");
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
log.error("**********");
|
||||||
|
}
|
||||||
log.debug("getResourceType : [currentCtx=]",currentCtx);
|
log.debug("getResourceType : [currentCtx=]",currentCtx);
|
||||||
ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx);
|
ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx);
|
||||||
//questo è un array di un elemento
|
//questo è un array di un elemento
|
||||||
String jsonResult = resourceRegistryClient.getType(typeName, true);
|
String jsonResult = resourceRegistryClient.getType(typeName, true);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ResourceTypeDTO dto = null;
|
||||||
//resourceRegistryClient returns an array of one element
|
try {
|
||||||
ResourceTypeImpl rt = objectMapper.readValue(jsonResult, ResourceTypeImpl[].class)[0];
|
List<Type> types = TypeMapper.deserializeTypeDefinitions(jsonResult);
|
||||||
String name = rt.getName();
|
for(Type type : types) {
|
||||||
String id = rt.getID().toString();
|
ResourceType resType = (ResourceType) type;
|
||||||
String desc = rt.getDescription();
|
String name = resType.getName();
|
||||||
boolean abst = rt.isAbstract();
|
String id = resType.getID().toString();
|
||||||
ResourceTypeDTO dto = new ResourceTypeDTO(name, id, desc, abst);
|
String desc = resType.getDescription();
|
||||||
List<LinkedEntity> fcts = rt.getFacets();
|
boolean abst = resType.isAbstract();
|
||||||
if(fcts!=null) {
|
|
||||||
ArrayList<FacetTypeDTO> facetTypes = new ArrayList<FacetTypeDTO>();
|
dto = new ResourceTypeDTO(name, id, desc, abst);
|
||||||
for(LinkedEntity le: fcts) {
|
List<LinkedEntity> fcts = resType.getFacets();
|
||||||
FacetTypeDTO ftDto = new FacetTypeDTO(le.getRelation(),le.getTarget(),le.getDescription(),le.getMin(),le.getMax());
|
if(fcts!=null) {
|
||||||
facetTypes.add(new FacetTypeDTO(le.getRelation(),le.getTarget(),le.getDescription(),le.getMin(),le.getMax()));
|
ArrayList<FacetTypeDTO> facetTypes = new ArrayList<FacetTypeDTO>();
|
||||||
}
|
for(LinkedEntity le: fcts) {
|
||||||
dto.setFacetTypes(facetTypes);
|
FacetTypeDTO ftDto = new FacetTypeDTO(le.getRelation(),le.getTarget(),le.getDescription(),le.getMin(),le.getMax());
|
||||||
|
facetTypes.add(new FacetTypeDTO(le.getRelation(),le.getTarget(),le.getDescription(),le.getMin(),le.getMax()));
|
||||||
|
}
|
||||||
|
dto.setFacetTypes(facetTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}catch(Exception e) {
|
||||||
|
log.error("**********");
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
log.error("**********");
|
||||||
|
}
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +336,6 @@ public class InformationSystemService {
|
||||||
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
String currentCtx = SecretManagerProvider.instance.get().getContext();
|
||||||
ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx);
|
ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx);
|
||||||
ModelKnowledge <Type, TypeInformation> modelKnowledge = resourceRegistryClient.getModelKnowledge();
|
ModelKnowledge <Type, TypeInformation> modelKnowledge = resourceRegistryClient.getModelKnowledge();
|
||||||
//Type resourcesType = modelKnowledge.getTypeByName(AccessType.RESOURCE.getName());
|
|
||||||
Type resourcesType = modelKnowledge.getTypeByName(resourceTypeName);
|
Type resourcesType = modelKnowledge.getTypeByName(resourceTypeName);
|
||||||
Tree<Type> typeTree = modelKnowledge.getTree(resourcesType.getAccessType());
|
Tree<Type> typeTree = modelKnowledge.getTree(resourcesType.getAccessType());
|
||||||
SimpleTreeMaker treeMaker = new SimpleTreeMaker();
|
SimpleTreeMaker treeMaker = new SimpleTreeMaker();
|
||||||
|
@ -406,17 +425,6 @@ public class InformationSystemService {
|
||||||
ArrayList<JSONArray> extraProps = new ArrayList<JSONArray>();
|
ArrayList<JSONArray> extraProps = new ArrayList<JSONArray>();
|
||||||
JSONArray props = new JSONArray();
|
JSONArray props = new JSONArray();
|
||||||
String sendingJson="";
|
String sendingJson="";
|
||||||
/*
|
|
||||||
ResourceDescription(type=EService, consistsOf=[FacetDescription(type=IsIdentifiedBy,
|
|
||||||
target={optional=true, name=Maria Teresa Paratore, group=gr, description=, version=v56, qualifier=}),
|
|
||||||
FacetDescription(type=ConsistsOf, target={optional=true, name=name, group=ggg, description=, version=v4,
|
|
||||||
qualifier=}), FacetDescription(type=ConsistsOf, target={protocol=proto, endpoint=endpoint,
|
|
||||||
entryName=EntryNameMio, description=dddd, authorization={type=ValueSchema, schema=mariateresa, value=mtPwd}}),
|
|
||||||
FacetDescription(type=ConsistsOf, target={event=on, date=2024-05-21}),
|
|
||||||
FacetDescription(type=ConsistsOf, target={value=v7}),
|
|
||||||
FacetDescription(type=ConsistsOf, target={textURL=myUrl, name=myName})],
|
|
||||||
isRelatedTo=[])
|
|
||||||
*/
|
|
||||||
try {
|
try {
|
||||||
facetNames = JsonPath.parse(formData).read("$..facetName");
|
facetNames = JsonPath.parse(formData).read("$..facetName");
|
||||||
facetRelations = JsonPath.parse(formData).read("$..relationFacet");
|
facetRelations = JsonPath.parse(formData).read("$..relationFacet");
|
||||||
|
@ -424,16 +432,29 @@ public class InformationSystemService {
|
||||||
props = JsonPath.parse(formData).read("$..props");
|
props = JsonPath.parse(formData).read("$..props");
|
||||||
ResourceDescription rd = new ResourceDescription();
|
ResourceDescription rd = new ResourceDescription();
|
||||||
rd = buildSendingJson(resourceType,facetNames,facetRelations,extraProps,props);
|
rd = buildSendingJson(resourceType,facetNames,facetRelations,extraProps,props);
|
||||||
ObjectMapper om = new ObjectMapper();
|
// create object mapper instance
|
||||||
// Getting object as a json string
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
sendingJson = om.writeValueAsString(rd);
|
// convert object to `JsonNode`
|
||||||
// Displaying JSON String on console
|
JsonNode node = mapper.valueToTree(rd);
|
||||||
|
// System.out.println(node.toPrettyString());
|
||||||
|
|
||||||
|
|
||||||
log.debug("******** JSON STRING TO BE SENT:");
|
log.debug("******** JSON STRING TO BE SENT:");
|
||||||
log.debug(sendingJson);
|
log.debug(sendingJson);
|
||||||
log.debug("********");
|
log.debug("********");
|
||||||
|
/*
|
||||||
//ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
|
try {
|
||||||
//sendingJson = ow.writeValueAsString(rd);
|
// create object mapper instance
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
// convert object to `JsonNode`
|
||||||
|
JsonNode node = mapper.valueToTree(rd);
|
||||||
|
System.out.println(node.toPrettyString());
|
||||||
|
|
||||||
|
}catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
log.error(e.getMessage(),e);
|
log.error(e.getMessage(),e);
|
||||||
}
|
}
|
||||||
|
@ -461,14 +482,6 @@ public class InformationSystemService {
|
||||||
//modifica per tipo ValueSchema e campo authorization
|
//modifica per tipo ValueSchema e campo authorization
|
||||||
if (facetName_i.equals("AccessPointFacet")&& propMap_i.keySet().contains("schema")&& propMap_i.keySet().contains("value")) {
|
if (facetName_i.equals("AccessPointFacet")&& propMap_i.keySet().contains("schema")&& propMap_i.keySet().contains("value")) {
|
||||||
TypeProperty vs = new TypeProperty();
|
TypeProperty vs = new TypeProperty();
|
||||||
/*LinkedHashMap authTypeMap = new LinkedHashMap<String, Object>();
|
|
||||||
authTypeMap.put("type", "ValueSchema");
|
|
||||||
authTypeMap.put("schema", (String)targetMap_i.get("schema"));
|
|
||||||
authTypeMap.put("value", (String)targetMap_i.get("value"));
|
|
||||||
targetMap_i.put("authorization", authTypeMap);
|
|
||||||
targetMap_i.remove("schema");
|
|
||||||
targetMap_i.remove("value");
|
|
||||||
*/
|
|
||||||
vs.setType("ValueSchema");
|
vs.setType("ValueSchema");
|
||||||
vs.setSchema((String)targetMap_i.get("schema"));
|
vs.setSchema((String)targetMap_i.get("schema"));
|
||||||
vs.setValue((String)targetMap_i.get("value"));
|
vs.setValue((String)targetMap_i.get("value"));
|
||||||
|
@ -494,7 +507,7 @@ public class InformationSystemService {
|
||||||
rd.setConsistsOf(new ArrayList<FacetDescription>());
|
rd.setConsistsOf(new ArrayList<FacetDescription>());
|
||||||
}
|
}
|
||||||
rd.getConsistsOf().add(facet_i);
|
rd.getConsistsOf().add(facet_i);
|
||||||
rd.setIsRelatedTo(new ArrayList<String>());
|
//rd.setIsRelatedTo(new ArrayList<String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
return rd;
|
return rd;
|
||||||
|
|
|
@ -16,7 +16,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class FacetDescription {
|
public class FacetDescription {
|
||||||
String type;
|
String type;
|
||||||
Map<String,String> target;
|
Map<String,Object> target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -126,8 +126,7 @@ public class InformationSystemResource{
|
||||||
//DOES NOT WORK TO RETRIEVE FACETS
|
//DOES NOT WORK TO RETRIEVE FACETS
|
||||||
// e.g. http://localhost:8081/api/is/resourcetype?typeName=HostingNode
|
// e.g. http://localhost:8081/api/is/resourcetype?typeName=HostingNode
|
||||||
public ResponseEntity<String> resourceType(@RequestParam String typeName,@RequestParam @Nullable String currentContext) {
|
public ResponseEntity<String> resourceType(@RequestParam String typeName,@RequestParam @Nullable String currentContext) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
ResourceTypeDTO dto = informationSystemService.getResourceType(typeName);
|
ResourceTypeDTO dto = informationSystemService.getResourceType(typeName);
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
String sc = objectMapper.writeValueAsString(dto);
|
String sc = objectMapper.writeValueAsString(dto);
|
||||||
|
@ -142,6 +141,7 @@ public class InformationSystemResource{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ritorna l'elenco delle facet e come costruirle
|
// ritorna l'elenco delle facet e come costruirle
|
||||||
@GetMapping("/facetspecifications")
|
@GetMapping("/facetspecifications")
|
||||||
public ResponseEntity<String> resourceTypeComplete(@RequestParam String typeName,@RequestParam @Nullable String currentContext) {
|
public ResponseEntity<String> resourceTypeComplete(@RequestParam String typeName,@RequestParam @Nullable String currentContext) {
|
||||||
|
@ -157,6 +157,7 @@ public class InformationSystemResource{
|
||||||
fs.setMax(ft.getMax());
|
fs.setMax(ft.getMax());
|
||||||
fs.setMin(ft.getMin());
|
fs.setMin(ft.getMin());
|
||||||
fs.setRelation(ft.getRelation());
|
fs.setRelation(ft.getRelation());
|
||||||
|
fs.setName(ft.getTarget());
|
||||||
fs.setRelationOptions(informationSystemService.getFacetRelationsOptions(ft.getRelation()));
|
fs.setRelationOptions(informationSystemService.getFacetRelationsOptions(ft.getRelation()));
|
||||||
facetSpecs.add(fs);
|
facetSpecs.add(fs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +1,74 @@
|
||||||
package org.gcube.informationsystem.web.rest;
|
package org.gcube.informationsystem.web.rest;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.util.ArrayList;
|
||||||
import java.nio.file.Files;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import io.swagger.v3.core.util.Json;
|
|
||||||
import io.swagger.v3.oas.models.Paths;
|
|
||||||
import net.minidev.json.JSONArray;
|
|
||||||
import net.minidev.json.JSONObject;
|
|
||||||
|
|
||||||
|
|
||||||
public class ProveVarie2 {
|
public class ProveVarie2 {
|
||||||
|
/*
|
||||||
|
* {
|
||||||
|
---"type" : "ConsistsOf",
|
||||||
|
"target" : {
|
||||||
|
"authorization":{
|
||||||
|
"schema" : "myname",
|
||||||
|
"value" : "mypassword",
|
||||||
|
"type" : "ValueSchema"
|
||||||
|
},
|
||||||
|
"protocol" : "proto",
|
||||||
|
"endpoint" : "eeeeeee",
|
||||||
|
"entryName" : "een",
|
||||||
|
"description" : "dede",
|
||||||
|
"type" : "AccessPointFacet"
|
||||||
|
}*/
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
ResourceDescription rd = new ResourceDescription();
|
||||||
|
rd.setType("EService");
|
||||||
|
//
|
||||||
|
ArrayList<FacetDescription> arrFd = new ArrayList<FacetDescription>();
|
||||||
|
FacetDescription fd1 = new FacetDescription();
|
||||||
|
fd1.setType("ConsistsOf");
|
||||||
|
|
||||||
|
Map<String,Object> targetMap = new HashMap<String,Object>();
|
||||||
|
targetMap.put("protocol","proto");
|
||||||
|
targetMap.put("endpoint","https://pippo.topolino.eeeeeee");
|
||||||
|
targetMap.put("entryName","een");
|
||||||
|
targetMap.put("description","dede");
|
||||||
|
targetMap.put("type","AccessPointFacet");
|
||||||
|
TypeProperty tp = new TypeProperty();
|
||||||
|
tp.setType("ValueSchema");
|
||||||
|
tp.setSchema("myschema");
|
||||||
|
tp.setValue("myvalue");
|
||||||
|
targetMap.put("authorization", tp);
|
||||||
|
|
||||||
|
fd1.setTarget(targetMap);
|
||||||
|
arrFd.add(fd1);
|
||||||
|
rd.setConsistsOf(arrFd);
|
||||||
try {
|
try {
|
||||||
// create Gson instance
|
// create object mapper instance
|
||||||
Gson gson = new Gson();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
// convert user object to `JsonNode`
|
||||||
// create a reader
|
JsonNode node = mapper.valueToTree(rd);
|
||||||
Reader reader = Files.newBufferedReader(java.nio.file.Paths.get("./test.json"));
|
System.out.println(node.toPrettyString());
|
||||||
|
|
||||||
// convert JSON file to map
|
}catch(Exception e) {
|
||||||
Map<?, ?> map = gson.fromJson(reader, Map.class);
|
e.printStackTrace();
|
||||||
|
|
||||||
// print map entries
|
|
||||||
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
|
||||||
System.out.println(entry.getKey() + "=" + entry.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
// close reader
|
|
||||||
reader.close();
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//rd.setIsRelatedTo(new ArrayList<ExtraPropertyString>());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createUno(String jsnStr) {
|
|
||||||
/*
|
|
||||||
Gson gson = new GsonBuilder()
|
|
||||||
//.registerTypeAdapter(null, jsnStr)
|
|
||||||
.enableComplexMapKeySerialization()
|
|
||||||
.serializeNulls()
|
|
||||||
.setDateFormat(DateFormat.LONG)
|
|
||||||
.setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
|
|
||||||
.setPrettyPrinting()
|
|
||||||
.setVersion(1.0)
|
|
||||||
.create();
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.informationsystem.service.dto.Serialization.ExtraProperty;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||||
|
|
||||||
//Risorsa da inviare per la creazione
|
//Risorsa da inviare per la creazione
|
||||||
|
@ -17,7 +19,7 @@ import lombok.NoArgsConstructor;
|
||||||
public class ResourceDescription {
|
public class ResourceDescription {
|
||||||
String type;
|
String type;
|
||||||
ArrayList<FacetDescription> consistsOf;
|
ArrayList<FacetDescription> consistsOf;
|
||||||
ArrayList<String> isRelatedTo;
|
//ArrayList<String> isRelatedTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,53 @@
|
||||||
{
|
{
|
||||||
"SoftwareFacet_IsIdentifiedBy": [
|
"type" : "EService",
|
||||||
{
|
"consistsOf" : [ {
|
||||||
"facetName": "SoftwareFacet",
|
"type" : "IsIdentifiedBy",
|
||||||
"max": "many",
|
"target" : {
|
||||||
"min": "1",
|
"name" : "nnnnn",
|
||||||
"facetDescription": "SoftwareFacet captures information on any software associated with the resource.",
|
"optional" : "true",
|
||||||
"relationFacet": "IsIdentifiedBy",
|
"group" : "gggrgrgrgr",
|
||||||
"isAdded": false,
|
"description" : "",
|
||||||
"extraProps": [
|
"version" : "vsvsvs",
|
||||||
{
|
"qualifier" : "",
|
||||||
"prop_deno": "custom 1",
|
"type" : "SoftwareFacet"
|
||||||
"prop_val": "value 1",
|
|
||||||
"prop_tipo": "String"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"prop_deno": "custom 2",
|
|
||||||
"prop_val": "value 2",
|
|
||||||
"prop_tipo": "String"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"prop_optional": true,
|
|
||||||
"prop_name": "npome",
|
|
||||||
"prop_group": "gruppo",
|
|
||||||
"prop_description": "",
|
|
||||||
"prop_version": "versione",
|
|
||||||
"prop_qualifier": ""
|
|
||||||
}
|
}
|
||||||
]
|
}, {
|
||||||
|
"type" : "ConsistsOf",
|
||||||
|
"target" : {
|
||||||
|
"name" : "nnnn",
|
||||||
|
"optional" : "true",
|
||||||
|
"group" : "ggggg",
|
||||||
|
"description" : "",
|
||||||
|
"version" : "vvvvv",
|
||||||
|
"qualifier" : "",
|
||||||
|
"type" : "SoftwareFacet"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type" : "ConsistsOf",
|
||||||
|
"target" : {
|
||||||
|
"authorization":{
|
||||||
|
"schema" : "myname",
|
||||||
|
"value" : "mypassword",
|
||||||
|
"type" : "ValueSchema"
|
||||||
|
},
|
||||||
|
"protocol" : "proto",
|
||||||
|
"endpoint" : "eeeeeee",
|
||||||
|
"entryName" : "een",
|
||||||
|
"description" : "dede",
|
||||||
|
"type" : "AccessPointFacet"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type" : "HasAddAction",
|
||||||
|
"target" : {
|
||||||
|
"event" : "eve",
|
||||||
|
"date" : "2024-05-31",
|
||||||
|
"type" : "EventFacet"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"type" : "ConsistsOf",
|
||||||
|
"target" : {
|
||||||
|
"value" : "vsvs",
|
||||||
|
"type" : "StateFacet"
|
||||||
|
}
|
||||||
|
} ]
|
||||||
}
|
}
|
|
@ -81,15 +81,17 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
|
|
||||||
let resTypeName:string;
|
let resTypeName:string;
|
||||||
//alert("fetching types--id:"+this.resType.id);
|
|
||||||
if(this.resType.id === undefined){ //if object is empty
|
if(this.resType.id === undefined){ //if object is empty
|
||||||
resTypeName = 'HostingNode';
|
resTypeName = 'HostingNode';
|
||||||
}else{
|
}else{
|
||||||
resTypeName = this.resType.name;
|
resTypeName = this.resType.name;
|
||||||
}
|
}
|
||||||
this.resTypeService.fetchOne(resTypeName).subscribe(res => {
|
this.resTypeService.fetchOne(resTypeName).subscribe(res => {
|
||||||
this.resType = res;
|
this.resType = res;
|
||||||
}) ;
|
},
|
||||||
|
err=>(console.log('******* HTTP Error *******',err)),
|
||||||
|
() => console.log('******* HTTP request completed *******')
|
||||||
|
) ;
|
||||||
|
|
||||||
//for the contexts form
|
//for the contexts form
|
||||||
this.ctxLoaderService.fetchAll().subscribe(res => {
|
this.ctxLoaderService.fetchAll().subscribe(res => {
|
||||||
|
|
|
@ -19,7 +19,6 @@ export class RestypesService {
|
||||||
//TODO: pipe per gestione errori
|
//TODO: pipe per gestione errori
|
||||||
|
|
||||||
fetchAll(): Observable<IResource[]> {
|
fetchAll(): Observable<IResource[]> {
|
||||||
//return this.http.get<IResource[]>(appProperties.BASEURL_API+'is/resourcetypes');
|
|
||||||
const resourceUrl = this.applicationConfigService.getEndpointFor('api/is/resourcetypes');
|
const resourceUrl = this.applicationConfigService.getEndpointFor('api/is/resourcetypes');
|
||||||
return this.http.get<IResource[]>(resourceUrl);
|
return this.http.get<IResource[]>(resourceUrl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue