ref #6190 removing svn property place holder in first line of code - java files
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / entitycreator / OccurrenceCreator.java
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.HashMap;
14 import java.util.LinkedHashMap;
15 import java.util.Map;
16
17 import org.apache.log4j.Logger;
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.jface.wizard.WizardDialog;
20
21 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
22 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
23 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
24 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
25 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorUtil;
26 import eu.etaxonomy.taxeditor.model.AbstractUtility;
27 import eu.etaxonomy.taxeditor.newWizard.NewDerivedUnitBaseWizard;
28
29 /**
30 * <p>
31 * OccurrenceCreator class.
32 * </p>
33 *
34 * @author n.hoffmann
35 * @created Jun 16, 2010
36 * @version 1.0
37 */
38 public class OccurrenceCreator implements
39 IEntityCreator<SpecimenOrObservationBase> {
40 private static final Logger logger = Logger
41 .getLogger(OccurrenceCreator.class);
42
43 /** {@inheritDoc} */
44 @Override
45 public SpecimenOrObservationBase createEntity(String text) {
46
47 return createEntity(DerivedUnit.class, text);
48 }
49
50 /** {@inheritDoc} */
51 @Override
52 public SpecimenOrObservationBase createEntity(Object key, String text) {
53
54 SpecimenOrObservationBase specimenOrObservation = null;
55 NewDerivedUnitBaseWizard wizard = new NewDerivedUnitBaseWizard((SpecimenOrObservationType)key);
56 wizard.init(null, null);
57 if(wizard.getEntity() != null) {
58 WizardDialog dialog = new WizardDialog(BulkEditorUtil.getShell(), wizard);
59 int status = dialog.open();
60
61 if (status == IStatus.OK) {
62 specimenOrObservation = wizard.getEntity();
63 }
64 }
65 return specimenOrObservation;
66 }
67
68 /**
69 * <p>
70 * getKeyLabelPairs
71 * </p>
72 *
73 * @return a {@link java.util.Map} object.
74 */
75 @Override
76 public Map<Object, String> getKeyLabelPairs() {
77 Map<Object, String> keyLabelPairs = new LinkedHashMap<Object, String>();
78 keyLabelPairs.putAll(AbstractUtility.orderTerms(Arrays.asList(SpecimenOrObservationType.values())));
79 return keyLabelPairs;
80 }
81
82 @Override
83 public boolean savesEntity() {
84 return true;
85 }
86
87
88 }