Project

General

Profile

« Previous | Next » 

Revision e7314de8

Added by Patrick Plitzner almost 6 years ago

ref #7505, #6321 Enable max count check for bulk editor searches

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java
62 62
    private static final int MAX_RESULTS_BEFORE_WARNING = 500;
63 63

  
64 64
	public List<TaxonName> findNames(IIdentifiableEntityServiceConfigurator configurator, ConversationHolder conversation){
65

  
66
		if(checkLargeResult(CdmStore.getService(INameService.class).countByTitle(configurator))){
65 67
	    List<TaxonName> records = CdmStore.getService(INameService.class).findByTitle(configurator).getRecords();
66 68
	    addUuidSearchResults(records, configurator, INameService.class);
67 69
	    return records;
68 70
	}
71
		return NO_RESULTS;
72
	}
69 73

  
70 74
	public List<NameRelationship> findNameRelationships(
71 75
			IIdentifiableEntityServiceConfigurator configurator) {
......
90 94
	}
91 95

  
92 96
	public List<Reference> findReferences(IIdentifiableEntityServiceConfigurator configurator){
97
		if(checkLargeResult(CdmStore.getService(IReferenceService.class).countByTitle(configurator))){
93 98
	    List<Reference> records = CdmStore.getService(IReferenceService.class).findByTitle(configurator).getRecords();
94 99
	    addUuidSearchResults(records, configurator, IReferenceService.class);
95 100
	    return records;
96 101
	}
102
		return NO_RESULTS;
103
	}
97 104

  
98 105
	public List<AgentBase> findAgents(IIdentifiableEntityServiceConfigurator configurator){
106

  
107
		if(checkLargeResult(CdmStore.getService(IAgentService.class).countByTitle(configurator))){
99 108
	    List<AgentBase> records = CdmStore.getService(IAgentService.class).findByTitle(configurator).getRecords();
100 109
	    addUuidSearchResults(records, configurator, IAgentService.class);
101 110
	    return records;
111
	}
112
		return NO_RESULTS;
102 113
	}
103 114

  
104 115
    /**
......
197 208
	}
198 209

  
199 210

  
211

  
212
    private boolean checkLargeResult(long count) {
213
        return checkLargeResult(count, MAX_RESULTS_BEFORE_WARNING);
214
    }
215

  
216
    private boolean checkLargeResult(long count, int maxBeforWarning) {
217
        if(count > maxBeforWarning){
218
            return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.SearchManager_LARGE_RESULT_EXPECTED,
219
                    String.format(Messages.SearchManager_LONG_SEARCH_WARNING, count));
220
        }else{
221
            return true;
222
        }
223
    }
224
    
200 225
	public List<Group> findGroups(IIdentifiableEntityServiceConfigurator configurator){
201 226
		String groupNameSearchString = sqlizeTitleSearchString(configurator);
202 227
		// TODO why are groups not identifiable entities?
......
213 238
	}
214 239

  
215 240
	public List findTaxa(IIdentifiableEntityServiceConfigurator configurator) {
241
		if(checkLargeResult(CdmStore.getService(ITaxonService.class).countByTitle(configurator))){
216 242
	    List<TaxonBase> records = CdmStore.getService(ITaxonService.class).findByTitle(configurator).getRecords();
217 243
	    addUuidSearchResults(records, configurator, ITaxonService.class);
218 244
	    return records;
219 245
	}
246
		return NO_RESULTS;
247
	}
220 248

  
221 249
	public List findMedia(IIdentifiableEntityServiceConfigurator configurator) {
250
        if(checkLargeResult(CdmStore.getService(IMediaService.class).countByTitle(configurator))){
222 251
	    List<Media> records = CdmStore.getService(IMediaService.class).findByTitle(configurator).getRecords();
223 252
	    addUuidSearchResults(records, configurator, IMediaService.class);
224 253
	    return records;
225 254
    }
226

  
227
    private boolean checkLargeResult(long count) {
228
        return checkLargeResult(count, MAX_RESULTS_BEFORE_WARNING);
255
        return NO_RESULTS;
229 256
    }
230 257

  
231
    private boolean checkLargeResult(long count, int maxBeforWarning) {
232
        if(count > maxBeforWarning){
233
            return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), Messages.SearchManager_LARGE_RESULT_EXPECTED,
234
                    String.format(Messages.SearchManager_LONG_SEARCH_WARNING, count));
235
        }else{
236
            return true;
237
        }
238
    }
239 258

  
240 259
}

Also available in: Unified diff