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