import {Entity} from "./Entity.interface"; import {ExampleEntityData} from "./example-entity-data"; export class NeverBounce implements Entity { private _application_id = ''; private _email_address = ''; private _email_history_list: EmailHistory[] = []; private _pred = -1; private _prob: number = -1; private _version: string = ''; private _exampleEntityData: ExampleEntityData = new ExampleEntityData('neverbounce'); constructor(obj?: any) { if (obj) { if (obj.email_history_list) { for (const i in obj.email_history_list) { this._email_history_list.push(new EmailHistory(obj.email_history_list[i])); } } if (obj.application_id) { this._application_id = obj.application_id; } if (obj.email_address) { this._email_address = obj.email_address; } if (obj.pred > -1) { this._pred = obj.pred; } if (obj.prob > -1) { this._prob = obj.prob; } if (obj.version) { this._version = obj.version; } if (obj.res && obj.res.email_address) { this._email_address = obj.res.email_address; } if (obj.res && obj.res.pred !== undefined) { this._pred = obj.res.pred; } } } public toDsProjectRoom() { const data: any = { text: this._exampleEntityData.getExampleData(), url: '', showInIframe: false }; const blocks = [ { blockName: '', blockDesc: '', numColumns: 4, fields: [ {label: 'email_address', inputType: 'text', value: this._email_address}, {label: 'pred', inputType: 'select', selectOptions: ['0', '1'], value: this._pred.toString()}, ] }]; const final = []; for (const i in blocks) { final.push(blocks[i]); } return {blocks: final, data: data}; } public fromDsProjectRoom(obj: any[], data: any) { const neverBounce: any = { text: data.text, res: {} }; let block: any; for (block of obj) { neverBounce.res = {}; let field: any; for (field of block.fields) { neverBounce.res[field.label] = field.value; } } return new NeverBounce(neverBounce); } nerEntityTypeOptions(): any[] { return []; } get application_id(): string { return this._application_id; } set application_id(value: string) { this._application_id = value; } get email_address(): string { return this._email_address; } set email_address(value: string) { this._email_address = value; } get email_history_list(): EmailHistory[] { return this._email_history_list; } set email_history_list(value: EmailHistory[]) { this._email_history_list = value; } get pred(): number { return this._pred; } set pred(value: number) { this._pred = value; } get prob(): number { return this._prob; } set prob(value: number) { this._prob = value; } get version(): string { return this._version; } set version(value: string) { this._version = value; } public toJSON() { return { pred: this.pred, prob: this.prob, version: this.version, application_id: this.application_id, email_address: this.email_address, email_history_list: this.email_history_list }; } public toNerEntities(type = 1) { return { relationOptions: [], entities: { email_address: '', application_id: '' } }; } public toShortInputOutput() { return { map_in: ['email_entry_list.0.email_address'], map_in_text: ['email address'], map_out: ['classification_result.0'], map_out_text: ['classification result'] }; } } export class EmailHistory { validation_time_stamp = 0; source = ''; value = ''; subvalue = ''; zipi_source_file = ''; constructor(obj?: any) { if (obj) { if (obj.validation_time_stamp) { this.validation_time_stamp = obj.validation_time_stamp; } if (obj.source) { this.source = obj.source; } if (obj.value) { this.value = obj.value; } if (obj.subvalue) { this.subvalue = obj.subvalue; } if (obj.zipi_source_file) { this.zipi_source_file = obj.zipi_source_file; } } } }