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>
27 public class ReferenceCreator
implements IEntityCreator
<Reference
> {
30 public Reference
createEntity(String text
) {
31 return createEntity(Reference
.class, text
);
35 public Reference
createEntity(Object key
, String text
) {
36 Reference reference
= null;
38 // TODO replace w more generic method when cdmlib matures accordingly
39 if (ReferenceType
.Article
.getLabel().equals(key
)) {
40 reference
= ReferenceFactory
.newArticle();
42 if (ReferenceType
.Book
.getLabel().equals(key
)) {
43 reference
= ReferenceFactory
.newBook();
45 if (ReferenceType
.BookSection
.getLabel().equals(key
)) {
46 reference
= ReferenceFactory
.newBookSection();
48 if (ReferenceType
.CdDvd
.getLabel().equals(key
)) {
49 reference
= ReferenceFactory
.newCdDvd();
51 if (ReferenceType
.Database
.getLabel().equals(key
)) {
52 reference
= ReferenceFactory
.newDatabase();
54 if (ReferenceType
.Generic
.getLabel().equals(key
)) {
55 reference
= ReferenceFactory
.newGeneric();
57 if (ReferenceType
.InProceedings
.getLabel().equals(key
)) {
58 reference
= ReferenceFactory
.newInProceedings();
60 if (ReferenceType
.Journal
.getLabel().equals(key
)) {
61 reference
= ReferenceFactory
.newJournal();
63 if (ReferenceType
.Map
.getLabel().equals(key
)) {
64 reference
= ReferenceFactory
.newMap();
66 if (ReferenceType
.Patent
.getLabel().equals(key
)) {
67 reference
= ReferenceFactory
.newPatent();
69 if (ReferenceType
.PersonalCommunication
.getLabel().equals(key
)) {
70 reference
= ReferenceFactory
.newPersonalCommunication();
72 if (ReferenceType
.PrintSeries
.getLabel().equals(key
)) {
73 reference
= ReferenceFactory
.newPrintSeries();
75 if (ReferenceType
.Proceedings
.getLabel().equals(key
)) {
76 reference
= ReferenceFactory
.newProceedings();
78 if (ReferenceType
.Report
.getLabel().equals(key
)) {
79 reference
= ReferenceFactory
.newReport();
81 if (ReferenceType
.Thesis
.getLabel().equals(key
)) {
82 reference
= ReferenceFactory
.newThesis();
84 if (ReferenceType
.WebPage
.getLabel().equals(key
)) {
85 reference
= ReferenceFactory
.newWebPage();
87 if (ReferenceType
.Section
.getLabel().equals(key
)) {
88 reference
= ReferenceFactory
.newSection();
90 if (reference
== null) {
91 MessagingUtils
.warn(getClass(), "Reference type " + key
+ " not found. Creating reference with default type.");
92 reference
= ReferenceFactory
.newGeneric();
94 reference
.setTitleCache(text
, true);
99 * <p>getKeyLabelPairs</p>
101 * @return a {@link java.util.Map} object.
104 public Map
<Object
, String
> getKeyLabelPairs() {
105 Map
<Object
, String
> result
= new HashMap
<Object
, String
>();
106 for (ReferenceType type
: ReferenceType
.values()) {
107 result
.put(type
.getLabel(), type
.getLabel());
113 public boolean savesEntity() {
114 // TODO Auto-generated method stub