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 org
.apache
.log4j
.Logger
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
19 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
20 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceType
;
21 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
22 import eu
.etaxonomy
.taxeditor
.bulkeditor
.BulkEditorUtil
;
25 * <p>ReferenceCreator class.</p>
31 public class ReferenceCreator
implements IEntityCreator
<Reference
> {
34 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
37 public Reference
createEntity(String text
) {
38 return createEntity(Reference
.class, text
);
42 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
45 public Reference
createEntity(Object key
, String text
) {
46 Reference reference
= null;
48 // TODO replace w more generic method when cdmlib matures accordingly
49 if (ReferenceType
.Article
.getMessage().equals(key
)) {
50 reference
= ReferenceFactory
.newArticle();
52 if (ReferenceType
.Book
.getMessage().equals(key
)) {
53 reference
= ReferenceFactory
.newBook();
55 if (ReferenceType
.BookSection
.getMessage().equals(key
)) {
56 reference
= ReferenceFactory
.newBookSection();
58 if (ReferenceType
.CdDvd
.getMessage().equals(key
)) {
59 reference
= ReferenceFactory
.newCdDvd();
61 if (ReferenceType
.Database
.getMessage().equals(key
)) {
62 reference
= ReferenceFactory
.newDatabase();
64 if (ReferenceType
.Generic
.getMessage().equals(key
)) {
65 reference
= ReferenceFactory
.newGeneric();
67 if (ReferenceType
.InProceedings
.getMessage().equals(key
)) {
68 reference
= ReferenceFactory
.newInProceedings();
70 if (ReferenceType
.Journal
.getMessage().equals(key
)) {
71 reference
= ReferenceFactory
.newJournal();
73 if (ReferenceType
.Map
.getMessage().equals(key
)) {
74 reference
= ReferenceFactory
.newMap();
76 if (ReferenceType
.Patent
.getMessage().equals(key
)) {
77 reference
= ReferenceFactory
.newPatent();
79 if (ReferenceType
.PersonalCommunication
.getMessage().equals(key
)) {
80 reference
= ReferenceFactory
.newPersonalCommunication();
82 if (ReferenceType
.PrintSeries
.getMessage().equals(key
)) {
83 reference
= ReferenceFactory
.newPrintSeries();
85 if (ReferenceType
.Proceedings
.getMessage().equals(key
)) {
86 reference
= ReferenceFactory
.newProceedings();
88 if (ReferenceType
.Report
.getMessage().equals(key
)) {
89 reference
= ReferenceFactory
.newReport();
91 if (ReferenceType
.Thesis
.getMessage().equals(key
)) {
92 reference
= ReferenceFactory
.newThesis();
94 if (ReferenceType
.WebPage
.getMessage().equals(key
)) {
95 reference
= ReferenceFactory
.newWebPage();
97 if (reference
== null) {
98 BulkEditorUtil
.warn(getClass(), "Reference type " + key
+ " not found. Creating reference with default type.");
99 reference
= ReferenceFactory
.newGeneric();
101 reference
.setTitleCache(text
);
106 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
109 * <p>getKeyLabelPairs</p>
111 * @return a {@link java.util.Map} object.
113 public Map
<Object
, String
> getKeyLabelPairs() {
114 Map
<Object
, String
> result
= new HashMap
<Object
, String
>();
115 for (ReferenceType type
: ReferenceType
.values()) {
116 result
.put(type
.getMessage(), type
.getMessage());