3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
;
13 import java
.util
.HashMap
;
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
.bulkeditor
.BulkEditorUtil
;
23 * <p>ReferenceCreator class.</p>
29 public class ReferenceCreator
implements IEntityCreator
<Reference
> {
32 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
35 public Reference
createEntity(String text
) {
36 return createEntity(Reference
.class, text
);
40 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
43 public Reference
createEntity(Object key
, String text
) {
44 Reference reference
= null;
46 // TODO replace w more generic method when cdmlib matures accordingly
47 if (ReferenceType
.Article
.getMessage().equals(key
)) {
48 reference
= ReferenceFactory
.newArticle();
50 if (ReferenceType
.Book
.getMessage().equals(key
)) {
51 reference
= ReferenceFactory
.newBook();
53 if (ReferenceType
.BookSection
.getMessage().equals(key
)) {
54 reference
= ReferenceFactory
.newBookSection();
56 if (ReferenceType
.CdDvd
.getMessage().equals(key
)) {
57 reference
= ReferenceFactory
.newCdDvd();
59 if (ReferenceType
.Database
.getMessage().equals(key
)) {
60 reference
= ReferenceFactory
.newDatabase();
62 if (ReferenceType
.Generic
.getMessage().equals(key
)) {
63 reference
= ReferenceFactory
.newGeneric();
65 if (ReferenceType
.InProceedings
.getMessage().equals(key
)) {
66 reference
= ReferenceFactory
.newInProceedings();
68 if (ReferenceType
.Journal
.getMessage().equals(key
)) {
69 reference
= ReferenceFactory
.newJournal();
71 if (ReferenceType
.Map
.getMessage().equals(key
)) {
72 reference
= ReferenceFactory
.newMap();
74 if (ReferenceType
.Patent
.getMessage().equals(key
)) {
75 reference
= ReferenceFactory
.newPatent();
77 if (ReferenceType
.PersonalCommunication
.getMessage().equals(key
)) {
78 reference
= ReferenceFactory
.newPersonalCommunication();
80 if (ReferenceType
.PrintSeries
.getMessage().equals(key
)) {
81 reference
= ReferenceFactory
.newPrintSeries();
83 if (ReferenceType
.Proceedings
.getMessage().equals(key
)) {
84 reference
= ReferenceFactory
.newProceedings();
86 if (ReferenceType
.Report
.getMessage().equals(key
)) {
87 reference
= ReferenceFactory
.newReport();
89 if (ReferenceType
.Thesis
.getMessage().equals(key
)) {
90 reference
= ReferenceFactory
.newThesis();
92 if (ReferenceType
.WebPage
.getMessage().equals(key
)) {
93 reference
= ReferenceFactory
.newWebPage();
95 if (reference
== null) {
96 BulkEditorUtil
.warn(getClass(), "Reference type " + key
+ " not found. Creating reference with default type.");
97 reference
= ReferenceFactory
.newGeneric();
99 reference
.setTitleCache(text
, true);
104 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
107 * <p>getKeyLabelPairs</p>
109 * @return a {@link java.util.Map} object.
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());