From: U-BGBM\k.luther Date: Tue, 6 Oct 2015 07:16:00 +0000 (+0200) Subject: improve messaging for deleteResult X-Git-Tag: 3.12.0^2~127 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/369ac904d6969d7ca128a9f3c764d50a3df24bb6 improve messaging for deleteResult --- 369ac904d6969d7ca128a9f3c764d50a3df24bb6 diff --cc eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java index 15ca69172,15ca69172..49aaed016 --- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java +++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java @@@ -10,6 -10,6 +10,9 @@@ package eu.etaxonomy.taxeditor.bulkeditor.handler; ++import java.util.ArrayList; ++import java.util.List; ++ import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; @@@ -44,6 -44,6 +47,7 @@@ import eu.etaxonomy.taxeditor.annotated import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotationModel; import eu.etaxonomy.taxeditor.bulkeditor.BulkEditor; import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; ++import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils; import eu.etaxonomy.taxeditor.model.MessagingUtils; import eu.etaxonomy.taxeditor.store.CdmStore; @@@ -84,6 -84,6 +88,7 @@@ public class DeleteHandler extends Abst LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object); DeleteResult result = new DeleteResult(); ++ String errorMessage= "The object "; //result.setError(); try { ICdmApplicationConfiguration controller; @@@ -93,60 -93,60 +98,64 @@@ IOccurrenceService service = controller.getOccurrenceService(); if (object != null){ result = service.delete(((SpecimenOrObservationBase) object).getUuid()); ++ errorMessage = "The specimen or observation "; } } else if (object instanceof Reference){ IReferenceService service = controller.getReferenceService(); if (object != null){ result = service.delete(((Reference) object).getUuid()); ++ errorMessage = "The reference "; } } else if (object instanceof Group){ IGroupService service = controller.getGroupService(); if (object != null){ result = service.delete(((Group) object).getUuid()); ++ errorMessage = "The group "; } }else if (object instanceof User){ IUserService service = controller.getUserService(); if (object != null){ result = service.delete(((User) object).getUuid()); ++ errorMessage = "The user "; } } else if (object instanceof TaxonNameBase){ INameService service = controller.getNameService(); if (object != null){ NameDeletionConfigurator config = new NameDeletionConfigurator(); result = service.delete(((TaxonNameBase) object).getUuid(), config); ++ errorMessage = "The name "; } } else if (object instanceof TaxonBase){ ITaxonService service = controller.getTaxonService(); if (object != null){ if (object instanceof Taxon){ result = service.deleteTaxon(((TaxonBase) object).getUuid(), null, null); ++ errorMessage = "The taxon "; }else{ result = service.deleteSynonym(((Synonym)object).getUuid(), null); ++ errorMessage = "The synonym "; } } } else if (object instanceof TeamOrPersonBase){ IAgentService service = controller.getAgentService(); //TeamOrPersonBase teamOrPerson = (TeamOrPersonBase)service.load(((TeamOrPersonBase) object).getUuid()); result = service.delete(((TeamOrPersonBase)object).getUuid()); ++ errorMessage = "The team or person "; } } catch (Exception e){ MessagingUtils.errorDialog("Exception occured. Delete not possible", getClass(), e.getMessage(), TaxeditorBulkeditorPlugin.PLUGIN_ID, null, true); } if (result.isError() || result.isAbort()){ if (!result.getExceptions().isEmpty()) { -- String message = null; ++ List messages = new ArrayList(); int i = result.getExceptions().size(); for (Exception e:result.getExceptions()){ -- i--; -- message+= e.getMessage(); -- if (i>0){ -- message+= ", "; -- } ++ messages.add(e.getMessage()); } ++ errorMessage += "could not be deleted."; -- -- MessagingUtils.messageDialog("Delete not possible", getClass(), result.getExceptions().toString(), null); ++ DeleteResultMessagingUtils.messageDialogWithDetails(result,errorMessage, TaxeditorBulkeditorPlugin.PLUGIN_ID); }else{ MessagingUtils.messageDialog("Delete not possible", getClass(), "The object could not be deleted. An exception occured.", null); } @@@ -154,7 -154,7 +163,13 @@@ if (result.isOk() ){ ((BulkEditor) editor).removeAnnotatedLine(annotation); if(result.getUpdatedObjects().size() != 0 || !result.getExceptions().isEmpty()){ -- MessagingUtils.informationDialog("Delete successfull", "The object is deleted but there are updated objects: " + result.toString()); ++ List messages = new ArrayList(); ++ int i = result.getExceptions().size(); ++ for (Exception e:result.getExceptions()){ ++ messages.add(e.getMessage()); ++ } ++ errorMessage += "was deleted but there where updated objects"; ++ DeleteResultMessagingUtils.messageDialogWithDetails(result, errorMessage, TaxeditorBulkeditorPlugin.PLUGIN_ID); } } diff --cc eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/DefaultNewEntityListener.java index 000000000,c26557731..aaf23e9ef mode 000000,100644..100644 --- a/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/DefaultNewEntityListener.java +++ b/eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/DefaultNewEntityListener.java @@@ -1,0 -1,37 +1,39 @@@ + // $Id$ + /** + * Copyright (C) 2015 EDIT + * European Distributed Institute of Taxonomy + * http://www.e-taxonomy.eu + * + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * See LICENSE.TXT at the top of this package for the full license terms. + */ + package eu.etaxonomy.taxeditor.session; + + import org.apache.log4j.Logger; + + import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController; + import eu.etaxonomy.cdm.api.application.CdmApplicationState; + import eu.etaxonomy.cdm.model.NewEntityListener; + import eu.etaxonomy.cdm.model.common.CdmBase; + + /** + * @author cmathew + * @date 30 Sep 2015 + * + */ + public class DefaultNewEntityListener implements NewEntityListener { + + private static final Logger logger = Logger.getLogger(DefaultNewEntityListener.class); + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.model.NewEntityListener#onCreate(eu.etaxonomy.cdm.model.common.CdmBase) + */ + @Override + public void onCreate(CdmBase cdmBase) { + logger.warn("New Entity created : " + cdmBase); - ((CdmApplicationRemoteController)CdmApplicationState.getCurrentAppConfig()).getCdmEntitySessionManager().getActiveSession().addNewCdmEntity(cdmBase); ++ if(CdmApplicationState.getCurrentAppConfig() instanceof CdmApplicationRemoteController){ ++ ((CdmApplicationRemoteController)CdmApplicationState.getCurrentAppConfig()).getCdmEntitySessionManager().getActiveSession().addNewCdmEntity(cdmBase); ++ } + } + + } diff --cc eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientDescriptionService.java index 52f3d9ff0,b7d278bc0..eed62fa60 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientDescriptionService.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientDescriptionService.java @@@ -1204,13 -1204,12 +1204,24 @@@ public class TransientDescriptionServic return defaultService.merge(arg0, arg1); } + /* (non-Javadoc) ++ + * @see eu.etaxonomy.cdm.api.service.IDescriptionService#moveTaxonDescription(java.util.UUID, java.util.UUID) + */ + @Override + public UpdateResult moveTaxonDescription(UUID descriptionUuid, UUID targetTaxonUuid) { - + return defaultService.moveTaxonDescription(descriptionUuid, targetTaxonUuid); + } + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.api.service.IService#merge(java.util.List, boolean) + */ + @Override + public List merge(List arg0, boolean arg1) { ++ + return defaultService.merge(arg0, arg1); + } + ++ ++ } diff --cc eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java index 0c9d862f7,aeac3d41e..1a04b047c --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/operation/MoveDescriptionToOtherTaxonOperation.java @@@ -16,10 -17,14 +17,16 @@@ import org.eclipse.core.runtime.IAdapta import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; ++import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController; ++import eu.etaxonomy.cdm.api.application.CdmApplicationState; import eu.etaxonomy.cdm.api.conversation.IConversationEnabled; import eu.etaxonomy.cdm.api.service.IDescriptionService; + import eu.etaxonomy.cdm.model.common.Annotation; + import eu.etaxonomy.cdm.model.common.AnnotationType; + import eu.etaxonomy.cdm.model.common.Language; import eu.etaxonomy.cdm.model.description.TaxonDescription; import eu.etaxonomy.cdm.model.taxon.TaxonNode; + import eu.etaxonomy.taxeditor.editor.EditorUtil; import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; @@@ -84,9 -89,7 +91,13 @@@ public class MoveDescriptionToOtherTaxo annotation.setAnnotationType(AnnotationType.TECHNICAL()); description.addAnnotation(annotation); newAcceptedTaxonNode.getTaxon().addDescription(description); - CdmStore.getService(IDescriptionService.class).saveOrUpdate(description);*/ - CdmStore.getService(IDescriptionService.class).merge(description); ++ if (CdmApplicationState.getCurrentAppConfig() instanceof CdmApplicationRemoteController) { ++ CdmStore.getService(IDescriptionService.class).merge(description); ++ } else { ++ CdmStore.getService(IDescriptionService.class).saveOrUpdate(description); ++ } + - CdmStore.getService(IDescriptionService.class).moveTaxonDescription(description.getUuid(), newAcceptedTaxonNode.getTaxon().getUuid()); ++ // CdmStore.getService(IDescriptionService.class).moveTaxonDescription(description.getUuid(), newAcceptedTaxonNode.getTaxon().getUuid()); monitor.worked(40); return postExecute(description); diff --cc eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java index 000000000,000000000..ef473c3a4 new file mode 100644 --- /dev/null +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/DeleteResultMessagingUtils.java @@@ -1,0 -1,0 +1,53 @@@ ++// $Id$ ++/** ++* Copyright (C) 2015 EDIT ++* European Distributed Institute of Taxonomy ++* http://www.e-taxonomy.eu ++* ++* The contents of this file are subject to the Mozilla Public License Version 1.1 ++* See LICENSE.TXT at the top of this package for the full license terms. ++*/ ++package eu.etaxonomy.taxeditor.model; ++ ++import java.util.ArrayList; ++import java.util.List; ++ ++import org.eclipse.core.runtime.IStatus; ++import org.eclipse.core.runtime.Status; ++ ++import eu.etaxonomy.cdm.api.service.DeleteResult; ++ ++/** ++ * @author k.luther ++ * @date Oct 5, 2015 ++ * ++ */ ++public class DeleteResultMessagingUtils extends MessagingUtils { ++ /** ++ * Displays a message {@link org.eclipse.jface.dialogs.MessageDialog}. ++ * ++ * @param title ++ * @param source ++ * @param message ++ */ ++ public static void messageDialogWithDetails(DeleteResult result, String message, String pluginId) { ++ if (result.isOk() && result.getExceptions().isEmpty()){ ++ return; ++ } ++ List details = new ArrayList(); ++ String title= ""; ++ ++ if (result.isOk() && result.getExceptions().size() > 0){ ++ for (Exception e:result.getExceptions()){ ++ details.add(e.getMessage()); ++ } ++ title = "The delete was successfull."; ++ } ++ String stackTraceWithContext = getContextInfo(details); ++ CdmErrorDialog ced = new CdmErrorDialog(AbstractUtility.getShell(), title, message, new Status(IStatus.ERROR, pluginId, null), stackTraceWithContext); ++ ced.open(); ++ ++ ++ ++ } ++} diff --cc eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java index b316c2a06,b316c2a06..36777e8ca --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/model/MessagingUtils.java @@@ -219,6 -219,6 +219,19 @@@ public class MessagingUtils return stackTraceAndContextInfo.toString(); } ++ public static String getContextInfo(List contextInfo) { ++ StringBuffer scontextInfoStringBuffer = new StringBuffer(); ++ ++ ++ for(String infoItem : contextInfo) { ++ scontextInfoStringBuffer.append(infoItem + System.getProperty("line.separator")); ++ } ++ ++ ++ ++ return scontextInfoStringBuffer.toString(); ++ } ++ private static Throwable getDefaultThrowable() { return new Throwable("Error thrown but no associated exception"); } diff --cc eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java index 90a1dc935,7cbc1e76d..ef365a8ec --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java @@@ -53,9 -53,8 +53,9 @@@ public class NewTaxonNodeWizard extend Taxon taxon = taxonNodePage.getTaxon(); try{ TaxonNode taxonNode = parent.addChildTaxon(taxon, parent.getReference(), parent.getMicroReference()); + if(CdmStore.getCurrentSessionManager().isRemoting()) { - taxonNode = CdmStore.getService(ITaxonNodeService.class).merge(taxonNode); + taxonNode = CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true); } else { taxonNode = CdmStore.getService(ITaxonNodeService.class).save(taxonNode); }