0cfeff3f47f679c23504877f3d190f91ec5a72af
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / entitycreator / AgentCreator.java
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 org.apache.log4j.Logger;
17
18 import eu.etaxonomy.cdm.model.agent.AgentBase;
19 import eu.etaxonomy.cdm.model.agent.Person;
20 import eu.etaxonomy.cdm.model.agent.Team;
21 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
22 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
23
24 /**
25 * <p>TeamOrPersonCreator class.</p>
26 *
27 * @author p.ciardelli
28 * @created 18.09.2009
29 * @version 1.0
30 */
31 public class AgentCreator implements IEntityCreator<AgentBase> {
32 private static final Logger logger = Logger
33 .getLogger(AgentCreator.class);
34
35 /* (non-Javadoc)
36 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.String)
37 */
38 /** {@inheritDoc} */
39 public AgentBase createEntity(String text) {
40 // FIXME
41 logger.error("FIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXME");
42 logger.error("We can only create Persons at the moment. See #1820");
43 logger.error("FIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXMEFIXME");
44 return createEntity(Person.class, text);
45 }
46
47 /* (non-Javadoc)
48 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
49 */
50 /** {@inheritDoc} */
51 public AgentBase createEntity(Object key, String text) {
52 TeamOrPersonBase teamOrPerson = null;
53 if (Team.class.equals(((Class) key))) {
54 teamOrPerson = Team.NewInstance();
55 }
56 if (Person.class.equals(((Class) key))) {
57 teamOrPerson = Person.NewInstance();
58 }
59 if (teamOrPerson != null) {
60 teamOrPerson.setTitleCache(text);
61 }
62 return teamOrPerson;
63 }
64
65 /* (non-Javadoc)
66 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
67 */
68 /**
69 * <p>getKeyLabelPairs</p>
70 *
71 * @return a {@link java.util.Map} object.
72 */
73 public Map<Object, String> getKeyLabelPairs() {
74 Map<Object, String> result = new HashMap<Object, String>();
75 result.put(Team.class, "Author Team");
76 result.put(Person.class, "Author");
77 return result;
78 }
79 }