Merged refactoring from development branch.
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / newWizard / NewDerivedUnitBaseWizard.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.newWizard;
12
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.DerivedUnitBase;
17 import eu.etaxonomy.cdm.model.occurrence.Specimen;
18 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
19 import eu.etaxonomy.taxeditor.store.CdmStore;
20 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseWizardPage;
21 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationWizardPage;
22 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventWizardPage;
23 import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralWizardPage;
24
25 /**
26 * <p>NewDerivedUnitBaseWizard class.</p>
27 *
28 * @author n.hoffmann
29 * @created Jun 16, 2010
30 * @version 1.0
31 */
32 public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUnitBase> {
33
34 /**
35 *
36 */
37 public NewDerivedUnitBaseWizard() {
38 setWindowTitle("New Specimen");
39 }
40
41 /** {@inheritDoc} */
42 @Override
43 public void addPages() {
44 addPage(new GeneralWizardPage(formFactory, getConversationHolder(), getFacade()));
45 addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), getFacade()));
46 addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), getFacade()));
47 addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), getFacade()));
48 }
49
50 /**
51 * @return
52 */
53 private DerivedUnitFacade getFacade() {
54 try {
55 return DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
56 } catch (DerivedUnitFacadeNotSupportedException e) {
57 // w should never get here
58 throw new IllegalStateException();
59 }
60 }
61
62 /* (non-Javadoc)
63 * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity()
64 */
65 /** {@inheritDoc} */
66 @Override
67 protected DerivedUnitBase createNewEntity() {
68 // TODO we do want to create different derivates of DerivedUnitBase but go with specimen for testing
69 // at the moment
70 // FIXME add wizard page that handles the selection of derived unit type
71 return Specimen.NewInstance();
72 }
73
74 /* (non-Javadoc)
75 * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#saveEntity()
76 */
77 /** {@inheritDoc} */
78 @Override
79 protected void saveEntity() {
80 CdmStore.getService(IOccurrenceService.class).saveOrUpdate(getEntity());
81 }
82 }