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
;
13 import java
.util
.HashMap
;
16 import org
.apache
.log4j
.Logger
;
18 import eu
.etaxonomy
.cdm
.model
.reference
.Article
;
19 import eu
.etaxonomy
.cdm
.model
.reference
.Book
;
20 import eu
.etaxonomy
.cdm
.model
.reference
.BookSection
;
21 import eu
.etaxonomy
.cdm
.model
.reference
.CdDvd
;
22 import eu
.etaxonomy
.cdm
.model
.reference
.Database
;
23 import eu
.etaxonomy
.cdm
.model
.reference
.Generic
;
24 import eu
.etaxonomy
.cdm
.model
.reference
.InProceedings
;
25 import eu
.etaxonomy
.cdm
.model
.reference
.Journal
;
26 import eu
.etaxonomy
.cdm
.model
.reference
.Patent
;
27 import eu
.etaxonomy
.cdm
.model
.reference
.PersonalCommunication
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.PrintSeries
;
29 import eu
.etaxonomy
.cdm
.model
.reference
.Proceedings
;
30 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
31 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceType
;
32 import eu
.etaxonomy
.cdm
.model
.reference
.Report
;
33 import eu
.etaxonomy
.cdm
.model
.reference
.Thesis
;
34 import eu
.etaxonomy
.cdm
.model
.reference
.WebPage
;
35 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
38 * <p>ReferenceCreator class.</p>
44 public class ReferenceCreator
implements IEntityCreator
<ReferenceBase
> {
45 private static final Logger logger
= Logger
46 .getLogger(ReferenceCreator
.class);
49 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
52 public ReferenceBase
createEntity(String text
) {
53 return createEntity(Generic
.class, text
);
57 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
60 public ReferenceBase
createEntity(Object key
, String text
) {
61 ReferenceBase reference
= null;
63 // TODO replace w more generic method when cdmlib matures accordingly
64 if (ReferenceType
.Article
.getMessage().equals(key
)) {
65 reference
= Article
.NewInstance();
67 if (ReferenceType
.Book
.getMessage().equals(key
)) {
68 reference
= Book
.NewInstance();
70 if (ReferenceType
.BookSection
.getMessage().equals(key
)) {
71 reference
= BookSection
.NewInstance();
73 if (ReferenceType
.CdDvd
.getMessage().equals(key
)) {
74 reference
= CdDvd
.NewInstance();
76 if (ReferenceType
.Database
.getMessage().equals(key
)) {
77 reference
= Database
.NewInstance();
79 if (ReferenceType
.Generic
.getMessage().equals(key
)) {
80 reference
= Generic
.NewInstance();
82 if (ReferenceType
.InProceedings
.getMessage().equals(key
)) {
83 reference
= InProceedings
.NewInstance();
85 if (ReferenceType
.Journal
.getMessage().equals(key
)) {
86 reference
= Journal
.NewInstance();
88 if (ReferenceType
.Map
.getMessage().equals(key
)) {
89 reference
= eu
.etaxonomy
.cdm
.model
.reference
.Map
.NewInstance();
91 if (ReferenceType
.Patent
.getMessage().equals(key
)) {
92 reference
= Patent
.NewInstance();
94 if (ReferenceType
.PersonalCommunication
.getMessage().equals(key
)) {
95 reference
= PersonalCommunication
.NewInstance();
97 if (ReferenceType
.PrintSeries
.getMessage().equals(key
)) {
98 reference
= PrintSeries
.NewInstance();
100 if (ReferenceType
.Proceedings
.getMessage().equals(key
)) {
101 reference
= Proceedings
.NewInstance();
103 if (ReferenceType
.Report
.getMessage().equals(key
)) {
104 reference
= Report
.NewInstance();
106 if (ReferenceType
.Thesis
.getMessage().equals(key
)) {
107 reference
= Thesis
.NewInstance();
109 if (ReferenceType
.WebPage
.getMessage().equals(key
)) {
110 reference
= WebPage
.NewInstance();
112 if (reference
== null) {
113 logger
.warn("Reference type " + key
+ " not found. Creating reference with default type.");
114 reference
= Generic
.NewInstance();
116 reference
.setTitleCache(text
);
121 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
124 * <p>getKeyLabelPairs</p>
126 * @return a {@link java.util.Map} object.
128 public Map
<Object
, String
> getKeyLabelPairs() {
129 Map
<Object
, String
> result
= new HashMap
<Object
, String
>();
130 for (ReferenceType type
: ReferenceType
.values()) {
131 result
.put(type
.getMessage(), type
.getMessage());