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 eu.etaxonomy.cdm.model.name.Rank;
|
17
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
18
|
import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
|
19
|
import eu.etaxonomy.taxeditor.parser.ParseHandler;
|
20
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
21
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
22
|
|
23
|
/**
|
24
|
* <p>NameCreator class.</p>
|
25
|
*
|
26
|
* @author p.ciardelli
|
27
|
* @created 07.07.2009
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class NameCreator implements IEntityCreator<TaxonNameBase> {
|
31
|
|
32
|
/* (non-Javadoc)
|
33
|
* @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
|
34
|
*/
|
35
|
/** {@inheritDoc} */
|
36
|
public TaxonNameBase createEntity(String text) {
|
37
|
TaxonNameBase name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
|
38
|
name.setTitleCache(text);
|
39
|
return name;
|
40
|
}
|
41
|
|
42
|
/* (non-Javadoc)
|
43
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
|
44
|
*/
|
45
|
/** {@inheritDoc} */
|
46
|
public TaxonNameBase createEntity(Object key, String text) {
|
47
|
return ParseHandler.parseName(text, (Rank) key);
|
48
|
}
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
|
52
|
*/
|
53
|
/**
|
54
|
* <p>getKeyLabelPairs</p>
|
55
|
*
|
56
|
* @return a {@link java.util.Map} object.
|
57
|
*/
|
58
|
public Map<Object, String> getKeyLabelPairs() {
|
59
|
Map<Object, String> result = new HashMap<Object, String>();
|
60
|
for (Rank rank : CdmStore.getTermManager().getPreferredTerms(Rank.class)) {
|
61
|
result.put(rank, rank.getLabel());
|
62
|
}
|
63
|
return result;
|
64
|
}
|
65
|
}
|