2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.bulkeditor
.input
.entitycreator
;
12 import java
.util
.HashMap
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
16 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
17 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceType
;
18 import eu
.etaxonomy
.taxeditor
.annotatedlineeditor
.IEntityCreator
;
19 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 * <p>ReferenceCreator class.</p>
28 public class ReferenceCreator
implements IEntityCreator
<Reference
> {
31 * @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)
44 public Reference
createEntity(Object key
, String text
) {
45 Reference reference
= null;
47 // TODO replace w more generic method when cdmlib matures accordingly
48 if (ReferenceType
.Article
.getMessage().equals(key
)) {
49 reference
= ReferenceFactory
.newArticle();
51 if (ReferenceType
.Book
.getMessage().equals(key
)) {
52 reference
= ReferenceFactory
.newBook();
54 if (ReferenceType
.BookSection
.getMessage().equals(key
)) {
55 reference
= ReferenceFactory
.newBookSection();
57 if (ReferenceType
.CdDvd
.getMessage().equals(key
)) {
58 reference
= ReferenceFactory
.newCdDvd();
60 if (ReferenceType
.Database
.getMessage().equals(key
)) {
61 reference
= ReferenceFactory
.newDatabase();
63 if (ReferenceType
.Generic
.getMessage().equals(key
)) {
64 reference
= ReferenceFactory
.newGeneric();
66 if (ReferenceType
.InProceedings
.getMessage().equals(key
)) {
67 reference
= ReferenceFactory
.newInProceedings();
69 if (ReferenceType
.Journal
.getMessage().equals(key
)) {
70 reference
= ReferenceFactory
.newJournal();
72 if (ReferenceType
.Map
.getMessage().equals(key
)) {
73 reference
= ReferenceFactory
.newMap();
75 if (ReferenceType
.Patent
.getMessage().equals(key
)) {
76 reference
= ReferenceFactory
.newPatent();
78 if (ReferenceType
.PersonalCommunication
.getMessage().equals(key
)) {
79 reference
= ReferenceFactory
.newPersonalCommunication();
81 if (ReferenceType
.PrintSeries
.getMessage().equals(key
)) {
82 reference
= ReferenceFactory
.newPrintSeries();
84 if (ReferenceType
.Proceedings
.getMessage().equals(key
)) {
85 reference
= ReferenceFactory
.newProceedings();
87 if (ReferenceType
.Report
.getMessage().equals(key
)) {
88 reference
= ReferenceFactory
.newReport();
90 if (ReferenceType
.Thesis
.getMessage().equals(key
)) {
91 reference
= ReferenceFactory
.newThesis();
93 if (ReferenceType
.WebPage
.getMessage().equals(key
)) {
94 reference
= ReferenceFactory
.newWebPage();
96 if (ReferenceType
.Section
.getMessage().equals(key
)) {
97 reference
= ReferenceFactory
.newSection();
99 if (reference
== null) {
100 MessagingUtils
.warn(getClass(), "Reference type " + key
+ " not found. Creating reference with default type.");
101 reference
= ReferenceFactory
.newGeneric();
103 reference
.setTitleCache(text
, true);
108 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
111 * <p>getKeyLabelPairs</p>
113 * @return a {@link java.util.Map} object.
116 public Map
<Object
, String
> getKeyLabelPairs() {
117 Map
<Object
, String
> result
= new HashMap
<Object
, String
>();
118 for (ReferenceType type
: ReferenceType
.values()) {
119 result
.put(type
.getMessage(), type
.getMessage());
125 public boolean savesEntity() {
126 // TODO Auto-generated method stub