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.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.FieldObservationDetailsWizardPage;
|
25
|
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationGeneralWizardPage;
|
26
|
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventDetailsWizardPage;
|
27
|
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenDetailsWizardPage;
|
28
|
import eu.etaxonomy.taxeditor.ui.section.occurrence.SpecimenGeneralWizardPage;
|
29
|
|
30
|
/**
|
31
|
* <p>NewDerivedUnitBaseWizard class.</p>
|
32
|
*
|
33
|
* @author n.hoffmann
|
34
|
* @created Jun 16, 2010
|
35
|
* @version 1.0
|
36
|
*/
|
37
|
public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<SpecimenOrObservationBase<?>> {
|
38
|
private SpecimenOrObservationType specOrObsType = null;
|
39
|
|
40
|
public NewDerivedUnitBaseWizard() {
|
41
|
super();
|
42
|
}
|
43
|
|
44
|
public NewDerivedUnitBaseWizard(SpecimenOrObservationType specOrObsType) {
|
45
|
super();
|
46
|
this.specOrObsType = specOrObsType;
|
47
|
}
|
48
|
/** {@inheritDoc} */
|
49
|
@Override
|
50
|
public void addPages() {
|
51
|
DerivedUnitFacade derivedUnitFacade = null;
|
52
|
try {
|
53
|
if (getEntity() != null) {
|
54
|
if(getEntity() instanceof FieldUnit){
|
55
|
derivedUnitFacade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.FieldUnit, (FieldUnit)getEntity());
|
56
|
|
57
|
addPage(new FieldObservationGeneralWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
|
58
|
addPage(new GatheringEventDetailsWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
|
59
|
addPage(new FieldObservationDetailsWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
|
60
|
}
|
61
|
else if(getEntity() instanceof DerivedUnit){
|
62
|
derivedUnitFacade = DerivedUnitFacade.NewInstance((DerivedUnit)getEntity(), PreferencesUtil.getDerivedUnitConfigurator());
|
63
|
|
64
|
addPage(new SpecimenGeneralWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
|
65
|
addPage(new SpecimenDetailsWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
|
66
|
addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), derivedUnitFacade));
|
67
|
}
|
68
|
}
|
69
|
} catch (DerivedUnitFacadeNotSupportedException e) {
|
70
|
// we should never get here
|
71
|
throw new IllegalStateException();
|
72
|
}
|
73
|
|
74
|
}
|
75
|
|
76
|
/* (non-Javadoc)
|
77
|
* @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity()
|
78
|
*/
|
79
|
/** {@inheritDoc} */
|
80
|
@Override
|
81
|
protected SpecimenOrObservationBase<?> createNewEntity() {
|
82
|
if(specOrObsType == null) {
|
83
|
return DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
|
84
|
} else {
|
85
|
if(SpecimenOrObservationType.Media.equals(specOrObsType) ||
|
86
|
((specOrObsType.getKindOf() != null) &&
|
87
|
specOrObsType.getKindOf().equals(SpecimenOrObservationType.Media))) {
|
88
|
return MediaSpecimen.NewInstance(SpecimenOrObservationType.Media);
|
89
|
} else if(specOrObsType == SpecimenOrObservationType.FieldUnit){
|
90
|
return FieldUnit.NewInstance();
|
91
|
} else {
|
92
|
return DerivedUnit.NewInstance(specOrObsType);
|
93
|
}
|
94
|
}
|
95
|
}
|
96
|
|
97
|
/* (non-Javadoc)
|
98
|
* @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#saveEntity()
|
99
|
*/
|
100
|
/** {@inheritDoc} */
|
101
|
@Override
|
102
|
protected void saveEntity() {
|
103
|
CdmStore.getService(IOccurrenceService.class).saveOrUpdate(getEntity());
|
104
|
}
|
105
|
|
106
|
@Override
|
107
|
protected String getEntityName() {
|
108
|
return "Specimen";
|
109
|
}
|
110
|
|
111
|
|
112
|
}
|