1
|
package eu.dnetlib.domain.functionality;
|
2
|
|
3
|
import eu.dnetlib.domain.SearchCriteria;
|
4
|
import eu.dnetlib.domain.SearchCriteriaImpl;
|
5
|
|
6
|
|
7
|
public class QueryHashSearchCriteria extends SearchCriteriaImpl implements
|
8
|
SearchCriteria {
|
9
|
|
10
|
private String cqlQuery = null;
|
11
|
private String userId = null;
|
12
|
private int hashValue = 0;
|
13
|
|
14
|
public void setUserId( String id ){
|
15
|
this.userId = id;
|
16
|
}
|
17
|
|
18
|
public String getUserId(){
|
19
|
return userId;
|
20
|
}
|
21
|
|
22
|
public void setHashValue( int val ){
|
23
|
this.hashValue = val;
|
24
|
}
|
25
|
|
26
|
public int getHashValue(){
|
27
|
return this.hashValue;
|
28
|
}
|
29
|
|
30
|
public boolean matches(Object o) {
|
31
|
QueryHash queryHash = (QueryHash) o;
|
32
|
|
33
|
if ( this.getUserId() != null ) {
|
34
|
if ( queryHash.getUserId() == null ){
|
35
|
return false;
|
36
|
}else if ( this.getUserId().equals( queryHash.getUserId() ) == true ) {
|
37
|
return true;
|
38
|
} else {
|
39
|
return false;
|
40
|
}
|
41
|
}
|
42
|
|
43
|
if ( this.getCqlQuery() != null ) {
|
44
|
if ( queryHash.getCqlQuery() == null ){
|
45
|
return false;
|
46
|
}else if ( this.getCqlQuery().equals( queryHash.getCqlQuery() ) == true ) {
|
47
|
return true;
|
48
|
} else {
|
49
|
return false;
|
50
|
}
|
51
|
}
|
52
|
|
53
|
return true;
|
54
|
}
|
55
|
|
56
|
public boolean equals(Object o) {
|
57
|
return this.equals((QueryHashSearchCriteria) o);
|
58
|
}
|
59
|
|
60
|
public boolean equals(QueryHashSearchCriteria crit) {
|
61
|
if (!super.equals(crit))
|
62
|
return false;
|
63
|
|
64
|
if( this.userId != null && crit.getUserId() != null ) {
|
65
|
if( this.userId.endsWith( crit.getUserId() ) ){
|
66
|
if( this.hashValue == crit.getHashValue() ){
|
67
|
return true;
|
68
|
}else{
|
69
|
return false;
|
70
|
}
|
71
|
} else {
|
72
|
return false;
|
73
|
}
|
74
|
} else if( this.userId == null && crit.getUserId() == null ){
|
75
|
if( this.hashValue == crit.getHashValue() ){
|
76
|
return true;
|
77
|
}else{
|
78
|
return false;
|
79
|
}
|
80
|
}else
|
81
|
return false;
|
82
|
}
|
83
|
|
84
|
public int hashCode() {
|
85
|
int code = super.hashCode();
|
86
|
|
87
|
if (userId != null)
|
88
|
code |= userId.hashCode();
|
89
|
|
90
|
code |= this.hashValue;
|
91
|
|
92
|
return code;
|
93
|
}
|
94
|
|
95
|
public void setCqlQuery(String cqlQuery) {
|
96
|
this.cqlQuery = cqlQuery;
|
97
|
}
|
98
|
|
99
|
public String getCqlQuery() {
|
100
|
return cqlQuery;
|
101
|
}
|
102
|
}
|
103
|
|