diff --git a/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/QueryInformationSystem.java b/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/QueryInformationSystem.java index 678b270a06..5fe3cf81f9 100644 --- a/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/QueryInformationSystem.java +++ b/dhp-workflows/dhp-enrichment/src/main/java/eu/dnetlib/dhp/bulktag/community/QueryInformationSystem.java @@ -1,8 +1,10 @@ package eu.dnetlib.dhp.bulktag.community; +import java.io.IOException; import java.util.List; +import org.apache.commons.io.IOUtils; import org.dom4j.DocumentException; import org.xml.sax.SAXException; @@ -13,74 +15,17 @@ import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; public class QueryInformationSystem { - private static final String XQUERY = "for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') " - + " let $subj := $x//CONFIGURATION/context/param[./@name='subject']/text() " - + " let $datasources := $x//CONFIGURATION/context/category[./@id=concat($x//CONFIGURATION/context/@id,'::contentproviders')]/concept " - + " let $organizations := $x//CONFIGURATION/context/category[./@id=concat($x//CONFIGURATION/context/@id,'::resultorganizations')]/concept " - + " let $communities := $x//CONFIGURATION/context/category[./@id=concat($x//CONFIGURATION/context/@id,'::zenodocommunities')]/concept " - + " let $fos := $x//CONFIGURATION/context/param[./@name='fos']/text() " - + " let $sdg := $x//CONFIGURATION/context/param[./@name='sdg']/text() " - + - "let $zenodo := $x//param[./@name='zenodoCommunity']/text() " - + " where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] and $x//context/param[./@name = 'status']/text() != 'hidden' " - + " return " - + " " - + " { $x//CONFIGURATION/context/@id} " - + " " + - "{$x//CONFIGURATION/context/param[./@name='advancedConstraints']/text() }" + - "" - + " " - + " {for $y in tokenize($subj,',') " - + " return " - + " {$y}} " - + " {for $y in tokenize($fos,',') " - + " return " - + " {$y}} " - + " {for $y in tokenize($sdg,',') " - + " return " - + " {$y}} " - + " " - + " " - + " {for $d in $datasources " - + " where $d/param[./@name='enabled']/text()='true' " - + " return " - + " " - + " " - + " {$d//param[./@name='openaireId']/text()} " - + " " - + " " - + " {$d/param[./@name='selcriteria']/text()} " - + " " - + " } " - + " " + - " " + - "{for $zc in $zenodo " + - "return " + - " " + - " " + - "{$zc} " + - " " + - "}" - + " {for $zc in $communities " - + " return " - + " " - + " " - + " {$zc/param[./@name='zenodoid']/text()} " - + " " - + " " - + " {$zc/param[./@name='selcriteria']/text()} " - + " " - + " } " - + " " - + "" - + "{$x//CONFIGURATION/context/param[./@name='advancedConstraint']/text()} " - + "" - + " "; public static CommunityConfiguration getCommunityConfiguration(final String isLookupUrl) - throws ISLookUpException, DocumentException, SAXException { + throws ISLookUpException, DocumentException, SAXException, IOException { ISLookUpService isLookUp = ISLookupClientFactory.getLookUpService(isLookupUrl); - final List res = isLookUp.quickSearchProfile(XQUERY); + final List res = isLookUp + .quickSearchProfile( + IOUtils + .toString( + QueryInformationSystem.class + .getResourceAsStream( + "/eu/dnetlib/dhp/bulktag/query.xq"))); final String xmlConf = "" + Joiner.on(" ").join(res) + ""; diff --git a/dhp-workflows/dhp-enrichment/src/main/resources/eu/dnetlib/dhp/bulktag/query.xq b/dhp-workflows/dhp-enrichment/src/main/resources/eu/dnetlib/dhp/bulktag/query.xq index e69de29bb2..6fbd74c8f8 100644 --- a/dhp-workflows/dhp-enrichment/src/main/resources/eu/dnetlib/dhp/bulktag/query.xq +++ b/dhp-workflows/dhp-enrichment/src/main/resources/eu/dnetlib/dhp/bulktag/query.xq @@ -0,0 +1,58 @@ +for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') +let $subj := $x//CONFIGURATION/context/param[./@name='subject']/text() +let $datasources := $x//CONFIGURATION/context/category[./@id=concat($x//CONFIGURATION/context/@id,'::contentproviders')]/concept +let $organizations := $x//CONFIGURATION/context/category[./@id=concat($x//CONFIGURATION/context/@id,'::resultorganizations')]/concept +let $communities := $x//CONFIGURATION/context/category[./@id=concat($x//CONFIGURATION/context/@id,'::zenodocommunities')]/concept +let $fos := $x//CONFIGURATION/context/param[./@name='fos']/text() +let $sdg := $x//CONFIGURATION/context/param[./@name='sdg']/text() +let $zenodo := $x//param[./@name='zenodoCommunity']/text() +where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] and $x//context/param[./@name = 'status']/text() != 'hidden' +return + +{ $x//CONFIGURATION/context/@id} + +{$x//CONFIGURATION/context/param[./@name='advancedConstraints']/text() } + + + {for $y in tokenize($subj,',') + return + {$y}} + {for $y in tokenize($fos,',') + return + {$y}} + {for $y in tokenize($sdg,',') + return + {$y}} + + + {for $d in $datasources + where $d/param[./@name='enabled']/text()='true' + return + + + {$d//param[./@name='openaireId']/text()} + + + {$d/param[./@name='selcriteria']/text()} + + } + + +{for $zc in $zenodo +return + + +{$zc} + +} +{for $zc in $communities +return + + +{$zc/param[./@name='zenodoid']/text()} + + +{$zc/param[./@name='selcriteria']/text()} + +} + \ No newline at end of file