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
|
/** {@inheritDoc} */
|
35
|
@Override
|
36
|
public void addPages() {
|
37
|
addPage(new GeneralWizardPage(formFactory, getConversationHolder(), getFacade()));
|
38
|
addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), getFacade()));
|
39
|
addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), getFacade()));
|
40
|
addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), getFacade()));
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* @return
|
45
|
*/
|
46
|
private DerivedUnitFacade getFacade() {
|
47
|
try {
|
48
|
return DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
|
49
|
} catch (DerivedUnitFacadeNotSupportedException e) {
|
50
|
// w should never get here
|
51
|
throw new IllegalStateException();
|
52
|
}
|
53
|
}
|
54
|
|
55
|
/* (non-Javadoc)
|
56
|
* @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity()
|
57
|
*/
|
58
|
/** {@inheritDoc} */
|
59
|
@Override
|
60
|
protected DerivedUnitBase createNewEntity() {
|
61
|
// TODO we do want to create different derivates of DerivedUnitBase but go with specimen for testing
|
62
|
// at the moment
|
63
|
// FIXME add wizard page that handles the selection of derived unit type
|
64
|
return Specimen.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
|
}
|