Project

General

Profile

Download (2.23 KB) Statistics
| Branch: | Tag: | Revision:
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.Comparator;
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<Rank, String> getKeyLabelPairs() {
64
		Map<Rank, String> result = new TreeMap<Rank, String>(
65
                (Comparator<Rank>) (o1, o2) -> o2.compareTo(o1)
66
        );
67
		List<Rank> ranks = CdmStore.getTermManager().getPreferredTerms(Rank.class);
68
		//Collections.reverse(ranks);
69
		for (Rank rank : ranks) {
70
			result.put(rank, rank.getLabel());
71
		}
72
		return result;
73
	}
74

    
75
	@Override
76
	public boolean savesEntity() {
77
		// TODO Auto-generated method stub
78
		return false;
79
	}
80
}
(4-4/8)