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[] = []; semanticAttr: Attribute[]; //need to add more class fields to describe the remaining elements of the json object fetched from the service. //e.g. the current dataset's metadata information, the DataRepository description information, etc constructor(){ } public buildIndex(){ this.fIndex = new Map>(); this.fIndSources = new Map(); this.fields.forEach((field) => { console.log("fieldid:" +field.key); this.fIndex.set(field.key, field); }); this.groups.forEach((group) => { group.groupFields.forEach((field) => { console.log("groupid: "+group.key + "fieldid:" +field.key); this.fIndex.set(field.key, field); }); }); this.semanticAttr.forEach((attr) => { attr.sources.forEach(src => { this.fIndSources.set(attr.id, src); console.log("fieldid: "+attr.id + "attr:" +src); }); }); } public getFieldByKey(key){ return this.fIndex.get(key); } }