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
.MediaSpecimen
;
18 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationType
;
19 import eu
.etaxonomy
.taxeditor
.preference
.PreferencesUtil
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
21 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.DerivedUnitBaseWizardPage
;
22 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.FieldObservationWizardPage
;
23 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.GatheringEventWizardPage
;
24 import eu
.etaxonomy
.taxeditor
.ui
.section
.occurrence
.GeneralWizardPage
;
27 * <p>NewDerivedUnitBaseWizard class.</p>
30 * @created Jun 16, 2010
33 public class NewDerivedUnitBaseWizard
extends AbstractNewEntityWizard
<DerivedUnit
> {
34 private SpecimenOrObservationType specOrObsType
= null;
36 public NewDerivedUnitBaseWizard() {
40 public NewDerivedUnitBaseWizard(SpecimenOrObservationType specOrObsType
) {
42 this.specOrObsType
= specOrObsType
;
46 public void addPages() {
47 DerivedUnitFacade derivedUnitFacade
= null;
49 if (getEntity() != null) {
50 derivedUnitFacade
= DerivedUnitFacade
.NewInstance(getEntity(), PreferencesUtil
.getDerivedUnitConfigurator());
52 } catch (DerivedUnitFacadeNotSupportedException e
) {
53 // we should never get here
54 throw new IllegalStateException();
56 addPage(new GeneralWizardPage(formFactory
, getConversationHolder(), derivedUnitFacade
));
57 addPage(new GatheringEventWizardPage(formFactory
, getConversationHolder(), derivedUnitFacade
));
58 addPage(new FieldObservationWizardPage(formFactory
, getConversationHolder(), derivedUnitFacade
));
59 addPage(new DerivedUnitBaseWizardPage(formFactory
, getConversationHolder(), derivedUnitFacade
));
64 * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity()
68 protected DerivedUnit
createNewEntity() {
69 if(specOrObsType
== null) {
70 return DerivedUnit
.NewInstance(SpecimenOrObservationType
.PreservedSpecimen
);
72 if(SpecimenOrObservationType
.Media
.equals(specOrObsType
) ||
73 ((specOrObsType
.getKindOf() != null) &&
74 specOrObsType
.getKindOf().equals(SpecimenOrObservationType
.Media
))) {
75 return MediaSpecimen
.NewInstance(SpecimenOrObservationType
.Media
);
77 return DerivedUnit
.NewInstance(specOrObsType
);
83 * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#saveEntity()
87 protected void saveEntity() {
88 CdmStore
.getService(IOccurrenceService
.class).saveOrUpdate(getEntity());
92 protected String
getEntityName() {