Skip to content

Commit 02f4dba

Browse files
committed
#390 support file upload, metadata deactivated for now (XML filetype not supported for upload)
1 parent 0c47b6f commit 02f4dba

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

R/geoflow_action.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,11 @@ register_actions <- function(){
527527
target = "entity",
528528
target_dir = "metadata",
529529
packages = list("metadataeditr"),
530-
available_options = list(),
530+
available_options = list(
531+
depositWithFiles = list(def = "Indicates if the action is uploading files", class = "logical", default = TRUE),
532+
depositDataPattern = list(def = "A regular expression to filter data files to upload in metadata editor", class = "character", default = ""),
533+
depositMetadataPattern = list(def = "A regular expression to filter metadata files to upload in metadata editor", class = "character", default = "")
534+
),
531535
fun = source(system.file("actions", "metadataeditr_create_project.R", package = "geoflow"))$value
532536
)
533537
)

inst/actions/metadataeditr_create_project.R

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ function(action, entity, config){
1515
collection_names = as.list(strsplit(MD_EDITOR_CONFIG$properties$collection_names, ",")[[1]])
1616
}
1717

18+
#options
19+
depositWithFiles <- action$getOption("depositWithFiles")
20+
depositDataPattern <- action$getOption("depositDataPattern")
21+
depositMetadataPattern <- action$getOption("depositMetadataPattern")
22+
1823
#basic function to map a geoflow_contact to a metadata editor contact
1924
produce_md_contact = function(x){
2025

@@ -344,4 +349,30 @@ function(action, entity, config){
344349
)
345350
}
346351
}
352+
353+
#files
354+
if(depositWithFiles){
355+
#data
356+
data_files <- list.files(file.path(getwd(),"data"), pattern = depositDataPattern)
357+
for(data_file in data_files){
358+
config$logger.info(sprintf("Upload data file '%s'", data_file))
359+
metadataeditr::resources_add(
360+
idno = entity$identifiers[["id"]],
361+
dctype = "dat",
362+
title = data_file,
363+
file_path = file.path(getwd(), "data", data_file)
364+
)
365+
}
366+
#metadata
367+
# metadata_files <- list.files(file.path(getwd(),"metadata"), pattern = depositMetadataPattern)
368+
# for(metadata_file in metadata_files){
369+
# config$logger.info(sprintf("Upload metadata file '%s'", metadata_file))
370+
# metadataeditr::resources_add(
371+
# idno = entity$identifiers[["id"]],
372+
# dctype = "dat",
373+
# title = metadata_file,
374+
# file_path = file.path(getwd(), "metadata", metadata_file)
375+
# )
376+
# }
377+
}
347378
}

0 commit comments

Comments
 (0)