Project

General

Profile

1 61381 k.triantaf
import {ResultLandingInfo} from "../utils/entities/resultLandingInfo";
2
import {ResultPreview} from "../utils/result-preview/result-preview";
3
4
export class WorkV3_0 {
5
  // automatically filled by orcid?
6
  "created-date" ?: CreatedDateV3_0;
7
  "last-modified-date" ?: LastModifiedDateV3_0;
8
  source ?: SourceV3_0;
9
10
  "put-code" ?: number;
11
  path ?: string;   // not sent
12
  title ?: WorkTitleV3_0;
13
  "journal-title" ?: TitleV3_0;
14
  "short-description" ?: string;
15
  citation ?: Citation; // not sent
16
  type ?: string;// = ['annotation', 'artistic-performance', 'book-chapter', 'book-review', 'book', 'conference-abstract', 'conference-paper', 'conference-poster', 'data-set', 'dictionary-entry', 'disclosure', 'dissertation-thesis', 'edited-book', 'encyclopedia-entry', 'invention', 'journal-article', 'journal-issue', 'lecture-speech', 'license', 'magazine-article', 'manual', 'newsletter-article', 'newspaper-article', 'online-resource', 'other', 'patent', 'physical-object', 'preprint', 'registered-copyright', 'report', 'research-technique', 'research-tool', 'software', 'spin-off-company', 'standards-and-policy', 'supervised-student-publication', 'technical-standard', 'test', 'trademark', 'translation', 'website', 'working-paper', 'undefined'],
17
  "publication-date" ?: PublicationDateV3_0;
18
  "external-ids" ?: ExternalIDsV3_0;
19
  url ?: UrlV3_0; // not sent - maybe url to landing with ?pid=...?
20
  contributors ?: WorkContributorsV3_0;
21
  "language-code" ?: string; // not sent // = ['ab', 'aa', 'af', 'ak', 'sq', 'am', 'ar', 'an', 'hy', 'as', 'av', 'ae', 'ay', 'az', 'bm', 'ba', 'eu', 'be', 'bn', 'bh', 'bi', 'bs', 'br', 'bg', 'my', 'ca', 'ch', 'ce', 'zh_CN', 'zh_TW', 'cu', 'cv', 'kw', 'co', 'cr', 'hr', 'cs', 'da', 'dv', 'nl', 'dz', 'en', 'eo', 'et', 'ee', 'fo', 'fj', 'fi', 'fr', 'fy', 'ff', 'gl', 'lg', 'ka', 'de', 'el', 'kl', 'gn', 'gu', 'ht', 'ha', 'iw', 'hz', 'hi', 'ho', 'hu', 'is', 'io', 'ig', 'in', 'ia', 'ie', 'iu', 'ik', 'ga', 'it', 'ja', 'jv', 'kn', 'kr', 'ks', 'kk', 'km', 'ki', 'rw', 'ky', 'kv', 'kg', 'ko', 'ku', 'kj', 'lo', 'la', 'lv', 'li', 'ln', 'lt', 'lu', 'lb', 'mk', 'mg', 'ms', 'ml', 'mt', 'gv', 'mi', 'mr', 'mh', 'mo', 'mn', 'na', 'nv', 'ng', 'ne', 'nd', 'se', 'no', 'nb', 'nn', 'ny', 'oc', 'oj', 'or', 'om', 'os', 'pi', 'pa', 'fa', 'pl', 'pt', 'ps', 'qu', 'rm', 'ro', 'rn', 'ru', 'sm', 'sg', 'sa', 'sc', 'gd', 'sr', 'sn', 'ii', 'sd', 'si', 'sk', 'sl', 'so', 'nr', 'st', 'es', 'su', 'sw', 'ss', 'sv', 'tl', 'ty', 'tg', 'ta', 'tt', 'te', 'th', 'bo', 'ti', 'to', 'ts', 'tn', 'tr', 'tk', 'tw', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'cy', 'wo', 'xh', 'ji', 'yo', 'za', 'zu'],
22
  country ?: CountryV3_0; // not sent
23
  visibility ?: string; // always public? // = ['limited', 'registered-only', 'public']
24
25
  private static mapType(type: string): string {
26
    if(type == "Annotation") {
27
      return "annotation";
28
    } else if(type == "Article") {
29
      return "journal-article";
30
    } else if(type == "Book") {
31
      return "book";
32
    } else if(type == "Clinical Trial") {
33
      return "test";
34
    } else if(type == "Dataset") {
35
      return "data-set";
36
    } else if(type == "Doctoral thesis") {
37
      return "dissertation-thesis";
38
    // } else if(type == "Film") {
39
    //   return "artistic-performance";
40
    } else if(type == "Lecture") {
41
      return "lecture-speech";
42
    } else if(type == "Newsletter") {
43
      return "newsletter-article";
44
    } else if(type == "Part of book or chapter of book") {
45
      return "book-chapter";
46
    } else if(type == "Patent") {
47
      return "patent";
48
    } else if(type == "PhysicalObject") {
49
      return "physical-object";
50
    } else if(type == "Preprint") {
51
      return "preprint";
52
    } else if(type == "Report") {
53
      return "report";
54
    } else if(type == "Research") {
55
      return "working-paper";
56
    } else if(type == "Review") {
57
      return "book-review";
58
    } else if(type == "Software") {
59
      return "software";
60
    }
61
    return "other";
62
  }
63
64
  public static resultLandingInfoConvert(resultLandingInfo: ResultLandingInfo, putCode: string) : WorkV3_0 {
65
    let description_limit: number = 5000;
66
67
    let work: WorkV3_0 = {};
68
    // let work = {};
69
70
    // created-date (CreatedDateV3_0, optional),
71
    // last-modified-date (LastModifiedDateV3_0, optional),
72
    //
73
    // work["source"] = {
74
    //   "source-orcid": {
75
    //     "uri": "https://sandbox.orcid.org/0000-0001-9541-4617",
76
    //     "path": "0000-0001-9541-4617",
77
    //     "host": "sandbox.orcid.org"
78
    //   }
79
    // };
80
    // work["source-client-id"] = null;
81
    // work["source-name"] = {
82
    //     "value": "OpenAIRE OpenAIRE"
83
    // };
84
    // work["assertion-origin-orcid"] = null;
85
    // work["assertion-origin-client-id"] = null;
86
    // work["assertion-origin-name"] = null;
87
    //
88
    if(putCode) {
89
      work['put-code'] = +putCode;
90
    }
91
    //   path (string, optional),
92
93
    if(resultLandingInfo.title || resultLandingInfo.subtitle) {
94
      let title = {};
95
      if(resultLandingInfo.title ) {
96
        title['title'] = {"value": resultLandingInfo.title};
97
      }
98
      if(resultLandingInfo.subtitle) {
99
        title['subtitle'] = { "value": resultLandingInfo.subtitle };
100
      }
101
      // translated-title
102
      work['title'] = title;
103
    }
104
105
    if(resultLandingInfo.journal && resultLandingInfo.journal.journal) {
106
      work['journal-title'] = { "value": resultLandingInfo.journal.journal };
107
    }
108
109
    if(resultLandingInfo.description && resultLandingInfo.description.length < description_limit) {
110
      work['short-description'] = resultLandingInfo.description;
111
    }
112
113
    // citation (Citation, optional),
114
115
    if(resultLandingInfo.types) {
116
      for(let type of resultLandingInfo.types) {
117
        work['type'] = this.mapType(type);
118
        if(work['type'] != "other") {
119
          break;
120
        }
121
      }
122
      // work['type'] = this.mapType(resultLandingInfo.types[0]);
123
    }
124
125
    if(resultLandingInfo.date || resultLandingInfo.dateofacceptance) {
126
      if(resultLandingInfo.dateofacceptance) {
127
        work['publication-date'] = {
128
          "year": { "value": ('0' + resultLandingInfo.dateofacceptance.getFullYear()).slice(-4) },
129
          "month": { "value": ('0' + (resultLandingInfo.dateofacceptance.getMonth() + 1)).slice(-2) },
130
          "day": { "value": ('0' + resultLandingInfo.dateofacceptance.getDate()).slice(-2) }
131
        }
132
      } else {
133
        work['publication-date'] = {
134
          "year": { "value": resultLandingInfo.date+"" }
135
        }
136
      }
137
    }
138
139
    if(resultLandingInfo.identifiers) {
140
      work['external-ids'] = { 'external-id': [] };
141
      resultLandingInfo.identifiers.forEach(((values, key) => {
142
        values.forEach(value => {
143
          work['external-ids']['external-id'].push(
144
            {
145
              "external-id-type": key,
146
              "external-id-value": value,
147
              "external-id-relationship": "self"
148
            }
149
          )
150
        })
151
      }))
152
    }
153
154
    // url (UrlV3_0, optional),
155
156
    if(resultLandingInfo.authors) {
157
      work['contributors'] = { 'contributor': [] };
158
      resultLandingInfo.authors.forEach((author, index) => {
159
        let contributor = {};
160
        if(author.orcid) {
161
          contributor["contributor-orcid"] =
162
            {
163
              // "uri": "string",
164
              "path": author.orcid.toUpperCase()
165
              // "host": "string"
166
            }
167
        }
168
        if(author.fullName) {
169
          contributor["credit-name"] =
170
            {
171
              "value": author.fullName
172
            }
173
        }
174
        // "contributor-email": {
175
        //   "value": "string"
176
        // },
177
        contributor["contributor-attributes"] = {
178
          "contributor-sequence": index == 0 ? "first" : "additional",
179
          "contributor-role": "author"
180
        };
181
182
        work['contributors']['contributor'].push(contributor);
183
      })
184
    }
185
186
    if(resultLandingInfo.languages) {
187
      // work["language-code"] = "";
188
    }
189
190
    if(resultLandingInfo.countries) {
191
      // work["country"] = {
192
      //   "value": "AF"
193
      // }
194
    }
195
196
    // visibility (string, optional) = ['limited', 'registered-only', 'public']
197
198
    return work;
199
  }
200
}
201
202
export interface CreatedDateV3_0 {
203
  value ?: string;//read only)
204
}
205
206
export interface LastModifiedDateV3_0 {
207
  value ?: string;//read only)
208
}
209
210
export interface SourceV3_0 {
211
  "source-orcid" ?: SourceOrcidV3_0;
212
  "source-client-id" ?: SourceClientIdV3_0;
213
  "source-name" ?: SourceNameV3_0;
214
  "assertion-origin-orcid" ?: SourceOrcidV3_0;
215
  "assertion-origin-client-id" ?: SourceClientIdV3_0;
216
  "assertion-origin-name" ?: SourceNameV3_0;
217
}
218
219
export interface WorkTitleV3_0 {
220
  title ?: TitleV3_0;
221
  subtitle ?: SubtitleV3_0;
222
  "translated-title" ?: TranslatedTitleV3_0;
223
}
224
225
export interface TitleV3_0 {
226
  value ?: string;
227
}
228
229
export interface Citation {
230
  "citation-type": string;//= ['formatted-unspecified', 'bibtex', 'formatted-apa', 'formatted-harvard', 'formatted-ieee', 'formatted-mla', 'formatted-vancouver', 'formatted-chicago', 'ris'],
231
  "citation-value": string;
232
}
233
234
export interface PublicationDateV3_0 {
235
  year: YearV3_0;
236
  month ?: MonthV3_0;
237
  day ?: DayV3_0;
238
}
239
240
export interface ExternalIDsV3_0 {
241
  "external-id" ?: ExternalIDV3_0[];
242
}
243
244
export interface UrlV3_0 {
245
  value ?: string;
246
}
247
248
export interface WorkContributorsV3_0 {
249
  contributor ?: ContributorV3_0[];
250
}
251
252
export interface CountryV3_0 {
253
  value ?: string;// = ['AF', 'AX', 'AL', 'DZ', 'AS', 'AD', 'AO', 'AI', 'AQ', 'AG', 'AR', 'AM', 'AW', 'AU', 'AT', 'AZ', 'BS', 'BH', 'BD', 'BB', 'BY', 'BE', 'BZ', 'BJ', 'BM', 'BT', 'BO', 'BQ', 'BA', 'BW', 'BV', 'BR', 'IO', 'BN', 'BG', 'BF', 'BI', 'KH', 'CM', 'CA', 'CV', 'KY', 'CF', 'TD', 'CL', 'CN', 'CX', 'CC', 'CO', 'KM', 'CG', 'CD', 'CK', 'CR', 'CI', 'HR', 'CU', 'CW', 'CY', 'CZ', 'DK', 'DJ', 'DM', 'DO', 'EC', 'EG', 'SV', 'GQ', 'ER', 'EE', 'ET', 'FK', 'FO', 'FJ', 'FI', 'FR', 'GF', 'PF', 'TF', 'GA', 'GM', 'GE', 'DE', 'GH', 'GI', 'GR', 'GL', 'GD', 'GP', 'GU', 'GT', 'GG', 'GN', 'GW', 'GY', 'HT', 'HM', 'VA', 'HN', 'HK', 'HU', 'IS', 'IN', 'ID', 'IR', 'IQ', 'IE', 'IM', 'IL', 'IT', 'JM', 'JP', 'JE', 'JO', 'KZ', 'KE', 'KI', 'KP', 'KR', 'KW', 'KG', 'LA', 'LV', 'LB', 'LS', 'LR', 'LY', 'LI', 'LT', 'LU', 'MO', 'MK', 'MG', 'MW', 'MY', 'MV', 'ML', 'MT', 'MH', 'MQ', 'MR', 'MU', 'YT', 'MX', 'FM', 'MD', 'MC', 'MN', 'ME', 'MS', 'MA', 'MZ', 'MM', 'NA', 'NR', 'NP', 'NL', 'NC', 'NZ', 'NI', 'NE', 'NG', 'NU', 'NF', 'MP', 'NO', 'OM', 'PK', 'PW', 'PS', 'PA', 'PG', 'PY', 'PE', 'PH', 'PN', 'PL', 'PT', 'PR', 'QA', 'RE', 'RO', 'RU', 'RW', 'BL', 'SH', 'KN', 'LC', 'MF', 'PM', 'VC', 'WS', 'SM', 'ST', 'SA', 'SN', 'RS', 'SC', 'SL', 'SG', 'SX', 'SK', 'SI', 'SB', 'SO', 'ZA', 'GS', 'SS', 'ES', 'LK', 'SD', 'SR', 'SJ', 'SZ', 'SE', 'CH', 'SY', 'TJ', 'TZ', 'TH', 'TL', 'TG', 'TK', 'TO', 'TT', 'TN', 'TR', 'TM', 'TC', 'TV', 'UG', 'UA', 'AE', 'GB', 'US', 'UM', 'UY', 'UZ', 'VU', 'VE', 'VN', 'VG', 'VI', 'WF', 'EH', 'YE', 'ZM', 'ZW', 'TW', 'XK']
254
}
255
256
export interface SourceOrcidV3_0 {
257
  uri ?: string;
258
  path ?: string;
259
  host ?: string;
260
}
261
262
export interface SourceClientIdV3_0 {
263
  uri ?: string;
264
  path ?: string;
265
  host ?: string;
266
}
267
268
export interface SourceNameV3_0 {
269
  value ?: string;
270
}
271
272
export interface SubtitleV3_0 {
273
  value ?: string;
274
}
275
276
export interface TranslatedTitleV3_0 {
277
  value ?: string;
278
  "language-code": string;// = ['ab', 'aa', 'af', 'ak', 'sq', 'am', 'ar', 'an', 'hy', 'as', 'av', 'ae', 'ay', 'az', 'bm', 'ba', 'eu', 'be', 'bn', 'bh', 'bi', 'bs', 'br', 'bg', 'my', 'ca', 'ch', 'ce', 'zh_CN', 'zh_TW', 'cu', 'cv', 'kw', 'co', 'cr', 'hr', 'cs', 'da', 'dv', 'nl', 'dz', 'en', 'eo', 'et', 'ee', 'fo', 'fj', 'fi', 'fr', 'fy', 'ff', 'gl', 'lg', 'ka', 'de', 'el', 'kl', 'gn', 'gu', 'ht', 'ha', 'iw', 'hz', 'hi', 'ho', 'hu', 'is', 'io', 'ig', 'in', 'ia', 'ie', 'iu', 'ik', 'ga', 'it', 'ja', 'jv', 'kn', 'kr', 'ks', 'kk', 'km', 'ki', 'rw', 'ky', 'kv', 'kg', 'ko', 'ku', 'kj', 'lo', 'la', 'lv', 'li', 'ln', 'lt', 'lu', 'lb', 'mk', 'mg', 'ms', 'ml', 'mt', 'gv', 'mi', 'mr', 'mh', 'mo', 'mn', 'na', 'nv', 'ng', 'ne', 'nd', 'se', 'no', 'nb', 'nn', 'ny', 'oc', 'oj', 'or', 'om', 'os', 'pi', 'pa', 'fa', 'pl', 'pt', 'ps', 'qu', 'rm', 'ro', 'rn', 'ru', 'sm', 'sg', 'sa', 'sc', 'gd', 'sr', 'sn', 'ii', 'sd', 'si', 'sk', 'sl', 'so', 'nr', 'st', 'es', 'su', 'sw', 'ss', 'sv', 'tl', 'ty', 'tg', 'ta', 'tt', 'te', 'th', 'bo', 'ti', 'to', 'ts', 'tn', 'tr', 'tk', 'tw', 'ug', 'uk', 'ur', 'uz', 've', 'vi', 'vo', 'wa', 'cy', 'wo', 'xh', 'ji', 'yo', 'za', 'zu']
279
}
280
281
export interface YearV3_0 {
282
  value ?: string;
283
}
284
285
export interface MonthV3_0 {
286
  value ?: string;
287
}
288
289
export interface DayV3_0 {
290
  value ?: string;
291
}
292
293
export interface ExternalIDV3_0 {
294
  "external-id-type": string;
295
  "external-id-value": string;
296
  "external-id-normalized"?: TransientNonEmptyString;
297
  "external-id-normalized-error"?: TransientError;
298
  "external-id-url"?: UrlV3_0;
299
  "external-id-relationship"?: string;// = ['part-of', 'self', 'version-of']}
300
}
301
302
export interface ContributorV3_0 {
303
  "contributor-orcid" ?: ContributorOrcidV3_0;
304
  "credit-name" ?: CreditNameV3_0;
305
  "contributor-email" ?: ContributorEmailV3_0;
306
  "contributor-attributes" ?: ContributorAttributesV3_0;
307
}
308
309
export interface TransientNonEmptyString {
310
  value ?: string;
311
  transient ?: boolean;
312
}
313
314
export interface TransientError {
315
  "error-code": string;
316
  "error-message": string;
317
  transient: boolean;
318
}
319
320
export interface ContributorOrcidV3_0 {
321
  uri ?: string;
322
  path ?: string;
323
  host ?: string;
324
}
325
326
export interface CreditNameV3_0 {
327
  value ?: string;
328
}
329
330
export interface ContributorEmailV3_0 {
331
  value ?: string;
332
}
333
334
export interface ContributorAttributesV3_0 {
335
  "contributor-sequence": string;// = ['first', 'additional'],
336
  "contributor-role": string;// = ['author', 'assignee', 'editor', 'chair-or-translator', 'co-investigator', 'co-inventor', 'graduate-student', 'other-inventor', 'principal-investigator', 'postdoctoral-researcher', 'support-staff']
337
}