2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
;
11 import java
.util
.Comparator
;
12 import java
.util
.List
;
14 import java
.util
.TreeMap
;
16 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
17 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
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
;
27 public class NameCreator
implements IEntityCreator
<TaxonName
> {
30 public TaxonName
createEntity(String text
) {
31 TaxonName name
= PreferencesUtil
.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
32 name
.setTitleCache(text
, true);
33 //name.setTitleCache(text);
38 public TaxonName
createEntity(Object key
, String text
) {
39 return ParseHandler
.parseName(text
, (Rank
) key
);
43 public Map
<Rank
, String
> getKeyLabelPairs() {
44 Map
<Rank
, String
> result
= new TreeMap
<Rank
, String
>(
45 (Comparator
<Rank
>) (o1
, o2
) -> o2
.compareTo(o1
)
47 List
<Rank
> ranks
= CdmStore
.getTermManager().getPreferredTerms(Rank
.class);
48 //Collections.reverse(ranks);
49 for (Rank rank
: ranks
) {
50 result
.put(rank
, rank
.getLabel());
56 public boolean savesEntity() {
57 // TODO Auto-generated method stub