Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / entitycreator / NameCreator.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.HashMap;
13 import java.util.Map;
14
15 import eu.etaxonomy.cdm.model.name.Rank;
16 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
17 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
18 import eu.etaxonomy.taxeditor.parser.ParseHandler;
19 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
20 import eu.etaxonomy.taxeditor.store.CdmStore;
21
22 /**
23 * <p>NameCreator class.</p>
24 *
25 * @author p.ciardelli
26 * @created 07.07.2009
27 * @version 1.0
28 */
29 public class NameCreator implements IEntityCreator<TaxonNameBase> {
30
31 /* (non-Javadoc)
32 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
33 */
34 /** {@inheritDoc} */
35 public TaxonNameBase createEntity(String text) {
36 TaxonNameBase name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
37 name.setTitleCache(text, true);
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
66 @Override
67 public boolean savesEntity() {
68 // TODO Auto-generated method stub
69 return false;
70 }
71 }