Revision 6ab5c17a
Added by Cherian Mathew over 10 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java | ||
---|---|---|
13 | 13 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade; |
14 | 14 |
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException; |
15 | 15 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
16 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
|
16 | 17 |
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; |
18 |
import eu.etaxonomy.cdm.model.occurrence.FieldUnit; |
|
19 |
import eu.etaxonomy.cdm.model.occurrence.MediaSpecimen; |
|
20 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
|
21 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
|
17 | 22 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
18 | 23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
24 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.OriginalSourceTypeSelectionDialog; |
|
25 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.SpecimenOrObservationTypeSelectionDialog; |
|
19 | 26 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.DerivedUnitBaseWizardPage; |
20 | 27 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.FieldObservationWizardPage; |
21 | 28 |
import eu.etaxonomy.taxeditor.ui.section.occurrence.GatheringEventWizardPage; |
... | ... | |
29 | 36 |
* @version 1.0 |
30 | 37 |
*/ |
31 | 38 |
public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUnit> { |
39 |
private SpecimenOrObservationType specOrObsType = null; |
|
32 | 40 |
|
41 |
public NewDerivedUnitBaseWizard() { |
|
42 |
super(); |
|
43 |
} |
|
44 |
|
|
45 |
public NewDerivedUnitBaseWizard(SpecimenOrObservationType specOrObsType) { |
|
46 |
super(); |
|
47 |
this.specOrObsType = specOrObsType; |
|
48 |
} |
|
33 | 49 |
/** {@inheritDoc} */ |
34 | 50 |
@Override |
35 | 51 |
public void addPages() { |
... | ... | |
37 | 53 |
addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), getFacade())); |
38 | 54 |
addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), getFacade())); |
39 | 55 |
addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), getFacade())); |
56 |
|
|
40 | 57 |
} |
41 | 58 |
|
42 | 59 |
/** |
... | ... | |
44 | 61 |
*/ |
45 | 62 |
private DerivedUnitFacade getFacade() { |
46 | 63 |
try { |
47 |
return DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator()); |
|
64 |
if(getEntity() != null) { |
|
65 |
return DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator()); |
|
66 |
} |
|
48 | 67 |
} catch (DerivedUnitFacadeNotSupportedException e) { |
49 | 68 |
// w should never get here |
50 | 69 |
throw new IllegalStateException(); |
51 | 70 |
} |
71 |
return null; |
|
52 | 72 |
} |
53 | 73 |
|
54 | 74 |
/* (non-Javadoc) |
... | ... | |
56 | 76 |
*/ |
57 | 77 |
/** {@inheritDoc} */ |
58 | 78 |
@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(); |
|
79 |
protected DerivedUnit createNewEntity() { |
|
80 |
if(specOrObsType == null) { |
|
81 |
return DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
|
82 |
} else { |
|
83 |
// if(SpecimenOrObservationType.FieldUnit.equals(specOrObsType)) { |
|
84 |
// //FIXME:3.3MC maybe generalise this wizard and super class to SpecimenOrObservationBase |
|
85 |
// return null;//FieldUnit.NewInstance(); |
|
86 |
// } else |
|
87 |
if(SpecimenOrObservationType.Media.equals(specOrObsType) || |
|
88 |
((((SpecimenOrObservationType)specOrObsType).getKindOf() != null) && |
|
89 |
((SpecimenOrObservationType)specOrObsType).getKindOf().equals(SpecimenOrObservationType.Media))) { |
|
90 |
return MediaSpecimen.NewInstance(SpecimenOrObservationType.Media); |
|
91 |
} else { |
|
92 |
return DerivedUnit.NewInstance((SpecimenOrObservationType)specOrObsType); |
|
93 |
} |
|
94 |
} |
|
65 | 95 |
} |
66 | 96 |
|
67 | 97 |
/* (non-Javadoc) |
Also available in: Unified diff
updated wizard to return new DerivedUnit for given type