From 79389cbbcd717ca9e4a2b74c5256dbdbeec19a02 Mon Sep 17 00:00:00 2001 From: mariateresa Date: Mon, 13 May 2024 18:21:37 +0200 Subject: [PATCH] working on editing GUI --- .../service/InformationSystemService.java | 22 +-- .../web/rest/InformationSystemResource.java | 71 ++++++++- .../web/rest/ProveVarie2.java | 149 +++++++++++------- .../facet-composer/facet-composer.service.ts | 19 ++- .../facet-editor/facet-editor.component.html | 1 + .../facet-editor/facet-editor.component.ts | 62 ++++---- 6 files changed, 225 insertions(+), 99 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java b/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java index e072aac..e3f63cc 100644 --- a/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java +++ b/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java @@ -24,6 +24,7 @@ import org.gcube.informationsystem.service.dto.FacetPropGui; import org.gcube.informationsystem.service.dto.FacetPropertyDTO; import org.gcube.informationsystem.service.dto.FacetSpecDTO; import org.gcube.informationsystem.service.dto.FacetTypeDTO; +import org.gcube.informationsystem.service.dto.ResourceImplFieldsDTO; import org.gcube.informationsystem.service.dto.ResourceTypeDTO; import org.gcube.informationsystem.service.dto.ValidationObjDTO; import org.gcube.informationsystem.tree.Tree; @@ -106,6 +107,8 @@ public class InformationSystemService { } + + public FacetSpecDTO getFacetSpecification(String facetName) throws Exception { String currentCtx = SecretManagerProvider.instance.get().getContext(); @@ -142,6 +145,16 @@ public class InformationSystemService { } + public String getResource(String type, String uid) throws Exception { + String raw = ""; + String currentCtx = SecretManagerProvider.instance.get().getContext(); + ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx); + resourceRegistryClient.setIncludeMeta(false); + UUID coso = UUID.fromString(uid); + raw = resourceRegistryClient.getInstance(type, coso); + return raw; + } + private FacetPropGui toFacetPropGui(FacetPropertyDTO fp, ResourceRegistryClient client) { FacetPropGui prop = new FacetPropGui(); prop.setPropDescription(fp.getDescription()); @@ -387,15 +400,6 @@ public class InformationSystemService { /* * Fetches the instance of a certain type for a given UUID */ - public String getResource(String type, String uid) throws Exception { - String raw = ""; - String currentCtx = SecretManagerProvider.instance.get().getContext(); - ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx); - resourceRegistryClient.setIncludeMeta(false); - UUID coso = UUID.fromString(uid); - raw = resourceRegistryClient.getInstance(type, coso); - return raw; - } diff --git a/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java b/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java index 388a15e..5590602 100644 --- a/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java +++ b/src/main/java/org/gcube/informationsystem/web/rest/InformationSystemResource.java @@ -18,6 +18,8 @@ import org.gcube.common.authorization.utils.manager.SecretManagerProvider; import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.config.TokenManager; import org.gcube.informationsystem.model.reference.entities.Resource; +import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient; +import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory; import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher; import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory; import org.gcube.informationsystem.serialization.ElementMapper; @@ -26,7 +28,12 @@ import org.gcube.informationsystem.service.dto.ContextDTO; import org.gcube.informationsystem.service.dto.FacetSpecDTO; import org.gcube.informationsystem.service.dto.FacetTypeDTO; import org.gcube.informationsystem.service.dto.ResourceBuilderDTO; +import org.gcube.informationsystem.service.dto.ResourceImplFieldsDTO; import org.gcube.informationsystem.service.dto.ResourceTypeDTO; +import org.gcube.informationsystem.types.TypeMapper; +import org.gcube.informationsystem.types.reference.Type; +import org.gcube.informationsystem.types.reference.entities.FacetType; +import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; import org.gcube.informationsystem.utils.UUIDUtility; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +47,10 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.util.UriUtils; +import com.jayway.jsonpath.JsonPath; + import lombok.RequiredArgsConstructor; +import net.minidev.json.JSONArray; import tech.jhipster.web.util.HeaderUtil; @@ -168,6 +178,7 @@ public class InformationSystemResource{ return ResponseEntity.ok().body(sc); } catch (Exception e) { //e.printStackTrace(); + log.error("****ERROR*************"); log.error(e.getMessage(), e); return ResponseEntity.noContent() @@ -175,7 +186,63 @@ public class InformationSystemResource{ } } - + /* + * Ritorna il raw json spacchettato in oggetti buoni per la rappresentazione nella GUI + */ + @GetMapping("/facetfields") + public ResponseEntity resourceInstanceMapped(@RequestParam @Nullable String currentContext, @RequestParam String resourceType, @RequestParam String uid) { + log.debug("Request facets fields"); + ArrayList facetFields = new ArrayList(); + ArrayList facetRelations = new ArrayList<>(); + ArrayList facetNames = new ArrayList<>(); + ArrayList extraProps = new ArrayList(); + try { + String currentCtx = SecretManagerProvider.instance.get().getContext(); + ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx); + informationSystemService.setUma(createUmaToken(currentContext)); + String rawJson = informationSystemService.getResource(resourceType, uid); + //TODO: qui spacchetta con Jsonpath + //String sc = rawJson; + facetRelations = JsonPath.parse(rawJson).read("$..consistsOf.*.type"); + facetNames = JsonPath.parse(rawJson).read("$..consistsOf.*.target.type"); + + // ArrayList mapKeys = new ArrayList(); + for(int i=0; i targetObj = JsonPath.parse(rawJson).read("$.consistsOf.["+i+"].target"); + String fName = facetNames.get(i); + ResourceImplFieldsDTO rif = new ResourceImplFieldsDTO(); + rif.setFrname(fName+"_"+facetRelations.get(i)); + Map facetProps = new HashMap<>(); + String jsonFacetDesc = resourceRegistryClient.getType(fName, true); + Type type = TypeMapper.deserializeTypeDefinitions(jsonFacetDesc).get(0); //only one result + FacetType ft = (FacetType) type; + if(ft.getProperties()!=null ) { + for(PropertyDefinition pd:ft.getProperties() ) { + try { + String propName = pd.getName(); + String propValue = ""; + if(targetObj.get(propName)!=null) { + propValue = targetObj.get(propName).toString(); + } + facetProps.put(propName, propValue); + }catch(Exception e) { + e.printStackTrace(); + } + } + } + rif.setProperties(facetProps); + facetFields.add(rif); + } + ObjectMapper om = new ObjectMapper(); + String json = om.writeValueAsString(facetFields); + return ResponseEntity.ok().body(json); + } catch (Exception e) { + log.error("****ERROR*************"); + log.error(e.getLocalizedMessage(), e); + return ResponseEntity.noContent() + .headers(HeaderUtil.createAlert(applicationName, e.getLocalizedMessage(), "")).build(); + } + } @GetMapping("/resourcetypejson") @@ -211,6 +278,8 @@ public class InformationSystemResource{ .headers(HeaderUtil.createAlert(applicationName, e.getLocalizedMessage(), "")).build(); } } + + /* * returns all the instances of resources given a certain type diff --git a/src/main/java/org/gcube/informationsystem/web/rest/ProveVarie2.java b/src/main/java/org/gcube/informationsystem/web/rest/ProveVarie2.java index 2926a5f..bbc6aaa 100644 --- a/src/main/java/org/gcube/informationsystem/web/rest/ProveVarie2.java +++ b/src/main/java/org/gcube/informationsystem/web/rest/ProveVarie2.java @@ -2,73 +2,116 @@ package org.gcube.informationsystem.web.rest; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.JsonNode; +import org.gcube.com.fasterxml.jackson.databind.ObjectMapper; +import org.gcube.common.authorization.utils.manager.SecretManagerProvider; +import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; +import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException; +import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient; +import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory; +import org.gcube.informationsystem.service.dto.FacetPropGui; +import org.gcube.informationsystem.service.dto.FacetPropertyDTO; +import org.gcube.informationsystem.service.dto.FacetSpecDTO; +import org.gcube.informationsystem.service.dto.ResourceImplFieldsDTO; +import org.gcube.informationsystem.types.TypeMapper; +import org.gcube.informationsystem.types.reference.Type; +import org.gcube.informationsystem.types.reference.entities.FacetType; +import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; + +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.JsonPath; +import net.minidev.json.JSONArray; public class ProveVarie2 { - /* - * { - ---"type" : "ConsistsOf", - "target" : { - "authorization":{ - "schema" : "myname", - "value" : "mypassword", - "type" : "ValueSchema" - }, - "protocol" : "proto", - "endpoint" : "eeeeeee", - "entryName" : "een", - "description" : "dede", - "type" : "AccessPointFacet" - }*/ + + static ArrayList facetRelations = new ArrayList<>(); + static ArrayList facetNames = new ArrayList<>(); + static ArrayList extraProps = new ArrayList(); + + + + static JSONArray props = new JSONArray(); public static void main(String[] args) { - ResourceDescription rd = new ResourceDescription(); - rd.setType("EService"); - // - ArrayList arrFd = new ArrayList(); - FacetDescription fd1 = new FacetDescription(); - fd1.setType("ConsistsOf"); - - Map targetMap = new HashMap(); - 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 { - // create object mapper instance - ObjectMapper mapper = new ObjectMapper(); - // convert user object to `JsonNode` - JsonNode node = mapper.valueToTree(rd); - System.out.println(node.toPrettyString()); - + ResourceImplFieldsDTO rd = buildFormFields(realData); + // System.out.println(Json.pretty(rd)); +// JsonElement je= JsonParser.parseString(realData); +// System.out.println(je); + }catch(Exception e) { e.printStackTrace(); } - - - - - - - //rd.setIsRelatedTo(new ArrayList()); - } + + public FacetSpecDTO getFacetSpecification2(String facetName) throws Exception { + + String currentCtx = SecretManagerProvider.instance.get().getContext(); + ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(currentCtx); + String jsonResult = resourceRegistryClient.getType(facetName, true); + Type type = TypeMapper.deserializeTypeDefinitions(jsonResult).get(0); //only one result + FacetSpecDTO fsdto = new FacetSpecDTO(); + ArrayList propsGui = new ArrayList(); + FacetType ft = (FacetType) type; + if(ft.getProperties()!=null ) { + for(PropertyDefinition pd:ft.getProperties() ) { + try { + FacetPropertyDTO prop = new FacetPropertyDTO(); + prop.setName(pd.getName()); + }catch(Exception e) { + e.printStackTrace(); + } + } + } + fsdto.setGuiProps(propsGui); + return fsdto; + } + + + + static ResourceImplFieldsDTO buildFormFields(String resData) { + ArrayList facetFields = new ArrayList(); + facetRelations = JsonPath.parse(realData).read("$..consistsOf.*.type"); + facetNames = JsonPath.parse(realData).read("$..consistsOf.*.target.type"); + Map targetObj = JsonPath.parse(realData).read("$.consistsOf.[0].target"); + String gruppo = targetObj.get("group").toString(); + //ArrayList facetFields = new ArrayList(); + ResourceImplFieldsDTO rf1 = new ResourceImplFieldsDTO(); + rf1.setFrname("cname1"); + Map props1 = new HashMap<>(); + props1.put("campo11", "valore11"); + props1.put("campo12", "valore12"); + rf1.setProperties(props1); + facetFields.add(rf1); + ResourceImplFieldsDTO rf2 = new ResourceImplFieldsDTO(); + rf2.setFrname("cname2"); + Map props2 = new HashMap<>(); + props2.put("campo21", "valore21"); + props2.put("campo22", "valore22"); + rf2.setProperties(props2); + facetFields.add(rf2); + ObjectMapper om = new ObjectMapper(); + + try { + String json = om.writeValueAsString(targetObj); + System.out.println(json); + }catch(Exception e) { + e.printStackTrace(); + } + + return null; + } + static String realData ="{\"type\":\"EService\",\"supertypes\":[\"Service\",\"GCubeResource\",\"Resource\"],\"id\":\"fc212f4e-8741-42fd-ae30-354c46462913\",\"consistsOf\":[{\"type\":\"IsIdentifiedBy\",\"supertypes\":[\"ConsistsOf\"],\"id\":\"4e26d21e-975b-4ea3-8b06-21450661da72\",\"propagationConstraint\":{\"type\":\"PropagationConstraint\",\"add\":\"propagate\",\"delete\":\"cascade\",\"remove\":\"cascade\",\"supertypes\":[\"Property\"]},\"target\":{\"type\":\"SoftwareFacet\",\"supertypes\":[\"Facet\"],\"id\":\"7b5d4e52-1fbf-4e34-949d-49af8dbfb7e5\",\"qualifier\":null,\"name\":\"StorageHub\",\"description\":\"REST web service for Jackrabbit\",\"optional\":false,\"version\":\"1.5.0-SNAPSHOT\",\"group\":\"DataAccess\"}},{\"type\":\"ConsistsOf\",\"id\":\"ab3ff917-dc8b-4015-9251-f23fdf752c9c\",\"propagationConstraint\":{\"type\":\"PropagationConstraint\",\"add\":\"propagate\",\"delete\":\"cascade\",\"remove\":\"cascade\",\"supertypes\":[\"Property\"]},\"target\":{\"type\":\"AccessPointFacet\",\"supertypes\":[\"Facet\"],\"id\":\"cd9392c4-1231-427e-8205-0dfd8f76aa04\",\"authorization\":{\"type\":\"ValueSchema\",\"schema\":null,\"value\":\"gcube-token\",\"supertypes\":[\"GCubeProperty\",\"Property\"]},\"endpoint\":\"https://workspace-repository.dev.d4science.org:443/storagehub/workspace\",\"protocol\":null,\"entryName\":\"org.gcube.data.access.storagehub.StorageHub\",\"description\":null}},{\"type\":\"ConsistsOf\",\"id\":\"ee23ac28-2db8-4b98-b86d-fba3d18eab87\",\"propagationConstraint\":{\"type\":\"PropagationConstraint\",\"add\":\"propagate\",\"delete\":\"cascade\",\"remove\":\"cascade\",\"supertypes\":[\"Property\"]},\"target\":{\"type\":\"AccessPointFacet\",\"supertypes\":[\"Facet\"],\"id\":\"b136870a-9865-4141-b997-c635eb66dfef\",\"authorization\":{\"type\":\"ValueSchema\",\"schema\":null,\"value\":\"gcube-token\",\"supertypes\":[\"GCubeProperty\",\"Property\"]},\"endpoint\":\"https://workspace-repository.dev.d4science.org:443/storagehub/gcube/resource\",\"protocol\":null,\"entryName\":\"StorageHub-remote-management\",\"description\":null}},{\"type\":\"ConsistsOf\",\"id\":\"882bad2f-7ab6-4aa5-884d-87a219ce3caf\",\"propagationConstraint\":{\"type\":\"PropagationConstraint\",\"add\":\"propagate\",\"delete\":\"cascade\",\"remove\":\"cascade\",\"supertypes\":[\"Property\"]},\"target\":{\"type\":\"StateFacet\",\"supertypes\":[\"Facet\"],\"id\":\"9f5e38a2-a202-4f2a-8f22-5aa8700c0cec\",\"date\":\"2024-03-25 14:24:35.934 +0100\",\"value\":\"down\"}},{\"type\":\"ConsistsOf\",\"id\":\"c8c23daf-26b0-4dfd-b0f3-daa408810d3d\",\"propagationConstraint\":{\"type\":\"PropagationConstraint\",\"add\":\"propagate\",\"delete\":\"cascade\",\"remove\":\"cascade\",\"supertypes\":[\"Property\"]},\"target\":{\"type\":\"EventFacet\",\"supertypes\":[\"Facet\"],\"id\":\"401a5260-7888-4de6-ab9d-e06ea084098c\",\"date\":\"2024-03-25 14:22:14.642 +0100\",\"event\":\"ready\"}},{\"type\":\"ConsistsOf\",\"id\":\"933fe059-8ef7-421d-94b9-841c7b504834\",\"propagationConstraint\":{\"type\":\"PropagationConstraint\",\"add\":\"propagate\",\"delete\":\"cascade\",\"remove\":\"cascade\",\"supertypes\":[\"Property\"]},\"target\":{\"type\":\"EventFacet\",\"supertypes\":[\"Facet\"],\"id\":\"5e849b79-172e-492a-981c-72859e1bd693\",\"date\":\"2024-03-25 14:24:35.934 +0100\",\"event\":\"down\"}}]}"; } diff --git a/src/main/webapp/app/facet-composer/facet-composer.service.ts b/src/main/webapp/app/facet-composer/facet-composer.service.ts index 9c9ca36..3fa6988 100644 --- a/src/main/webapp/app/facet-composer/facet-composer.service.ts +++ b/src/main/webapp/app/facet-composer/facet-composer.service.ts @@ -3,7 +3,7 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { ApplicationConfigService } from 'app/core/config/application-config.service'; -import { IFacetComposer } from './i-facet-composer'; +import { IFacetComposer, IFacetProps } from './i-facet-composer'; @@ -13,6 +13,11 @@ export interface ITypeSpecification{ facetSpecs: IFacetComposer[]; } +export interface IFacetFields{ + name:string, //nome facet+relazione + facetSpecs: IFacetProps[]; +} + @Injectable({ providedIn: 'root' @@ -61,5 +66,15 @@ export class FacetComposerService { return this.http.post(serviceUrl,id,{ headers,params}) } - + getGuiFields(ctxPath:string,type:string,uid:string):Observable{ + const serviceUrl = this.applicationConfigService.getEndpointFor('api/is/facetfields'); + const headers = new HttpHeaders() + .append( + 'Content-Type', + 'application/json' + ); + let queryParams = new HttpParams(); + queryParams = queryParams.append("uid",uid).append("resourceType",type).append("currentContext",ctxPath); + return this.http.get(serviceUrl,{params:queryParams}); + } } diff --git a/src/main/webapp/app/facet-editor/facet-editor.component.html b/src/main/webapp/app/facet-editor/facet-editor.component.html index facf9e0..30378d7 100644 --- a/src/main/webapp/app/facet-editor/facet-editor.component.html +++ b/src/main/webapp/app/facet-editor/facet-editor.component.html @@ -12,6 +12,7 @@

{{typeSpec.description}}

+

{{guiFacetFields|json}}

diff --git a/src/main/webapp/app/facet-editor/facet-editor.component.ts b/src/main/webapp/app/facet-editor/facet-editor.component.ts index 18703a6..cb7c680 100644 --- a/src/main/webapp/app/facet-editor/facet-editor.component.ts +++ b/src/main/webapp/app/facet-editor/facet-editor.component.ts @@ -10,7 +10,7 @@ import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/materia import { MatExpansionModule } from '@angular/material/expansion'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; -import { FacetComposerService, ITypeSpecification } from 'app/facet-composer/facet-composer.service'; +import { FacetComposerService, IFacetFields, ITypeSpecification } from 'app/facet-composer/facet-composer.service'; import { IFacetComposer, IFacetProps } from 'app/facet-composer/i-facet-composer'; import { IContextNode } from 'app/services/i-context-node'; import { IResource } from 'app/services/i-resource'; @@ -26,7 +26,7 @@ import { MatSelectFilterModule } from 'mat-select-filter'; imports:[CommonModule,MatFormFieldModule,SharedModule, ReactiveFormsModule,MatButtonModule, MatDialogModule,MatInputModule,MatExpansionModule,MatSelectFilterModule], - providers: [ResourcesImplService, FacetComposerService] + providers: [FacetComposerService] }) @@ -43,6 +43,8 @@ export class FacetEditorComponent implements OnInit { // facetData: IFacetComposer[]; typeSpec: ITypeSpecification; fieldsMap: Map; + guiFacetMaps: Map; + guiFacetFields: IFacetFields[]; rawjson: string|any; optionTypes = [ @@ -72,42 +74,30 @@ export class FacetEditorComponent implements OnInit { this.selectedOption = ''; this.typeSpec = {} as ITypeSpecification; this.fieldsMap = new Map(); + this.guiFacetFields = {} as IFacetFields[]; + this.guiFacetMaps = new Map(); this.myForm = this.fb.group({}); } - ngOnInit(): void { + ngOnInit(): void { /* - this.dataService.getJsonDetails('',this.titleType,this.uid).subscribe(res => { - this.lookoutObject(res); - //TODO: qui va creato rawJson - }); + this.dataService.getJsonDetails('',this.titleType,this.uid).subscribe(data => { + this.lookoutObject(data); */ - this.guiService.getFormStructure(this.titlePath,this.titleType).subscribe(res => { + //getGuiFields(ctxPath:string,type:string,uid:string + this.guiService.getGuiFields(this.titlePath,this.titleType,this.uid).subscribe(res => { + this.guiFacetFields = res; + this.guiFacetMaps = new Map(res.map((obj) => [obj.name,obj.facetSpecs])) + }); + + this.guiService.getFormStructure(this.titlePath,this.titleType).subscribe(res => { this.typeSpec = res; this.fieldsMap = new Map(res.facetSpecs.map((obj) => [obj.name+'_'+obj.relation, obj])); - console.debug("*********** typeSpec *********"); - console.debug(this.typeSpec.name); - console.debug("********************"); this.createAndFillForm(this.rawjson,this.typeSpec); }); - - } - - lookoutObject(obj:any){ - for(const key in obj){ - //console.debug("*********** lookoutObject *********"); - console.debug("key: " + key + ", value: " + obj[key]); - // console.debug("*********** *********"); - if(obj[key] instanceof Object){ - this.lookoutObject(obj[key]); - } - } - } - - createAndFillForm(rawSource:string, fData:ITypeSpecification):void{ //TODO: VA PASSATO RAWSOURCE (O MAPPA) PER RIEMPIRE LA FORM for(let i=0; ithis.fieldsMap.get(deno); const singleFacetArray = this.myForm.controls[deno] as FormArray; - singleFacetArray.push(this.createFacetGroup(icf,true)); + singleFacetArray.push(this.createFacetGroup(icf,true,this.guiFacetMaps.get(deno))); } - createFacetGroup(item: IFacetComposer,isAdded: boolean):FormGroup{ + createFacetGroup(item: IFacetComposer,isAdded: boolean,facetFields: IFacetComposer):FormGroup{ const facetFg: FormGroup = this.fb.group({}); const nameFc = this.fb.control(item.name); facetFg.addControl('facetName', nameFc); @@ -191,17 +182,20 @@ export class FacetEditorComponent implements OnInit { //1. creo group con le properties //2. aggiungo formgroup delle properties ai controls per la facet // facetFg.addControl('properties',this.createPropertyControls(item.guiProps)); - return this.addPropertyControls(facetFg,item.guiProps); + return this.addPropertyControls(facetFg,item.guiProps,this.guiFacetMaps.get(nameFc+"_"+relationFc)!); } - addPropertyControls(facetFg:FormGroup, props: IFacetProps[]):FormGroup{ + addPropertyControls(facetFg:FormGroup, props: IFacetProps[], values: IFacetProps[]):FormGroup{ + const propsFg = this.fb.group({}); let fc:FormControl; - for(let i=0; i