argos/dmp-frontend/src/app/entities/DataModel.ts

63 lines
1.5 KiB
TypeScript
Raw Normal View History

import { GroupBase } from '../form/dynamic-form-group/group-base';
import { FieldBase } from '../form/fields/field-base';
import { Attribute } from './model/attribute';
2017-09-21 12:02:11 +02:00
import { Source } from './model/source';
export class DataModel {
2017-09-18 18:08:15 +02:00
private fIndex : Map<string, FieldBase<any>>;
2017-09-21 12:02:11 +02:00
private fIndSources : Map<string, Source>;
2017-09-18 18:08:15 +02:00
groups: GroupBase<any>[] = [];
fields: FieldBase<any>[] = [];
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<string, FieldBase<any>>();
2017-09-21 12:02:11 +02:00
this.fIndSources = new Map<string, Source>();
2017-09-18 18:08:15 +02:00
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);
});
});
2017-09-21 12:02:11 +02:00
this.semanticAttr.forEach((attr) => {
attr.sources.forEach(src => {
this.fIndSources.set(attr.id, src);
console.log("fieldid: "+attr.id + "attr:" +src);
});
});
2017-09-18 18:08:15 +02:00
}
public getFieldByKey(key){
return this.fIndex.get(key);
}
}