12 |
12 |
import java.util.ArrayList;
|
13 |
13 |
import java.util.Arrays;
|
14 |
14 |
import java.util.List;
|
15 |
|
import java.util.UUID;
|
16 |
15 |
|
17 |
16 |
import org.eclipse.jface.dialogs.MessageDialog;
|
18 |
17 |
import org.eclipse.swt.widgets.Display;
|
... | ... | |
24 |
23 |
import eu.etaxonomy.cdm.api.service.INameService;
|
25 |
24 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
26 |
25 |
import eu.etaxonomy.cdm.api.service.IReferenceService;
|
27 |
|
import eu.etaxonomy.cdm.api.service.IService;
|
28 |
26 |
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
29 |
27 |
import eu.etaxonomy.cdm.api.service.IUserService;
|
30 |
28 |
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
|
... | ... | |
32 |
30 |
import eu.etaxonomy.cdm.model.agent.AgentBase;
|
33 |
31 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
|
34 |
32 |
import eu.etaxonomy.cdm.model.common.Group;
|
35 |
|
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
36 |
33 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
37 |
34 |
import eu.etaxonomy.cdm.model.common.RelationshipBase;
|
38 |
35 |
import eu.etaxonomy.cdm.model.common.User;
|
... | ... | |
63 |
60 |
|
64 |
61 |
public List<TaxonName> findNames(IIdentifiableEntityServiceConfigurator configurator, ConversationHolder conversation){
|
65 |
62 |
List<TaxonName> records = CdmStore.getService(INameService.class).findByTitle(configurator).getRecords();
|
66 |
|
addUuidSearchResults(records, configurator, INameService.class);
|
67 |
63 |
return records;
|
68 |
64 |
}
|
69 |
65 |
|
... | ... | |
91 |
87 |
|
92 |
88 |
public List<Reference> findReferences(IIdentifiableEntityServiceConfigurator configurator){
|
93 |
89 |
List<Reference> records = CdmStore.getService(IReferenceService.class).findByTitle(configurator).getRecords();
|
94 |
|
addUuidSearchResults(records, configurator, IReferenceService.class);
|
95 |
90 |
return records;
|
96 |
91 |
}
|
97 |
92 |
|
98 |
93 |
public List<AgentBase> findAgents(IIdentifiableEntityServiceConfigurator configurator){
|
99 |
94 |
List<AgentBase> records = CdmStore.getService(IAgentService.class).findByTitle(configurator).getRecords();
|
100 |
|
addUuidSearchResults(records, configurator, IAgentService.class);
|
101 |
95 |
return records;
|
102 |
96 |
}
|
103 |
97 |
|
104 |
|
/**
|
105 |
|
* Check search string if it is a {@link UUID} and, if <code>true</code>, search for the corresponding entity.
|
106 |
|
* @param records the list to which the search results are added
|
107 |
|
* @param configurator the configurator holding the search string
|
108 |
|
* @param service the service to use for searching
|
109 |
|
*/
|
110 |
|
private <T extends ICdmBase> void addUuidSearchResults(List<T> records, IIdentifiableEntityServiceConfigurator configurator, Class<? extends IService<T>> service) {
|
111 |
|
String titleSearchString = configurator.getTitleSearchString();
|
112 |
|
try {
|
113 |
|
UUID uuid = UUID.fromString(titleSearchString);
|
114 |
|
T foundRecord = (T) CdmStore.getService(service).load(uuid, configurator.getPropertyPaths());
|
115 |
|
if(foundRecord!=null){
|
116 |
|
records.add(foundRecord);
|
117 |
|
}
|
118 |
|
} catch (IllegalArgumentException e) {
|
119 |
|
//search string was no UUID
|
120 |
|
}
|
121 |
|
}
|
122 |
|
|
123 |
98 |
@SuppressWarnings("unchecked")
|
124 |
99 |
public List<TeamOrPersonBase> findTeamOrPersons(IIdentifiableEntityServiceConfigurator configurator){
|
125 |
100 |
configurator.setClazz(TeamOrPersonBase.class);
|
... | ... | |
182 |
157 |
else{
|
183 |
158 |
records = CdmStore.getService(IOccurrenceService.class).findByTitle(configurator).getRecords();
|
184 |
159 |
}
|
185 |
|
addUuidSearchResults(records, configurator, IOccurrenceService.class);
|
186 |
160 |
return records;
|
187 |
161 |
}
|
188 |
162 |
|
... | ... | |
192 |
166 |
List<User> records = CdmStore.getService(IUserService.class).listByUsername(userNameSearchString,
|
193 |
167 |
configurator.getMatchMode(), configurator.getCriteria(), configurator.getPageSize(),
|
194 |
168 |
configurator.getPageNumber(), configurator.getOrderHints(), configurator.getPropertyPaths());
|
195 |
|
addUuidSearchResults(records, configurator, IUserService.class);
|
196 |
169 |
return records;
|
197 |
170 |
}
|
198 |
171 |
|
... | ... | |
217 |
190 |
List<Group> records = CdmStore.getService(IGroupService.class).listByName(groupNameSearchString,
|
218 |
191 |
configurator.getMatchMode(), configurator.getCriteria(), configurator.getPageSize(),
|
219 |
192 |
configurator.getPageNumber(), configurator.getOrderHints(), configurator.getPropertyPaths());
|
220 |
|
addUuidSearchResults(records, configurator, IGroupService.class);
|
221 |
193 |
return records;
|
222 |
194 |
}
|
223 |
195 |
|
... | ... | |
228 |
200 |
|
229 |
201 |
public List findTaxa(IIdentifiableEntityServiceConfigurator configurator) {
|
230 |
202 |
List<TaxonBase> records = CdmStore.getService(ITaxonService.class).findByTitle(configurator).getRecords();
|
231 |
|
addUuidSearchResults(records, configurator, ITaxonService.class);
|
232 |
203 |
return records;
|
233 |
204 |
}
|
234 |
205 |
|
235 |
206 |
public List findMedia(IIdentifiableEntityServiceConfigurator configurator) {
|
236 |
207 |
List<Media> records = CdmStore.getService(IMediaService.class).findByTitle(configurator).getRecords();
|
237 |
|
addUuidSearchResults(records, configurator, IMediaService.class);
|
238 |
208 |
return records;
|
239 |
209 |
}
|
240 |
210 |
|
Fix endless loop when searching for UUID in bulk editors