Project

General

Profile

Revision ace720cf

IDace720cf6b0926c701dc666d52db1f23953abb4f
Parent f7678187
Child bd07c1ce

Added by Andreas Müller over 7 years ago

Add MediaSpecimen (still missing schema updater and tests) #3614

View differences:

.gitattributes
868 868
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DeterminationEvent.java -text
869 869
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/FieldUnit.java -text
870 870
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/GatheringEvent.java -text
871
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/MediaSpecimen.java -text
871 872
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/PreservationMethod.java -text
872 873
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/SpecimenOrObservationBase.java -text
873 874
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/SpecimenOrObservationType.java -text
cdmlib-ext/src/test/resources/dbscripts/001-cdm.h2.sql
306 306
     MARKER_ID INTEGER,
307 307
     PURIFICATION_ID INTEGER,
308 308
     REVERSEPRIMER_ID INTEGER,
309
     GELPHOTO_ID INTEGER,
309 310
     PRIMARY KEY (ID)
310 311
);
311 312

  
......
335 336
    MARKER_ID INTEGER,
336 337
    PURIFICATION_ID INTEGER,
337 338
    REVERSEPRIMER_ID INTEGER,
339
    GELPHOTO_ID INTEGER,
338 340
    PRIMARY KEY (ID)
339 341
);
340 342

  
......
3501 3503
    STOREDUNDER_ID INTEGER,
3502 3504
    PRESERVATION_ID INTEGER,
3503 3505
    GATHERINGEVENT_ID INTEGER,
3504
    PRIMARYCOLLECTOR_ID INTEGER
3506
    PRIMARYCOLLECTOR_ID INTEGER,
3507
    MEDIASPECIMEN_ID INTEGER
3505 3508
);
3506 3509
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.SPECIMENOROBSERVATIONBASE;
3507 3510
CREATE INDEX PUBLIC.SPECIMENOROBSERVATIONBASETITLECACHEINDEX ON PUBLIC.SPECIMENOROBSERVATIONBASE(TITLECACHE);
......
3540 3543
    STOREDUNDER_ID INTEGER,
3541 3544
    PRESERVATION_ID INTEGER,
3542 3545
    GATHERINGEVENT_ID INTEGER,
3543
    PRIMARYCOLLECTOR_ID INTEGER
3546
    PRIMARYCOLLECTOR_ID INTEGER,
3547
    MEDIASPECIMEN_ID INTEGER
3544 3548
);
3545 3549
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.SPECIMENOROBSERVATIONBASE_AUD;
3546 3550
CREATE CACHED TABLE PUBLIC.SPECIMENOROBSERVATIONBASE_ANNOTATION(
cdmlib-io/src/test/resources/dbscripts/001-cdm.h2.sql
306 306
     MARKER_ID INTEGER,
307 307
     PURIFICATION_ID INTEGER,
308 308
     REVERSEPRIMER_ID INTEGER,
309
     GELPHOTO_ID INTEGER,
309 310
     PRIMARY KEY (ID)
310 311
);
311 312

  
......
335 336
    MARKER_ID INTEGER,
336 337
    PURIFICATION_ID INTEGER,
337 338
    REVERSEPRIMER_ID INTEGER,
339
    GELPHOTO_ID INTEGER,
338 340
    PRIMARY KEY (ID)
339 341
);
340 342

  
......
3501 3503
    STOREDUNDER_ID INTEGER,
3502 3504
    PRESERVATION_ID INTEGER,
3503 3505
    GATHERINGEVENT_ID INTEGER,
3504
    PRIMARYCOLLECTOR_ID INTEGER
3506
    PRIMARYCOLLECTOR_ID INTEGER,
3507
    MEDIASPECIMEN_ID INTEGER
3505 3508
);
3506 3509
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.SPECIMENOROBSERVATIONBASE;
3507 3510
CREATE INDEX PUBLIC.SPECIMENOROBSERVATIONBASETITLECACHEINDEX ON PUBLIC.SPECIMENOROBSERVATIONBASE(TITLECACHE);
......
3540 3543
    STOREDUNDER_ID INTEGER,
3541 3544
    PRESERVATION_ID INTEGER,
3542 3545
    GATHERINGEVENT_ID INTEGER,
3543
    PRIMARYCOLLECTOR_ID INTEGER
3546
    PRIMARYCOLLECTOR_ID INTEGER,
3547
    MEDIASPECIMEN_ID INTEGER
