import {Entity} from './entity'; import {DsProjectRoomBlock, DsProjectRoomBlockField, DsProjectRoomData} from "../dynamic-labeling-room/entities"; import {ExampleEntityData} from "./example-entity-data"; export class Teams implements Entity { private _url = ''; private _helper_url_list: string[] = []; private _html_ref = ''; private _domain = ''; private _page_title = ''; private _page_description = ''; private _page_keywords = ''; private _page_type = ''; private _exampleEntityData: ExampleEntityData = new ExampleEntityData('teams'); private _records: TeamsRecord[] = []; constructor(obj?) { if (obj) { if (obj.url) { this._url = obj.url; } if (obj.helper_url_list) { for (const i in obj.helper_url_list) { this.helper_url_list.push(obj.helper_url_list[i]); } } if (obj.html_ref) { this._html_ref = obj.html_ref; } if (obj.records) { for (const i in obj.records) { this._records.push(new TeamsRecord(obj.records[i])); } } } } get url(): string { return this._url; } set url(value: string) { this._url = value; } get records(): any[] { return this._records; } set records(value: any[]) { this._records = value; } get helper_url_list(): string[] { return this._helper_url_list; } set helper_url_list(value: string[]) { this._helper_url_list = value; } get html_ref(): string { return this._html_ref; } set html_ref(value: string) { this._html_ref = value; } get page_type(): string { return this._page_type; } set page_type(value: string) { this._page_type = value; } get page_keywords(): string { return this._page_keywords; } set page_keywords(value: string) { this._page_keywords = value; } get page_description(): string { return this._page_description; } set page_description(value: string) { this._page_description = value; } get page_title(): string { return this._page_title; } set page_title(value: string) { this._page_title = value; } get domain(): string { return this._domain; } set domain(value: string) { this._domain = value; } public toJSON() { return { url: this.url, helper_url_list: this.helper_url_list, records: this.records.map((o) => o.toJSON()) }; } nerEntityTypeOptions(): any[] { return []; } public toNerEntities(): any { } public toDsProjectRoom() { const data: DsProjectRoomData = new DsProjectRoomData({ text: '', url: this._exampleEntityData.getExampleData(), showInIframe: false, isList: true, listHeader: 'Teams Records', listItemDefaultHeader: 'Teams Record', listObjIndex: 0, listFirstItemIndex: 3, listSecondItemIndex: 6 }); const blocks = [ { blockName: 'Teams Record', blockDesc: '', numColumns: 4, fields: [ {label: 'bio', inputType: 'text'}, {label: 'company', inputType: 'text'}, {label: 'credentials', inputType: 'text'}, {label: 'first', inputType: 'text'}, {label: 'idx', inputType: 'text'}, {label: 'job_title', inputType: 'text'}, {label: 'last', inputType: 'text'}, {label: 'middle', inputType: 'text'}, {label: 'n_sections', inputType: 'text'}, {label: 'prefix', inputType: 'text'}, {label: 'section_headline', inputType: 'text'}, {label: 'section_idx', inputType: 'text'}, {label: 'section_type', inputType: 'text'}, {label: 'section_valid', inputType: 'checkbox'}, {label: 'suffix', inputType: 'text'}, ] }, { blockName: 'connections', blockDesc: '', numColumns: 3, fields: [ {label: 'audit_changes', inputType: 'text_list'}, {label: 'emails', inputType: 'text_list'}, {label: 'faxes', inputType: 'text_list'}, {label: 'images', inputType: 'text_list'}, {label: 'links', inputType: 'text_list'}, {label: 'mobiles', inputType: 'text_list'}, {label: 'phones', inputType: 'text_list'}, {label: 'urls', inputType: 'text_list'} ] } ]; 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 teams = { url: data.url, records: [] }; let block: DsProjectRoomBlock; let item: any; for (item of obj) { const teamsRecord = {}; for (block of item) { let field: DsProjectRoomBlockField; for (field of block.fields) { teamsRecord[field.label] = field.value; } } teams.records.push(teamsRecord); } return new Teams(teams); } } export class TeamsRecord implements Entity { prefix = ''; first = ''; middle = ''; last = ''; suffix = ''; credentials = ''; job_title = ''; company = ''; bio = ''; resume: TeamsOrgDetails[] = []; education: TeamsOrgDetails[] = []; images: string[] = []; links: string[] = []; phones: string[] = []; mobiles: string[] = []; faxes: string[] = []; urls: string[] = []; emails: string[] = []; // removed by Noam request // idx = 0; // valid = true; // section_type = ''; // section_idx = 0; // section_valid = false; // section_headline = ''; // n_sections = 0; // audit_changes: string[] = []; // text: ''; constructor(obj?) { if (obj) { if (obj.prefix) { this.prefix = obj.prefix; } if (obj.first) { this.first = obj.first; } if (obj.middle) { this.middle = obj.middle; } if (obj.last) { this.last = obj.last; } if (obj.suffix) { this.suffix = obj.suffix; } if (obj.credentials) { this.credentials = obj.credentials; } if (obj.job_title) { this.job_title = obj.job_title; } if (obj.company) { this.company = obj.company; } if (obj.resume) { for (const i in obj.resume) { this.resume.push(obj.resume[i]); } } if (obj.education) { for (const i in obj.education) { this.education.push(obj.education[i]); } } if (obj.images) { for (const i in obj.images) { this.images.push(obj.images[i]); } } if (obj.links) { for (const i in obj.links) { this.links.push(obj.links[i]); } } if (obj.phones) { for (const i in obj.phones) { this.phones.push(obj.phones[i]); } } if (obj.mobiles) { for (const i in obj.mobiles) { this.mobiles.push(obj.mobiles[i]); } } if (obj.faxes) { for (const i in obj.faxes) { this.faxes.push(obj.faxes[i]); } } if (obj.urls) { for (const i in obj.urls) { this.urls.push(obj.urls[i]); } } if (obj.emails) { for (const i in obj.emails) { this.emails.push(obj.emails[i]); } } // removed by Noam request // if (obj.audit_changes) { // for (const i in obj.audit_changes) { // this.audit_changes.push(obj.audit_changes[i]); // } // } // if (obj.idx) { // this.idx = obj.idx; // } // if (obj.valid) { // this.valid = obj.valid; // } // if (obj.section_type) { // this.section_type = obj.section_type; // } // if (obj.section_idx) { // this.section_idx = obj.section_idx; // } // if (obj.n_sections) { // this.n_sections = obj.n_sections; // } // if (obj.section_valid) { // this.section_valid = obj.section_valid; // } // if (obj.text) { // this.text = obj.text; // } // if (obj.section_headline) { // this.section_headline = obj.section_headline; // } } } toJSON() { return { prefix: this.prefix, first: this.first, middle: this.middle, last: this.last, suffix: this.suffix, credentials: this.credentials, job_title: this.job_title, company: this.company, bio: this.bio, resume: this.resume, education: this.education, images: this.images, links: this.links, phones: this.phones, mobiles: this.mobiles, faxes: this.faxes, urls: this.urls, emails: this.emails, // removed by Noam request // idx: this.idx, // valid: this.valid, // section_type: this.section_type, // section_idx: this.section_idx, // n_sections: this.n_sections, // section_valid: this.section_valid, // section_headline: this.section_headline, // audit_changes: this.audit_changes, }; } public toNerEntities(type = 1) { let obj: any = { relationOptions: ['per:employee_of', 'per:schools_attended', 'per:title', 'no_relation'], entities: { section_headline: '', section_mteam: '', section_oteam: '', section_bod: '', section_obod: '', section_directory: '', person: '', bio: '', prefix: '', first: '', middle: '', last: '', suffix: '', credentials: '', job_title: '', company: '', image: '', link: '', phone: '', mobile: '', fax: '', urls: '', email: '', text: '' } }; return obj; } nerEntityTypeOptions(): any[] { return []; } } export class TeamsOrgDetails { organization = ''; title = ''; date_from = ''; date_to = ''; constructor(obj?) { if (obj) { if (obj.organization) { this.organization = obj.organization; } if (obj.title) { this.title = obj.title; } if (obj.date_from) { this.date_from = obj.date_from; } if (obj.date_to) { this.date_to = obj.date_to; } } } public toJSON() { return { organization: this.organization, title: this.title, date_from: this.date_from, date_to: this.date_to }; } }