fix #5216: merge grantedAuthority checks for existing grantedAuthority first and...
authorKatja Luther <k.luther@bgbm.org>
Thu, 2 Feb 2017 09:02:11 +0000 (10:02 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 2 Feb 2017 09:04:36 +0000 (10:04 +0100)
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages.properties
eu.etaxonomy.taxeditor.store/OSGI-INF/l10n/messages_de.properties
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/Messages.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewGrantedAuthorityWizard.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/grantedAuthority/GrantedAuthorityCollectionElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/grantedAuthority/GrantedAuthorityDetailElement.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/grantedAuthority/GrantedAuthorityDetailSection.java

index fadec7c1d88dc3fc10acd70ee970195cadc92724..d95d94bebe43e18dd59b0490d12d7f54c08a0f86 100644 (file)
@@ -140,4 +140,6 @@ PresenceAbsenceTermDetailElement_LABEL_COLOR=Color
 DeleteConfiguration_media_removeFromGallery=Remove the media from the image gallery but leave it in database
 DeleteConfiguration_media_deleteIfUsedInTaxonDescription=Delete also if media is used in taxon description
 DeleteConfiguration_media_deleteIfUsedInSpecimenDescription=Delete also if media is used in specimen description        
-DeleteConfiguration_media_delete=Delete the media completely
\ No newline at end of file
+DeleteConfiguration_media_delete=Delete the media completely
+
+NewGrantedAuthority_AlreadyInDb=The granted authority already exists.
\ No newline at end of file
index 3000cd5ddb203171e6814b2879eb6ba78ea70ab6..422a58574a342f03bcca70e57d448670e2a2494d 100644 (file)
@@ -139,3 +139,7 @@ DeleteConfiguration_media_removeFromGallery=Entferne Medienobjekt aus der Galler
 DeleteConfiguration_media_deleteIfUsedInTaxonDescription=Lösche das Medienobjekt, auch wenn es von einem Taxon verwendet wird
 DeleteConfiguration_media_deleteIfUsedInSpecimenDescription=Lösche das Medienobjekt, auch wenn es von einem Specimen verwendet wird
 DeleteConfiguration_media_delete=Lösche das Medienobjekt
+
+NewGrantedAuthority_AlreadyInDb=Die GrantedAuthority ist bereits in der DB enthalten.
+
+
index d92c1d2bc265d9179d37d030699fdb0fc862d637..7b79196554d45b6ef73e96bff5bf1987381cd6ee 100644 (file)
@@ -149,6 +149,7 @@ public class Messages extends NLS {
        public static String DeleteConfiguration_media_deleteIfUsedInTaxonDescription;
        public static String DeleteConfiguration_media_deleteIfUsedInSpecimenDescription;
        public static String DeleteConfiguration_media_delete;
+       public static String NewGrantedAuthority_AlreadyInDb;
        static {
         // initialize resource bundle
         NLS.initializeMessages(BUNDLE_NAME, Messages.class);
index ee27d3245c52d31abcb920ddcf19a7b134237e39..bb25e707944a0b4c72b4466c3cb7f41d44ac04e9 100644 (file)
@@ -11,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.Messages;
+import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.section.grantedAuthority.GrantedAuthorityDetailWizardPage;
 
@@ -37,8 +39,12 @@ public class NewGrantedAuthorityWizard extends AbstractNewEntityWizard<GrantedAu
         */
        @Override
        protected void saveEntity() {
-           CdmStore.getService(IGrantedAuthorityService.class).merge(getEntity(), true);
-          
+           try{
+               CdmStore.getService(IGrantedAuthorityService.class).merge(getEntity(), true);
+           }catch (Exception e){
+               MessagingUtils.info(Messages.NewGrantedAuthority_AlreadyInDb);
+           }
+
        }
 
        /* (non-Javadoc)
index fb250dba30837cf98f00c3aa0676db6550010b09..f40a6403ddb65ee28a42f7fb75e88b86cee180a9 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2012 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 +12,7 @@ package eu.etaxonomy.taxeditor.ui.section.grantedAuthority;
 import org.eclipse.swt.events.SelectionListener;
 
 import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
+import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -24,14 +25,16 @@ import eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement;
  *
  */
 public class GrantedAuthorityCollectionElement extends AbstractEntityCollectionElement<GrantedAuthorityImpl> {
-       
+
        private EntitySelectionElement<GrantedAuthorityImpl> selection_authority;
+       private Group grantedAuthorityUser;
 
 
        public GrantedAuthorityCollectionElement(CdmFormFactory formFactory,
-                       AbstractFormSection section, GrantedAuthorityImpl entity,
+                       AbstractFormSection section, GrantedAuthorityImpl entity, Group group,
                        SelectionListener removeListener, int style) {
-               super(formFactory, section, entity, removeListener, null, style);               
+               super(formFactory, section, entity, removeListener, null, style);
+               this.grantedAuthorityUser = group;
                // TODO Auto-generated constructor stub
        }
 
@@ -40,8 +43,8 @@ public class GrantedAuthorityCollectionElement extends AbstractEntityCollectionE
         */
        @Override
        public void setEntity(GrantedAuthorityImpl entity) {
-               selection_authority.setEntity(entity);
-               
+               this.entity = entity;
+
        }
 
        /* (non-Javadoc)
@@ -59,7 +62,12 @@ public class GrantedAuthorityCollectionElement extends AbstractEntityCollectionE
        @Override
        public void handleEvent(Object eventSource) {
                if (eventSource == selection_authority) {
+                   GrantedAuthorityImpl oldGrantedAuthority = entity;
+                   grantedAuthorityUser.removeGrantedAuthority(entity);
+
                        setEntity(selection_authority.getEntity());
+                       grantedAuthorityUser.addGrantedAuthority(entity);
+
                }
        }
 
index 75a70728e618a3c5c5ed9cd0e6fe787438812f35..ab5a27897341e0afded11b405fa46e68e09c6522 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * 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.
 */
@@ -10,7 +10,6 @@
 package eu.etaxonomy.taxeditor.ui.section.grantedAuthority;
 
 import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
-import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
 import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
 import eu.etaxonomy.taxeditor.ui.element.TextWithLabelElement;
@@ -25,7 +24,7 @@ import eu.etaxonomy.taxeditor.ui.section.AbstractCdmDetailElement;
 public class GrantedAuthorityDetailElement extends AbstractCdmDetailElement<GrantedAuthorityImpl> {
 
        private TextWithLabelElement text_authority;
-       
+
        /**
         * @param formFactory
         * @param formElement
@@ -38,10 +37,13 @@ public class GrantedAuthorityDetailElement extends AbstractCdmDetailElement<Gran
        @Override
        protected void createControls(ICdmFormElement formElement,
                        GrantedAuthorityImpl entity, int style) {
-               
-               String labelText = GrantedAuthorityLabelTextProvider.getText(entity);
-               text_authority = formFactory.createTextWithLabelElement(formElement, "Authority", labelText, style);
-               
+
+               String labelText = null;
+               if (entity.getAuthority() != null){
+                   labelText = GrantedAuthorityLabelTextProvider.getText(entity);
+               }
+           text_authority = formFactory.createTextWithLabelElement(formElement, "Authority", null, style);
+
        }
 
        @Override
@@ -49,9 +51,9 @@ public class GrantedAuthorityDetailElement extends AbstractCdmDetailElement<Gran
                if(eventSource == text_authority){
                        getEntity().setAuthority(text_authority.getText());
                }
-               
+
        }
 
 
-       
+
 }
index c94bb2a5a745e5f9a935d68477beb438469818d4..f83a8d31273e598bc0ac5b475947dfd012a3218b 100644 (file)
@@ -119,6 +119,7 @@ public class GrantedAuthorityDetailSection extends
      */
     @Override
     public GrantedAuthority addExisting() {
+        System.err.println("Test");
         return null;
     }