3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.newWizard
;
13 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
14 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeNotSupportedException
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
16 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
17 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
18 import eu
.etaxonomy
.cdm
.model
.occurrence
.MediaSpecimen
;
19 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
20 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
21 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
22 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.DerivedUnitBaseWizardPage
;
24 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.FieldObservationWizardPage
;
25 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.GatheringEventWizardPage
;
26 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.GeneralWizardPage
;
29 * <p>NewDerivedUnitBaseWizard class.</p>
32 * @created Jun 16, 2010
35 public class NewDerivedUnitBaseWizard
extends AbstractNewEntityWizard
<SpecimenOrObservationBase
<?
>> {
36 private SpecimenOrObservationType specOrObsType
= null;
38 public NewDerivedUnitBaseWizard() {
42 public NewDerivedUnitBaseWizard(SpecimenOrObservationType specOrObsType
) {
44 this.specOrObsType
= specOrObsType
;
48 public void addPages() {
49 DerivedUnitFacade derivedUnitFacade
= null;
51 if (getEntity() != null) {
52 if(getEntity() instanceof FieldUnit
){
53 derivedUnitFacade
= DerivedUnitFacade
.NewInstance(SpecimenOrObservationType
.FieldUnit
, (FieldUnit
)getEntity());
54 addPage(new GeneralWizardPage(formFactory
, getConversationHolder(), derivedUnitFacade
));
55 addPage(new GatheringEventWizardPage(formFactory
, getConversationHolder(), derivedUnitFacade
));
56 addPage(new FieldObservationWizardPage(formFactory
, getConversationHolder(), derivedUnitFacade
));
58 else if(getEntity() instanceof DerivedUnit
){
59 derivedUnitFacade
= DerivedUnitFacade
.NewInstance((DerivedUnit
)getEntity(), PreferencesUtil
.getDerivedUnitConfigurator());
60 addPage(new DerivedUnitBaseWizardPage(formFactory
, getConversationHolder(), derivedUnitFacade
));
63 } catch (DerivedUnitFacadeNotSupportedException e
) {
64 // we should never get here
65 throw new IllegalStateException();
71 * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity()
75 protected SpecimenOrObservationBase
<?
> createNewEntity() {
76 if(specOrObsType
== null) {
77 return DerivedUnit
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
79 if(SpecimenOrObservationType
.Media
.equals(specOrObsType
) ||
80 ((specOrObsType
.getKindOf() != null) &&
81 specOrObsType
.getKindOf().equals(SpecimenOrObservationType
.Media
))) {
82 return MediaSpecimen
.NewInstance(SpecimenOrObservationType
.Media
);
83 } else if(specOrObsType
== SpecimenOrObservationType
.FieldUnit
){
84 return FieldUnit
.NewInstance();
86 return DerivedUnit
.NewInstance(specOrObsType
);
92 * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#saveEntity()
96 protected void saveEntity() {
97 CdmStore
.getService(IOccurrenceService
.class).saveOrUpdate(getEntity());
101 protected String
getEntityName() {