14 |
14 |
import java.util.List;
|
15 |
15 |
import java.util.UUID;
|
16 |
16 |
|
17 |
|
import org.eclipse.jface.dialogs.MessageDialog;
|
18 |
|
import org.eclipse.swt.widgets.Display;
|
19 |
|
|
20 |
17 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
21 |
18 |
import eu.etaxonomy.cdm.api.service.IAgentService;
|
22 |
19 |
import eu.etaxonomy.cdm.api.service.IGroupService;
|
... | ... | |
43 |
40 |
import eu.etaxonomy.cdm.model.reference.Reference;
|
44 |
41 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
45 |
42 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
46 |
|
import eu.etaxonomy.taxeditor.l10n.Messages;
|
47 |
43 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
48 |
44 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
49 |
45 |
|
... | ... | |
59 |
55 |
|
60 |
56 |
public static int NO_COUNT = -1;
|
61 |
57 |
|
62 |
|
|
63 |
|
// TODO make this configurable via preferences
|
64 |
|
private static final int MAX_RESULTS_BEFORE_WARNING = 500;
|
65 |
|
|
66 |
58 |
public List<TaxonName> findNames(IIdentifiableEntityServiceConfigurator configurator, ConversationHolder conversation){
|
67 |
|
|
68 |
|
if(checkLargeResult(CdmStore.getService(INameService.class).countByTitle(configurator))){
|
69 |
|
List<TaxonName> records = CdmStore.getService(INameService.class).findByTitle(configurator).getRecords();
|
70 |
|
addUuidSearchResults(records, configurator, INameService.class);
|
71 |
|
return records;
|
72 |
|
}
|
73 |
|
return NO_RESULTS;
|
|
59 |
List<TaxonName> records = CdmStore.getService(INameService.class).findByTitle(configurator).getRecords();
|
|
60 |
addUuidSearchResults(records, configurator, INameService.class);
|
|
61 |
return records;
|
74 |
62 |
}
|
75 |
63 |
|
76 |
64 |
public List<NameRelationship> findNameRelationships(
|
... | ... | |
96 |
84 |
}
|
97 |
85 |
|
98 |
86 |
public List<Reference> findReferences(IIdentifiableEntityServiceConfigurator configurator){
|
99 |
|
if(checkLargeResult(CdmStore.getService(IReferenceService.class).countByTitle(configurator))){
|
100 |
|
List<Reference> records = CdmStore.getService(IReferenceService.class).findByTitle(configurator).getRecords();
|
101 |
|
addUuidSearchResults(records, configurator, IReferenceService.class);
|
102 |
|
return records;
|
103 |
|
}
|
104 |
|
return NO_RESULTS;
|
|
87 |
List<Reference> records = CdmStore.getService(IReferenceService.class).findByTitle(configurator).getRecords();
|
|
88 |
addUuidSearchResults(records, configurator, IReferenceService.class);
|
|
89 |
return records;
|
105 |
90 |
}
|
106 |
91 |
|
107 |
92 |
public List<AgentBase> findAgents(IIdentifiableEntityServiceConfigurator configurator){
|
108 |
|
|
109 |
|
if(checkLargeResult(CdmStore.getService(IAgentService.class).countByTitle(configurator))){
|
110 |
|
List<AgentBase> records = CdmStore.getService(IAgentService.class).findByTitle(configurator).getRecords();
|
111 |
|
addUuidSearchResults(records, configurator, IAgentService.class);
|
112 |
|
return records;
|
113 |
|
}
|
114 |
|
return NO_RESULTS;
|
|
93 |
List<AgentBase> records = CdmStore.getService(IAgentService.class).findByTitle(configurator).getRecords();
|
|
94 |
addUuidSearchResults(records, configurator, IAgentService.class);
|
|
95 |
return records;
|
115 |
96 |
}
|
116 |
97 |
|
117 |
98 |
/**
|
... | ... | |
188 |
169 |
}
|
189 |
170 |
configurator.setPropertyPaths(occurrencePropertyPaths);
|
190 |
171 |
|
191 |
|
if(checkLargeResult(CdmStore.getService(IOccurrenceService.class).countOccurrences(configurator))){
|
192 |
|
records = CdmStore.getService(IOccurrenceService.class).findByTitle(configurator).getRecords();
|
193 |
|
}
|
|
172 |
records = CdmStore.getService(IOccurrenceService.class).findByTitle(configurator).getRecords();
|
194 |
173 |
addUuidSearchResults(records, configurator, IOccurrenceService.class);
|
195 |
174 |
return records;
|
196 |
175 |
}
|
... | ... | |
213 |
192 |
}
|
214 |
193 |
|
215 |
194 |
|
216 |
|
private boolean checkLargeResult(int count) {
|
217 |
|
return checkLargeResult(count, MAX_RESULTS_BEFORE_WARNING);
|
218 |
|
}
|
219 |
|
|
220 |
|
private boolean checkLargeResult(int count, int maxBeforWarning) {
|
221 |
|
if(count > maxBeforWarning){
|
222 |
|
return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.SearchManager_LARGE_RESULT_EXPECTED,
|
223 |
|
String.format(Messages.SearchManager_LONG_SEARCH_WARNING, count));
|
224 |
|
}else{
|
225 |
|
return true;
|
226 |
|
}
|
227 |
|
}
|
228 |
|
|
229 |
195 |
private String sqlizeTitleSearchString(IIdentifiableEntityServiceConfigurator configurator){
|
230 |
196 |
return configurator.getTitleSearchString().replace(WILDCARD, "%"); //$NON-NLS-1$
|
231 |
197 |
}
|
232 |
198 |
|
233 |
199 |
public List findTaxa(IIdentifiableEntityServiceConfigurator configurator) {
|
234 |
|
if(checkLargeResult(CdmStore.getService(ITaxonService.class).countByTitle(configurator))){
|
235 |
|
List<TaxonBase> records = CdmStore.getService(ITaxonService.class).findByTitle(configurator).getRecords();
|
236 |
|
addUuidSearchResults(records, configurator, ITaxonService.class);
|
237 |
|
return records;
|
238 |
|
}
|
239 |
|
return NO_RESULTS;
|
|
200 |
List<TaxonBase> records = CdmStore.getService(ITaxonService.class).findByTitle(configurator).getRecords();
|
|
201 |
addUuidSearchResults(records, configurator, ITaxonService.class);
|
|
202 |
return records;
|
240 |
203 |
}
|
241 |
204 |
|
242 |
205 |
public List findMedia(IIdentifiableEntityServiceConfigurator configurator) {
|
243 |
|
if(checkLargeResult(CdmStore.getService(IMediaService.class).countByTitle(configurator))){
|
244 |
|
List<Media> records = CdmStore.getService(IMediaService.class).findByTitle(configurator).getRecords();
|
245 |
|
addUuidSearchResults(records, configurator, IMediaService.class);
|
246 |
|
return records;
|
247 |
|
}
|
248 |
|
return NO_RESULTS;
|
|
206 |
List<Media> records = CdmStore.getService(IMediaService.class).findByTitle(configurator).getRecords();
|
|
207 |
addUuidSearchResults(records, configurator, IMediaService.class);
|
|
208 |
return records;
|
249 |
209 |
}
|
250 |
210 |
|
251 |
211 |
|
fix #6321 Implement parallel loading + progress bar for bulk editor