Revision a07e7327
Added by Katja Luther almost 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/handler/DeleteHandlerE4.java | ||
---|---|---|
53 | 53 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
54 | 54 |
import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils; |
55 | 55 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
56 |
import eu.etaxonomy.taxeditor.remoting.CdmEagerLoadingException; |
|
56 | 57 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
57 | 58 |
import eu.etaxonomy.taxeditor.ui.dialog.configurator.deleteConfigurator.DeleteConfiguratorDialog; |
58 | 59 |
|
... | ... | |
68 | 69 |
private static final String COULD_NOT_BE_DELETED = eu.etaxonomy.taxeditor.l10n.Messages.DeleteHandler_COULD_NOT_BE_DELETED; |
69 | 70 |
private static final String AN_EXCEPTION_OCCURED = Messages.DeleteHandler_EXCEPTION; |
70 | 71 |
private static final String DELETE_NOT_POSSIBLE = Messages.DeleteHandler_DELETE_NOT_POSSIBLE; |
72 |
private static final String ALREADY_DELETED = Messages.DeleteHandler_ALREADY_DELETED; |
|
71 | 73 |
private static final String DO_YOU_REALLY_WANT_TO_DELETE_THE_S = Messages.DeleteHandler_REALLY_DELETE; |
72 | 74 |
private static final String MEDIA = Messages.DeleteHandler_MEDIA; |
73 | 75 |
private static final String TEAM_OR_PERSON = Messages.DeleteHandler_TEAM_OR_PERSON; |
... | ... | |
133 | 135 |
}else if (object instanceof User){ |
134 | 136 |
errorMessage = USER; |
135 | 137 |
} else if (object instanceof TaxonName){ |
136 |
TaxonName name = HibernateProxyHelper.deproxy(object, TaxonName.class); |
|
137 |
config = new NameDeletionConfigurator(); |
|
138 |
try{ |
|
139 |
TaxonName name = HibernateProxyHelper.deproxy(object, TaxonName.class); |
|
140 |
config = new NameDeletionConfigurator(); |
|
138 | 141 |
|
139 |
DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, |
|
140 |
shell, CONFIRM_DELETION, null, |
|
141 |
String.format( |
|
142 |
DO_YOU_REALLY_WANT_TO_DELETE_THE_S+"\n"+Messages.DeleteHandler_IRREVERSIBLE, |
|
143 |
NAME), |
|
144 |
MessageDialog.WARNING, new String[] { DELETE, SKIP }, 0, true); |
|
145 |
int result_dialog = dialog.open(); |
|
146 |
if (result_dialog != IStatus.OK){ |
|
142 |
DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, |
|
143 |
shell, CONFIRM_DELETION, null, |
|
144 |
String.format( |
|
145 |
DO_YOU_REALLY_WANT_TO_DELETE_THE_S+"\n"+Messages.DeleteHandler_IRREVERSIBLE, |
|
146 |
NAME), |
|
147 |
MessageDialog.WARNING, new String[] { DELETE, SKIP }, 0, true); |
|
148 |
int result_dialog = dialog.open(); |
|
149 |
if (result_dialog != IStatus.OK){ |
|
150 |
return; |
|
151 |
} |
|
152 |
result = controller.getNameService().isDeletable(name.getUuid(), config); |
|
153 |
errorMessage = NAME; |
|
154 |
} catch(Exception e){ |
|
155 |
MessagingUtils.messageDialog(((TaxonName) object).getTitleCache() + " " +ALREADY_DELETED, getClass(), |
|
156 |
Messages.DeleteHandler_ALREADY_DELETED, |
|
157 |
null); |
|
147 | 158 |
return; |
148 | 159 |
} |
149 |
result = controller.getNameService().isDeletable(name.getUuid(), config); |
|
150 |
errorMessage = NAME; |
|
151 | 160 |
|
152 | 161 |
} else if (object instanceof TaxonBase){ |
153 | 162 |
|
154 | 163 |
// synonym |
155 | 164 |
if(object instanceof Synonym){ |
156 |
Synonym synonym = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
157 |
config = new SynonymDeletionConfigurator(); |
|
158 |
errorMessage = SYNONYM; |
|
159 |
DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, |
|
160 |
shell, CONFIRM_DELETION, null, |
|
161 |
String.format(DO_YOU_REALLY_WANT_TO_DELETE_THE_S, SYNONYM), |
|
162 |
MessageDialog.WARNING, new String[] { DELETE, SKIP }, 0, true); |
|
163 |
int result_dialog = dialog.open(); |
|
164 |
if (result_dialog != IStatus.OK){ |
|
165 |
try{ |
|
166 |
Synonym synonym = HibernateProxyHelper.deproxy(object, Synonym.class); |
|
167 |
config = new SynonymDeletionConfigurator(); |
|
168 |
errorMessage = SYNONYM; |
|
169 |
DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, |
|
170 |
shell, CONFIRM_DELETION, null, |
|
171 |
String.format(DO_YOU_REALLY_WANT_TO_DELETE_THE_S, SYNONYM), |
|
172 |
MessageDialog.WARNING, new String[] { DELETE, SKIP }, 0, true); |
|
173 |
int result_dialog = dialog.open(); |
|
174 |
if (result_dialog != IStatus.OK){ |
|
175 |
return; |
|
176 |
} |
|
177 |
result = controller.getTaxonService().isDeletable(synonym.getUuid(), config); |
|
178 |
} catch(CdmEagerLoadingException e){ |
|
179 |
MessagingUtils.messageDialog(((TaxonBase) object).getTitleCache() + " " +ALREADY_DELETED, getClass(), |
|
180 |
Messages.DeleteHandler_ALREADY_DELETED, |
|
181 |
null); |
|
165 | 182 |
return; |
166 | 183 |
} |
167 |
result = controller.getTaxonService().isDeletable(synonym.getUuid(), config); |
|
184 |
|
|
168 | 185 |
|
169 | 186 |
} |
170 | 187 |
else if(object instanceof Taxon ){ |
171 |
Taxon taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
172 |
if (((Taxon)object).getTaxonNodes().isEmpty()){ |
|
173 |
errorMessage = TAXON; |
|
174 |
} else { |
|
175 |
MessagingUtils.messageDialog(DELETE_NOT_POSSIBLE, getClass(), |
|
176 |
Messages.DeleteHandler_TAXON_CAN_NOT_BE_DELETED, |
|
188 |
try{ |
|
189 |
Taxon taxon = HibernateProxyHelper.deproxy(object, Taxon.class); |
|
190 |
if (((Taxon)object).getTaxonNodes().isEmpty()){ |
|
191 |
errorMessage = TAXON; |
|
192 |
} else { |
|
193 |
MessagingUtils.messageDialog(DELETE_NOT_POSSIBLE, getClass(), |
|
194 |
Messages.DeleteHandler_TAXON_CAN_NOT_BE_DELETED, |
|
195 |
null); |
|
196 |
return; |
|
197 |
} |
|
198 |
config = new TaxonDeletionConfigurator(); |
|
199 |
((TaxonDeletionConfigurator) config).setDeleteInAllClassifications(true); |
|
200 |
DeleteConfiguratorDialog dialog; |
|
201 |
dialog = new DeleteConfiguratorDialog(config, shell, |
|
202 |
CONFIRM_DELETION, null, |
|
203 |
String.format(DO_YOU_REALLY_WANT_TO_DELETE_THE_S, TAXON), |
|
204 |
MessageDialog.WARNING, new String[] { DELETE, SKIP }, 0, true); |
|
205 |
int result_dialog = dialog.open(); |
|
206 |
if (result_dialog != IStatus.OK){ |
|
207 |
return; |
|
208 |
} |
|
209 |
result = controller.getTaxonService().isDeletable(taxon.getUuid(), config); |
|
210 |
|
|
211 |
} catch(CdmEagerLoadingException e){ |
|
212 |
MessagingUtils.messageDialog(((TaxonBase) object).getTitleCache() + " " +ALREADY_DELETED, getClass(), |
|
213 |
Messages.DeleteHandler_ALREADY_DELETED, |
|
177 | 214 |
null); |
178 | 215 |
return; |
179 | 216 |
} |
180 |
config = new TaxonDeletionConfigurator(); |
|
181 |
((TaxonDeletionConfigurator) config).setDeleteInAllClassifications(true); |
|
182 |
DeleteConfiguratorDialog dialog; |
|
183 |
dialog = new DeleteConfiguratorDialog(config, shell, |
|
184 |
CONFIRM_DELETION, null, |
|
185 |
String.format(DO_YOU_REALLY_WANT_TO_DELETE_THE_S, TAXON), |
|
186 |
MessageDialog.WARNING, new String[] { DELETE, SKIP }, 0, true); |
|
187 |
int result_dialog = dialog.open(); |
|
188 |
if (result_dialog != IStatus.OK){ |
|
189 |
return; |
|
190 |
} |
|
191 |
result = controller.getTaxonService().isDeletable(taxon.getUuid(), config); |
|
192 | 217 |
|
193 | 218 |
} |
194 | 219 |
} else if (object instanceof TeamOrPersonBase){ |
Also available in: Unified diff
smaller changes in bulk editor