Merge pull request 'enrichment_wfs' (#39) from enrichment_wfs into master

LGTM
This commit is contained in:
Claudio Atzori 2020-08-11 17:26:13 +02:00
commit f7cc52ab02
5 changed files with 46 additions and 27 deletions

View File

@ -110,13 +110,13 @@ public class CommunityConfigurationFactory {
} }
private static List<ZenodoCommunity> parseZenodoCommunities(final Node node) { private static List<ZenodoCommunity> parseZenodoCommunities(final Node node) {
final Node oacommunitynode = node.selectSingleNode("./oacommunity"); // final Node oacommunitynode = node.selectSingleNode("./oacommunity");
String oacommunity = null; // String oacommunity = null;
if (oacommunitynode != null) { // if (oacommunitynode != null) {
String tmp = oacommunitynode.getText(); // String tmp = oacommunitynode.getText();
if (StringUtils.isNotBlank(tmp)) // if (StringUtils.isNotBlank(tmp))
oacommunity = tmp; // oacommunity = tmp;
} // }
final List<Node> list = node.selectNodes("./zenodocommunities/zenodocommunity"); final List<Node> list = node.selectNodes("./zenodocommunities/zenodocommunity");
final List<ZenodoCommunity> zenodoCommunityList = new ArrayList<>(); final List<ZenodoCommunity> zenodoCommunityList = new ArrayList<>();
@ -127,11 +127,11 @@ public class CommunityConfigurationFactory {
zenodoCommunityList.add(zc); zenodoCommunityList.add(zc);
} }
if (oacommunity != null) { // if (oacommunity != null) {
ZenodoCommunity zc = new ZenodoCommunity(); // ZenodoCommunity zc = new ZenodoCommunity();
zc.setZenodoCommunityId(oacommunity); // zc.setZenodoCommunityId(oacommunity);
zenodoCommunityList.add(zc); // zenodoCommunityList.add(zc);
} // }
log.info("size of the zenodo community list " + zenodoCommunityList.size()); log.info("size of the zenodo community list " + zenodoCommunityList.size());
return zenodoCommunityList; return zenodoCommunityList;
} }

View File

@ -44,7 +44,7 @@ public class Provider implements Serializable {
} }
private void setSelCriteria(String json, VerbResolver resolver) { private void setSelCriteria(String json, VerbResolver resolver) {
log.info("Selection constraints for datasource = " + json); log.debug("Selection constraints for datasource = " + json);
selectionConstraints = new Gson().fromJson(json, SelectionConstraints.class); selectionConstraints = new Gson().fromJson(json, SelectionConstraints.class);
selectionConstraints.setSelection(resolver); selectionConstraints.setSelection(resolver);
@ -54,7 +54,7 @@ public class Provider implements Serializable {
try { try {
setSelCriteria(n.getText(), resolver); setSelCriteria(n.getText(), resolver);
} catch (Exception e) { } catch (Exception e) {
log.info("not set selection criteria... "); log.debug("not set selection criteria... ");
selectionConstraints = null; selectionConstraints = null;
} }
} }

View File

@ -17,6 +17,8 @@ public class QueryInformationSystem {
+ " let $datasources := $x//CONFIGURATION/context/category[./@id=concat($x//CONFIGURATION/context/@id,'::contentproviders')]/concept " + " 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 $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 $communities := $x//CONFIGURATION/context/category[./@id=concat($x//CONFIGURATION/context/@id,'::zenodocommunities')]/concept "
+
"let $zenodo := $x//param[./@name='zenodoCommunity']/text() "
+ " where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] " + " where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] "
+ " return " + " return "
+ " <community> " + " <community> "
@ -38,8 +40,15 @@ public class QueryInformationSystem {
+ " {$d/param[./@name='selcriteria']/text()} " + " {$d/param[./@name='selcriteria']/text()} "
+ " </selcriteria> " + " </selcriteria> "
+ " </datasource> } " + " </datasource> } "
+ " </datasources> " + " </datasources> " +
+ " <zenodocommunities> " " <zenodocommunities> " +
"{for $zc in $zenodo " +
"return " +
"<zenodocommunity> " +
"<zenodoid> " +
"{$zc} " +
"</zenodoid> " +
"</zenodocommunity>}"
+ " {for $zc in $communities " + " {for $zc in $communities "
+ " return " + " return "
+ " <zenodocommunity> " + " <zenodocommunity> "

View File

@ -71,10 +71,9 @@ public class ResultTagger implements Serializable {
// tagging for Subject // tagging for Subject
final Set<String> subjects = new HashSet<>(); final Set<String> subjects = new HashSet<>();
Optional<List<StructuredProperty>> oresultsubj = Optional.ofNullable(result.getSubject());
if (oresultsubj.isPresent()) { if (Objects.nonNull(result.getSubject())){
oresultsubj result.getSubject()
.get()
.stream() .stream()
.map(subject -> subject.getValue()) .map(subject -> subject.getValue())
.filter(StringUtils::isNotBlank) .filter(StringUtils::isNotBlank)
@ -90,15 +89,23 @@ public class ResultTagger implements Serializable {
final Set<String> datasources = new HashSet<>(); final Set<String> datasources = new HashSet<>();
final Set<String> tmp = new HashSet<>(); final Set<String> tmp = new HashSet<>();
Optional<List<Instance>> oresultinstance = Optional.ofNullable(result.getInstance()); if (Objects.nonNull(result.getInstance())) {
if (oresultinstance.isPresent()) { for (Instance i : result.getInstance()) {
for (Instance i : oresultinstance.get()) { if(Objects.nonNull(i.getCollectedfrom())){
tmp.add(StringUtils.substringAfter(i.getCollectedfrom().getKey(), "|")); if(Objects.nonNull(i.getCollectedfrom().getKey())){
tmp.add(StringUtils.substringAfter(i.getHostedby().getKey(), "|")); tmp.add(StringUtils.substringAfter(i.getCollectedfrom().getKey(), "|"));
}
}
if(Objects.nonNull(i.getHostedby())){
if(Objects.nonNull(i.getHostedby().getKey())){
tmp.add(StringUtils.substringAfter(i.getHostedby().getKey(), "|"));
}
}
} }
oresultinstance result
.get() .getInstance()
.stream() .stream()
.map(i -> new Pair<>(i.getCollectedfrom().getKey(), i.getHostedby().getKey())) .map(i -> new Pair<>(i.getCollectedfrom().getKey(), i.getHostedby().getKey()))
.flatMap(p -> Stream.of(p.getFst(), p.getSnd())) .flatMap(p -> Stream.of(p.getFst(), p.getSnd()))

View File

@ -257,6 +257,9 @@
<zenodoid>bodhgaya</zenodoid> <zenodoid>bodhgaya</zenodoid>
<selcriteria/> <selcriteria/>
</zenodocommunity> </zenodocommunity>
<zenodocommunity>
<zenodoid>oac_dh-ch</zenodoid>
</zenodocommunity>
</zenodocommunities> </zenodocommunities>
<organizations/> <organizations/>
</community> </community>