Project

General

Profile

Revision cc3a997a

IDcc3a997ad416591f75a79a24d7555eead6ddde57
Parent a8541d12
Child c398ed0b

Added by Andreas Müller over 8 years ago

Separate interface for DefinedTermBase and enumerations #3618

View differences:

.gitattributes
721 721
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IParsable.java -text
722 722
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IReferencedEntity.java -text
723 723
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IRelated.java -text
724
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ISimpleTerm.java -text
724 725
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ISourceable.java -text
725 726
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IVersionableEntity.java -text svneol=unset#text/plain
726 727
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableEntity.java -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IDefinedTerm.java
10 10
package eu.etaxonomy.cdm.model.common;
11 11

  
12 12
import java.util.Set;
13
import java.util.UUID;
14

  
15
import javax.persistence.Transient;
16

  
17 13

  
18 14
import eu.etaxonomy.cdm.model.media.Media;
19 15

  
20
public interface IDefinedTerm<T extends IDefinedTerm> extends ILoadableTerm<T> {
16
public interface IDefinedTerm<T extends IDefinedTerm> extends ISimpleTerm<T>, ILoadableTerm<T> {
21 17

  
22
	@Transient
23
	public UUID getUuid();
24
	
25
	public T getByUuid(UUID uuid);
26

  
27
	/**
28
	 * Returns the defined term this term is a kind of.
29
	 * Therefore the returned term is a generalization of <code>this</code> term
30
	 */
31
	public T getKindOf();
32 18

  
33 19
//	public void setKindOf(T kindOf);
34 20

  
35
	/**
36
	 * Returns all defined terms this term is a generalization for.
37
	 * Therefore the returned terms are kind of <code>this</code> term
38
	 */
39
	public Set<T> getGeneralizationOf();
40 21

  
41 22
//	public void setGeneralizationOf(Set<T> generalizationOf);
42 23
//
......
47 28
	/**
48 29
	 * Returns the defined term this term is a part of.
49 30
	 * Therefore the returned term includes <code>this</code> term
31
	 * Discuss: move to {@link ISimpleTerm}?
32
	 * @see #getIncludes()
50 33
	 */
34
	//Discuss: move to ISimpleTerm
51 35
	public T getPartOf();
52 36

  
53 37
//	public void setPartOf(T partOf);
......
55 39
	/**
56 40
	 * Returns all defined terms this term includes.
57 41
	 * Therefore the returned terms are part of <code>this</code> term
42
	 * Discuss: move to {@link ISimpleTerm}?
43
	 * @see #getPartOf()
58 44
	 */
59 45
	public Set<T> getIncludes();
60 46

  
......
64 50
//
65 51
//	public void removeIncludes(T includes);
66 52

  
53
	/**
54
	 * Returns the media attached to this {@link IDefinedTerm term}
55
	 * @return
56
	 */
67 57
	public Set<Media> getMedia();
68 58

  
69 59
//	public void setMedia(Set<Media> media);
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ISimpleTerm.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.model.common;
5

  
6
import java.util.Set;
7
import java.util.UUID;
8

  
9
import javax.persistence.Transient;
10

  
11
/**
12
 * The common interface which is implemented by {@link DefinedTermBase defined terms} and enumerations
13
 * replacing fully {@link DefinedTermBase defined terms}.
14
 * 
15
 * @author a.mueller
16
 * @created 14-Jul-1913
17
 */
18
public interface ISimpleTerm<T extends ISimpleTerm> {
19

  
20
	@Transient
21
	public UUID getUuid();
22
	
23
	public T getByUuid(UUID uuid);
24

  
25

  
26
	/**
27
	 * Returns the defined term this term is a kind of.
28
	 * Therefore the returned term is a generalization of <code>this</code> term
29
	 */
30
	public T getKindOf();
31
	
32

  
33
	/**
34
	 * Returns all defined terms this term is a generalization for.
35
	 * Therefore the returned terms are kind of <code>this</code> term
36
	 */
37
	public Set<T> getGeneralizationOf();
38

  
39
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/OriginalSourceType.java
36 36
 * @created 15.05.2013
37 37
 */
38 38
@XmlEnum
39
public enum OriginalSourceType implements IDefinedTerm<OriginalSourceType>, Serializable{
39
public enum OriginalSourceType implements ISimpleTerm<OriginalSourceType>, Serializable{
40 40
	
41 41
	//0
42 42
	/**
......
119 119
	;
120 120
	
121 121
	
122
	@SuppressWarnings("unused")
122 123
	private static final Logger logger = Logger.getLogger(OriginalSourceType.class);
123 124

  
124 125
	private String readableString;
......
137 138
		//TODO make multi-lingual
138 139
		return readableString;
139 140
	}
140
	
141

  
142
	@Override
143
    public OriginalSourceType readCsvLine(Class<OriginalSourceType> termClass,
144
			List<String> csvLine, java.util.Map<UUID, DefinedTermBase> terms) {
145
		// TODO Auto-generated method stub
146
		return null;
147
	}
148

  
149

  
150
	@Override
151
    public void writeCsvLine(CSVWriter writer, OriginalSourceType term) {
152
		logger.warn("write csvLine not yet implemented");
153
	}
154 141

  
155 142

  
156 143
	@Override
......
169 156
		return null;
170 157
	}
171 158

  
172

  
173 159
	@Override
174 160
    public OriginalSourceType getKindOf() {
175 161
		return null;
......
181 167
		return new HashSet<OriginalSourceType>();
182 168
	}
183 169

  
184

  
185
	@Override
186
    public OriginalSourceType getPartOf() {
187
		return null;
188
	}
189

  
190

  
191
	@Override
192
    public Set<OriginalSourceType> getIncludes() {
193
		return new HashSet<OriginalSourceType>();
194
	}
195

  
196

  
197
	@Override
198
    public Set<Media> getMedia() {
199
		return new HashSet<Media>();
200
	}
201
	
202
	@Override
203
	public String getIdInVocabulary() {
204
		return this.toString();
205
	}
206

  
207
	@Override
208
	public void setIdInVocabulary(String idInVocabulary) {
209
		//not applicable
210
	}
211

  
212 170
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/TermType.java
70 70
 * @created 11.06.2013
71 71
 */
72 72
@XmlEnum
73
public enum TermType implements IDefinedTerm<TermType>, Serializable{
73
public enum TermType implements ISimpleTerm<TermType>, Serializable{
74 74
	
75 75
	//0
76 76
	/**
......
438 438
	}
439 439
	
440 440
	
441
	
442
	
443
	
444
	
445
	
446
	
447
	
448
	
449
	
450
	
451
	
452

  
453
	@Override
454
    public TermType readCsvLine(Class<TermType> termClass,
455
			List<String> csvLine, java.util.Map<UUID, DefinedTermBase> terms) {
456
		// TODO Auto-generated method stub
457
		return null;
458
	}
459

  
460

  
461
	@Override
462
    public void writeCsvLine(CSVWriter writer, TermType term) {
463
		logger.warn("write csvLine not yet implemented");
464
	}
465 441

  
466 442

  
467 443
	@Override
......
485 461
    public TermType getKindOf() {
486 462
		return parent;
487 463
	}
488

  
489

  
490 464
	
491 465
	
492 466
	@Override
......
495 469
		return new HashSet<TermType>(children);
496 470
	}
497 471

  
498

  
499
	@Override
500
    public TermType getPartOf() {
501
		return null;
502
	}
503

  
504

  
505
	@Override
506
    public Set<TermType> getIncludes() {
507
		return new HashSet<TermType>();
508
	}
509

  
510

  
511
	@Override
512
    public Set<Media> getMedia() {
513
		return new HashSet<Media>();
514
	}
515
	
516
	@Override
517
	public String getIdInVocabulary() {
518
		return this.toString();
519
	}
520

  
521
	@Override
522
	public void setIdInVocabulary(String idInVocabulary) {
523
		throw new RuntimeException("id can't be set for termtype");
524
	}
525

  
526 472
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NomenclaturalCode.java
11 11

  
12 12
import java.io.Serializable;
13 13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.Map;
16 14
import java.util.Set;
17 15
import java.util.UUID;
18 16

  
......
23 21

  
24 22
import org.apache.log4j.Logger;
25 23

  
26
import au.com.bytecode.opencsv.CSVWriter;
27
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
28
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
29
import eu.etaxonomy.cdm.model.media.Media;
24
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
30 25

  
31 26
/**
32 27
 * The class for the five nomenclature codes (ICNB, ICBN, ICNCP, ICZN and ICVCN)
......
49 44

  
50 45
@XmlType(name = "NomenclaturalCode")
51 46
@XmlEnum
52
public enum NomenclaturalCode implements IDefinedTerm<NomenclaturalCode>, Serializable {
47
public enum NomenclaturalCode implements ISimpleTerm<NomenclaturalCode>, Serializable {
53 48
	//0
54 49
	/**
55 50
	 * International Code of Nomenclature of Bacteria
......
132 127
	/* (non-Javadoc)
133 128
	 * @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getByUuid(java.util.UUID)
134 129
	 */
130
	@Override
135 131
	public NomenclaturalCode getByUuid(UUID uuid) {
136 132
		for (NomenclaturalCode nomCode : NomenclaturalCode.values()){
137 133
			if (nomCode.getUuid().equals(uuid)){
......
141 137
		return null;
142 138
	}
143 139

  
144
	/* (non-Javadoc)
145
	 * @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getGeneralizationOf()
146
	 */
140
	@Override
147 141
	public Set<NomenclaturalCode> getGeneralizationOf() {
148 142
		return new HashSet<NomenclaturalCode>();
149 143
	}
150 144

  
151
	/* (non-Javadoc)
152
	 * @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getIncludes()
153
	 */
154
	public Set<NomenclaturalCode> getIncludes() {
155
		return new HashSet<NomenclaturalCode>();
156
	}
157 145

  
158
	/* (non-Javadoc)
159
	 * @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getKindOf()
160
	 */
146
	@Override
161 147
	public NomenclaturalCode getKindOf() {
162 148
		return null;
163 149
	}
164 150

  
165

  
166
	/* (non-Javadoc)
167
	 * @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getPartOf()
168
	 */
169
	public NomenclaturalCode getPartOf() {
170
		return null;
171
	}
172
	
173
	/* (non-Javadoc)
174
	 * @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getMedia()
175
	 */
176
	public Set<Media> getMedia() {
177
		// TODO add links to codes
178
		return new HashSet<Media>();
179
	}
180

  
181

  
182
	/* (non-Javadoc)
183
	 * @see eu.etaxonomy.cdm.model.common.ILoadableTerm#readCsvLine(java.lang.Class, java.util.List, java.util.Map)
184
	 */
185
	public NomenclaturalCode readCsvLine(Class<NomenclaturalCode> termClass,
186
			List<String> csvLine, Map<UUID, DefinedTermBase> terms) {
187
		throw new UnsupportedOperationException("readCsvLine not supported by enum class");
188
	}
189

  
190
	/* (non-Javadoc)
191
	 * @see eu.etaxonomy.cdm.model.common.ILoadableTerm#writeCsvLine(au.com.bytecode.opencsv.CSVWriter, eu.etaxonomy.cdm.model.common.IDefinedTerm)
192
	 */
193
	public void writeCsvLine(CSVWriter writer, NomenclaturalCode term) {
194
		throw new UnsupportedOperationException("writeCsvLine not supported by enum class");
195
	}
196

  
197 151
	/**
198 152
	 * Creates a new particular {@link TaxonNameBase taxon name} (botanical, zoological,
199 153
	 * cultivar plant, bacterial or viral name) instance depending on <i>this</i>
......
301 255
			return "synonym";
302 256
		}
303 257
	}
304

  
305
	@Override
306
	public String getIdInVocabulary() {
307
		return this.toString();
308
	}
309

  
310
	@Override
311
	public void setIdInVocabulary(String idInVocabulary) {
312
		//not applicable
313
	}	
314
}
315

  
258
	
259
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/RankClass.java
13 13
import java.io.Serializable;
14 14
import java.util.HashMap;
15 15
import java.util.HashSet;
16
import java.util.List;
17 16
import java.util.Map;
18 17
import java.util.Set;
19 18
import java.util.UUID;
......
24 23

  
25 24
import org.apache.log4j.Logger;
26 25

  
27
import au.com.bytecode.opencsv.CSVWriter;
28
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
29
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
30
import eu.etaxonomy.cdm.model.media.Media;
26
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
31 27

  
32 28
/**
33 29
 * The rank class defines the category of ranks a certain rank belongs to. This information is
......
40 36
 * @created 11.06.2013
41 37
 */
42 38
@XmlEnum
43
public enum RankClass implements IDefinedTerm<RankClass>, Serializable{
39
public enum RankClass implements ISimpleTerm<RankClass>, Serializable{
44 40
	
45 41
	//0
46 42
	/**
......
78 74
	;
79 75
	
80 76
	
77
	@SuppressWarnings("unused")
81 78
	private static final Logger logger = Logger.getLogger(RankClass.class);
82 79

  
83 80
	private String readableString;
......
117 114
		//TODO make multi-lingual
118 115
		return readableString;
119 116
	}
120
	
121
	
122
	
123
	
124
	@Override
125
	public RankClass readCsvLine(Class<RankClass> termClass, List<String> csvLine, Map<UUID, DefinedTermBase> terms) {
126
		// TODO Auto-generated method stub
127
		return null;
128
	}
129
	
130

  
131
	@Override
132
    public void writeCsvLine(CSVWriter writer, RankClass term) {
133
		logger.warn("write csvLine not yet implemented");
134
	}
135 117

  
136 118

  
137 119
	@Override
......
161 143
    public Set<RankClass> getGeneralizationOf() {
162 144
		return new HashSet<RankClass>();
163 145
	}
164

  
165

  
166
	@Override
167
    public RankClass getPartOf() {
168
		return null;
169
	}
170

  
171

  
172
	@Override
173
    public Set<RankClass> getIncludes() {
174
		return new HashSet<RankClass>();
175
	}
176

  
177

  
178
	@Override
179
    public Set<Media> getMedia() {
180
		return new HashSet<Media>();
181
	}
182
	
183
	@Override
184
	public String getIdInVocabulary() {
185
		return this.toString();
186
	}
187

  
188
	@Override
189
	public void setIdInVocabulary(String idInVocabulary) {
190
		//not applicable
191
	}
192

  
193

  
194 146
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/SpecimenOrObservationType.java
13 13
import java.io.Serializable;
14 14
import java.util.HashMap;
15 15
import java.util.HashSet;
16
import java.util.List;
17 16
import java.util.Map;
18 17
import java.util.Set;
19 18
import java.util.UUID;
......
24 23

  
25 24
import org.apache.log4j.Logger;
26 25

  
27
import au.com.bytecode.opencsv.CSVWriter;
28
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
29
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
26
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
30 27
import eu.etaxonomy.cdm.model.common.Language;
31
import eu.etaxonomy.cdm.model.media.Media;
32 28

  
33 29

  
34 30
/**
......
45 41
 * @created 27.06.2013
46 42
 */
47 43
@XmlEnum
48
public enum SpecimenOrObservationType implements IDefinedTerm<SpecimenOrObservationType>, Serializable{
44
public enum SpecimenOrObservationType implements ISimpleTerm<SpecimenOrObservationType>, Serializable{
49 45
	
50 46
	//0
51 47
	/**
......
173 169
	//types (e.g. Observation)
174 170
	@XmlEnumValue("FieldUnit")
175 171
	FieldUnit(UUID.fromString("d38d22db-17f9-45ba-a32f-32393788726f"), "Field Unit", "FU"),	
176

  
177 172
	;
178 173
	
179
	
174
	@SuppressWarnings("unused")
180 175
	private static final Logger logger = Logger.getLogger(SpecimenOrObservationType.class);
181 176

  
182 177
	private String readableString;
......
312 307
		}
313 308
		return null;
314 309
	}
315
	
316

  
317
	@Override
318
	public SpecimenOrObservationType readCsvLine(Class<SpecimenOrObservationType> termClass,
319
			List<String> csvLine, Map<UUID, DefinedTermBase> terms) {
320
		String message = "readCsvLine not implemented";
321
		throw new RuntimeException(message);
322
	}	
323
	
324
	@Override
325
    public void writeCsvLine(CSVWriter writer, SpecimenOrObservationType term) {
326
		logger.warn("write csvLine not yet implemented");
327
	}
328 310

  
329 311

  
330 312
	@Override
......
354 336
    public Set<SpecimenOrObservationType> getGeneralizationOf() {
355 337
		return new HashSet<SpecimenOrObservationType>();
356 338
	}
357

  
358

  
359
	@Override
360
    public SpecimenOrObservationType getPartOf() {
361
		return null;
362
	}
363

  
364

  
365
	@Override
366
    public Set<SpecimenOrObservationType> getIncludes() {
367
		return new HashSet<SpecimenOrObservationType>();
368
	}
369

  
370

  
371
	@Override
372
    public Set<Media> getMedia() {
373
		return new HashSet<Media>();
374
	}
375
	
376
	@Override
377
	public String getIdInVocabulary() {
378
		return this.toString();
379
	}
380

  
381
	@Override
382
	public void setIdInVocabulary(String idInVocabulary) {
383
		//not applicable
384
	}
385

  
386

  
387

  
388

  
389 339
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/ReferenceType.java
12 12

  
13 13
import java.io.Serializable;
14 14
import java.util.HashSet;
15
import java.util.List;
16 15
import java.util.Set;
17 16
import java.util.UUID;
18 17

  
......
22 21

  
23 22
import org.apache.log4j.Logger;
24 23

  
25
import au.com.bytecode.opencsv.CSVWriter;
26
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
27
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
24
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
28 25
import eu.etaxonomy.cdm.model.common.Language;
29
import eu.etaxonomy.cdm.model.media.Media;
30 26
import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy;
31 27
import eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy;
32 28
import eu.etaxonomy.cdm.strategy.cache.reference.BookSectionDefaultCacheStrategy;
......
48 44
 * @version 1.0
49 45
 */
50 46
@XmlEnum
51
public enum ReferenceType implements IDefinedTerm<ReferenceType>, Serializable{
47
public enum ReferenceType implements ISimpleTerm<ReferenceType>, Serializable{
52 48
	//0
53 49
	@XmlEnumValue("Article")
54 50
	Article(UUID.fromString("fddfb343-f652-4f33-b6cb-7c94daa2f1ec"), "Article", ArticleDefaultCacheStrategy.class),
......
96 92
	Thesis(UUID.fromString("cd054393-4f5e-4842-b820-b820e5732d72"), "Thesis", ThesisDefaultCacheStrategy.class),
97 93
	//15
98 94
	@XmlEnumValue("Web Page")
99
	WebPage(UUID.fromString("1ed8b0df-0532-40ea-aef6-ee4361341165"), "Web Page", ReferenceBaseDefaultCacheStrategy.class);
95
	WebPage(UUID.fromString("1ed8b0df-0532-40ea-aef6-ee4361341165"), "Web Page", ReferenceBaseDefaultCacheStrategy.class)
96
	;
100 97

  
98
	@SuppressWarnings("unused")
101 99
	private static final Logger logger = Logger.getLogger(ReferenceType.class);
102 100

  
103 101
	private String readableString;
......
178 176

  
179 177

  
180 178
	@Override
181
    public ReferenceType readCsvLine(Class<ReferenceType> termClass,
182
			List<String> csvLine, java.util.Map<UUID, DefinedTermBase> terms) {
183
		// TODO Auto-generated method stub
184
		return null;
185
	}
186

  
187

  
188
	@Override
189
    public void writeCsvLine(CSVWriter writer, ReferenceType term) {
190
		logger.warn("write csvLine not yet implemented");
191
	}
192

  
193

  
194
	@Override
195 179
    public UUID getUuid() {
196 180
		return this.uuid;
197 181
	}
......
219 203
		return new HashSet<ReferenceType>();
220 204
	}
221 205

  
222

  
223
	@Override
224
    public ReferenceType getPartOf() {
225
		return null;
226
	}
227

  
228

  
229
	@Override
230
    public Set<ReferenceType> getIncludes() {
231
		return new HashSet<ReferenceType>();
232
	}
233

  
234

  
235
	@Override
236
    public Set<Media> getMedia() {
237
		return new HashSet<Media>();
238
	}
239
	
240
	@Override
241
	public String getIdInVocabulary() {
242
		return this.toString();
243
	}
244

  
245
	@Override
246
	public void setIdInVocabulary(String idInVocabulary) {
247
		//not applicable
248
	}
249

  
250 206
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)