1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator;
|
11
|
|
12
|
import java.util.Arrays;
|
13
|
import java.util.LinkedHashMap;
|
14
|
import java.util.Map;
|
15
|
|
16
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
17
|
import org.eclipse.core.runtime.IStatus;
|
18
|
import org.eclipse.jface.wizard.WizardDialog;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
21
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
22
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
|
23
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
24
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
25
|
import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
|
26
|
|
27
|
/**
|
28
|
* <p>
|
29
|
* OccurrenceCreator class.
|
30
|
* </p>
|
31
|
*
|
32
|
* @author n.hoffmann
|
33
|
* @created Jun 16, 2010
|
34
|
*/
|
35
|
public class OccurrenceCreator implements
|
36
|
IEntityCreator<SpecimenOrObservationBase> {
|
37
|
|
38
|
@SuppressWarnings("unused")
|
39
|
private static final Logger logger = LogManager.getLogger(OccurrenceCreator.class);
|
40
|
|
41
|
@Override
|
42
|
public SpecimenOrObservationBase createEntity(String text) {
|
43
|
return createEntity(DerivedUnit.class, text);
|
44
|
}
|
45
|
|
46
|
@Override
|
47
|
public SpecimenOrObservationBase createEntity(Object key, String text) {
|
48
|
|
49
|
SpecimenOrObservationBase<?> specimenOrObservation = null;
|
50
|
NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard((SpecimenOrObservationType)key);
|
51
|
wizard.init(null, null);
|
52
|
if(wizard.getEntity() != null) {
|
53
|
WizardDialog dialog = new WizardDialog(AbstractUtility.getShell(), wizard);
|
54
|
int status = dialog.open();
|
55
|
|
56
|
if (status == IStatus.OK) {
|
57
|
specimenOrObservation = wizard.getEntity();
|
58
|
}
|
59
|
}
|
60
|
return specimenOrObservation;
|
61
|
}
|
62
|
|
63
|
@Override
|
64
|
public Map<Object, String> getKeyLabelPairs() {
|
65
|
Map<Object, String> keyLabelPairs = new LinkedHashMap<>();
|
66
|
keyLabelPairs.putAll(AbstractUtility.orderTerms(Arrays.asList(SpecimenOrObservationType.values())));
|
67
|
return keyLabelPairs;
|
68
|
}
|
69
|
|
70
|
@Override
|
71
|
public boolean savesEntity() {
|
72
|
return true;
|
73
|
}
|
74
|
}
|