import {Entity} from './entity'; import {DsProjectRoomBlock, DsProjectRoomBlockField, DsProjectRoomData} from "../dynamic-labeling-room/entities"; 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?) { 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: DsProjectRoomData = new DsProjectRoomData({ 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(new DsProjectRoomBlock(blocks[i])); } return {blocks: final, data: data}; } public fromDsProjectRoom(obj: DsProjectRoomBlock[], data: DsProjectRoomData) { const neverBounce = { text: data.text, res: {} }; let block: DsProjectRoomBlock; for (block of obj) { neverBounce.res = {}; let field: DsProjectRoomBlockField; 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: '' } }; } } export class EmailHistory { validation_time_stamp = 0; source = ''; value = ''; subvalue = ''; zipi_source_file = ''; constructor(obj?) { if (obj) { for (const key in obj) { if (obj[key] !== undefined && obj[key] !== null) { this[key] = obj[key]; } } } } }