Project

General

Profile

« Previous | Next » 

Revision 3be6ef3e

Added by Niels Hoffmann over 13 years ago

performed javacscript:fix and worked on documentation

View differences:

taxeditor-bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/ReferenceCreator.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
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.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.bulkeditor;
12

  
13
import java.util.HashMap;
14
import java.util.Map;
15

  
16
import org.apache.log4j.Logger;
17

  
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;
36

  
37
/**
38
 * @author p.ciardelli
39
 * @created 07.07.2009
40
 * @version 1.0
41
 */
42
public class ReferenceCreator implements IEntityCreator<ReferenceBase> {
43
	private static final Logger logger = Logger
44
			.getLogger(ReferenceCreator.class);
45

  
46
	/* (non-Javadoc)
47
	 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
48
	 */
49
	public ReferenceBase createEntity(String text) {
50
		return createEntity(Generic.class, text);
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
55
	 */
56
	public ReferenceBase createEntity(Object key, String text) {
57
		ReferenceBase reference = null;
58
		
59
		// TODO replace w more generic method when cdmlib matures accordingly
60
		if  (ReferenceType.Article.getMessage().equals(key)) {
61
			reference = Article.NewInstance();
62
		}
63
		if  (ReferenceType.Book.getMessage().equals(key)) {
64
			reference = Book.NewInstance();
65
		}
66
		if  (ReferenceType.BookSection.getMessage().equals(key)) {
67
			reference = BookSection.NewInstance();
68
		}
69
		if  (ReferenceType.CdDvd.getMessage().equals(key)) {
70
			reference = CdDvd.NewInstance();
71
		}
72
		if  (ReferenceType.Database.getMessage().equals(key)) {
73
			reference = Database.NewInstance();
74
		}
75
		if  (ReferenceType.Generic.getMessage().equals(key)) {
76
			reference = Generic.NewInstance();
77
		}
78
		if  (ReferenceType.InProceedings.getMessage().equals(key)) {
79
			reference = InProceedings.NewInstance();
80
		}
81
		if  (ReferenceType.Journal.getMessage().equals(key)) {
82
			reference = Journal.NewInstance();
83
		}
84
		if  (ReferenceType.Map.getMessage().equals(key)) {
85
			reference = eu.etaxonomy.cdm.model.reference.Map.NewInstance();
86
		}
87
		if  (ReferenceType.Patent.getMessage().equals(key)) {
88
			reference = Patent.NewInstance();
89
		}
90
		if  (ReferenceType.PersonalCommunication.getMessage().equals(key)) {
91
			reference = PersonalCommunication.NewInstance();
92
		}
93
		if  (ReferenceType.PrintSeries.getMessage().equals(key)) {
94
			reference = PrintSeries.NewInstance();
95
		}
96
		if  (ReferenceType.Proceedings.getMessage().equals(key)) {
97
			reference = Proceedings.NewInstance();
98
		}
99
		if  (ReferenceType.Report.getMessage().equals(key)) {
100
			reference = Report.NewInstance();
101
		}
102
		if  (ReferenceType.Thesis.getMessage().equals(key)) {
103
			reference = Thesis.NewInstance();
104
		}
105
		if  (ReferenceType.WebPage.getMessage().equals(key)) {
106
			reference = WebPage.NewInstance();
107
		}
108
		if (reference == null) {
109
			logger.warn("Reference type " + key + " not found. Creating reference with default type.");
110
			reference = Generic.NewInstance();
111
		}
112
		reference.setTitleCache(text);
113
		return reference;
114
	}
115

  
116
	/* (non-Javadoc)
117
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
118
	 */
119
	public Map<Object, String> getKeyLabelPairs() {
120
		Map<Object, String> result = new HashMap<Object, String>();
121
		for (ReferenceType type : ReferenceType.values()) {
122
			result.put(type.getMessage(), type.getMessage());
123
		}
124
		return result;
125
	}
126
}
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
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.
9
*/
10

  
11
package eu.etaxonomy.taxeditor.bulkeditor;
12

  
13
import java.util.HashMap;
14
import java.util.Map;
15

  
16
import org.apache.log4j.Logger;
17

  
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;
36

  
37
/**
38
 * <p>ReferenceCreator class.</p>
39
 *
40
 * @author p.ciardelli
41
 * @created 07.07.2009
42
 * @version 1.0
43
 */
44
public class ReferenceCreator implements IEntityCreator<ReferenceBase> {
45
	private static final Logger logger = Logger
46
			.getLogger(ReferenceCreator.class);
47

  
48
	/* (non-Javadoc)
49
	 * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
50
	 */
51
	/** {@inheritDoc} */
52
	public ReferenceBase createEntity(String text) {
53
		return createEntity(Generic.class, text);
54
	}
55

  
56
	/* (non-Javadoc)
57
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
58
	 */
59
	/** {@inheritDoc} */
60
	public ReferenceBase createEntity(Object key, String text) {
61
		ReferenceBase reference = null;
62
		
63
		// TODO replace w more generic method when cdmlib matures accordingly
64
		if  (ReferenceType.Article.getMessage().equals(key)) {
65
			reference = Article.NewInstance();
66
		}
67
		if  (ReferenceType.Book.getMessage().equals(key)) {
68
			reference = Book.NewInstance();
69
		}
70
		if  (ReferenceType.BookSection.getMessage().equals(key)) {
71
			reference = BookSection.NewInstance();
72
		}
73
		if  (ReferenceType.CdDvd.getMessage().equals(key)) {
74
			reference = CdDvd.NewInstance();
75
		}
76
		if  (ReferenceType.Database.getMessage().equals(key)) {
77
			reference = Database.NewInstance();
78
		}
79
		if  (ReferenceType.Generic.getMessage().equals(key)) {
80
			reference = Generic.NewInstance();
81
		}
82
		if  (ReferenceType.InProceedings.getMessage().equals(key)) {
83
			reference = InProceedings.NewInstance();
84
		}
85
		if  (ReferenceType.Journal.getMessage().equals(key)) {
86
			reference = Journal.NewInstance();
87
		}
88
		if  (ReferenceType.Map.getMessage().equals(key)) {
89
			reference = eu.etaxonomy.cdm.model.reference.Map.NewInstance();
90
		}
91
		if  (ReferenceType.Patent.getMessage().equals(key)) {
92
			reference = Patent.NewInstance();
93
		}
94
		if  (ReferenceType.PersonalCommunication.getMessage().equals(key)) {
95
			reference = PersonalCommunication.NewInstance();
96
		}
97
		if  (ReferenceType.PrintSeries.getMessage().equals(key)) {
98
			reference = PrintSeries.NewInstance();
99
		}
100
		if  (ReferenceType.Proceedings.getMessage().equals(key)) {
101
			reference = Proceedings.NewInstance();
102
		}
103
		if  (ReferenceType.Report.getMessage().equals(key)) {
104
			reference = Report.NewInstance();
105
		}
106
		if  (ReferenceType.Thesis.getMessage().equals(key)) {
107
			reference = Thesis.NewInstance();
108
		}
109
		if  (ReferenceType.WebPage.getMessage().equals(key)) {
110
			reference = WebPage.NewInstance();
111
		}
112
		if (reference == null) {
113
			logger.warn("Reference type " + key + " not found. Creating reference with default type.");
114
			reference = Generic.NewInstance();
115
		}
116
		reference.setTitleCache(text);
117
		return reference;
118
	}
119

  
120
	/* (non-Javadoc)
121
	 * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#getClassLabelPairs()
122
	 */
123
	/**
124
	 * <p>getKeyLabelPairs</p>
125
	 *
126
	 * @return a {@link java.util.Map} object.
127
	 */
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());
132
		}
133
		return result;
134
	}
135
}

Also available in: Unified diff