0bdd381a6b4911dbb6be274bd4ad5677c801348f
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / entitycreator / ReferenceCreator.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 eu.etaxonomy.cdm.model.reference.Reference;
17 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
18 import eu.etaxonomy.cdm.model.reference.ReferenceType;
19 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
20 import eu.etaxonomy.taxeditor.model.MessagingUtils;
21
22 /**
23 * <p>ReferenceCreator class.</p>
24 *
25 * @author p.ciardelli
26 * @created 07.07.2009
27 * @version 1.0
28 */
29 public class ReferenceCreator implements IEntityCreator<Reference> {
30
31 /* (non-Javadoc)
32 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
33 */
34 /** {@inheritDoc} */
35 public Reference createEntity(String text) {
36 return createEntity(Reference.class, text);
37 }
38
39 /* (non-Javadoc)
40 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
41 */
42 /** {@inheritDoc} */
43 public Reference createEntity(Object key, String text) {
44 Reference reference = null;
45
46 // TODO replace w more generic method when cdmlib matures accordingly
47 if (ReferenceType.Article.getMessage().equals(key)) {
48 reference = ReferenceFactory.newArticle();
49 }
50 if (ReferenceType.Book.getMessage().equals(key)) {
51 reference = ReferenceFactory.newBook();
52 }
53 if (ReferenceType.BookSection.getMessage().equals(key)) {
54 reference = ReferenceFactory.newBookSection();
55 }
56 if (ReferenceType.CdDvd.getMessage().equals(key)) {
57 reference = ReferenceFactory.newCdDvd();
58 }
59 if (ReferenceType.Database.getMessage().equals(key)) {
60 reference = ReferenceFactory.newDatabase();
61 }
62 if (ReferenceType.Generic.getMessage().equals(key)) {
63 reference = ReferenceFactory.newGeneric();
64 }
65 if (ReferenceType.InProceedings.getMessage().equals(key)) {
66 reference = ReferenceFactory.newInProceedings();
67 }
68 if (ReferenceType.Journal.getMessage().equals(key)) {
69 reference = ReferenceFactory.newJournal();
70 }
71 if (ReferenceType.Map.getMessage().equals(key)) {
72 reference = ReferenceFactory.newMap();
73 }
74 if (ReferenceType.Patent.getMessage().equals(key)) {
75 reference = ReferenceFactory.newPatent();
76 }
77 if (ReferenceType.PersonalCommunication.getMessage().equals(key)) {
78 reference = ReferenceFactory.newPersonalCommunication();
79 }
80 if (ReferenceType.PrintSeries.getMessage().equals(key)) {
81 reference = ReferenceFactory.newPrintSeries();
82 }
83 if (ReferenceType.Proceedings.getMessage().equals(key)) {
84 reference = ReferenceFactory.newProceedings();
85 }
86 if (ReferenceType.Report.getMessage().equals(key)) {
87 reference = ReferenceFactory.newReport();
88 }
89 if (ReferenceType.Thesis.getMessage().equals(key)) {
90 reference = ReferenceFactory.newThesis();
91 }
92 if (ReferenceType.WebPage.getMessage().equals(key)) {
93 reference = ReferenceFactory.newWebPage();
94 }
95 if (reference == null) {
96 MessagingUtils.warn(getClass(), "Reference type " + key + " not found. Creating reference with default type.");
97 reference = ReferenceFactory.newGeneric();
98 }
99 reference.setTitleCache(text, true);
100 return reference;
101 }
102
103 /* (non-Javadoc)
104 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
105 */
106 /**
107 * <p>getKeyLabelPairs</p>
108 *
109 * @return a {@link java.util.Map} object.
110 */
111 public Map<Object, String> getKeyLabelPairs() {
112 Map<Object, String> result = new HashMap<Object, String>();
113 for (ReferenceType type : ReferenceType.values()) {
114 result.put(type.getMessage(), type.getMessage());
115 }
116 return result;
117 }
118
119 @Override
120 public boolean savesEntity() {
121 // TODO Auto-generated method stub
122 return false;
123 }
124 }