debugging Resources editor

This commit is contained in:
Maria Teresa Paratore 2024-05-09 17:32:41 +02:00
parent adfb060279
commit e180a94b6b
5 changed files with 58 additions and 40 deletions

View File

@ -226,8 +226,10 @@ public class InformationSystemService {
String jsonResult = resourceRegistryClient.getType(typeName, true); String jsonResult = resourceRegistryClient.getType(typeName, true);
ResourceTypeDTO dto = null; ResourceTypeDTO dto = null;
try { try {
List<Type> types = TypeMapper.deserializeTypeDefinitions(jsonResult); //List<Type> types = TypeMapper.deserializeTypeDefinitions(jsonResult);
for(Type type : types) { //for(Type type : types) {
//prendo solo il primo (non voglio la gerarchia annidata)
Type type = TypeMapper.deserializeTypeDefinitions(jsonResult).get(0);
ResourceType resType = (ResourceType) type; ResourceType resType = (ResourceType) type;
String name = resType.getName(); String name = resType.getName();
String id = resType.getID().toString(); String id = resType.getID().toString();
@ -246,7 +248,7 @@ public class InformationSystemService {
} }
} //}
}catch(Exception e) { }catch(Exception e) {
log.error("**********"); log.error("**********");
log.error(e.getMessage(),e); log.error(e.getMessage(),e);
@ -432,28 +434,17 @@ 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);
// create object mapper instance
ObjectMapper mapper = new ObjectMapper();
// convert object to `JsonNode`
JsonNode node = mapper.valueToTree(rd);
// System.out.println(node.toPrettyString()); // System.out.println(node.toPrettyString());
try {
// create object mapper instance
log.debug("******** JSON STRING TO BE SENT:"); ObjectMapper mapper = new ObjectMapper();
log.debug(sendingJson); // convert object to `JsonNode`
log.debug("********"); JsonNode node = mapper.valueToTree(rd);
/* log.debug(node.toPrettyString());
try { sendingJson = node.toString();
// create object mapper instance }catch(Exception e) {
ObjectMapper mapper = new ObjectMapper(); log.error(e.getMessage(),e);
// 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);

View File

@ -67,7 +67,6 @@
</ng-template> </ng-template>
</div> </div>
</div> </div>
<!-- ADDITIONAL PROPERTIES --> <!-- ADDITIONAL PROPERTIES -->
<div formArrayName ="extraProps" style="border: 2px solid rgb(176, 206, 230); padding: 10px; margin: 5px;"> <div formArrayName ="extraProps" style="border: 2px solid rgb(176, 206, 230); padding: 10px; margin: 5px;">
<span [style.width.px]="350" [style.font-weight]="900">Custom Properties</span> <span [style.width.px]="350" [style.font-weight]="900">Custom Properties</span>

View File

@ -80,17 +80,20 @@ export class FacetComposerComponent implements OnInit {
*/ */
optionTypes = [ optionTypes = [
{ value: 'String'} //per ora solo tipo String
/*
{ value: 'Boolean'}, { value: 'Boolean'},
{ value: 'Integer'}, { value: 'Integer'},
{ value: 'Short'}, { value: 'Short'},
{ value: 'Long'}, { value: 'Long'},
{ value: 'Float'}, { value: 'Float'},
{ value: 'Double'}, { value: 'Double'},
{ value: 'Password'},//Password implica salvare criptato { value: 'Password'},
{ value: 'Date'}, { value: 'Date'},
{ value: 'String'}, { value: 'String'},
{ value: 'Binary'}, { value: 'Binary'},
{ value: 'Byte'} { value: 'Byte'}
*/
]; ];

View File

@ -13,7 +13,9 @@
</mat-expansion-panel-header> </mat-expansion-panel-header>
<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" >
@ -43,14 +45,28 @@
<!-- PROPERTIES --> <!-- PROPERTIES -->
<div formGroupName ="props" > <div formGroupName ="props" >
<div *ngFor="let prop of facetTemplate.value.guiProps"> <div *ngFor="let prop of facetTemplate.value.guiProps">
<mat-form-field> <div *ngIf="prop.type==='typeprop'; else singlefield" style="border: 1px solid rgb(202, 202, 202); padding: 10px; margin: 5px;">
<mat-label>{{prop.label}}</mat-label> <p style="color: darkgrey;">{{prop.label}}</p>
<input matInput formControlName="{{prop.name}}" id="{{prop.name}}" <mat-form-field>
type="{{prop.type}}"/> <mat-label>username</mat-label>
<input matInput formControlName="schema" id="username"
type="text"/>
</mat-form-field>
<mat-form-field>
<mat-label>password</mat-label>
<input matInput formControlName="value" id="password"
type="password"/>
</mat-form-field>
</div>
<ng-template #singlefield>
<mat-form-field>
<mat-label>{{prop.label}}</mat-label>
<input matInput formControlName="{{prop.name}}" id="{{prop.name}}"
type="{{prop.type}}"/>
</mat-form-field> </mat-form-field>
</ng-template>
</div> </div>
</div> </div>
<!-- ADDITIONAL PROPERTIES --> <!-- ADDITIONAL PROPERTIES -->
<div formArrayName ="extraProps" style="border: 2px solid rgb(176, 206, 230); padding: 10px; margin: 5px;"> <div formArrayName ="extraProps" style="border: 2px solid rgb(176, 206, 230); padding: 10px; margin: 5px;">
<span [style.width.px]="350" [style.font-weight]="900">Custom Properties</span> <span [style.width.px]="350" [style.font-weight]="900">Custom Properties</span>

View File

@ -26,7 +26,7 @@ import { MatSelectFilterModule } from 'mat-select-filter';
imports:[CommonModule,MatFormFieldModule,SharedModule, imports:[CommonModule,MatFormFieldModule,SharedModule,
ReactiveFormsModule,MatButtonModule, ReactiveFormsModule,MatButtonModule,
MatDialogModule,MatInputModule,MatExpansionModule,MatSelectFilterModule], MatDialogModule,MatInputModule,MatExpansionModule,MatSelectFilterModule],
providers: [ResourcesImplService] providers: [ResourcesImplService, FacetComposerService]
}) })
@ -46,6 +46,8 @@ export class FacetEditorComponent implements OnInit {
rawjson: string|any; rawjson: string|any;
optionTypes = [ optionTypes = [
{ value: 'String'}, //per ora solo tipo String
/*
{ value: 'Boolean'}, { value: 'Boolean'},
{ value: 'Integer'}, { value: 'Integer'},
{ value: 'Short'}, { value: 'Short'},
@ -54,13 +56,13 @@ export class FacetEditorComponent implements OnInit {
{ value: 'Double'}, { value: 'Double'},
{ value: 'Password'},//Password implica salvare criptato { value: 'Password'},//Password implica salvare criptato
{ value: 'Date'}, { value: 'Date'},
{ value: 'String'},
{ value: 'Binary'}, { value: 'Binary'},
{ value: 'Byte'} { value: 'Byte'}
*/
] ]
//TODO: PASSARE UID COME STRINGA
constructor(private dataService: ResourcesImplService, private guiService: FacetComposerService, private fb: FormBuilder, constructor(private dataService: ResourcesImplService, private guiService: FacetComposerService, private fb: FormBuilder,
private dialogRef:MatDialogRef<FacetEditorComponent>, private dialogRef:MatDialogRef<FacetEditorComponent>,
@Inject(MAT_DIALOG_DATA) data: {type: IResource ,context:IContextNode, uid:string}){ @Inject(MAT_DIALOG_DATA) data: {type: IResource ,context:IContextNode, uid:string}){
@ -75,24 +77,30 @@ export class FacetEditorComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
/*
this.dataService.getJsonDetails('',this.titleType,this.uid).subscribe(res => { this.dataService.getJsonDetails('',this.titleType,this.uid).subscribe(res => {
this.lookoutObject(res); this.lookoutObject(res);
//TODO: qui va creato rawJson
}); });
*/
this.guiService.getFormStructure(this.titlePath,this.titleType).subscribe(res => { this.guiService.getFormStructure(this.titlePath,this.titleType).subscribe(res => {
this.typeSpec = res; this.typeSpec = res;
this.fieldsMap = new Map(res.facetSpecs.map((obj) => [obj.name+'_'+obj.relation, obj])); 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);
}); });
this.createAndFillForm(this.rawjson,this.typeSpec);
} }
lookoutObject(obj:any){ lookoutObject(obj:any){
for(const key in obj){ for(const key in obj){
console.debug("*********** lookoutObject *********"); //console.debug("*********** lookoutObject *********");
console.debug("key: " + key + ", value: " + obj[key]); console.debug("key: " + key + ", value: " + obj[key]);
console.debug("*********** *********"); // console.debug("*********** *********");
if(obj[key] instanceof Object){ if(obj[key] instanceof Object){
this.lookoutObject(obj[key]); this.lookoutObject(obj[key]);
} }
@ -101,6 +109,7 @@ export class FacetEditorComponent implements OnInit {
createAndFillForm(rawSource:string, fData:ITypeSpecification):void{ createAndFillForm(rawSource:string, fData:ITypeSpecification):void{
//TODO: VA PASSATO RAWSOURCE (O MAPPA) PER RIEMPIRE LA FORM
for(let i=0; i<fData.facetSpecs.length; i++){ for(let i=0; i<fData.facetSpecs.length; i++){
const facetSpec = fData.facetSpecs[i]; const facetSpec = fData.facetSpecs[i];
this.createFacetArrayEntry(facetSpec); this.createFacetArrayEntry(facetSpec);