Revision 233a8fe2
Added by Cherian Mathew almost 9 years ago
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; |
... | ... | |
47 | 41 |
public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase> { |
48 | 42 |
|
49 | 43 |
/** |
50 |
*
|
|
44 |
* |
|
51 | 45 |
*/ |
52 | 46 |
private static final long serialVersionUID = 3387950621617078479L; |
53 | 47 |
|
54 | 48 |
/** Constant <code>ID="bulkeditor.input.author"</code> */ |
55 | 49 |
public static final String ID = "bulkeditor.input.author"; |
56 |
|
|
50 |
|
|
57 | 51 |
private static AgentEditorInput instance; |
58 | 52 |
|
59 | 53 |
/** |
... | ... | |
64 | 58 |
public static String getID() { |
65 | 59 |
return ID; |
66 | 60 |
} |
67 |
|
|
61 |
|
|
68 | 62 |
/* (non-Javadoc) |
69 | 63 |
* @see org.eclipse.ui.IEditorInput#getName() |
70 | 64 |
*/ |
... | ... | |
73 | 67 |
* |
74 | 68 |
* @return a {@link java.lang.String} object. |
75 | 69 |
*/ |
76 |
public String getName() { |
|
70 |
@Override |
|
71 |
public String getName() { |
|
77 | 72 |
return BulkEditorInputType.AGENT.label; |
78 | 73 |
} |
79 | 74 |
|
... | ... | |
85 | 80 |
* |
86 | 81 |
* @return a {@link java.lang.String} object. |
87 | 82 |
*/ |
88 |
public String getToolTipText() { |
|
83 |
@Override |
|
84 |
public String getToolTipText() { |
|
89 | 85 |
return getName(); |
90 | 86 |
} |
91 | 87 |
|
... | ... | |
109 | 105 |
public boolean isMergingEnabled() { |
110 | 106 |
return true; |
111 | 107 |
} |
112 |
|
|
108 |
|
|
113 | 109 |
/* (non-Javadoc) |
114 | 110 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInput#isMergingEnabled() |
115 | 111 |
*/ |
... | ... | |
118 | 114 |
public boolean isConvertingEnabled() { |
119 | 115 |
return true; |
120 | 116 |
} |
121 |
|
|
117 |
|
|
122 | 118 |
/** {@inheritDoc} */ |
123 | 119 |
@Override |
124 | 120 |
public boolean merge(TeamOrPersonBase entity, TeamOrPersonBase mergeTarget) { |
... | ... | |
126 | 122 |
try { |
127 | 123 |
IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(Person.class); |
128 | 124 |
strategy.setMergeMode("institutionalMemberships", MergeMode.FIRST); |
129 |
CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, strategy);
|
|
125 |
CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, Person.class);
|
|
130 | 126 |
} catch (MergeException e) { |
131 | 127 |
MessagingUtils.errorDialog("Bulk Editor Merge Error", |
132 | 128 |
this, |
... | ... | |
144 | 140 |
public List<TeamOrPersonBase> listEntities(IIdentifiableEntityServiceConfigurator configurator) { |
145 | 141 |
return CdmStore.getSearchManager().findTeamOrPersons(configurator); |
146 | 142 |
} |
147 |
|
|
148 |
/** {@inheritDoc}
|
|
143 |
|
|
144 |
/** {@inheritDoc} |
|
149 | 145 |
@Override |
150 | 146 |
public AgentBase loadEntity(UUID uuid) { |
151 |
List<String> propertyPaths = Arrays.asList(new String[]{});
|
|
147 |
List<String> propertyPaths = Arrays.asList(new String[]{}); |
|
152 | 148 |
return CdmStore.getService(IAgentService.class).load(uuid, propertyPaths); |
153 | 149 |
}*/ |
154 | 150 |
|
155 |
|
|
151 |
|
|
156 | 152 |
public boolean delete(AgentBase entity) throws ReferencedObjectUndeletableException { |
157 |
|
|
158 |
return CdmStore.getService(IAgentService.class).delete(entity) != null; |
|
159 |
|
|
160 |
} |
|
161 | 153 |
|
162 |
/** {@inheritDoc} */ |
|
163 |
public boolean save(AgentBase entity) { |
|
164 |
|
|
165 |
return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null; |
|
154 |
return CdmStore.getService(IAgentService.class).delete(entity) != null; |
|
155 |
|
|
166 | 156 |
} |
167 | 157 |
|
158 |
// /** {@inheritDoc} */ |
|
159 |
// public boolean save(AgentBase entity) { |
|
160 |
// |
|
161 |
// return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null; |
|
162 |
// } |
|
163 |
|
|
168 | 164 |
/* (non-Javadoc) |
169 | 165 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#getSortProviders() |
170 | 166 |
*/ |
171 | 167 |
@Override |
172 | 168 |
public List<IBulkEditorSortProvider<TeamOrPersonBase>> getSortProviders() { |
173 | 169 |
List<IBulkEditorSortProvider<TeamOrPersonBase>> sortProviders = super.getSortProviders(); |
174 |
|
|
170 |
|
|
175 | 171 |
sortProviders.add(0, new IdentifiableEntitySortProvider<TeamOrPersonBase>()); |
176 |
|
|
172 |
|
|
177 | 173 |
return sortProviders; |
178 | 174 |
} |
179 |
|
|
175 |
|
|
180 | 176 |
/* (non-Javadoc) |
181 | 177 |
* @see eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput#createEntityCreator() |
182 | 178 |
*/ |
... | ... | |
187 | 183 |
|
188 | 184 |
@Override |
189 | 185 |
public boolean save(TeamOrPersonBase entity) { |
190 |
return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null; |
|
186 |
if(CdmStore.getCurrentSessionManager().isRemoting()) { |
|
187 |
return CdmStore.getService(IAgentService.class).merge(entity) != null; |
|
188 |
} else { |
|
189 |
return CdmStore.getService(IAgentService.class).saveOrUpdate(entity) != null; |
|
190 |
} |
|
191 | 191 |
} |
192 | 192 |
|
193 | 193 |
@Override |
Also available in: Unified diff
#5012 Adding remoting session and updating save methods for Bulk Editor
Replace properties file with xml file
#5012 updates for making Bulk Editor remoting capable