1 |
7647352a
|
Cherian Mathew
|
package eu.etaxonomy.cdm.remote.dto.namecatalogue;
|
2 |
|
|
import java.util.AbstractMap;
|
3 |
|
|
import java.util.ArrayList;
|
4 |
|
|
import java.util.HashSet;
|
5 |
|
|
import java.util.Hashtable;
|
6 |
|
|
import java.util.Iterator;
|
7 |
|
|
import java.util.List;
|
8 |
|
|
import java.util.Map;
|
9 |
|
|
import java.util.Map.Entry;
|
10 |
|
|
import java.util.Set;
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
14 |
8adc5a34
|
Cherian Mathew
|
import eu.etaxonomy.cdm.remote.dto.common.RemoteResponse;
|
15 |
7647352a
|
Cherian Mathew
|
|
16 |
|
|
/**
|
17 |
|
|
* The class representing the response from the CDM Remote Web Service API to a single name search query.
|
18 |
|
|
* All information contained in this class originates from a call to {@link TaxonNameBase taxon names}
|
19 |
|
|
* <P>
|
20 |
|
|
*
|
21 |
|
|
* @author c.mathew
|
22 |
|
|
* @version 1.0
|
23 |
|
|
* @created 17-Apr-2012 13:00:43
|
24 |
|
|
*/
|
25 |
|
|
|
26 |
|
|
|
27 |
|
|
public class NameSearch implements RemoteResponse {
|
28 |
f93b7fb5
|
Cherian Mathew
|
|
29 |
|
|
private NameSearch.NameSearchRequest request;
|
30 |
|
|
private List<NameSearch.NameSearchResponse> response;
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
public NameSearch() {
|
34 |
|
|
this.response = new ArrayList<NameSearch.NameSearchResponse>();
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
public void setRequest(String q) {
|
38 |
|
|
request = new NameSearchRequest();
|
39 |
|
|
request.setQuery(q);
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
public NameSearchRequest getRequest() {
|
43 |
|
|
return this.request;
|
44 |
|
|
}
|
45 |
|
|
|
46 |
ef422766
|
Cherian Mathew
|
public void addToResponseList(String title, String name, float score, String nameUuid, Set<TaxonBase> taxonBases,Set<TaxonBase> accTaxonBases) {
|
47 |
f93b7fb5
|
Cherian Mathew
|
|
48 |
|
|
NameSearch.NameSearchResponse res = responseWithtitle(title);
|
49 |
|
|
if (res == null) {
|
50 |
|
|
res = new NameSearch.NameSearchResponse();
|
51 |
|
|
res.setTitle(title);
|
52 |
|
|
res.setName(name);
|
53 |
ef422766
|
Cherian Mathew
|
res.setScore(score);
|
54 |
f93b7fb5
|
Cherian Mathew
|
response.add(res);
|
55 |
|
|
}
|
56 |
|
|
res.addToNameUuids(nameUuid);
|
57 |
|
|
for (TaxonBase tb : taxonBases) {
|
58 |
|
|
res.addToTaxonConceptUuids(tb.getUuid().toString());
|
59 |
|
|
}
|
60 |
|
|
for (TaxonBase acctb : accTaxonBases) {
|
61 |
|
|
res.addToAcceptedTaxontUuids(acctb.getUuid().toString());
|
62 |
|
|
}
|
63 |
|
|
}
|
64 |
786696e3
|
Andreas Müller
|
|
65 |
|
|
public void addToResponseList(String title,
|
66 |
|
|
String name,
|
67 |
|
|
float score,
|
68 |
|
|
String nameUuid,
|
69 |
|
|
String[] taxonBaseUuids,
|
70 |
|
|
String[] accTaxonUuids) {
|
71 |
|
|
|
72 |
|
|
NameSearch.NameSearchResponse res = responseWithtitle(title);
|
73 |
|
|
if (res == null) {
|
74 |
|
|
res = new NameSearch.NameSearchResponse();
|
75 |
|
|
res.setTitle(title);
|
76 |
|
|
res.setName(name);
|
77 |
|
|
res.setScore(score);
|
78 |
|
|
response.add(res);
|
79 |
|
|
}
|
80 |
|
|
res.addToNameUuids(nameUuid);
|
81 |
|
|
for (String tbuuid : taxonBaseUuids) {
|
82 |
|
|
res.addToTaxonConceptUuids(tbuuid);
|
83 |
|
|
}
|
84 |
|
|
for (String acctbuuid : accTaxonUuids) {
|
85 |
|
|
res.addToAcceptedTaxontUuids(acctbuuid);
|
86 |
|
|
}
|
87 |
|
|
}
|
88 |
f93b7fb5
|
Cherian Mathew
|
|
89 |
|
|
public List<NameSearch.NameSearchResponse> getResponse() {
|
90 |
|
|
return this.response;
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
private NameSearch.NameSearchResponse responseWithtitle(String title) {
|
94 |
|
|
for(NameSearch.NameSearchResponse nsres : response) {
|
95 |
|
|
if(nsres.getTitle().trim().equals(title.trim())) {
|
96 |
|
|
return nsres;
|
97 |
|
|
}
|
98 |
|
|
}
|
99 |
|
|
return null;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
public class NameSearchRequest {
|
103 |
|
|
private String query;
|
104 |
|
|
public NameSearchRequest() {
|
105 |
|
|
this.query = "";
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
public void setQuery(String q) {
|
109 |
|
|
this.query = q;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
public String getQuery() {
|
113 |
|
|
return this.query;
|
114 |
|
|
}
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
public class NameSearchResponse {
|
118 |
|
|
private String title;
|
119 |
|
|
private String name;
|
120 |
ef422766
|
Cherian Mathew
|
private float score;
|
121 |
|
|
private Set<String> nameUuids;
|
122 |
f93b7fb5
|
Cherian Mathew
|
private Set<String> taxonConceptUuids;
|
123 |
|
|
private Set<String> acceptedTaxontUuids;
|
124 |
|
|
|
125 |
|
|
public NameSearchResponse() {
|
126 |
|
|
title = "";
|
127 |
|
|
name = "";
|
128 |
ef422766
|
Cherian Mathew
|
score = 0;
|
129 |
f93b7fb5
|
Cherian Mathew
|
nameUuids = new HashSet<String>();
|
130 |
|
|
taxonConceptUuids = new HashSet<String>();
|
131 |
|
|
acceptedTaxontUuids = new HashSet<String>();
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
public void setTitle(String title) {
|
135 |
|
|
this.title = title;
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
public String getTitle() {
|
139 |
|
|
return this.title;
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
public void setName(String name) {
|
143 |
|
|
this.name = name;
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
public String getName() {
|
147 |
|
|
return this.name;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
ef422766
|
Cherian Mathew
|
public float getScore() {
|
151 |
|
|
return score;
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
public void setScore(float score) {
|
155 |
|
|
this.score = score;
|
156 |
|
|
}
|
157 |
|
|
|
158 |
f93b7fb5
|
Cherian Mathew
|
public void addToNameUuids(String nameUuid) {
|
159 |
|
|
nameUuids.add(nameUuid);
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
public Set<String> getNameUuids() {
|
163 |
|
|
return this.nameUuids;
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
public void addToTaxonConceptUuids(String taxonUuid) {
|
167 |
|
|
taxonConceptUuids.add(taxonUuid);
|
168 |
|
|
}
|
169 |
|
|
|
170 |
|
|
public Set<String> getTaxonConceptUuids() {
|
171 |
|
|
return this.taxonConceptUuids;
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
public void addToAcceptedTaxontUuids(String taxonUuid) {
|
175 |
|
|
acceptedTaxontUuids.add(taxonUuid);
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
public Set<String> getAcceptedTaxonUuids() {
|
179 |
|
|
return this.acceptedTaxontUuids;
|
180 |
|
|
}
|
181 |
|
|
}
|
182 |
|
|
|
183 |
7647352a
|
Cherian Mathew
|
}
|
184 |
f93b7fb5
|
Cherian Mathew
|
|
185 |
7647352a
|
Cherian Mathew
|
|
186 |
|
|
|