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.bulkeditor.input.entitycreator;
|
12
|
|
13
|
import java.util.HashMap;
|
14
|
import java.util.Map;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.molecular.DnaSample;
|
19
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
20
|
import eu.etaxonomy.cdm.model.occurrence.FieldObservation;
|
21
|
import eu.etaxonomy.cdm.model.occurrence.Fossil;
|
22
|
import eu.etaxonomy.cdm.model.occurrence.LivingBeing;
|
23
|
import eu.etaxonomy.cdm.model.occurrence.Observation;
|
24
|
import eu.etaxonomy.cdm.model.occurrence.Specimen;
|
25
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
26
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
27
|
|
28
|
/**
|
29
|
* <p>
|
30
|
* OccurrenceCreator class.
|
31
|
* </p>
|
32
|
*
|
33
|
* @author n.hoffmann
|
34
|
* @created Jun 16, 2010
|
35
|
* @version 1.0
|
36
|
*/
|
37
|
public class OccurrenceCreator implements
|
38
|
IEntityCreator<SpecimenOrObservationBase> {
|
39
|
private static final Logger logger = Logger
|
40
|
.getLogger(OccurrenceCreator.class);
|
41
|
|
42
|
/** {@inheritDoc} */
|
43
|
@Override
|
44
|
public SpecimenOrObservationBase createEntity(String text) {
|
45
|
return createEntity(Specimen.class, text);
|
46
|
}
|
47
|
|
48
|
/** {@inheritDoc} */
|
49
|
@Override
|
50
|
public SpecimenOrObservationBase createEntity(Object key, String text) {
|
51
|
SpecimenOrObservationBase specimenOrObservation = null;
|
52
|
|
53
|
if (FieldObservation.class.equals((key))) {
|
54
|
specimenOrObservation = FieldObservation.NewInstance();
|
55
|
} else if (DerivedUnit.class.equals((key))) {
|
56
|
specimenOrObservation = DerivedUnit.NewInstance();
|
57
|
} else if (LivingBeing.class.equals((key))) {
|
58
|
specimenOrObservation = LivingBeing.NewInstance();
|
59
|
} else if (Observation.class.equals((key))) {
|
60
|
specimenOrObservation = Observation.NewInstance();
|
61
|
} else if (Specimen.class.equals((key))) {
|
62
|
specimenOrObservation = Specimen.NewInstance();
|
63
|
} else if (DnaSample.class.equals((key))) {
|
64
|
specimenOrObservation = DnaSample.NewInstance();
|
65
|
} else if (Fossil.class.equals((key))) {
|
66
|
specimenOrObservation = Fossil.NewInstance();
|
67
|
}
|
68
|
|
69
|
if (specimenOrObservation != null) {
|
70
|
specimenOrObservation.setTitleCache(text, true);
|
71
|
}
|
72
|
return specimenOrObservation;
|
73
|
}
|
74
|
|
75
|
/**
|
76
|
* <p>
|
77
|
* getKeyLabelPairs
|
78
|
* </p>
|
79
|
*
|
80
|
* @return a {@link java.util.Map} object.
|
81
|
*/
|
82
|
@Override
|
83
|
public Map<Object, String> getKeyLabelPairs() {
|
84
|
Map<Object, String> result = new HashMap<Object, String>();
|
85
|
|
86
|
result.put(Specimen.class, "Specimen");
|
87
|
result.put(Observation.class, "Observation");
|
88
|
result.put(LivingBeing.class, "Living Being");
|
89
|
result.put(Fossil.class, "Fossil");
|
90
|
result.put(DerivedUnit.class, "Derived Unit");
|
91
|
|
92
|
// Omitted at the moment see #2266
|
93
|
// result.put(DnaSample.class, "Dna Sample");
|
94
|
|
95
|
// Omitted see #2266
|
96
|
// result.put(FieldObservation.class, "Field Observation");
|
97
|
// result.put(Observation.class, "Observation");
|
98
|
|
99
|
return result;
|
100
|
}
|
101
|
}
|