Revision caddd4f3
Added by Patrick Plitzner over 8 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorQuery.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
24 | 24 |
* @version 1.0 |
25 | 25 |
*/ |
26 | 26 |
public class BulkEditorQuery { |
27 |
|
|
28 |
private String searchString; |
|
29 |
private Comparator<?> comparator; |
|
30 |
private IIdentifiableEntityServiceConfigurator searchConfigurator; |
|
27 |
|
|
28 |
private final String searchString;
|
|
29 |
private final Comparator<?> comparator;
|
|
30 |
private final IIdentifiableEntityServiceConfigurator searchConfigurator;
|
|
31 | 31 |
|
32 | 32 |
public BulkEditorQuery (String searchString, Comparator comparator) { |
33 | 33 |
this.searchString = searchString; |
... | ... | |
38 | 38 |
searchConfigurator.setTitleSearchString(searchString); |
39 | 39 |
searchConfigurator.setMatchMode(null); |
40 | 40 |
searchConfigurator.setPropertyPaths(propertyPath); |
41 |
|
|
41 |
|
|
42 | 42 |
if(searchString != null && searchString.trim().equals("*")){ |
43 | 43 |
searchConfigurator.setPageSize(1000); |
44 | 44 |
} |
45 |
|
|
45 |
|
|
46 | 46 |
} |
47 | 47 |
|
48 |
/* (non-Javadoc) |
|
49 |
* @see eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery#getComparator() |
|
50 |
*/ |
|
51 | 48 |
public Comparator getComparator() { |
52 | 49 |
return comparator; |
53 | 50 |
} |
54 | 51 |
|
55 |
/* (non-Javadoc) |
|
56 |
* @see eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery#getSearchString() |
|
57 |
*/ |
|
58 | 52 |
public String getSearchString() { |
59 | 53 |
return searchString; |
60 | 54 |
} |
61 | 55 |
|
62 |
/* (non-Javadoc) |
|
63 |
* @see eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery#getSearchConfigurator() |
|
64 |
*/ |
|
65 | 56 |
public IIdentifiableEntityServiceConfigurator getSearchConfigurator() { |
66 | 57 |
return searchConfigurator; |
67 | 58 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/BulkEditorSearch.java | ||
---|---|---|
148 | 148 |
} |
149 | 149 |
|
150 | 150 |
|
151 |
/* |
|
151 |
/**
|
|
152 | 152 |
* Shows the results of the search. |
153 | 153 |
*/ |
154 | 154 |
private void updateEditorInput() { |
155 | 155 |
|
156 | 156 |
String searchString = getSearchString().trim(); |
157 | 157 |
|
158 |
if(DEFAULT_TEXT.equals(searchString) || CdmUtils.isEmpty(searchString)){
|
|
158 |
if(DEFAULT_TEXT.equals(searchString) || CdmUtils.isBlank(searchString)){
|
|
159 | 159 |
return; |
160 | 160 |
} |
161 | 161 |
|
162 |
BulkEditorQuery query = new BulkEditorQuery(getSearchString(), getComparator());
|
|
162 |
BulkEditorQuery query = new BulkEditorQuery(searchString, getComparator());
|
|
163 | 163 |
editor.performSearch(query); |
164 | 164 |
} |
165 | 165 |
|
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.taxeditor.bulkeditor.input; |
11 | 11 |
|
12 |
import java.util.Arrays; |
|
13 | 12 |
import java.util.List; |
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.eclipse.core.commands.ExecutionException; |
|
17 | 13 |
|
18 | 14 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
19 | 15 |
import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator; |
20 |
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException; |
|
21 | 16 |
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException; |
22 | 17 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
23 | 18 |
import eu.etaxonomy.cdm.model.agent.Person; |
... | ... | |
29 | 24 |
import eu.etaxonomy.cdm.strategy.merge.MergeMode; |
30 | 25 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator; |
31 | 26 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider; |
32 |
import eu.etaxonomy.taxeditor.bulkeditor.handler.MergeGroupHandler; |
|
33 | 27 |
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.AgentCreator; |
34 | 28 |
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider; |
35 | 29 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
... | ... | |
38 | 32 |
|
39 | 33 |
|
40 | 34 |
/** |
41 |
* <p>AgentEditorInput class.</p> |
|
42 |
* |
|
43 | 35 |
* @author p.ciardelli |
44 | 36 |
* @created 25.06.2009 |
45 | 37 |
* @version 1.0 |
46 | 38 |
*/ |
47 | 39 |
public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase> { |
48 | 40 |
|
49 |
/** |
|
50 |
* |
|
51 |
*/ |
|
52 | 41 |
private static final long serialVersionUID = 3387950621617078479L; |
53 | 42 |
|
54 |
/** Constant <code>ID="bulkeditor.input.author"</code> */ |
|
55 | 43 |
public static final String ID = "bulkeditor.input.author"; |
56 |
|
|
44 |
|
|
57 | 45 |
private static AgentEditorInput instance; |
58 | 46 |
|
59 |
/** |
|
60 |
* <p>getID</p> |
|
61 |
* |
|
62 |
* @return the iD |
|
63 |
*/ |
|
64 | 47 |
public static String getID() { |
65 | 48 |
return ID; |
66 | 49 |
} |
67 |
|
|
68 |
/* (non-Javadoc) |
|
69 |
* @see org.eclipse.ui.IEditorInput#getName() |
|
70 |
*/ |
|
71 |
/** |
|
72 |
* <p>getName</p> |
|
73 |
* |
|
74 |
* @return a {@link java.lang.String} object. |
|
75 |
*/ |
|
76 |
public String getName() { |
|
50 |
|
|
51 |
@Override |
|
52 |
public String getName() { |
|
77 | 53 |
return BulkEditorInputType.AGENT.label; |
78 | 54 |
} |
79 | 55 |
|
80 |
/* (non-Javadoc) |
|
81 |
* @see org.eclipse.ui.IEditorInput#getToolTipText() |
|
82 |
*/ |
|
83 |
/** |
|
84 |
* <p>getToolTipText</p> |
|
85 |
* |
|
86 |
* @return a {@link java.lang.String} object. |
|
87 |
*/ |
|
88 |
public String getToolTipText() { |
|
56 |
@Override |
|
57 |
public String getToolTipText() { |
|
89 | 58 |
return getName(); |
90 | 59 |
} |
91 | 60 |
|
92 |
/** |
|
93 |
* <p>Getter for the field <code>instance</code>.</p> |
|
94 |
* |
|
95 |
* @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object. |
|
96 |
*/ |
|
97 | 61 |
public static AbstractBulkEditorInput getInstance() { |
98 | 62 |
if (instance == null) { |
99 | 63 |
instance = new AgentEditorInput(); |
... | ... | |
101 | 65 |
return instance; |
102 | 66 |
} |
103 | 67 |
|
104 |
/* (non-Javadoc) |
|
105 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled() |
|
106 |
*/ |
|
107 | 68 |
/** {@inheritDoc} */ |
108 | 69 |
@Override |
109 | 70 |
public boolean isMergingEnabled() { |
110 | 71 |
return true; |
111 | 72 |
} |
112 |
|
|
113 |
/* (non-Javadoc) |
|
114 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled() |
|
115 |
*/ |
|
73 |
|
|
116 | 74 |
/** {@inheritDoc} */ |
117 | 75 |
@Override |
118 | 76 |
public boolean isConvertingEnabled() { |
119 | 77 |
return true; |
120 | 78 |
} |
121 |
|
|
79 |
|
|
122 | 80 |
/** {@inheritDoc} */ |
123 | 81 |
@Override |
124 | 82 |
public boolean merge(TeamOrPersonBase entity, TeamOrPersonBase mergeTarget) { |
... | ... | |
126 | 84 |
try { |
127 | 85 |
IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(Person.class); |
128 | 86 |
strategy.setMergeMode("institutionalMemberships", MergeMode.FIRST); |
129 |
CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, strategy);
|
|
87 |
CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, strategy); |
|
130 | 88 |
} catch (MergeException e) { |
131 | 89 |
MessagingUtils.errorDialog("Bulk Editor Merge Error", |
132 | 90 |
this, |
... | ... | |
144 | 102 |
public List<TeamOrPersonBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) { |
145 | 103 |
return CdmStore.getSearchManager().findTeamOrPersons(configurator); |
146 | 104 |
} |
147 |
|
|
148 |
/** {@inheritDoc}
|
|
105 |
|
|
106 |
/** {@inheritDoc} |
|
149 | 107 |
@Override |
150 | 108 |
public AgentBase loadEntity(UUID uuid) { |
151 |
List<String> propertyPaths = Arrays.asList(new String[]{});
|
|
109 |
List<String> propertyPaths = Arrays.asList(new String[]{}); |
|
152 | 110 |
return CdmStore.getService(IAgentService.class).load(uuid, propertyPaths); |
153 | 111 |
}*/ |
154 | 112 |
|
155 |
|
|
113 |
|
|
156 | 114 |
public boolean delete(AgentBase entity) throws ReferencedObjectUndeletableException { |
157 |
|
|
158 |
return CdmStore.getService(IAgentService.class).delete(entity) != null;
|
|
159 |
|
|
115 |
|
|
116 |
return CdmStore.getService(IAgentService.class).delete(entity) != null; |
|
117 |
|
|
160 | 118 |
} |
161 | 119 |
|
162 | 120 |
/** {@inheritDoc} */ |
163 | 121 |
public boolean save(AgentBase entity) { |
164 |
|
|
122 |
|
|
165 | 123 |
return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null; |
166 | 124 |
} |
167 | 125 |
|
168 |
/* (non-Javadoc) |
|
169 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders() |
|
170 |
*/ |
|
171 | 126 |
@Override |
172 | 127 |
public List<IBulkEditorSortProvider<TeamOrPersonBase>> getSortProviders() { |
173 | 128 |
List<IBulkEditorSortProvider<TeamOrPersonBase>> sortProviders = super.getSortProviders(); |
174 |
|
|
129 |
|
|
175 | 130 |
sortProviders.add(0, new IdentifiableEntitySortProvider<TeamOrPersonBase>()); |
176 |
|
|
131 |
|
|
177 | 132 |
return sortProviders; |
178 | 133 |
} |
179 |
|
|
180 |
/* (non-Javadoc) |
|
181 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator() |
|
182 |
*/ |
|
134 |
|
|
183 | 135 |
@Override |
184 | 136 |
protected IEntityCreator<TeamOrPersonBase> createEntityCreator() { |
185 | 137 |
return new AgentCreator(); |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java | ||
---|---|---|
59 | 59 |
// TODO make this configurable via preferences |
60 | 60 |
private static final int MAX_RESULTS_BEFORE_WARNING = 500; |
61 | 61 |
|
62 |
/** |
|
63 |
* <p>findNames</p> |
|
64 |
* |
|
65 |
* @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object. |
|
66 |
* @return a {@link java.util.List} object. |
|
67 |
*/ |
|
68 | 62 |
public List<TaxonNameBase> findNames(IIdentifiableEntityServiceConfigurator configurator){ |
69 | 63 |
if(checkLargeResult(CdmStore.getService(INameService.class).countByTitle(configurator))){ |
70 | 64 |
return CdmStore.getService(INameService.class).findByTitle(configurator).getRecords(); |
... | ... | |
86 | 80 |
relationships.add((NameRelationship) relationship); |
87 | 81 |
} |
88 | 82 |
} |
89 |
|
|
90 |
|
|
91 | 83 |
return relationships; |
92 |
|
|
93 | 84 |
} |
94 | 85 |
|
95 |
/** |
|
96 |
* <p>findTaxaAndNames</p> |
|
97 |
* |
|
98 |
* @param configurator a {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator} object. |
|
99 |
* @return a {@link java.util.List} object. |
|
100 |
*/ |
|
101 | 86 |
public List<UuidAndTitleCache<IdentifiableEntity>> findTaxaAndNames(IFindTaxaAndNamesConfigurator<TaxonBase> configurator){ |
102 | 87 |
return CdmStore.getService(ITaxonService.class).findTaxaAndNamesForEditor(configurator); |
103 | 88 |
} |
104 | 89 |
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
/** |
|
109 |
* <p>findReferences</p> |
|
110 |
* |
|
111 |
* @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object. |
|
112 |
* @return a {@link java.util.List} object. |
|
113 |
*/ |
|
114 | 90 |
public List<Reference> findReferences(IIdentifiableEntityServiceConfigurator configurator){ |
115 | 91 |
if(checkLargeResult(CdmStore.getService(IReferenceService.class).countByTitle(configurator))){ |
116 | 92 |
return CdmStore.getService(IReferenceService.class).findByTitle(configurator).getRecords(); |
... | ... | |
118 | 94 |
return NO_RESULTS; |
119 | 95 |
} |
120 | 96 |
|
121 |
|
|
122 |
/** |
|
123 |
* <p>findAgents</p> |
|
124 |
* |
|
125 |
* @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object. |
|
126 |
* @return a {@link java.util.List} object. |
|
127 |
*/ |
|
128 | 97 |
public List<AgentBase> findAgents(IIdentifiableEntityServiceConfigurator configurator){ |
129 | 98 |
if(checkLargeResult(CdmStore.getService(IAgentService.class).countByTitle(configurator))){ |
130 | 99 |
return CdmStore.getService(IAgentService.class).findByTitle(configurator).getRecords(); |
... | ... | |
132 | 101 |
return NO_RESULTS; |
133 | 102 |
} |
134 | 103 |
|
135 |
/** |
|
136 |
* <p>findTeamOrPersons</p> |
|
137 |
* |
|
138 |
* @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object. |
|
139 |
* @return a {@link java.util.List} object. |
|
140 |
*/ |
|
141 | 104 |
@SuppressWarnings("unchecked") |
142 | 105 |
public List<TeamOrPersonBase> findTeamOrPersons(IIdentifiableEntityServiceConfigurator configurator){ |
143 | 106 |
configurator.setClazz(TeamOrPersonBase.class); |
... | ... | |
214 | 177 |
} |
215 | 178 |
|
216 | 179 |
|
217 |
/** |
|
218 |
* @param count |
|
219 |
* @return |
|
220 |
*/ |
|
221 | 180 |
private boolean checkLargeResult(int count) { |
222 | 181 |
if(count > MAX_RESULTS_BEFORE_WARNING){ |
223 | 182 |
return MessageDialog.openConfirm(Display.getDefault().getActiveShell(), "Large result expected", |
... | ... | |
228 | 187 |
} |
229 | 188 |
} |
230 | 189 |
|
231 |
/** |
|
232 |
* |
|
233 |
* @param configurator |
|
234 |
* @return |
|
235 |
*/ |
|
236 | 190 |
private String sqlizeTitleSearchString(IIdentifiableEntityServiceConfigurator configurator){ |
237 | 191 |
return configurator.getTitleSearchString().replace(WILDCARD, "%"); |
238 | 192 |
} |
Also available in: Unified diff
Trim code