Revision 635b598e
Added by Katja Luther almost 9 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java | ||
---|---|---|
20 | 20 |
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException; |
21 | 21 |
import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException; |
22 | 22 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
23 |
import eu.etaxonomy.cdm.model.agent.Person; |
|
24 |
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; |
|
25 |
import eu.etaxonomy.cdm.strategy.merge.DefaultMergeStrategy; |
|
26 |
import eu.etaxonomy.cdm.strategy.merge.IMergable; |
|
27 |
import eu.etaxonomy.cdm.strategy.merge.IMergeStrategy; |
|
28 |
import eu.etaxonomy.cdm.strategy.merge.MergeException; |
|
29 |
import eu.etaxonomy.cdm.strategy.merge.MergeMode; |
|
23 | 30 |
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator; |
24 | 31 |
import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider; |
32 |
import eu.etaxonomy.taxeditor.bulkeditor.handler.MergeGroupHandler; |
|
25 | 33 |
import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.AgentCreator; |
26 | 34 |
import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.IdentifiableEntitySortProvider; |
35 |
import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; |
|
36 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
27 | 37 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
28 | 38 |
|
29 | 39 |
|
... | ... | |
34 | 44 |
* @created 25.06.2009 |
35 | 45 |
* @version 1.0 |
36 | 46 |
*/ |
37 |
public class AgentEditorInput extends AbstractBulkEditorInput<AgentBase> {
|
|
47 |
public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase> {
|
|
38 | 48 |
|
39 | 49 |
/** |
40 | 50 |
* |
... | ... | |
99 | 109 |
public boolean isMergingEnabled() { |
100 | 110 |
return true; |
101 | 111 |
} |
112 |
|
|
113 |
/* (non-Javadoc) |
|
114 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled() |
|
115 |
*/ |
|
116 |
/** {@inheritDoc} */ |
|
117 |
@Override |
|
118 |
public boolean isConvertingEnabled() { |
|
119 |
return true; |
|
120 |
} |
|
121 |
|
|
122 |
/** {@inheritDoc} */ |
|
123 |
@Override |
|
124 |
public boolean merge(TeamOrPersonBase entity, TeamOrPersonBase mergeTarget) { |
|
125 |
if (entity instanceof IMergable) { |
|
126 |
try { |
|
127 |
IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(Person.class); |
|
128 |
strategy.setMergeMode("institutionalMemberships", MergeMode.FIRST); |
|
129 |
CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, strategy); |
|
130 |
} catch (MergeException e) { |
|
131 |
MessagingUtils.errorDialog("Bulk Editor Merge Error", |
|
132 |
this, |
|
133 |
"Could not merge chosen objects of type " + entity.getClass().getName(), |
|
134 |
TaxeditorBulkeditorPlugin.PLUGIN_ID, |
|
135 |
e, |
|
136 |
true); |
|
137 |
} |
|
138 |
} |
|
139 |
return true; |
|
140 |
} |
|
102 | 141 |
|
103 | 142 |
/** {@inheritDoc} */ |
104 | 143 |
@Override |
105 |
public List<AgentBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
|
|
144 |
public List<TeamOrPersonBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) {
|
|
106 | 145 |
return CdmStore.getSearchManager().findTeamOrPersons(configurator); |
107 | 146 |
} |
108 | 147 |
|
... | ... | |
130 | 169 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders() |
131 | 170 |
*/ |
132 | 171 |
@Override |
133 |
public List<IBulkEditorSortProvider<AgentBase>> getSortProviders() {
|
|
134 |
List<IBulkEditorSortProvider<AgentBase>> sortProviders = super.getSortProviders();
|
|
172 |
public List<IBulkEditorSortProvider<TeamOrPersonBase>> getSortProviders() {
|
|
173 |
List<IBulkEditorSortProvider<TeamOrPersonBase>> sortProviders = super.getSortProviders();
|
|
135 | 174 |
|
136 |
sortProviders.add(0, new IdentifiableEntitySortProvider<AgentBase>());
|
|
175 |
sortProviders.add(0, new IdentifiableEntitySortProvider<TeamOrPersonBase>());
|
|
137 | 176 |
|
138 | 177 |
return sortProviders; |
139 | 178 |
} |
... | ... | |
142 | 181 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator() |
143 | 182 |
*/ |
144 | 183 |
@Override |
145 |
protected IEntityCreator<AgentBase> createEntityCreator() {
|
|
184 |
protected IEntityCreator<TeamOrPersonBase> createEntityCreator() {
|
|
146 | 185 |
return new AgentCreator(); |
147 | 186 |
} |
148 | 187 |
|
188 |
@Override |
|
189 |
public boolean save(TeamOrPersonBase entity) { |
|
190 |
// TODO Auto-generated method stub |
|
191 |
return false; |
|
192 |
} |
|
193 |
|
|
194 |
@Override |
|
195 |
public boolean delete(TeamOrPersonBase entity) |
|
196 |
throws ReferencedObjectUndeletableException { |
|
197 |
// TODO Auto-generated method stub |
|
198 |
return false; |
|
199 |
} |
|
200 |
|
|
149 | 201 |
} |
Also available in: Unified diff
bulkeditor: merge of teams and persons and convert team to person and person to team