changed to allow and logic in constraints verification

This commit is contained in:
Miriam Baglioni 2020-11-18 12:13:13 +01:00
parent a4781ddf65
commit 8555082bb1
2 changed files with 70 additions and 0 deletions

View File

@ -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<Constraints> criteria;
public SelectionConstraints() {
}
public List<Constraints> getCriteria() {
return criteria;
}
public void setCriteria(List<Constraints> criteria) {
this.criteria = criteria;
}
public void setSc(String json) {
Type collectionType = new TypeToken<Collection<Constraints>>() {
}.getType();
criteria = new Gson().fromJson(json, collectionType);
}
// Constraints in and
public boolean verifyCriteria(final Map<String, String> 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);
}
}
}

View File

@ -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<SelectionConstraints> whitelist;
public List<SelectionConstraints> getWhitelist() {
return whitelist;
}
public void setWhitelist(List<SelectionConstraints> whitelist) {
this.whitelist = whitelist;
}
}