From 8555082bb196b5571ae6232b543aa564cb23f542 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Wed, 18 Nov 2020 12:13:13 +0100 Subject: [PATCH] changed to allow and logic in constraints verification --- .../authorpids/SelectionConstraints.java | 53 +++++++++++++++++++ .../oa/graph/clean/authorpids/WhiteList.java | 17 ++++++ 2 files changed, 70 insertions(+) create mode 100644 dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/authorpids/SelectionConstraints.java create mode 100644 dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/authorpids/WhiteList.java diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/authorpids/SelectionConstraints.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/authorpids/SelectionConstraints.java new file mode 100644 index 0000000000..fdc4164709 --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/authorpids/SelectionConstraints.java @@ -0,0 +1,53 @@ + +package eu.dnetlib.dhp.oa.graph.clean.authorpids; + +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; + +import eu.dnetlib.dhp.oa.graph.clean.authorpids.constraints.ConstraintResolver; + +public class SelectionConstraints implements Serializable { + private List criteria; + + public SelectionConstraints() { + } + + public List getCriteria() { + return criteria; + } + + public void setCriteria(List criteria) { + this.criteria = criteria; + } + + public void setSc(String json) { + Type collectionType = new TypeToken>() { + }.getType(); + criteria = new Gson().fromJson(json, collectionType); + } + + // Constraints in and + public boolean verifyCriteria(final Map param) { + for (Constraints selc : criteria) { + if (!selc.verifyCriteria(param)) { + return false; + } + } + return true; + } + + public void setSelection(ConstraintResolver resolver) + throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { + + for (Constraints cs : criteria) { + cs.setSelection(resolver); + } + } +} diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/authorpids/WhiteList.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/authorpids/WhiteList.java new file mode 100644 index 0000000000..ee0a02191a --- /dev/null +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/oa/graph/clean/authorpids/WhiteList.java @@ -0,0 +1,17 @@ + +package eu.dnetlib.dhp.oa.graph.clean.authorpids; + +import java.io.Serializable; +import java.util.List; + +public class WhiteList implements Serializable { + private List whitelist; + + public List getWhitelist() { + return whitelist; + } + + public void setWhitelist(List whitelist) { + this.whitelist = whitelist; + } +}