@@ -173,12 +173,17 @@ function(action, entity, config){
173
173
}else {
174
174
config $ logger.info(" Setting Zenodo record metadata properties" )
175
175
}
176
+ # language
177
+ if (! is.null(entity $ language )){
178
+ zenodo_metadata $ addLanguage(entity $ language )
179
+ }
176
180
# basic record description
177
181
zenodo_metadata $ setTitle(entity $ titles [[" title" ]])
178
182
if (! is.null(entity $ titles [[" alternative" ]])){
179
183
zenodo_metadata $ addAdditionalTitle(entity $ titles [[" alternative" ]], type = " alternative-title" )
180
184
}
181
- zenodo_metadata $ setDescription(entity $ descriptions [[" abstract" ]])
185
+ abstract = gsub(" \n " , " <\b r>" , entity $ descriptions [[" abstract" ]])
186
+ zenodo_metadata $ setDescription(abstract )
182
187
if (! is.null(entity $ descriptions [[" info" ]])){
183
188
zenodo_metadata $ addAdditionalDescription(entity $ descriptions [[" info" ]], type = " technical-info" )
184
189
}
@@ -254,7 +259,54 @@ function(action, entity, config){
254
259
contact_added <- c(contact_added , contact $ identifiers [[" id" ]])
255
260
}
256
261
}
257
- # TODO contributors
262
+ # contributors
263
+ zenodo_metadata $ metadata $ contributors <- list ()
264
+ zenodo_role_types = c(" contactperson" , " datacollector" , " datacurator" , " datamanager" ,
265
+ " distributor" , " editor" , " funder" , " hostinginstitution" , " producer" ,
266
+ " projectleader" , " projectmanager" , " projectmember" , " registrationagency" ,
267
+ " registrationauthority" , " relatedperson" , " researcher" , " researchgroup" ,
268
+ " rightsholder" , " supervisor" , " sponsor" , " workpackageleader" ,
269
+ " other" )
270
+ for (zenodo_role_type in zenodo_role_types ){
271
+ contrib_added <- list ()
272
+ contacts <- list ()
273
+ if (length(entity $ contacts )> 0 ){
274
+ contacts <- entity $ contacts [sapply(entity $ contacts , function (x ){x $ role == zenodo_role_type })]
275
+ if (length(contacts )> 0 ){
276
+ config $ logger.info(sprintf(" Adding contributors with role '%s'" , zenodo_role_type ))
277
+ for (contact in contacts ){
278
+
279
+ # manage orcid?
280
+ orcid <- NULL
281
+ contrib_ids <- contact $ identifiers
282
+ if (any(names(contrib_ids )== " orcid" )){
283
+ contrib_ids <- contrib_ids [names(contrib_ids )== " orcid" ]
284
+ if (length(contrib_ids )> 0 ) orcid <- contrib_ids [[1 ]]
285
+ }
286
+ # add/update creators
287
+ if (! (contact $ identifiers [[" id" ]] %in% contrib_added )){
288
+ if (is.na(contact $ firstName ) || is.na(contact $ lastName )){
289
+ zenodo_metadata $ addContributor(
290
+ name = contact $ organizationName ,
291
+ affiliations = contact $ organizationName ,
292
+ role = zenodo_role_type ,
293
+ orcid = orcid
294
+ )
295
+ }else {
296
+ zenodo_metadata $ addContributor(
297
+ firstname = contact $ firstName ,
298
+ lastname = contact $ lastName ,
299
+ affiliations = contact $ organizationName ,
300
+ role = zenodo_role_type ,
301
+ orcid = orcid
302
+ )
303
+ }
304
+ contrib_added <- c(contrib_added , contact $ identifiers [[" id" ]])
305
+ }
306
+ }
307
+ }
308
+ }
309
+ }
258
310
259
311
# Licenses
260
312
if (length(entity $ rights )> 0 ){
@@ -325,14 +377,15 @@ function(action, entity, config){
325
377
}
326
378
327
379
# grants
328
- if (length(entity $ relations )){
329
- grants = entity $ relations [sapply(entity $ relations , function (x ){tolower(x $ key ) == " grant" })]
330
- if (length(grants )> 0 ){
331
- for (grant in grants ){
332
- zenodo_metadata $ addGrant(grant , sandbox = ZENODO $ sandbox )
333
- }
334
- }
335
- }
380
+ # TODO missing support in zen4R
381
+ # if(length(entity$relations)){
382
+ # grants = entity$relations[sapply(entity$relations, function(x){tolower(x$key) == "grant"})]
383
+ # if(length(grants)>0){
384
+ # for(grant in grants){
385
+ # zenodo_metadata$addGrant(grant, sandbox = ZENODO$sandbox)
386
+ # }
387
+ # }
388
+ # }
336
389
337
390
}else {
338
391
config $ logger.info(" Skipping update of Zenodo record metadata (option 'update_metadata' FALSE)" )
0 commit comments