Skip to content

Commit

Permalink
#387 manage record communities
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed May 24, 2024
1 parent 906cc16 commit 5371257
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: geoflow
Version: 0.20240520
Date: 2024-05-20
Version: 0.20240524
Date: 2024-05-24
Title: Tools to Orchestrate Geospatial (Meta)Data Management Workflows and Manage FAIR Services
Description: An engine to facilitate the orchestration and execution of metadata-driven data management workflows, in compliance with FAIR
(Findable, Accessible, Interoperable and Reusable) data management principles. By means of a pivot metadata model, relying on the DublinCore standard (<https://dublincore.org/>),
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Build Status](https://github.com/r-geoflow/geoflow/actions/workflows/r-cmd-check.yml/badge.svg?branch=master)](https://github.com/r-geoflow/geoflow/actions/workflows/r-cmd-check.yml)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/geoflow)](https://cran.r-project.org/package=geoflow)
[![Github_Status_Badge](https://img.shields.io/badge/Github-0.20240520-blue.svg)](https://github.com/r-geoflow/geoflow)
[![Github_Status_Badge](https://img.shields.io/badge/Github-0.20240524-blue.svg)](https://github.com/r-geoflow/geoflow)
[![DOI](https://zenodo.org/badge/DOI//10.5281/zenodo.3138920.svg)](https://doi.org//10.5281/zenodo.3138920)

**R engine to orchestrate and run (meta)data workflows**
Expand Down
33 changes: 27 additions & 6 deletions inst/actions/zen4R_deposit_record.R
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,6 @@ function(action, entity, config){
}
}

#communities
#TODO to analyze if this can be done with new Zenodo API
# if(length(communities)>0){
# zenodo_metadata$metadata$communities <- list()
# for(community in communities) if(!is.na(community)) zenodo_metadata$addCommunity(community, sandbox = ZENODO$sandbox)
# }
}else{
config$logger.info("Skipping update of Zenodo record metadata (option 'update_metadata' FALSE)")
}
Expand Down Expand Up @@ -499,6 +493,33 @@ function(action, entity, config){
errMsg <- sprintf("Zenodo: %s", out$errors[[1]]$message)
config$logger.error(errMsg)
stop(errMsg)
}else{
#business logic for communities
#check that record is not yet associated to community
#If ok, then check there is no pending request
#If ok, we submit it to the community
#If the geoflow user is maintainer of this community, make possible to accept immediatly the record
if(length(communities)>0){
for(community in communities){
config$logger.info(sprintf("-> Processing community %s", community))
zen_com = ZENODO$getCommunityById(community)
#we check the comunity exists
if(!is.null(zen_com)){
#we check if the record is already in community
rec_coms = ZENODO$getRecordCommunities(out)
has_com = FALSE
if(length(rec_coms)>0) has_com = any(sapply(rec_coms, function(x){x$id == zen_com$id}))
if(!has_com){
#if record is not in community we check pending requests
pending_reqs = ZENODO$getRequests(q = sprintf("status:submitted AND receiver.community:%s AND topic.record:%s", zen_com$id, out$id))
if(length(pending_reqs)==0){
ZENODO$submitToCommunities(record, communities = community)
#TODO in case the geoflow user is manager for the community, give action option to accept it immediatly
}
}
}
}
}
}

#we set the (prereserved) doi to the entity in question
Expand Down

0 comments on commit 5371257

Please sign in to comment.