- fixed bug leading to multiple FieldUnits for one DerivedUnit because multiple...
authorPatric Plitzner <p.plitzner@bgbm.org>
Thu, 22 Aug 2013 17:18:12 +0000 (17:18 +0000)
committerPatric Plitzner <p.plitzner@bgbm.org>
Thu, 22 Aug 2013 17:18:12 +0000 (17:18 +0000)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java

index 401bc1091b1011b6745311e5d8d318c598e5d03d..1dfb04352f9db4f0620678649fee8b049bf35998 100644 (file)
@@ -1,9 +1,9 @@
 // $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.
 */
@@ -32,56 +32,50 @@ import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralWizardPage;
  */
 public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUnit> {
        private SpecimenOrObservationType specOrObsType = null;
-       
+
        public NewDerivedUnitBaseWizard() {
-               super();        
+               super();
        }
-       
+
        public NewDerivedUnitBaseWizard(SpecimenOrObservationType specOrObsType) {
                super();
                this.specOrObsType = specOrObsType;
        }
        /** {@inheritDoc} */
        @Override
-       public void addPages() {
-               addPage(new GeneralWizardPage(formFactory, getConversationHolder(), getFacade()));
-               addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), getFacade()));
-               addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), getFacade()));
-               addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), getFacade()));
-               
-       }
-       
-       /**
-        * @return
-        */
-       private DerivedUnitFacade getFacade() {
-               try {
-                       if(getEntity() != null) {
-                               return DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
-                       }
-               } catch (DerivedUnitFacadeNotSupportedException e) {
-                       // w should never get here
-                       throw new IllegalStateException();
-               }
-               return null;
-       }
+    public void addPages() {
+        DerivedUnitFacade derivedUnitFacade = null;
+        try {
+            if (getEntity() != null) {
+                derivedUnitFacade = DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
+            }
+        } catch (DerivedUnitFacadeNotSupportedException e) {
+            // we should never get here
+            throw new IllegalStateException();
+        }
+        addPage(new GeneralWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
+        addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
+        addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
+        addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
+
+    }
 
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity()
         */
        /** {@inheritDoc} */
        @Override
-       protected DerivedUnit createNewEntity() {               
+       protected DerivedUnit createNewEntity() {
                if(specOrObsType == null) {
                        return DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
-               } else {                        
-                       if(SpecimenOrObservationType.Media.equals(specOrObsType) || 
-                                       ((((SpecimenOrObservationType)specOrObsType).getKindOf() != null) &&
-                                       ((SpecimenOrObservationType)specOrObsType).getKindOf().equals(SpecimenOrObservationType.Media))) {
+               } else {
+                       if(SpecimenOrObservationType.Media.equals(specOrObsType) ||
+                                       ((specOrObsType.getKindOf() != null) &&
+                                       specOrObsType.getKindOf().equals(SpecimenOrObservationType.Media))) {
                                return MediaSpecimen.NewInstance(SpecimenOrObservationType.Media);
                        } else {
-                               return DerivedUnit.NewInstance((SpecimenOrObservationType)specOrObsType);
-                       }                                               
+                               return DerivedUnit.NewInstance(specOrObsType);
+                       }
                }
        }
 
@@ -98,6 +92,6 @@ public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUni
        protected String getEntityName() {
                return "Specimen";
        }
-       
-       
+
+
 }