From 77b44527b5ab05872603e2d1d14c9321553e69d5 Mon Sep 17 00:00:00 2001 From: annampak Date: Thu, 21 Sep 2017 13:02:11 +0300 Subject: [PATCH] sources for comboboxes --- .gitignore | 1 + dmp-frontend/src/app/entities/DataModel.ts | 11 +++++ .../src/app/entities/model/attribute.ts | 2 +- .../fields/dynamic-form-field.component.html | 4 +- .../app/services/dataModelBuilder.service.ts | 41 +++++++++++++++---- .../src/app/services/server.service.ts | 3 +- 6 files changed, 50 insertions(+), 12 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..d150e2eb8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dmp-frontend/dist.7z diff --git a/dmp-frontend/src/app/entities/DataModel.ts b/dmp-frontend/src/app/entities/DataModel.ts index ddf67026a..257465c89 100644 --- a/dmp-frontend/src/app/entities/DataModel.ts +++ b/dmp-frontend/src/app/entities/DataModel.ts @@ -1,10 +1,12 @@ import { GroupBase } from '../form/dynamic-form-group/group-base'; import { FieldBase } from '../form/fields/field-base'; import { Attribute } from './model/attribute'; +import { Source } from './model/source'; export class DataModel { private fIndex : Map>; + private fIndSources : Map; groups: GroupBase[] = []; fields: FieldBase[] = []; @@ -24,6 +26,7 @@ export class DataModel { this.fIndex = new Map>(); + this.fIndSources = new Map(); this.fields.forEach((field) => { console.log("fieldid:" +field.key); @@ -37,6 +40,14 @@ export class DataModel { }); }); + this.semanticAttr.forEach((attr) => { + attr.sources.forEach(src => { + this.fIndSources.set(attr.id, src); + console.log("fieldid: "+attr.id + "attr:" +src); + }); + + }); + } public getFieldByKey(key){ diff --git a/dmp-frontend/src/app/entities/model/attribute.ts b/dmp-frontend/src/app/entities/model/attribute.ts index 1fd60f550..f5c1190de 100644 --- a/dmp-frontend/src/app/entities/model/attribute.ts +++ b/dmp-frontend/src/app/entities/model/attribute.ts @@ -12,6 +12,6 @@ export class Attribute { multiplicityMax: number; validationType: any; validation : Rule[]; - source: Source[]; + sources: Source[]; } diff --git a/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html b/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html index 8f015d75e..80ede029d 100644 --- a/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html +++ b/dmp-frontend/src/app/form/fields/dynamic-form-field.component.html @@ -36,8 +36,8 @@ required="field.required" [(ngModel)]="field.value"> + + diff --git a/dmp-frontend/src/app/services/dataModelBuilder.service.ts b/dmp-frontend/src/app/services/dataModelBuilder.service.ts index 86e4c6b95..de78b37e9 100644 --- a/dmp-frontend/src/app/services/dataModelBuilder.service.ts +++ b/dmp-frontend/src/app/services/dataModelBuilder.service.ts @@ -7,6 +7,7 @@ import { RadioBoxField } from '../../app/form/fields/radiobox/field-radiobox'; import { DataModel } from '../entities/DataModel'; import {Rule} from '../entities/common/rule'; import { GroupBase } from '../form/dynamic-form-group/group-base'; +import { Attribute } from '../entities/model/attribute'; @Injectable() export class dataModelBuilder { @@ -20,18 +21,18 @@ export class dataModelBuilder { return this.dataModel; this.dataModel = new DataModel(); - //this.dataModel.fields = this.getFieldVisibility(data.dataset.profile.viewstyle.definition.root.fields.field); this.fields = this.buildFields(data.dataset.profile.viewstyle.definition.root.fields.field); - this.dataModel.groups = this.getGroups(data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup, this.fields); - //this.getDummyGroups(); - this.dataModel.buildIndex(); - + this.dataModel.groups = this.getGroups(data.dataset.profile.viewstyle.definition.root.fieldGroups.fieldGroup, this.fields);debugger; + this.dataModel.semanticAttr = new Array(new Attribute); + //this.dataModel.semanticAttr = data.dataset.profile.definition.root.fields.field; + this.dataModel.semanticAttr = this.getFieldsAttributes(data.dataset.profile.definition.root.fields.field, this.fields) ; + this.dataModel.buildIndex(); + return this.dataModel; } private buildFields(fields:any[]) { - console.log(fields); let fieldsVisible :FieldBase[] =[]; fields.forEach(element => { if (element.viewStyle._renderstyle == "freetext"){ @@ -45,7 +46,8 @@ export class dataModelBuilder { order:element._ordinal, rules: element.visible.rule != undefined ? element.visible.rule: rule, visible: element._defaultVisibility, - group : element._group + group : element._group, + description: element.description.__cdata }); fieldsVisible.push(newfield); @@ -61,6 +63,7 @@ export class dataModelBuilder { order:element._ordinal, rules: element.visible.rule != undefined ? element.visible.rule: rule, visible: element._defaultVisibility, + description: element.description.__cdata, group : element._group }); fieldsVisible.push(newfield); @@ -77,6 +80,7 @@ export class dataModelBuilder { rules: element.visible.rule != undefined ? element.visible.rule: rule, visible: element._defaultVisibility, group : element._group, + description: element.description.__cdata, type: "checkbox" }); fieldsVisible.push(newfield); @@ -197,6 +201,27 @@ export class dataModelBuilder { return groups; } - + + private getFieldsAttributes(attributes:any, fields:any[]){ + let attribute:Attribute[]=[]; + attributes.forEach(attr => { + let newAttribute = new Attribute(); + newAttribute.datatype = attr._datatype; + newAttribute.defaultValue = attr.defaultValue._value; + newAttribute.id = attr._id; + newAttribute.multiplicityMax = attr.multiplicity._max; + newAttribute.multiplicityMin = attr.multiplicity._min; + newAttribute.ordinal = attr._ordinal; + newAttribute.sources = new Array(); + newAttribute.sources.push(attr.sources.source) + newAttribute.validation = attr.validation; + + console.log(newAttribute); + attribute.push(newAttribute); + }); + + + return attribute; + } } \ No newline at end of file diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index 056be452c..c1d1bebbf 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -19,7 +19,8 @@ export class ServerService { xml2jsonOBJ: any; //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a868dbbb-ee37-4ce6-81c8-27048e0599a9'; //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/a71a6a92-5c23-40d7-ab87-e30bc860f5a4';//include rules! - fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/d597c26e-3d8b-416a-bc07-1734d68c79c9';//'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/d619d418-88be-4f2c-9dcc-db7ad4fc60b3';//include sections! + //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/d597c26e-3d8b-416a-bc07-1734d68c79c9';//include sections! + 3groupfields + fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/9a4a4a57-4d01-465e-9887-254534f31600'; //fetchURL: string = 'http://dl010.madgik.di.uoa.gr:8080/dmp-backend/rest/DMP/6c845c42-dc09-42ed-9959-cceb3b616364'; /*