Project

General

Profile

Revision 6fd99a64

ID6fd99a64a083bbc1ddcab30c260eda6b4910fce1
Parent 92ec40db
Child 587cdbe5

Added by Patrick Plitzner over 2 years ago

ref #7505 re-enable parallel loading for bulk editor

View differences:

eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorQuery.java
36 36
		searchConfigurator.setMatchMode(null);
37 37
		searchConfigurator.setOrderHints(OrderHint.ORDER_BY_TITLE_CACHE.asList());
38 38
		searchConfigurator.setPropertyPaths(propertyPath);
39
//		searchConfigurator.setPageSize(20);
40 39
	}
41 40

  
42 41
	public String getSearchString() {
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
18 18
import java.util.Set;
19 19
import java.util.UUID;
20 20

  
21
import org.eclipse.core.runtime.ICoreRunnable;
21 22
import org.eclipse.core.runtime.jobs.Job;
22 23
import org.eclipse.jface.viewers.IStructuredSelection;
23 24

  
......
169 170

  
170 171
			IIdentifiableEntityServiceConfigurator configurator = bulkEditorQuery.getSearchConfigurator();
171 172

  
172
//            int pageSize = configurator.getPageSize()!=null?configurator.getPageSize():getPageSize();
173
//			long count = countEntities(configurator);
174
//			int totalWork = count>Integer.MAX_VALUE?Integer.MAX_VALUE:(int)count;
175
//			String jobLabel = String.format(Messages.AbstractBulkEditorInput_LOADING, getName(), bulkEditorQuery.getSearchString());
176
//	        searchJob = Job.create(jobLabel, (ICoreRunnable) monitor -> {
177
//	            monitor.beginTask(jobLabel, totalWork);
178
//	            int pageNumber = 0;
173
            int pageSize = configurator.getPageSize()!=null?configurator.getPageSize():getPageSize();
174
            configurator.setPageSize(pageSize);
175
			long count = countEntities(configurator);
176
			int totalWork = count>Integer.MAX_VALUE?Integer.MAX_VALUE:(int)count;
177
			String jobLabel = String.format(Messages.AbstractBulkEditorInput_LOADING, getName(), bulkEditorQuery.getSearchString());
178
	        searchJob = Job.create(jobLabel, (ICoreRunnable) monitor -> {
179
	            monitor.beginTask(jobLabel, totalWork);
180
	            int pageNumber = 0;
179 181
	            List<T> entities;
180
//                do {
181
//                    if (monitor.isCanceled()) {
182
//                        break;
183
//                    }
184
//                    configurator.setPageNumber(pageNumber);
182
                do {
183
                    if (monitor.isCanceled()) {
184
                        break;
185
                    }
186
                    configurator.setPageNumber(pageNumber);
185 187
                    entities = listEntities(configurator);
186 188
                    model.addAll(entities);
187
//                    //select if entity is loaded
188
//                    if(selection!=null && model.containsAll(selection.toList())){
189
//                        EventUtility.postAsyncEvent(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED, selection);
190
//                    }
191
//                    pageNumber++;
192
//                    monitor.worked(pageSize);
193
//                    long workedLong = pageSize*pageNumber;
194
//                    int loadedCount =  workedLong>Integer.MAX_VALUE?Integer.MAX_VALUE:(int)workedLong;
195
//                    monitor.setTaskName(String.format(Messages.AbstractBulkEditorInput_LOADED, loadedCount, totalWork, getName()));
196
//                } while (!entities.isEmpty());
197
//	            monitor.done();
189
                    //select if entity is loaded
190
                    if(selection!=null && model.containsAll(selection.toList())){
191
                        EventUtility.postAsyncEvent(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED, selection);
192
                    }
193
                    pageNumber++;
194
                    monitor.worked(pageSize);
195
                    long workedLong = pageSize*pageNumber;
196
                    int loadedCount =  workedLong>Integer.MAX_VALUE?Integer.MAX_VALUE:(int)workedLong;
197
                    monitor.setTaskName(String.format(Messages.AbstractBulkEditorInput_LOADED, loadedCount, totalWork, getName()));
198
                } while (!entities.isEmpty());
199
	            monitor.done();
198 200
	            EventUtility.postAsyncEvent(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED, selection);
199
//	        });
200
//	        searchJob.schedule();
201
	        });
202
	        searchJob.schedule();
201 203
		}
202 204
	}
203 205

  
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))){
67 65
	    List<TaxonName> records = CdmStore.getService(INameService.class).findByTitle(configurator).getRecords();
68 66
	    addUuidSearchResults(records, configurator, INameService.class);
69 67
	    return records;
70 68
	}
71
		return NO_RESULTS;
72
	}
73 69

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

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

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

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

  
115 104
    /**
......
221 210
            return true;
222 211
        }
223 212
    }
224
    
213

  
225 214
	public List<Group> findGroups(IIdentifiableEntityServiceConfigurator configurator){
226 215
		String groupNameSearchString = sqlizeTitleSearchString(configurator);
227 216
		// TODO why are groups not identifiable entities?
......
238 227
	}
239 228

  
240 229
	public List findTaxa(IIdentifiableEntityServiceConfigurator configurator) {
241
		if(checkLargeResult(CdmStore.getService(ITaxonService.class).countByTitle(configurator))){
242 230
	    List<TaxonBase> records = CdmStore.getService(ITaxonService.class).findByTitle(configurator).getRecords();
243 231
	    addUuidSearchResults(records, configurator, ITaxonService.class);
244 232
	    return records;
245 233
	}
246
		return NO_RESULTS;
247
	}
248 234

  
249 235
	public List findMedia(IIdentifiableEntityServiceConfigurator configurator) {
250
        if(checkLargeResult(CdmStore.getService(IMediaService.class).countByTitle(configurator))){
251 236
	    List<Media> records = CdmStore.getService(IMediaService.class).findByTitle(configurator).getRecords();
252 237
	    addUuidSearchResults(records, configurator, IMediaService.class);
253 238
	    return records;
254 239
    }
255
        return NO_RESULTS;
256
    }
257

  
258 240

  
259 241
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)