Project

General

Profile

1
package eu.dnetlib.domain.data;
2

    
3
import eu.dnetlib.domain.SearchCriteria;
4
import eu.dnetlib.domain.SearchCriteriaImpl;
5

    
6
public class RepositorySearchCriteria extends SearchCriteriaImpl implements
7
		SearchCriteria {
8
	private Boolean haveDocuments = null;
9
	private String protocolType = null;
10
	private String adminInfo = null;
11
	private String officialName = null;
12
	private String registeredBy = null;
13
	private String country = null;
14
	private Boolean verified = false;
15

    
16
	public String getRegisteredBy() {
17
		return registeredBy;
18
	}
19

    
20
	public void setRegisteredBy(String registeredBy) {
21
		this.registeredBy = registeredBy;
22
	}
23

    
24
	public String getCountry() {
25
		return country;
26
	}
27

    
28
	public void setCountry(String country) {
29
		this.country = country;
30
	}
31

    
32
	public String getProtocolType() {
33
		return protocolType;
34
	}
35

    
36
	public void setProtocolType(String protocolType) {
37
		this.protocolType = protocolType;
38
	}
39

    
40
	public Boolean getHaveDocuments() {
41
		return haveDocuments;
42
	}
43

    
44
	public void setHaveDocuments(Boolean haveDocuments) {
45
		this.haveDocuments = haveDocuments;
46
	}
47

    
48
	public String getAdminInfo() {
49
		return adminInfo;
50
	}
51

    
52
	public void setAdminInfo(String adminInfo) {
53
		this.adminInfo = adminInfo;
54
	}
55

    
56
	public boolean equals(Object o) {
57
		return this.equals((RepositorySearchCriteria) o);
58
	}
59

    
60
	public boolean equals(RepositorySearchCriteria c) {
61
		if (!super.equals(c))
62
			return false;
63

    
64
		if (this.getHaveDocuments() != null && c.getHaveDocuments() == null)
65
			return false;
66
		else if (this.getHaveDocuments() == null
67
				&& c.getHaveDocuments() != null)
68
			return false;
69
		else if (this.getHaveDocuments() != null
70
				&& c.getHaveDocuments() != null)
71
			return this.haveDocuments == c.haveDocuments;
72

    
73
		if (this.getProtocolType() != null) {
74
			if (c.getProtocolType() == null
75
					|| !this.getProtocolType().equals(c.getProtocolType()))
76
				return false;
77
		} else if (c.getProtocolType() != null)
78
			return false;
79

    
80
		if (this.getAdminInfo() != null) {
81
			if (c.getAdminInfo() == null
82
					|| !this.getAdminInfo().equals(c.getAdminInfo()))
83
				return false;
84
		} else if (c.getAdminInfo() != null)
85
			return false;
86

    
87
		if (this.getOfficialName() != null) {
88
			if (c.getOfficialName() == null
89
					|| !this.getOfficialName().equals(c.getOfficialName()))
90
				return false;
91
		} else if (c.getOfficialName() != null)
92
			return false;
93
		
94
		if (this.getCountry() != null) {
95
			if (c.getCountry() == null || !this.getCountry().equals(c.getCountry()))
96
				return false;
97
		} else if (c.getCountry() != null)
98
			return false;
99
		
100
		if (this.isVerified() != null) {
101
			if (c.isVerified() == null || !this.isVerified().equals(c.isVerified()))
102
				return false;
103
		} else if (c.isVerified() != null)
104
			return false;
105

    
106
		return true;
107
	}
108

    
109
	@Override
110
	public int hashCode() {
111
		int code = super.hashCode();
112

    
113
		if (haveDocuments != null)
114
			code |= haveDocuments.hashCode();
115

    
116
		if (protocolType != null) {
117
			code |= protocolType.hashCode();
118
		}
119

    
120
		if (adminInfo != null) {
121
			code |= adminInfo.hashCode();
122
		}
123

    
124
		if (officialName != null) {
125
			code |= officialName.hashCode();
126
		}
127
		
128
		if (country != null)
129
			code |= country.hashCode();
130
		
131
		if (verified != null)
132
			code |= verified.hashCode();
133

    
134
		return code;
135
	}
136

    
137
	public boolean matches(Object o) {
138
		if (!(o instanceof Repository)) {
139
			return false;
140
		}
141

    
142
		Repository repository = (Repository) o;
143

    
144
		if (this.getContains() != null) {
145
			if (repository.getOfficialName() == null
146
					|| !repository.getOfficialName().toLowerCase().contains(
147
							this.getContains().toLowerCase()))
148
				return false;
149
		}
150

    
151
		if (this.getStartsWith() != null) {
152
			if (repository.getOfficialName() == null
153
					|| !repository.getOfficialName().toLowerCase().startsWith(
154
							this.getStartsWith().toLowerCase()))
155
				return false;
156
		}
157

    
158
		if (this.getEndsWith() != null) {
159
			if (repository.getOfficialName() == null
160
					|| !repository.getOfficialName().toLowerCase().endsWith(
161
							this.getEndsWith().toLowerCase()))
162
				return false;
163
		}
164

    
165
		if (this.getHaveDocuments() != null) {
166
			if (repository.getNumberOfObjects() == null
167
					|| (repository.getNumberOfObjects() > 0) != this
168
							.getHaveDocuments())
169

    
170
				return false;
171
		}
172

    
173
		if (this.getOfficialName() != null) {
174
			if (!this.getOfficialName().equals(repository.getOfficialName()))
175
				return false;
176
		}
177
		
178
		if (this.getRegisteredBy() != null) {
179
			if (!this.getRegisteredBy().equals(repository.getRegisteredBy()))
180
				return false;
181
		}
182
		
183
		if (this.getCountry() != null) {
184
			if (!this.getCountry().equals(repository.getCountryName()))
185
				return false;
186
		}
187
		
188
		if (this.isVerified() != null) {
189
			if (!this.isVerified().equals(repository.isVerified()))
190
				return false;
191
		}
192

    
193
		return true;
194
	}
195

    
196
	public boolean isOAICompliant(Repository repository) {
197
		boolean retval = false;
198
		for (RepositoryInterface ri : repository.getInterfaces()) {
199
			if (ri.getAccessProtocol() != null
200
					&& ri.getAccessProtocol().equals("OAI")) {
201
				retval = true;
202
				break;
203
			}
204
		}
205

    
206
		return retval;
207
	}
208

    
209
	public String getOfficialName() {
210
		return officialName;
211
	}
212

    
213
	public void setOfficialName(String officialName) {
214
		this.officialName = officialName;
215
	}
216

    
217
	public Boolean isVerified() {
218
		return verified;
219
	}
220

    
221
	public void setVerified(Boolean verified) {
222
		this.verified = verified;
223
	}
224
}
(18-18/23)