Skip to content

Commit 330f142

Browse files
committed
Merge branch 'staging'
2 parents 4118db0 + eb96dd2 commit 330f142

3 files changed

Lines changed: 147 additions & 87 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export default [
2+
'annelis',
3+
'bibid',
4+
'bnf',
5+
'cnrs-unit',
6+
'crunchbase',
7+
'cti',
8+
'dealroom',
9+
'ed',
10+
'euTransparency',
11+
'eter',
12+
'etid',
13+
'finess',
14+
'fundref',
15+
'googleScholar',
16+
'grid',
17+
'hatvp',
18+
'idhal',
19+
'idref',
20+
'isil',
21+
'isni',
22+
'oc',
23+
'openAlexStructId',
24+
'openAlexPersonId',
25+
'openAlexTermId',
26+
'orgref',
27+
'pia',
28+
'piaweb-organization',
29+
'piaweb-project',
30+
'pic',
31+
'rcr',
32+
'ringgold',
33+
'rna',
34+
'rnsr',
35+
'ror',
36+
'rtoad',
37+
'sdid',
38+
'siret',
39+
'uai',
40+
'wikidata',
41+
];

src/api/structures/root/root.middlewares.js

Lines changed: 15 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { client, db } from '../../../services/mongo.service';
22
import catalog from '../../commons/catalog';
33
import { BadRequestError, NotFoundError } from '../../commons/http-errors';
44
import readQuery from '../../commons/queries/structures.query';
5+
import identifierTypes from '../identifiers/bulk-import-identifier-types';
56
import {
67
categoriesRepository,
78
identifiersRepository,
@@ -152,88 +153,20 @@ export const fromPayloadToStructure = async (req, res, next) => {
152153
id: await catalog.getUniqueId('weblinks', 15),
153154
});
154155
}
155-
const structureIdentifiers = [];
156-
if (payload.idref) {
157-
structureIdentifiers.push({
158-
value: payload.idref,
159-
type: 'idref',
160-
createdBy: req.currentUser.id,
161-
createdAt: new Date(),
162-
id: await catalog.getUniqueId('identifiers', 15),
163-
});
164-
}
165-
if (payload.wikidata) {
166-
structureIdentifiers.push({
167-
value: payload.wikidata,
168-
type: 'wikidata',
169-
createdBy: req.currentUser.id,
170-
createdAt: new Date(),
171-
id: await catalog.getUniqueId('identifiers', 15),
172-
});
173-
}
174-
if (payload.uai) {
175-
structureIdentifiers.push({
176-
value: payload.uai,
177-
type: 'uai',
178-
createdBy: req.currentUser.id,
179-
createdAt: new Date(),
180-
id: await catalog.getUniqueId('identifiers', 15),
181-
});
182-
}
183-
if (payload.siret) {
184-
structureIdentifiers.push({
185-
value: payload.siret,
186-
type: 'siret',
187-
createdBy: req.currentUser.id,
188-
createdAt: new Date(),
189-
id: await catalog.getUniqueId('identifiers', 15),
190-
});
191-
}
192-
if (payload.rnsr) {
193-
structureIdentifiers.push({
194-
value: payload.rnsr,
195-
type: 'rnsr',
196-
createdBy: req.currentUser.id,
197-
createdAt: new Date(),
198-
id: await catalog.getUniqueId('identifiers', 15),
199-
});
200-
}
201-
if (payload.ed) {
202-
structureIdentifiers.push({
203-
value: payload.ed,
204-
type: 'ed',
205-
createdBy: req.currentUser.id,
206-
createdAt: new Date(),
207-
id: await catalog.getUniqueId('identifiers', 15),
208-
});
209-
}
210-
if (payload.crunchbase) {
211-
structureIdentifiers.push({
212-
value: payload.crunchbase,
213-
type: 'crunchbase',
214-
createdBy: req.currentUser.id,
215-
createdAt: new Date(),
216-
id: await catalog.getUniqueId('identifiers', 15),
217-
});
218-
}
219-
if (payload.dealroom) {
220-
structureIdentifiers.push({
221-
value: payload.dealroom,
222-
type: 'dealroom',
223-
createdBy: req.currentUser.id,
224-
createdAt: new Date(),
225-
id: await catalog.getUniqueId('identifiers', 15),
226-
});
227-
}
228-
if (payload.ror) {
229-
structureIdentifiers.push({
230-
value: payload.ror,
231-
type: 'ror',
232-
createdBy: req.currentUser.id,
233-
createdAt: new Date(),
234-
id: await catalog.getUniqueId('identifiers', 15),
235-
});
236-
}
156+
const structureIdentifiers = (await Promise.all(
157+
identifierTypes.map(async (type) => {
158+
if (payload[type]) {
159+
return {
160+
value: payload[type],
161+
type,
162+
createdBy: req.currentUser.id,
163+
createdAt: new Date(),
164+
id: await catalog.getUniqueId('identifiers', 15),
165+
};
166+
}
167+
return null;
168+
}),
169+
)).filter(Boolean);
237170
const structureSocialMedias = [];
238171
if (payload.twitter) {
239172
structureSocialMedias.push({

src/openapi/schemas/structures/structure-create-payload.yml

Lines changed: 91 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
title: StructureBulkInsertPayload
2-
description: Liste
2+
description: Liste
33
additionalProperties: false
44
type: object
55
properties:
@@ -46,7 +46,7 @@ properties:
4646
- dans les
4747
- aux
4848
- au
49-
- ''
49+
- ""
5050
- null
5151
structureStatus:
5252
type: string
@@ -62,7 +62,7 @@ properties:
6262
nullable: true
6363
creationOfficialTextId:
6464
type: string
65-
pattern: '^[a-zA-Z0-9]{15}$'
65+
pattern: "^[a-zA-Z0-9]{15}$"
6666
description: Identifiant d'un texte officiel
6767
nullable: true
6868
closureDate:
@@ -71,7 +71,7 @@ properties:
7171
nullable: true
7272
closureOfficialTextId:
7373
type: string
74-
pattern: '^[a-zA-Z0-9]{15}$'
74+
pattern: "^[a-zA-Z0-9]{15}$"
7575
description: Identifiant d'un texte officiel
7676
nullable: true
7777
creationReason:
@@ -172,4 +172,90 @@ properties:
172172
iso3:
173173
type: string
174174
nullable: true
175-
pattern: '^[A-Z]{3}$'
175+
annelis:
176+
type: string
177+
nullable: true
178+
bibid:
179+
type: string
180+
nullable: true
181+
bnf:
182+
type: string
183+
nullable: true
184+
cnrs-unit:
185+
type: string
186+
nullable: true
187+
cti:
188+
type: string
189+
nullable: true
190+
ringgold:
191+
type: string
192+
nullable: true
193+
euTransparency:
194+
type: string
195+
nullable: true
196+
eter:
197+
type: string
198+
nullable: true
199+
etid:
200+
type: string
201+
nullable: true
202+
finess:
203+
type: string
204+
nullable: true
205+
fundref:
206+
type: string
207+
nullable: true
208+
googleScholar:
209+
type: string
210+
nullable: true
211+
grid:
212+
type: string
213+
nullable: true
214+
hatvp:
215+
type: string
216+
nullable: true
217+
idhal:
218+
type: string
219+
nullable: true
220+
isil:
221+
type: string
222+
nullable: true
223+
isni:
224+
type: string
225+
nullable: true
226+
oc:
227+
type: string
228+
nullable: true
229+
openAlexPersonId:
230+
type: string
231+
nullable: true
232+
openAlexTermId:
233+
type: string
234+
nullable: true
235+
orgref:
236+
type: string
237+
nullable: true
238+
pia:
239+
type: string
240+
nullable: true
241+
piaweb-organization:
242+
type: string
243+
nullable: true
244+
piaweb-project:
245+
type: string
246+
nullable: true
247+
pic:
248+
type: string
249+
nullable: true
250+
rcr:
251+
type: string
252+
nullable: true
253+
rna:
254+
type: string
255+
nullable: true
256+
rtoad:
257+
type: string
258+
nullable: true
259+
sdid:
260+
type: string
261+
nullable: true

0 commit comments

Comments
 (0)