3544 3548
);
3545 3549
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.SPECIMENOROBSERVATIONBASE_AUD;
3546 3550
CREATE CACHED TABLE PUBLIC.SPECIMENOROBSERVATIONBASE_ANNOTATION(
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/MediaSpecimen.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
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.
8
*/
9

  
10
package eu.etaxonomy.cdm.model.occurrence;
11

  
12

  
13
import javax.persistence.Entity;
14
import javax.persistence.FetchType;
15
import javax.persistence.ManyToOne;
16
import javax.xml.bind.annotation.XmlAccessType;
17
import javax.xml.bind.annotation.XmlAccessorType;
18
import javax.xml.bind.annotation.XmlElement;
19
import javax.xml.bind.annotation.XmlIDREF;
20
import javax.xml.bind.annotation.XmlRootElement;
21
import javax.xml.bind.annotation.XmlSchemaType;
22
import javax.xml.bind.annotation.XmlType;
23

  
24
import org.apache.log4j.Logger;
25
import org.hibernate.annotations.Cascade;
26
import org.hibernate.annotations.CascadeType;
27
import org.hibernate.envers.Audited;
28
import org.hibernate.search.annotations.Indexed;
29

  
30
import eu.etaxonomy.cdm.model.media.Media;
31
import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
32

  
33
/**
34
 * Instances of MediaSpecimen represent a specimen which IS a media (photo, drawing, ...).
35
 * Therefore it usually the media is part of a collection and has it's own catalog/collection
36
 * number. The individuum shown by the media may or may not be a collection specimen on it's own.
37
 * Often it is not, which may be the reason why a picture (or other media) is taken instead.
38
 * This is often the case for older (type) specimen which have only be drawn or painted.
39
 * Also it may be the cases for small biota which can not be individualized 
40
 * or preserved accordingly and may therefore be photographed instead.
41
 *
42
 * @author a.mueller
43
 * @created 14-Jul-2013 13:06:22
44
 */
45
@XmlAccessorType(XmlAccessType.FIELD)
46
@XmlType(name = "MediaSpecimen", propOrder = {
47
    "mediaSpecimen"
48
})
49
@XmlRootElement(name = "MediaSpecimen")
50
@Entity
51
@Indexed(index = "eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase")
52
@Audited
53
public class MediaSpecimen extends DerivedUnit implements Cloneable {
54
	private static final long serialVersionUID = -5717424451590705378L;
55
	@SuppressWarnings("unused")
56
	private static final Logger logger = Logger.getLogger(MediaSpecimen.class);
57
	
58
// ****************** FACTORY METHOD *****************/
59
	
60
	/**
61
	 * Factory method.
62
	 * @param type must be {@link SpecimenOrObservationType#Media} or a subtype of it.
63
	 * @return
64
	 */
65
	public static MediaSpecimen NewInstance(SpecimenOrObservationType type){
66
		return new MediaSpecimen(type);
67
	}
68

  
69
// ************** ATTRIBUTES ****************************/	
70
		
71
	@XmlElement(name = "sequence")
72
    @XmlIDREF
73
    @XmlSchemaType(name = "IDREF")
74
	@ManyToOne(fetch = FetchType.LAZY)
75
    @Cascade(CascadeType.SAVE_UPDATE)
76
	private Media mediaSpecimen;
77

  
78
// ******************* CONSTRUCTOR *************************/
79
	
80
	/**
81
	 * Constructor
82
	 */
83
	private MediaSpecimen() {
84
		this(SpecimenOrObservationType.Media);
85
	}
86
	
87
	private MediaSpecimen(SpecimenOrObservationType type) {
88
		super(type);
89
		this.cacheStrategy = new IdentifiableEntityDefaultCacheStrategy<DerivedUnit>();
90
	}
91

  
92
	
93
//************ GETTER / SETTER  **********************************/	
94

  
95
	/**
96
	 * The media which represents this specimen. It is important to realize
97
	 * that a media specimen is not a media which only shows the specimen
98
	 * but it is the specimen itself. Therefore this method should only be used
99
	 * for specimen which ARE media.<BR>
100
	 * This is often the case for older (type) specimen which have only be drawn or painted.
101
	 * Also it may be the cases for small biota which can not be individualized 
102
	 * or preserved accordingly and may therefore be photographed instead.
103
	 */
104
	public Media getMediaSpecimen() {
105
		return mediaSpecimen;
106
	}
107

  
108
	/**
109
	 * @see #getMediaSpecimen()
110
	 */
111
	public void setMediaSpecimen(Media mediaSpecimen) {
112
		this.mediaSpecimen = mediaSpecimen;
113
	}
114
	
115
// ************* Convenience Getter / Setter ************/
116
	
117
	
118

  
119
//*********** CLONE **********************************/	
120

  
121

  
122
	/** 
123
	 * Clones <i>this</i> dna sample. This is a shortcut that enables to
124
	 * create a new instance that differs only slightly from <i>this</i> dna sample
125
	 * by modifying only some of the attributes.<BR>
126
	 * This method overrides the clone method from {@link Specimen Specimen}.
127
	 * @throws CloneNotSupportedException 
128
	 * 
129
	 * @see Specimen#clone()
130
	 * @see DerivedUnit#clone()
131
	 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
132
	 * @see java.lang.Object#clone()
133
	 */
134
	@Override
135
	public MediaSpecimen clone() {
136
		MediaSpecimen result = (MediaSpecimen)super.clone();
137

  
138
		//no changes to: mediaSpecimen
139
		return result;
140
	}
141
}
cdmlib-persistence/src/main/resources/eu/etaxonomy/cdm/hibernate.cfg.xml
167 167
      <mapping class="eu.etaxonomy.cdm.model.occurrence.DerivationEvent"/>
168 168
      <mapping class="eu.etaxonomy.cdm.model.occurrence.DerivationEventType"/>
169 169
      <mapping class="eu.etaxonomy.cdm.model.occurrence.DerivedUnit"/>
170
      <mapping class="eu.etaxonomy.cdm.model.occurrence.MediaSpecimen"/>
170 171
      <mapping class="eu.etaxonomy.cdm.model.occurrence.DeterminationEvent"/>
171 172
      <mapping class="eu.etaxonomy.cdm.model.occurrence.FieldUnit"/>
172 173
      <mapping class="eu.etaxonomy.cdm.model.occurrence.GatheringEvent"/>
cdmlib-persistence/src/test/resources/dbscripts/001-cdm.h2.sql
306 306
     MARKER_ID INTEGER,
307 307
     PURIFICATION_ID INTEGER,
308 308
     REVERSEPRIMER_ID INTEGER,
309
     GELPHOTO_ID INTEGER,
309 310
     PRIMARY KEY (ID)
310 311
);
311 312

  
......
335 336
    MARKER_ID INTEGER,
