Revision 56415
Added by Miriam Baglioni almost 5 years ago
SelectionConstraints.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.bulktag; |
2 | 2 |
|
3 |
import com.google.common.reflect.TypeToken; |
|
3 | 4 |
import com.google.gson.Gson; |
4 | 5 |
import eu.dnetlib.data.bulktag.selectioncriteria.VerbResolver; |
5 | 6 |
|
6 | 7 |
import java.io.Serializable; |
8 |
import java.lang.reflect.Type; |
|
9 |
import java.util.Collection; |
|
7 | 10 |
import java.util.List; |
8 | 11 |
import java.util.Map; |
9 | 12 |
|
10 | 13 |
public class SelectionConstraints implements Serializable { |
11 |
private ConstraintsList cl;
|
|
14 |
private List<Constraints> criteria;
|
|
12 | 15 |
|
13 |
// private List<Constraints>cl; |
|
14 |
|
|
15 |
|
|
16 | 16 |
public SelectionConstraints() { |
17 | 17 |
} |
18 | 18 |
|
19 |
public ConstraintsList getCl() { |
|
20 |
return cl; |
|
19 |
|
|
20 |
public List<Constraints> getCriteria() { |
|
21 |
return criteria; |
|
21 | 22 |
} |
22 | 23 |
|
23 |
public void setCl(ConstraintsList cl) {
|
|
24 |
this.cl = cl;
|
|
24 |
public void setCriteria(List<Constraints> criteria) {
|
|
25 |
this.criteria = criteria;
|
|
25 | 26 |
} |
26 | 27 |
|
27 | 28 |
public void setSc(String json){ |
28 |
|
|
29 |
cl = new Gson().fromJson(json, ConstraintsList.class);
|
|
29 |
Type collectionType = new TypeToken<Collection<Constraints>>(){}.getType(); |
|
30 |
criteria = new Gson().fromJson(json, collectionType);
|
|
30 | 31 |
} |
31 | 32 |
|
32 |
|
|
33 |
//Constraints in or |
|
33 | 34 |
public boolean verifyCriteria(Map<String,List<String>> param){ |
34 |
for(Constraints selc: cl.getCriteria()){
|
|
35 |
for(Constraints selc: criteria){
|
|
35 | 36 |
if(selc.verifyCriteria(param)){ |
36 | 37 |
return true; |
37 | 38 |
} |
... | ... | |
40 | 41 |
} |
41 | 42 |
public void setSelection(VerbResolver resolver) { |
42 | 43 |
|
43 |
for(Constraints cs : cl.getCriteria()){
|
|
44 |
for(Constraints cs : criteria){
|
|
44 | 45 |
cs.setSelection(resolver); |
45 | 46 |
} |
46 | 47 |
} |
Also available in: Unified diff
removing not necessary incapsulation