forked from D-Net/dnet-hadoop
Merge pull request 'horizontalConstraints' (#259) from horizontalConstraints into beta
Reviewed-on: D-Net/dnet-hadoop#259
This commit is contained in:
commit
7d264a1d69
|
@ -26,6 +26,9 @@ public class QueryInformationSystem {
|
||||||
+ " return "
|
+ " return "
|
||||||
+ " <community> "
|
+ " <community> "
|
||||||
+ " { $x//CONFIGURATION/context/@id} "
|
+ " { $x//CONFIGURATION/context/@id} "
|
||||||
|
+ " <advancedConstraints>" +
|
||||||
|
"{$x//CONFIGURATION/context/param[./@name='advancedConstraints']/text() }" +
|
||||||
|
"</advancedConstraints>"
|
||||||
+ " <subjects> "
|
+ " <subjects> "
|
||||||
+ " {for $y in tokenize($subj,',') "
|
+ " {for $y in tokenize($subj,',') "
|
||||||
+ " return "
|
+ " return "
|
||||||
|
|
|
@ -9,16 +9,16 @@ import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||||
|
import eu.dnetlib.dhp.schema.common.ModelSupport;
|
||||||
|
import eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.jayway.jsonpath.DocumentContext;
|
import com.jayway.jsonpath.DocumentContext;
|
||||||
import com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
|
|
||||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
|
||||||
import eu.dnetlib.dhp.schema.common.ModelSupport;
|
|
||||||
import eu.dnetlib.dhp.schema.oaf.*;
|
import eu.dnetlib.dhp.schema.oaf.*;
|
||||||
import eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils;
|
|
||||||
|
|
||||||
/** Created by miriam on 02/08/2018. */
|
/** Created by miriam on 02/08/2018. */
|
||||||
public class ResultTagger implements Serializable {
|
public class ResultTagger implements Serializable {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.spark.SparkConf;
|
import org.apache.spark.SparkConf;
|
||||||
import org.apache.spark.api.java.JavaRDD;
|
import org.apache.spark.api.java.JavaRDD;
|
||||||
import org.apache.spark.api.java.JavaSparkContext;
|
import org.apache.spark.api.java.JavaSparkContext;
|
||||||
|
import org.apache.spark.api.java.function.ForeachFunction;
|
||||||
import org.apache.spark.sql.Encoders;
|
import org.apache.spark.sql.Encoders;
|
||||||
import org.apache.spark.sql.Row;
|
import org.apache.spark.sql.Row;
|
||||||
import org.apache.spark.sql.SparkSession;
|
import org.apache.spark.sql.SparkSession;
|
||||||
|
@ -45,7 +46,9 @@ public class BulkTagJobTest {
|
||||||
+ " \"orcid\" : \"$['author'][*]['pid'][*][?(@['key']=='ORCID')]['value']\","
|
+ " \"orcid\" : \"$['author'][*]['pid'][*][?(@['key']=='ORCID')]['value']\","
|
||||||
+ " \"contributor\" : \"$['contributor'][*]['value']\","
|
+ " \"contributor\" : \"$['contributor'][*]['value']\","
|
||||||
+ " \"description\" : \"$['description'][*]['value']\", "
|
+ " \"description\" : \"$['description'][*]['value']\", "
|
||||||
+ " \"subject\" :\"$['subject'][*]['value']\" }";
|
+ " \"subject\" :\"$['subject'][*]['value']\" , " +
|
||||||
|
|
||||||
|
"\"fos\" : \"$['subject'][?(@['qualifier']['classid']=='subject:fos')].value\"} ";
|
||||||
|
|
||||||
private static SparkSession spark;
|
private static SparkSession spark;
|
||||||
|
|
||||||
|
@ -769,28 +772,14 @@ public class BulkTagJobTest {
|
||||||
org.apache.spark.sql.Dataset<Row> idExplodeCommunity = spark.sql(query);
|
org.apache.spark.sql.Dataset<Row> idExplodeCommunity = spark.sql(query);
|
||||||
|
|
||||||
idExplodeCommunity.show(false);
|
idExplodeCommunity.show(false);
|
||||||
Assertions.assertEquals(4, idExplodeCommunity.count());
|
Assertions.assertEquals(5, idExplodeCommunity.count());
|
||||||
|
|
||||||
Assertions
|
Assertions
|
||||||
.assertEquals(
|
.assertEquals(
|
||||||
3, idExplodeCommunity.filter("provenance = 'community:datasource'").count());
|
3, idExplodeCommunity.filter("provenance = 'community:datasource'").count());
|
||||||
Assertions
|
Assertions
|
||||||
.assertEquals(
|
.assertEquals(
|
||||||
1, idExplodeCommunity.filter("provenance = 'community:advconstraint'").count());
|
2, idExplodeCommunity.filter("provenance = 'community:advconstraint'").count());
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
|
||||||
// void test1(){
|
|
||||||
// ProtoMap params = new Gson().fromJson(pathMap, ProtoMap.class);
|
|
||||||
// HashMap<String, String> param = new HashMap<>();
|
|
||||||
// for (String key : params.keySet()) {
|
|
||||||
// try {
|
|
||||||
// param.put(key, jsonContext.read(params.get(key)));
|
|
||||||
// } catch (com.jayway.jsonpath.PathNotFoundException e) {
|
|
||||||
// param.put(key, new ArrayList<>());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return param;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -844,6 +844,89 @@
|
||||||
<organizations/>
|
<organizations/>
|
||||||
</community>
|
</community>
|
||||||
<community id="dariah">
|
<community id="dariah">
|
||||||
|
<advancedConstraints>
|
||||||
|
{
|
||||||
|
"criteria": [
|
||||||
|
{
|
||||||
|
"constraint": [
|
||||||
|
{
|
||||||
|
"verb": "equals_caseinsensitive",
|
||||||
|
"field": "subject",
|
||||||
|
"value": "North America"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "contains",
|
||||||
|
"field": "fos",
|
||||||
|
"value": "05"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constraint": [
|
||||||
|
{
|
||||||
|
"verb": "equals_caseinsensitive",
|
||||||
|
"field": "subject",
|
||||||
|
"value": "North America"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "contains",
|
||||||
|
"field": "fos",
|
||||||
|
"value": "06"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constraint": [
|
||||||
|
{
|
||||||
|
"verb": "equals_caseinsensitive",
|
||||||
|
"field": "subject",
|
||||||
|
"value": "Mexico"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "equals_caseinsensitive",
|
||||||
|
"field": "subject",
|
||||||
|
"value": "United States"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "equals_caseinsensitive",
|
||||||
|
"field": "subject",
|
||||||
|
"value": "Canada"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "contains",
|
||||||
|
"field": "fos",
|
||||||
|
"value": "05"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"constraint": [
|
||||||
|
{
|
||||||
|
"verb": "equals_caseinsensitive",
|
||||||
|
"field": "subject",
|
||||||
|
"value": "Mexico"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "equals_caseinsensitive",
|
||||||
|
"field": "subject",
|
||||||
|
"value": "United States"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "equals_caseinsensitive",
|
||||||
|
"field": "subject",
|
||||||
|
"value": "Canada"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"verb": "contains",
|
||||||
|
"field": "fos",
|
||||||
|
"value": "06"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
</advancedConstraints>
|
||||||
<subjects/>
|
<subjects/>
|
||||||
<datasources>
|
<datasources>
|
||||||
<datasource>
|
<datasource>
|
||||||
|
@ -1174,7 +1257,9 @@
|
||||||
</zenodocommunities>
|
</zenodocommunities>
|
||||||
<organizations/>
|
<organizations/>
|
||||||
</community>
|
</community>
|
||||||
|
|
||||||
<community id="euromarine">
|
<community id="euromarine">
|
||||||
|
|
||||||
<subjects/>
|
<subjects/>
|
||||||
<datasources/>
|
<datasources/>
|
||||||
<zenodocommunities/>
|
<zenodocommunities/>
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue