Aligning Editor with 3.3 model changes. First phase commit which updates only the...
[taxeditor.git] / eu.etaxonomy.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.DerivedUnit;
17 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
18 import eu.etaxonomy.taxeditor.store.CdmStore;
19 import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseWizardPage;
20 import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationWizardPage;
21 import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventWizardPage;
22 import eu.etaxonomy.taxeditor.ui.section.occurrence.GeneralWizardPage;
23
24 /**
25 * <p>NewDerivedUnitBaseWizard class.</p>
26 *
27 * @author n.hoffmann
28 * @created Jun 16, 2010
29 * @version 1.0
30 */
31 public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUnit> {
32
33 /** {@inheritDoc} */
34 @Override
35 public void addPages() {
36 addPage(new GeneralWizardPage(formFactory, getConversationHolder(), getFacade()));
37 addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), getFacade()));
38 addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), getFacade()));
39 addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), getFacade()));
40 }
41
42 /**
43 * @return
44 */
45 private DerivedUnitFacade getFacade() {
46 try {
47 return DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
48 } catch (DerivedUnitFacadeNotSupportedException e) {
49 // w should never get here
50 throw new IllegalStateException();
51 }
52 }
53
54 /* (non-Javadoc)
55 * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity()
56 */
57 /** {@inheritDoc} */
58 @Override
59 protected DerivedUnit createNewEntity() {
60 // TODO we do want to create different derivates of DerivedUnitBase but go with specimen for testing
61 // at the moment
62 // FIXME add wizard page that handles the selection of derived unit type
63 //FIXME:3.3MC
64 return DerivedUnit.NewInstance();
65 }
66
67 /* (non-Javadoc)
68 * @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#saveEntity()
69 */
70 /** {@inheritDoc} */
71 @Override
72 protected void saveEntity() {
73 CdmStore.getService(IOccurrenceService.class).saveOrUpdate(getEntity());
74 }
75
76 @Override
77 protected String getEntityName() {
78 return "Specimen";
79 }
80
81
82 }