Revision 963d252b
Added by Patrick Plitzner over 10 years ago
- fixed bug leading to multiple FieldUnits for one DerivedUnit because multiple DerivedUnitFacades were created
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewDerivedUnitBaseWizard.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
32 | 32 |
*/ |
33 | 33 |
public class NewDerivedUnitBaseWizard extends AbstractNewEntityWizard<DerivedUnit> { |
34 | 34 |
private SpecimenOrObservationType specOrObsType = null; |
35 |
|
|
35 |
|
|
36 | 36 |
public NewDerivedUnitBaseWizard() { |
37 |
super();
|
|
37 |
super(); |
|
38 | 38 |
} |
39 |
|
|
39 |
|
|
40 | 40 |
public NewDerivedUnitBaseWizard(SpecimenOrObservationType specOrObsType) { |
41 | 41 |
super(); |
42 | 42 |
this.specOrObsType = specOrObsType; |
43 | 43 |
} |
44 | 44 |
/** {@inheritDoc} */ |
45 | 45 |
@Override |
46 |
public void addPages() { |
|
47 |
addPage(new GeneralWizardPage(formFactory, getConversationHolder(), getFacade())); |
|
48 |
addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), getFacade())); |
|
49 |
addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), getFacade())); |
|
50 |
addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), getFacade())); |
|
51 |
|
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* @return |
|
56 |
*/ |
|
57 |
private DerivedUnitFacade getFacade() { |
|
58 |
try { |
|
59 |
if(getEntity() != null) { |
|
60 |
return DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator()); |
|
61 |
} |
|
62 |
} catch (DerivedUnitFacadeNotSupportedException e) { |
|
63 |
// w should never get here |
|
64 |
throw new IllegalStateException(); |
|
65 |
} |
|
66 |
return null; |
|
67 |
} |
|
46 |
public void addPages() { |
|
47 |
DerivedUnitFacade derivedUnitFacade = null; |
|
48 |
try { |
|
49 |
if (getEntity() != null) { |
|
50 |
derivedUnitFacade = DerivedUnitFacade.NewInstance(getEntity(), PreferencesUtil.getDerivedUnitConfigurator()); |
|
51 |
} |
|
52 |
} catch (DerivedUnitFacadeNotSupportedException e) { |
|
53 |
// we should never get here |
|
54 |
throw new IllegalStateException(); |
|
55 |
} |
|
56 |
addPage(new GeneralWizardPage(formFactory, getConversationHolder(), derivedUnitFacade)); |
|
57 |
addPage(new GatheringEventWizardPage(formFactory, getConversationHolder(), derivedUnitFacade)); |
|
58 |
addPage(new FieldObservationWizardPage(formFactory, getConversationHolder(), derivedUnitFacade)); |
|
59 |
addPage(new DerivedUnitBaseWizardPage(formFactory, getConversationHolder(), derivedUnitFacade)); |
|
60 |
|
|
61 |
} |
|
68 | 62 |
|
69 | 63 |
/* (non-Javadoc) |
70 | 64 |
* @see eu.etaxonomy.taxeditor.editor.newWizard.AbstractNewEntityWizard#createNewEntity() |
71 | 65 |
*/ |
72 | 66 |
/** {@inheritDoc} */ |
73 | 67 |
@Override |
74 |
protected DerivedUnit createNewEntity() {
|
|
68 |
protected DerivedUnit createNewEntity() { |
|
75 | 69 |
if(specOrObsType == null) { |
76 | 70 |
return DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen); |
77 |
} else {
|
|
78 |
if(SpecimenOrObservationType.Media.equals(specOrObsType) ||
|
|
79 |
((((SpecimenOrObservationType)specOrObsType).getKindOf() != null) &&
|
|
80 |
((SpecimenOrObservationType)specOrObsType).getKindOf().equals(SpecimenOrObservationType.Media))) {
|
|
71 |
} else { |
|
72 |
if(SpecimenOrObservationType.Media.equals(specOrObsType) || |
|
73 |
((specOrObsType.getKindOf() != null) &&
|
|
74 |
specOrObsType.getKindOf().equals(SpecimenOrObservationType.Media))) {
|
|
81 | 75 |
return MediaSpecimen.NewInstance(SpecimenOrObservationType.Media); |
82 | 76 |
} else { |
83 |
return DerivedUnit.NewInstance((SpecimenOrObservationType)specOrObsType);
|
|
84 |
}
|
|
77 |
return DerivedUnit.NewInstance(specOrObsType); |
|
78 |
} |
|
85 | 79 |
} |
86 | 80 |
} |
87 | 81 |
|
... | ... | |
98 | 92 |
protected String getEntityName() { |
99 | 93 |
return "Specimen"; |
100 | 94 |
} |
101 |
|
|
102 |
|
|
95 |
|
|
96 |
|
|
103 | 97 |
} |
Also available in: Unified diff