336 337
    PURIFICATION_ID INTEGER,
337 338
    REVERSEPRIMER_ID INTEGER,
339
    GELPHOTO_ID INTEGER,
338 340
    PRIMARY KEY (ID)
339 341
);
340 342

  
......
3501 3503
    STOREDUNDER_ID INTEGER,
3502 3504
    PRESERVATION_ID INTEGER,
3503 3505
    GATHERINGEVENT_ID INTEGER,
3504
    PRIMARYCOLLECTOR_ID INTEGER
3506
    PRIMARYCOLLECTOR_ID INTEGER,
3507
    MEDIASPECIMEN_ID INTEGER
3505 3508
);
3506 3509
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.SPECIMENOROBSERVATIONBASE;
3507 3510
CREATE INDEX PUBLIC.SPECIMENOROBSERVATIONBASETITLECACHEINDEX ON PUBLIC.SPECIMENOROBSERVATIONBASE(TITLECACHE);
......
3540 3543
    STOREDUNDER_ID INTEGER,
3541 3544
    PRESERVATION_ID INTEGER,
3542 3545
    GATHERINGEVENT_ID INTEGER,
3543
    PRIMARYCOLLECTOR_ID INTEGER
3546
    PRIMARYCOLLECTOR_ID INTEGER,
3547
    MEDIASPECIMEN_ID INTEGER
3544 3548
);
3545 3549
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.SPECIMENOROBSERVATIONBASE_AUD;
3546 3550
CREATE CACHED TABLE PUBLIC.SPECIMENOROBSERVATIONBASE_ANNOTATION(
cdmlib-services/src/test/resources/dbscripts/001-cdm.h2.sql
306 306
     MARKER_ID INTEGER,
307 307
     PURIFICATION_ID INTEGER,
308 308
     REVERSEPRIMER_ID INTEGER,
309
     GELPHOTO_ID INTEGER,
309 310
     PRIMARY KEY (ID)
310 311
);
311 312

  
......
335 336
    MARKER_ID INTEGER,
336 337
    PURIFICATION_ID INTEGER,
337 338
    REVERSEPRIMER_ID INTEGER,
339
    GELPHOTO_ID INTEGER,
338 340
    PRIMARY KEY (ID)
339 341
);
340 342

  
......
3501 3503
    STOREDUNDER_ID INTEGER,
3502 3504
    PRESERVATION_ID INTEGER,
3503 3505
    GATHERINGEVENT_ID INTEGER,
3504
    PRIMARYCOLLECTOR_ID INTEGER
3506
    PRIMARYCOLLECTOR_ID INTEGER,
3507
    MEDIASPECIMEN_ID INTEGER
3505 3508
);
3506 3509
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.SPECIMENOROBSERVATIONBASE;
3507 3510
CREATE INDEX PUBLIC.SPECIMENOROBSERVATIONBASETITLECACHEINDEX ON PUBLIC.SPECIMENOROBSERVATIONBASE(TITLECACHE);
......
3540 3543
    STOREDUNDER_ID INTEGER,
3541 3544
    PRESERVATION_ID INTEGER,
3542 3545
    GATHERINGEVENT_ID INTEGER,
3543
    PRIMARYCOLLECTOR_ID INTEGER
3546
    PRIMARYCOLLECTOR_ID INTEGER,
3547
    MEDIASPECIMEN_ID INTEGER
3544 3548
);
3545 3549
-- 0 +/- SELECT COUNT(*) FROM PUBLIC.SPECIMENOROBSERVATIONBASE_AUD;
3546 3550
CREATE CACHED TABLE PUBLIC.SPECIMENOROBSERVATIONBASE_ANNOTATION(

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)