Revision fd28a17f
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java | ||
---|---|---|
9 | 9 |
package eu.etaxonomy.taxeditor.bulkeditor.input; |
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 |
import java.util.Collections; |
|
13 | 12 |
import java.util.Comparator; |
14 | 13 |
import java.util.HashMap; |
15 | 14 |
import java.util.HashSet; |
... | ... | |
20 | 19 |
import java.util.UUID; |
21 | 20 |
|
22 | 21 |
import org.eclipse.core.runtime.ICoreRunnable; |
23 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
24 | 22 |
import org.eclipse.core.runtime.jobs.Job; |
25 | 23 |
|
26 | 24 |
import ca.odell.glazedlists.BasicEventList; |
... | ... | |
102 | 100 |
|
103 | 101 |
protected abstract List<T> listEntities(IIdentifiableEntityServiceConfigurator configurator); |
104 | 102 |
|
103 |
protected abstract long countEntities(IIdentifiableEntityServiceConfigurator configurator); |
|
104 |
|
|
105 | 105 |
protected abstract T loadEntity(UUID entityUuid); |
106 | 106 |
|
107 | 107 |
public void setMergeTarget(T t){ |
... | ... | |
160 | 160 |
IIdentifiableEntityServiceConfigurator configurator = bulkEditorQuery.getSearchConfigurator(); |
161 | 161 |
Comparator queryComparator = (bulkEditorQuery.getComparator() != null) ? bulkEditorQuery.getComparator() : new TitleCacheComparator(); |
162 | 162 |
|
163 |
long count = countEntities(configurator); |
|
164 |
int totalWork = count>Integer.MAX_VALUE?Integer.MAX_VALUE:(int)count; |
|
163 | 165 |
String jobLabel = String.format(Messages.AbstractBulkEditorInput_LOADING, getName(), bulkEditorQuery.getSearchString()); |
164 | 166 |
searchJob = Job.create(jobLabel, (ICoreRunnable) monitor -> { |
165 |
monitor.beginTask(jobLabel, IProgressMonitor.UNKNOWN);
|
|
167 |
monitor.beginTask(jobLabel, totalWork);
|
|
166 | 168 |
int pageNumber = 0; |
167 | 169 |
List<T> entities; |
168 | 170 |
do { |
... | ... | |
173 | 175 |
entities = listEntities(configurator); |
174 | 176 |
model.addAll(entities); |
175 | 177 |
pageNumber++; |
176 |
Collections.sort(model, queryComparator); |
|
178 |
monitor.worked(configurator.getPageSize()); |
|
179 |
long workedLong = configurator.getPageSize()*pageNumber; |
|
180 |
int loadedCount = workedLong>Integer.MAX_VALUE?Integer.MAX_VALUE:(int)workedLong; |
|
181 |
monitor.setTaskName(String.format("%s/%s %s loaded", loadedCount, totalWork, getName())); |
|
177 | 182 |
} while (!entities.isEmpty()); |
178 | 183 |
monitor.done(); |
179 | 184 |
}); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java | ||
---|---|---|
102 | 102 |
return true; |
103 | 103 |
} |
104 | 104 |
|
105 |
@Override |
|
106 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
107 |
return CdmStore.getService(IAgentService.class).countByTitle(configurator); |
|
108 |
} |
|
109 |
|
|
105 | 110 |
/** {@inheritDoc} */ |
106 | 111 |
@Override |
107 | 112 |
public List<TeamOrPersonBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) { |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java | ||
---|---|---|
67 | 67 |
return CdmStore.getService(IGroupService.class).delete(entity.getUuid()) != null; |
68 | 68 |
} |
69 | 69 |
|
70 |
@Override |
|
71 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
72 |
//TODO there is no count method for groups |
|
73 |
return CdmStore.getService(IGroupService.class).count(Group.class); |
|
74 |
} |
|
75 |
|
|
70 | 76 |
/* (non-Javadoc) |
71 | 77 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator) |
72 | 78 |
*/ |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/MediaEditorInput.java | ||
---|---|---|
68 | 68 |
} |
69 | 69 |
|
70 | 70 |
@Override |
71 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
72 |
return CdmStore.getService(IMediaService.class).countByTitle(configurator); |
|
73 |
} |
|
74 |
|
|
75 |
@Override |
|
71 | 76 |
protected List<Media> listEntities(IIdentifiableEntityServiceConfigurator configurator) { |
72 | 77 |
return CdmStore.getSearchManager().findMedia(configurator); |
73 | 78 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameEditorInput.java | ||
---|---|---|
74 | 74 |
return false; |
75 | 75 |
} |
76 | 76 |
|
77 |
@Override |
|
78 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
79 |
return CdmStore.getService(INameService.class).countByTitle(configurator); |
|
80 |
} |
|
81 |
|
|
77 | 82 |
/** {@inheritDoc} */ |
78 | 83 |
@Override |
79 | 84 |
public List listEntities(IIdentifiableEntityServiceConfigurator configurator) { |
80 |
|
|
81 | 85 |
configurator.setPropertyPaths(getPropertyPaths()); |
82 | 86 |
return CdmStore.getSearchManager().findNames(configurator, this.getConversation()); |
83 | 87 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameRelationshipEditorInput.java | ||
---|---|---|
76 | 76 |
return false; |
77 | 77 |
} |
78 | 78 |
|
79 |
@Override |
|
80 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
81 |
//TODO there is neither a service for name relationships nor any concrete |
|
82 |
//method for counting them |
|
83 |
return CdmStore.getCommonService().count(NameRelationship.class); |
|
84 |
} |
|
85 |
|
|
79 | 86 |
/* (non-Javadoc) |
80 | 87 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator) |
81 | 88 |
*/ |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/OccurrenceEditorInput.java | ||
---|---|---|
58 | 58 |
return instance; |
59 | 59 |
} |
60 | 60 |
|
61 |
@Override |
|
62 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
63 |
return CdmStore.getService(IOccurrenceService.class).countByTitle(configurator); |
|
64 |
} |
|
65 |
|
|
61 | 66 |
/** {@inheritDoc} */ |
62 | 67 |
@Override |
63 | 68 |
protected List<SpecimenOrObservationBase> listEntities( |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/ReferenceEditorInput.java | ||
---|---|---|
91 | 91 |
return super.isMarkerTypeEditingEnabled(markerType); |
92 | 92 |
} |
93 | 93 |
|
94 |
@Override |
|
95 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
96 |
return CdmStore.getService(IReferenceService.class).countByTitle(configurator); |
|
97 |
} |
|
94 | 98 |
|
95 | 99 |
/** {@inheritDoc} */ |
96 | 100 |
@Override |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/TaxonEditorInput.java | ||
---|---|---|
82 | 82 |
return CdmStore.getService(ITaxonService.class).merge(entity, true).getMergedEntity(); |
83 | 83 |
} |
84 | 84 |
|
85 |
|
|
85 |
@Override |
|
86 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
87 |
return CdmStore.getService(ITaxonService.class).countByTitle(configurator); |
|
88 |
} |
|
86 | 89 |
|
87 | 90 |
/** {@inheritDoc} */ |
88 | 91 |
@Override |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/UserEditorInput.java | ||
---|---|---|
64 | 64 |
return CdmStore.getService(IUserService.class).delete(entity) != null; |
65 | 65 |
} |
66 | 66 |
|
67 |
@Override |
|
68 |
protected long countEntities(IIdentifiableEntityServiceConfigurator configurator) { |
|
69 |
//TODO there is no count method for users |
|
70 |
return CdmStore.getService(IUserService.class).count(User.class); |
|
71 |
} |
|
72 |
|
|
67 | 73 |
/* (non-Javadoc) |
68 | 74 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#listEntities(eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator) |
69 | 75 |
*/ |
Also available in: Unified diff
ref #6321 Show search progress in progress bar