Warning, /firebird/firebird-ng/src/app/model/entry.ts is written in an unsupported language. File is not indexed.
0001 import {EntryComponent, EntryComponentFactory, getComponentFactory} from "./entry-component";
0002
0003 export class Entry
0004 {
0005 id: string = "";
0006 components: EntryComponent[] = [];
0007
0008 toDexObject(): any {
0009 const objComponents: any[] = [];
0010 for (const component of this.components) {
0011 objComponents.push(component.toDexObject());
0012 }
0013 return {
0014 id: this.id,
0015 components: objComponents,
0016 };
0017 }
0018
0019 static fromDexObject(obj: any): Entry {
0020 let result = new Entry();
0021 result.id = obj["id"];
0022 for(const objComponent of obj["components"]) {
0023 const compType = objComponent["type"];
0024
0025 if(!compType) {
0026 console.warn(`A problem with entry component type (a required field). It is: '${compType}'`);
0027 continue;
0028 }
0029
0030 const factory = getComponentFactory(compType);
0031 if(factory === null || factory === undefined ) {
0032 console.warn(`Can't find EntryComponent factory for type name: '${compType}'`)
0033 }
0034 else {
0035 result.components.push(factory.fromDexObject(objComponent));
0036 }
0037 }
0038 return result;
0039 }
0040 }