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
.model
.MessagingUtils
;
23 * <p>ReferenceCreator class.</p>
29 public class ReferenceCreator
implements IEntityCreator
<Reference
> {
32 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
36 public Reference
createEntity(String text
) {
37 return createEntity(Reference
.class, text
);
41 * @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 (ReferenceType
.Section
.getMessage().equals(key
)) {
98 reference
= ReferenceFactory
.newSection();
100 if (reference
== null) {
101 MessagingUtils
.warn(getClass(), "Reference type " + key
+ " not found. Creating reference with default type.");
102 reference
= ReferenceFactory
.newGeneric();
104 reference
.setTitleCache(text
, true);
109 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
112 * <p>getKeyLabelPairs</p>
114 * @return a {@link java.util.Map} object.
117 public Map
<Object
, String
> getKeyLabelPairs() {
118 Map
<Object
, String
> result
= new HashMap
<Object
, String
>();
119 for (ReferenceType type
: ReferenceType
.values()) {
120 result
.put(type
.getMessage(), type
.getMessage());
126 public boolean savesEntity() {
127 // TODO Auto-generated method stub