44 |
44 |
import eu.etaxonomy.cdm.model.reference.Reference;
|
45 |
45 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
46 |
46 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
|
|
47 |
import eu.etaxonomy.taxeditor.Messages;
|
47 |
48 |
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
|
48 |
49 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
49 |
50 |
|
... | ... | |
56 |
57 |
|
57 |
58 |
public static final List NO_RESULTS = Arrays.asList(new Object[]{});
|
58 |
59 |
|
59 |
|
public static final String WILDCARD = "*";
|
|
60 |
public static final String WILDCARD = "*"; //$NON-NLS-1$
|
60 |
61 |
|
61 |
62 |
public static int NO_COUNT = -1;
|
62 |
|
|
|
63 |
|
63 |
64 |
|
64 |
65 |
// TODO make this configurable via preferences
|
65 |
66 |
private static final int MAX_RESULTS_BEFORE_WARNING = 500;
|
66 |
67 |
|
67 |
68 |
public List<TaxonNameBase> findNames(IIdentifiableEntityServiceConfigurator configurator, ConversationHolder conversation){
|
68 |
|
|
|
69 |
|
69 |
70 |
if(checkLargeResult(CdmStore.getService(INameService.class).countByTitle(configurator))){
|
70 |
71 |
List<TaxonNameBase> records = CdmStore.getService(INameService.class).findByTitle(configurator).getRecords();
|
71 |
72 |
addUuidSearchResults(records, configurator, INameService.class);
|
... | ... | |
166 |
167 |
public List<SpecimenOrObservationBase> findOccurrences(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> configurator, boolean showFieldUnits){
|
167 |
168 |
List<SpecimenOrObservationBase> records = new ArrayList<SpecimenOrObservationBase>();
|
168 |
169 |
final List<String> BASE_OCCURRENCE_INIT_STRATEGY = Arrays.asList(new String[] {
|
169 |
|
"collection",
|
170 |
|
"descriptions",
|
171 |
|
"identifiers",
|
172 |
|
"derivationEvents.originals",
|
173 |
|
"derivedFrom.originals",
|
174 |
|
"gatheringEvent.country.representations",
|
175 |
|
"gatheringEvent.collector",
|
176 |
|
"gatheringEvent.locality",
|
177 |
|
"descriptions.descriptionElements",
|
178 |
|
"kindOfUnit",
|
179 |
|
"amplificationResults",
|
180 |
|
"sequences.singleReadAlignments",
|
181 |
|
"mediaSpecimen"
|
|
170 |
"collection", //$NON-NLS-1$
|
|
171 |
"descriptions", //$NON-NLS-1$
|
|
172 |
"identifiers", //$NON-NLS-1$
|
|
173 |
"derivationEvents.originals", //$NON-NLS-1$
|
|
174 |
"derivedFrom.originals", //$NON-NLS-1$
|
|
175 |
"gatheringEvent.country.representations", //$NON-NLS-1$
|
|
176 |
"gatheringEvent.collector", //$NON-NLS-1$
|
|
177 |
"gatheringEvent.locality", //$NON-NLS-1$
|
|
178 |
"descriptions.descriptionElements", //$NON-NLS-1$
|
|
179 |
"kindOfUnit", //$NON-NLS-1$
|
|
180 |
"amplificationResults", //$NON-NLS-1$
|
|
181 |
"sequences.singleReadAlignments", //$NON-NLS-1$
|
|
182 |
"mediaSpecimen" //$NON-NLS-1$
|
182 |
183 |
});
|
183 |
184 |
|
184 |
185 |
List<String> occurrencePropertyPaths = new ArrayList<String>();
|
185 |
186 |
occurrencePropertyPaths.addAll(BASE_OCCURRENCE_INIT_STRATEGY);
|
186 |
187 |
for(String propertyPath:BASE_OCCURRENCE_INIT_STRATEGY) {
|
187 |
|
occurrencePropertyPaths.add("derivationEvents.derivatives." + propertyPath);
|
|
188 |
occurrencePropertyPaths.add("derivationEvents.derivatives." + propertyPath); //$NON-NLS-1$
|
188 |
189 |
}
|
189 |
190 |
configurator.setPropertyPaths(occurrencePropertyPaths);
|
190 |
191 |
|
... | ... | |
219 |
220 |
|
220 |
221 |
private boolean checkLargeResult(int count, int maxBeforWarning) {
|
221 |
222 |
if(count > maxBeforWarning){
|
222 |
|
return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Large result expected",
|
223 |
|
String.format("The current search will return %s objects. This will " +
|
224 |
|
"take a long time and/or might render the editor unusable. Please consider refining your search.", count));
|
|
223 |
return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.SearchManager_LARGE_RESULT_EXPECTED,
|
|
224 |
String.format(Messages.SearchManager_LONG_SEARCH_WARNING, count));
|
225 |
225 |
}else{
|
226 |
226 |
return true;
|
227 |
227 |
}
|
228 |
228 |
}
|
229 |
229 |
|
230 |
230 |
private String sqlizeTitleSearchString(IIdentifiableEntityServiceConfigurator configurator){
|
231 |
|
return configurator.getTitleSearchString().replace(WILDCARD, "%");
|
|
231 |
return configurator.getTitleSearchString().replace(WILDCARD, "%"); //$NON-NLS-1$
|
232 |
232 |
}
|
233 |
233 |
|
234 |
234 |
public List findTaxa(IIdentifiableEntityServiceConfigurator configurator) {
|
i18n for SearchManager