Merge branch 'release/4.7.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / newWizard / NewGrantedAuthorityWizard.java
index d14e60819095bb07201120674d8c3be2daae0fe1..4d8132fd50c298a1159f91a6e3f5971a23fa4a32 100644 (file)
@@ -1,9 +1,8 @@
-// $Id$
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.
 */
@@ -12,6 +11,8 @@ package eu.etaxonomy.taxeditor.newWizard;
 
 import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
 import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailWizardPage;
 
@@ -20,9 +21,9 @@ import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetail
  * @created Sept 13 2012
  */
 public class NewGrantedAuthorityWizard extends AbstractNewEntityWizard<GrantedAuthorityImpl> {
-       
+
        private GrantedAuthorityDetailWizardPage authorityPage;
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.jface.wizard.Wizard#addPages()
         */
@@ -38,7 +39,12 @@ public class NewGrantedAuthorityWizard extends AbstractNewEntityWizard<GrantedAu
         */
        @Override
        protected void saveEntity() {
-               CdmStore.getService(IGrantedAuthorityService.class).saveOrUpdate(getEntity());
+           try{
+               CdmStore.getService(IGrantedAuthorityService.class).merge(getEntity(), true);
+           }catch (Exception e){
+               MessagingUtils.info(Messages.NewGrantedAuthority_AlreadyInDb);
+           }
+
        }
 
        /* (non-Javadoc)
@@ -46,7 +52,7 @@ public class NewGrantedAuthorityWizard extends AbstractNewEntityWizard<GrantedAu
         */
        @Override
        protected GrantedAuthorityImpl createNewEntity() {
-               return GrantedAuthorityImpl.NewInstance();
+               return GrantedAuthorityImpl.NewInstance("");
        }
 
        /* (non-Javadoc)