diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/QueryInformationSystem.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/QueryInformationSystem.java
index fe4036925..d1f295fcf 100644
--- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/QueryInformationSystem.java
+++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/QueryInformationSystem.java
@@ -17,7 +17,7 @@ public class QueryInformationSystem {
private ISLookUpService isLookUp;
- private static final String XQUERY = "for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') "
+ private static final String XQUERY_ALL = "for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') "
+
" where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] " +
" and ($x//context/param[./@name = 'status']/text() = 'all') "
@@ -28,9 +28,22 @@ public class QueryInformationSystem {
"{$x//CONFIGURATION/context/@label}" +
"";
- public CommunityMap getCommunityMap()
+ private static final String XQUERY_CI = "for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') "
+ +
+ " where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] " +
+ " and $x//CONFIGURATION/context[./@id=%s] "
+ +
+ " return " +
+ " " +
+ "{$x//CONFIGURATION/context/@id}" +
+ "{$x//CONFIGURATION/context/@label}" +
+ "";
+
+ public CommunityMap getCommunityMap(boolean singleCommunity, String community_id)
throws ISLookUpException, DocumentException {
- return getMap(isLookUp.quickSearchProfile(XQUERY));
+ if (singleCommunity)
+ return getMap(isLookUp.quickSearchProfile(XQUERY_CI.replace("%s", "'" + community_id + "'")));
+ return getMap(isLookUp.quickSearchProfile(XQUERY_ALL));
}
diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SaveCommunityMap.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SaveCommunityMap.java
index 6ac626518..0d41b6646 100644
--- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SaveCommunityMap.java
+++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/dump/SaveCommunityMap.java
@@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
+import java.util.Optional;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
@@ -71,14 +72,19 @@ public class SaveCommunityMap implements Serializable {
final String isLookUpUrl = parser.get("isLookUpUrl");
log.info("isLookUpUrl: {}", isLookUpUrl);
+ final Boolean singleCommunity = Optional.ofNullable(parser.get("singleDeposition"))
+ .map(Boolean::valueOf).orElse(false);
+
+ final String community_id = Optional.ofNullable(parser.get("communityId")).orElse(null);
+
final SaveCommunityMap scm = new SaveCommunityMap(outputPath, nameNode, isLookUpUrl);
- scm.saveCommunityMap();
+ scm.saveCommunityMap(singleCommunity, community_id);
}
- private void saveCommunityMap() throws ISLookUpException, IOException, DocumentException {
- writer.write(Utils.OBJECT_MAPPER.writeValueAsString(queryInformationSystem.getCommunityMap()));
+ private void saveCommunityMap(boolean singleCommunity, String community_id) throws ISLookUpException, IOException, DocumentException {
+ writer.write(Utils.OBJECT_MAPPER.writeValueAsString(queryInformationSystem.getCommunityMap(singleCommunity, community_id)));
writer.close();
}
}
diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/workflow.xml b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/workflow.xml
index b72b843b5..ac199c05a 100644
--- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/workflow.xml
+++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/community/oozie_app/workflow.xml
@@ -134,29 +134,31 @@
--outputPath${workingDir}/communityMap
--nameNode${nameNode}
--isLookUpUrl${isLookUpUrl}
-
-
-
-
-
-
-
- ${wf:conf('singleDeposition') eq true}
-
-
-
-
-
-
- eu.dnetlib.dhp.oa.graph.dump.community.RemoveCommunities
- --path${workingDir}/communityMap
- --nameNode${nameNode}
- --communityId${communityId}
+ --singleDeposition${singleDeposition}
+ --communityId>${communityId}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/input_cm_parameters.json b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/input_cm_parameters.json
index 6e42bfa64..677715847 100644
--- a/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/input_cm_parameters.json
+++ b/dhp-workflows/dhp-graph-mapper/src/main/resources/eu/dnetlib/dhp/oa/graph/dump/input_cm_parameters.json
@@ -18,6 +18,18 @@
"paramLongName": "outputPath",
"paramDescription": "the path used to store temporary output files",
"paramRequired": true
+ },
+ {
+ "paramName": "sd",
+ "paramLongName": "singleDeposition",
+ "paramDescription": "true if the dump should be created for a single community",
+ "paramRequired": true
+ },
+ {
+ "paramName": "ci",
+ "paramLongName": "communityId",
+ "paramDescription": "the id of the community for which to create the dump",
+ "paramRequired": true
}
]