Skip to content

Commit eb6d156

Browse files
committed
#293 allow layername support with temp shp renaming; test uuid recycling (not working for now)
1 parent fd32981 commit eb6d156

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

R/geoflow_entity.R

+9
Original file line numberDiff line numberDiff line change
@@ -1166,11 +1166,20 @@ geoflow_entity <- R6Class("geoflow_entity",
11661166
enrichWithIdentifiers = function(config){
11671167
geometa_action <- NULL
11681168
actions <- list()
1169+
1170+
#on geometa, set uuid in case geometa is run with option use_uuid is enabled / and no uuid already set
11691171
if(length(config$actions)>0) actions <- config$actions[sapply(config$actions, function(x){regexpr("geometa-create-iso-19115",x$id)>0})]
11701172
if(length(actions)>0) geometa_action <- actions[[1]]
11711173
if(!is.null(geometa_action)) if(geometa_action$getOption("use_uuid")) if(is.null(self$identifiers[["uuid"]])){
11721174
self$identifiers[["uuid"]] <- uuid::UUIDgenerate()
11731175
}
1176+
1177+
#on geonode4R, set uuid in case action is run / and no uuid already set
1178+
if(length(config$actions)>0) actions <- config$actions[sapply(config$actions, function(x){regexpr("geonode4R-publish-ogc-services",x$id)>0})]
1179+
if(length(actions)>0) geonode4R_action <- actions[[1]]
1180+
if(!is.null(geonode4R_action)) if(is.null(self$identifiers[["uuid"]])){
1181+
self$identifiers[["uuid"]] <- uuid::UUIDgenerate()
1182+
}
11741183
},
11751184

11761185
#'@description This function that will enrich the entity with relations. At now this is essentially related to adding

inst/actions/geonode4R_publish_ogc_services.R

+16-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function(action, entity, config){
4343

4444
#check if resources already exists
4545
#-------------------------------------------------------------------------------------------------
46-
resource = GEONODE$getResourceByUUID(uuid = entity$identifiers$id)
46+
resource = GEONODE$getResourceByUUID(uuid = entity$identifiers[["uuid"]])
4747
if(!is.null(resource)){
4848
config$logger.warn(sprintf("Resource '%s' (id = %s) already exists! Deleting it...", resource$uuid, resource$pk))
4949
deleted = GEONODE$deleteResource(id = resource$pk)
@@ -67,8 +67,21 @@ function(action, entity, config){
6767
config$logger.info(sprintf("Upload file '%s' [%s] to GeoNode...", filepath, data_object$uploadType))
6868
files = list.files(path = "data", pattern = datasource_name, full.names = TRUE)
6969
files = files[!endsWith(files, ".zip")]
70-
created = GEONODE$upload(files)
71-
uploaded = created$success
70+
dir.create("data/temp")
71+
for(file in files){
72+
file_ext = unlist(strsplit(file, "\\."))[2]
73+
target = file.path(getwd(), "data/temp", paste0(layername, ".", file_ext))
74+
file.copy(from = file, to = target, copy.mode = T)
75+
if(file_ext == "xml"){
76+
#post-process metadata identifier if existing to match entity uuid
77+
md = geometa::readISO19139(target)
78+
md$fileIdentifier <- entity$identifiers[["uuid"]]
79+
md$save(target)
80+
}
81+
}
82+
created = GEONODE$upload(files = list.files(path = "data/temp", pattern = layername, full.names = TRUE))
83+
uploaded = !is.null(created$dataset)
84+
unlink("data/temp",recursive = TRUE, force = TRUE)
7285
}else{
7386
errMsg <- sprintf("Upload from local file(s): no zipped file found for source '%s' (%s)", filepath, datasource)
7487
config$logger.error(errMsg)

0 commit comments

Comments
 (0)