Revision cc0b954b
Added by Andreas Müller about 2 years ago
cdmlib-cache/src/main/resources/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml | ||
---|---|---|
179 | 179 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivationEvent"/> |
180 | 180 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivationEventType"/> |
181 | 181 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivedUnit"/> |
182 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent"/> |
|
183 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MediaSpecimen"/> |
|
184 | 182 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DeterminationEvent"/> |
185 | 183 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.FieldUnit"/> |
186 | 184 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.GatheringEvent"/> |
185 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent"/> |
|
186 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MediaSpecimen"/> |
|
187 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.OccurrenceStatus"/> |
|
187 | 188 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.PreservationMethod"/> |
188 | 189 |
|
189 | 190 |
<!-- Permission Package --> |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/CdmMetaData.java | ||
---|---|---|
53 | 53 |
* be handled by SCHEMA_VALIDATION.UPDATE |
54 | 54 |
* The last number represents the date of change. |
55 | 55 |
*/ |
56 |
private static final String dbSchemaVersion = CdmVersion.V_05_27_01.versionString;
|
|
56 |
private static final String dbSchemaVersion = CdmVersion.V_05_29_00.versionString;
|
|
57 | 57 |
|
58 | 58 |
public enum CdmVersion { |
59 | 59 |
V_05_12_00("5.12.0.0.20191202"), |
... | ... | |
72 | 72 |
V_05_25_00("5.25.0.0.20210609"), |
73 | 73 |
V_05_25_01("5.25.1.0.20210702"), |
74 | 74 |
V_05_27_00("5.27.0.0.20210913"), |
75 |
V_05_27_01("5.27.1.0.20210922") |
|
75 |
V_05_27_01("5.27.1.0.20210922"), |
|
76 |
V_05_29_00("5.29.0.0.20211122") |
|
76 | 77 |
; |
77 | 78 |
private String versionString; |
78 | 79 |
private CdmVersion(String versionString){ |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DerivedUnit.java | ||
---|---|---|
18 | 18 |
import javax.persistence.ManyToOne; |
19 | 19 |
import javax.persistence.OneToMany; |
20 | 20 |
import javax.persistence.Transient; |
21 |
import javax.validation.constraints.NotNull; |
|
21 | 22 |
import javax.xml.bind.annotation.XmlAccessType; |
22 | 23 |
import javax.xml.bind.annotation.XmlAccessorType; |
23 | 24 |
import javax.xml.bind.annotation.XmlElement; |
... | ... | |
37 | 38 |
import org.hibernate.search.annotations.IndexedEmbedded; |
38 | 39 |
|
39 | 40 |
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; |
41 |
import eu.etaxonomy.cdm.model.EntityCollectionSetterAdapter; |
|
42 |
import eu.etaxonomy.cdm.model.EntityCollectionSetterAdapter.SetterAdapterException; |
|
40 | 43 |
import eu.etaxonomy.cdm.model.molecular.DnaSample; |
41 | 44 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation; |
42 | 45 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
46 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
47 |
import eu.etaxonomy.cdm.model.term.DefinedTerm; |
|
43 | 48 |
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy; |
44 | 49 |
import eu.etaxonomy.cdm.strategy.cache.occurrence.DerivedUnitDefaultCacheStrategy; |
45 | 50 |
|
... | ... | |
68 | 73 |
"preservation", |
69 | 74 |
"exsiccatum", |
70 | 75 |
"originalLabelInfo", |
71 |
"specimenTypeDesignations" |
|
76 |
"specimenTypeDesignations", |
|
77 |
"status" |
|
72 | 78 |
}) |
73 | 79 |
@XmlRootElement(name = "DerivedUnit") |
74 | 80 |
@Entity |
... | ... | |
144 | 150 |
@Cascade({ CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE }) |
145 | 151 |
private final Set<SpecimenTypeDesignation> specimenTypeDesignations = new HashSet<SpecimenTypeDesignation>(); |
146 | 152 |
|
153 |
@XmlElementWrapper(name = "OccurrenceStatuses") |
|
154 |
@XmlElement(name = "OccurrenceStatus") |
|
155 |
@OneToMany(fetch= FetchType.LAZY, mappedBy = "unit", orphanRemoval=true) |
|
156 |
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE,CascadeType.DELETE}) |
|
157 |
@NotNull |
|
158 |
@IndexedEmbedded(depth=1) |
|
159 |
private Set<OccurrenceStatus> status = new HashSet<>(); |
|
147 | 160 |
|
148 | 161 |
//*** attributes valid only for preserved specimen (PreservedSpecimen, Fossil, DnaSample) |
149 | 162 |
|
... | ... | |
369 | 382 |
} |
370 | 383 |
} |
371 | 384 |
|
385 |
//** Status **/ |
|
386 |
|
|
387 |
/** |
|
388 |
* Returns the set of {@link OccurrenceStatus occurrence status} assigned |
|
389 |
* to <i>this</i> unit. |
|
390 |
* This includes the occurrence status type of the occurrence status. |
|
391 |
* |
|
392 |
* @see OccurrenceStatus |
|
393 |
*/ |
|
394 |
public Set<OccurrenceStatus> getStatus() { |
|
395 |
if(status == null) { |
|
396 |
this.status = new HashSet<>(); |
|
397 |
} |
|
398 |
return status; |
|
399 |
} |
|
400 |
|
|
401 |
/** |
|
402 |
* Adds a new {@link OccurrenceStatus occurrence status} |
|
403 |
* to <i>this</i> unit's set of occurrence status. |
|
404 |
* |
|
405 |
* @param nomStatus the occurrence status to be added |
|
406 |
* @see #getStatus() |
|
407 |
*/ |
|
408 |
public void addStatus(OccurrenceStatus occStatus) { |
|
409 |
this.status.add(occStatus); |
|
410 |
if (!this.equals(occStatus.getUnit())){ |
|
411 |
occStatus.setUnit(this); |
|
412 |
} |
|
413 |
} |
|
414 |
public OccurrenceStatus addStatus(DefinedTerm statusType, Reference citation, String microCitation) { |
|
415 |
OccurrenceStatus newStatus = OccurrenceStatus.NewInstance(statusType, citation, microCitation); |
|
416 |
addStatus(newStatus); |
|
417 |
return newStatus; |
|
418 |
} |
|
419 |
|
|
420 |
/** |
|
421 |
* Removes one element from the set of occurrence status of <i>this</i> unit. |
|
422 |
* |
|
423 |
* @param occStatus the occurrence status of <i>this</i> unit which should be deleted |
|
424 |
* @see #getStatus() |
|
425 |
*/ |
|
426 |
public void removeStatus(OccurrenceStatus nomStatus) { |
|
427 |
//TODO to be implemented? |
|
428 |
logger.warn("not yet fully implemented?"); |
|
429 |
this.status.remove(nomStatus); |
|
430 |
} |
|
431 |
|
|
432 |
public void setStatus(Set<OccurrenceStatus> nomStatus) throws SetterAdapterException { |
|
433 |
new EntityCollectionSetterAdapter<DerivedUnit, OccurrenceStatus>(DerivedUnit.class, OccurrenceStatus.class, "status", "addStatus", "removeStatus").setCollection(this, nomStatus); |
|
434 |
} |
|
435 |
|
|
436 |
// ****************** METHODS ********************************************/ |
|
437 |
|
|
372 | 438 |
public String getMostSignificantIdentifier() { |
373 | 439 |
if (isNotBlank(getAccessionNumber())) { |
374 | 440 |
return getAccessionNumber(); |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/OccurrenceStatus.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 |
package eu.etaxonomy.cdm.model.occurrence; |
|
10 |
|
|
11 |
import javax.persistence.Entity; |
|
12 |
import javax.persistence.FetchType; |
|
13 |
import javax.persistence.ManyToOne; |
|
14 |
import javax.xml.bind.annotation.XmlAccessType; |
|
15 |
import javax.xml.bind.annotation.XmlAccessorType; |
|
16 |
import javax.xml.bind.annotation.XmlElement; |
|
17 |
import javax.xml.bind.annotation.XmlIDREF; |
|
18 |
import javax.xml.bind.annotation.XmlSchemaType; |
|
19 |
import javax.xml.bind.annotation.XmlType; |
|
20 |
|
|
21 |
import org.apache.log4j.Logger; |
|
22 |
import org.hibernate.envers.Audited; |
|
23 |
|
|
24 |
import eu.etaxonomy.cdm.model.common.SingleSourcedEntityBase; |
|
25 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
26 |
import eu.etaxonomy.cdm.model.term.DefinedTerm; |
|
27 |
|
|
28 |
/** |
|
29 |
* The class representing the assignment of a occurrence status to a |
|
30 |
* {@link DerivedUnit derived unit}. This includes an {@link OccurrenceStatusType occurrence status type} |
|
31 |
* (for instance "destroyed", "lost" or "not seen by ..."). |
|
32 |
* |
|
33 |
* @author m.doering |
|
34 |
* @since 08-Nov-2007 13:06:39 |
|
35 |
*/ |
|
36 |
@XmlAccessorType(XmlAccessType.FIELD) |
|
37 |
@XmlType(name = "OccurrenceStatus", propOrder = { |
|
38 |
"unit", |
|
39 |
"type" |
|
40 |
}) |
|
41 |
@Entity |
|
42 |
@Audited |
|
43 |
public class OccurrenceStatus |
|
44 |
extends SingleSourcedEntityBase { |
|
45 |
|
|
46 |
private static final long serialVersionUID = 623891726208046243L; |
|
47 |
private static Logger logger = Logger.getLogger(OccurrenceStatus.class); |
|
48 |
|
|
49 |
@XmlElement(name = "OccurrenceStatusType") |
|
50 |
@XmlIDREF |
|
51 |
@XmlSchemaType(name = "IDREF") |
|
52 |
@ManyToOne(fetch = FetchType.LAZY) |
|
53 |
private DefinedTerm type; |
|
54 |
|
|
55 |
@XmlElement(name = "Name") |
|
56 |
@XmlIDREF |
|
57 |
@XmlSchemaType(name = "IDREF") |
|
58 |
@ManyToOne(fetch = FetchType.LAZY) |
|
59 |
private DerivedUnit unit; |
|
60 |
|
|
61 |
// ************************** FACTORY *********************************/ |
|
62 |
|
|
63 |
/** |
|
64 |
* Creates a new occurrence status instance with a given |
|
65 |
* occurrence status type. |
|
66 |
* |
|
67 |
* @see #OccurrenceStatus() |
|
68 |
*/ |
|
69 |
public static OccurrenceStatus NewInstance(DefinedTerm occurrenceStatusType){ |
|
70 |
return NewInstance(occurrenceStatusType, null, null); |
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
/** |
|
75 |
* Creates a new occurrence status instance with a given |
|
76 |
* occurrence status type. |
|
77 |
* |
|
78 |
* @see #OccurrenceStatus() |
|
79 |
*/ |
|
80 |
public static OccurrenceStatus NewInstance(DefinedTerm occurrenceStatusType, Reference citation, String microCitation){ |
|
81 |
OccurrenceStatus status = new OccurrenceStatus(); |
|
82 |
status.setType(occurrenceStatusType); |
|
83 |
status.setCitation(citation); |
|
84 |
status.setCitationMicroReference(microCitation); |
|
85 |
return status; |
|
86 |
} |
|
87 |
|
|
88 |
// ************************ CONSTRUCTOR *************************/ |
|
89 |
|
|
90 |
protected OccurrenceStatus() { |
|
91 |
super(); |
|
92 |
} |
|
93 |
|
|
94 |
// ************************ GETTER / SETTER ************************/ |
|
95 |
|
|
96 |
public DerivedUnit getUnit() { |
|
97 |
return unit; |
|
98 |
} |
|
99 |
protected void setUnit(DerivedUnit unit) { |
|
100 |
if (this.unit != null && !this.unit.equals(unit)){ |
|
101 |
this.unit.removeStatus(this); |
|
102 |
} |
|
103 |
this.unit = unit; |
|
104 |
if (unit != null){ |
|
105 |
unit.addStatus(this); |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
/** |
|
110 |
* Returns the occurrence status type of <i>this</i> |
|
111 |
* occurrence status. |
|
112 |
*/ |
|
113 |
public DefinedTerm getType(){ |
|
114 |
return this.type; |
|
115 |
} |
|
116 |
/** |
|
117 |
* @see #getType() |
|
118 |
*/ |
|
119 |
public void setType(DefinedTerm type){ |
|
120 |
this.type = type; |
|
121 |
} |
|
122 |
|
|
123 |
//*********************** CLONE ********************************************************/ |
|
124 |
|
|
125 |
/** |
|
126 |
* Clones <i>this</i> occurrence status. This is a shortcut that enables to create |
|
127 |
* a new instance that differs only slightly from <i>this</i> occurrence status by |
|
128 |
* modifying only some of the attributes. |
|
129 |
* |
|
130 |
* @see eu.etaxonomy.cdm.model.common.SingleSourcedEntityBase#clone() |
|
131 |
* @see java.lang.Object#clone() |
|
132 |
*/ |
|
133 |
@Override |
|
134 |
public OccurrenceStatus clone() { |
|
135 |
try { |
|
136 |
OccurrenceStatus result = (OccurrenceStatus)super.clone(); |
|
137 |
//no changes to: type |
|
138 |
return result; |
|
139 |
} catch (CloneNotSupportedException e) { |
|
140 |
logger.warn("Object does not implement cloneable"); |
|
141 |
e.printStackTrace(); |
|
142 |
return null; |
|
143 |
} |
|
144 |
} |
|
145 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/DefinedTerm.java | ||
---|---|---|
69 | 69 |
public static final UUID uuidLastScrutiny = UUID.fromString("b4495910-28e9-4a49-86cf-a0476c78f460"); |
70 | 70 |
public static final UUID uuidAuthorOfSubtree = UUID.fromString("c2c7e9b7-d6a7-48a0-b13f-a7a2e2a9b8c9"); |
71 | 71 |
|
72 |
protected static Map<UUID, DefinedTerm> termMap = null; |
|
72 |
//Occurrence status type |
|
73 |
public static final UUID uuidNotExtant = UUID.fromString("6b4888d8-194a-45c3-a16a-e5b5465a8f3d"); |
|
74 |
public static final UUID uuidDestroyed = UUID.fromString("d41cce17-9e68-47f8-904f-fcea1b0029bc"); |
|
75 |
public static final UUID uuidLost = UUID.fromString("9d82974f-9535-432d-af5b-f233016abe51"); |
|
76 |
public static final UUID uuidNotFound = UUID.fromString("c7df83c2-6e4b-42e8-8fa7-c07720a78e2b"); |
|
77 |
public static final UUID uuidNotSeen = UUID.fromString("44f5f025-8814-49dd-b1ef-17557a13ea3e"); |
|
78 |
public static final UUID uuidNotPreserved = UUID.fromString("87447824-06d8-4449-abe6-0c11ed77fdc9"); |
|
79 |
public static final UUID uuidDriedOut = UUID.fromString("01fe0283-0da6-46a5-a050-22f9be338461"); |
|
73 | 80 |
|
81 |
protected static Map<UUID, DefinedTerm> termMap = null; |
|
74 | 82 |
|
75 |
protected static DefinedTerm getTermByUuid(UUID uuid){
|
|
83 |
public static DefinedTerm getTermByUuid(UUID uuid){
|
|
76 | 84 |
if (termMap == null || termMap.isEmpty()){ |
77 | 85 |
return getTermByClassAndUUID(DefinedTerm.class, uuid); |
78 | 86 |
} else{ |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/TermType.java | ||
---|---|---|
503 | 503 |
@XmlEnumValue("TermRelationType") |
504 | 504 |
TermRelationType(UUID.fromString("2541032f-3d24-4ce0-a414-f028054f98ef"), "Term relation type", "TERT", null), |
505 | 505 |
|
506 |
//42 |
|
507 |
/** |
|
508 |
* The type for occurrence status. |
|
509 |
**/ |
|
510 |
@XmlEnumValue("OccurrenceStatusType") |
|
511 |
OccurrenceStatusType(UUID.fromString("c50a977a-e697-4973-9514-08aeb0d05483"), "Occurrence status type", "OST", null), |
|
512 |
|
|
506 | 513 |
; |
507 | 514 |
|
508 | 515 |
|
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/term/VocabularyEnum.java | ||
---|---|---|
92 | 92 |
MediaSpecimenKindOfUnit("56f47c83-8d42-404a-88fc-03c57b560f6d", DefinedTerm.class), |
93 | 93 |
IdentifierType("67d91839-484e-4183-8b4c-6a4a80dfc066", DefinedTerm.class), |
94 | 94 |
DnaQualityType("55746f7b-78a8-4e5f-8e70-ee9ce047c835", OrderedTerm.class), |
95 |
TaxonNodeAgentRelationType("0aa8e0c6-c7b5-42dd-91b7-0bd273a64b2c", DefinedTerm.class) |
|
95 |
TaxonNodeAgentRelationType("0aa8e0c6-c7b5-42dd-91b7-0bd273a64b2c", DefinedTerm.class), |
|
96 |
OccurrenceStatusType("6d06b750-4f48-42de-85b5-220256e4e5ba", DefinedTerm.class), |
|
96 | 97 |
; |
97 | 98 |
|
98 | 99 |
private UUID uuid; |
cdmlib-model/src/main/resources/terms/OccurrenceStatusType.csv | ||
---|---|---|
1 |
"6d06b750-4f48-42de-85b5-220256e4e5ba",,"Occurrence Status Type","Occurrence Status Type","OST","0" |
|
2 |
"6b4888d8-194a-45c3-a16a-e5b5465a8f3d",,"not extant","not extant","" |
|
3 |
"d41cce17-9e68-47f8-904f-fcea1b0029bc",,"destroyed","destroyed","" |
|
4 |
"9d82974f-9535-432d-af5b-f233016abe51",,"lost","lost","" |
|
5 |
"c7df83c2-6e4b-42e8-8fa7-c07720a78e2b",,"not found","not found","" |
|
6 |
"44f5f025-8814-49dd-b1ef-17557a13ea3e",,"not seen","not seen","" |
|
7 |
"87447824-06d8-4449-abe6-0c11ed77fdc9",,"not preserved","not preserved","" |
|
8 |
"01fe0283-0da6-46a5-a050-22f9be338461",,"dried out","dried out (for specimens in alcohol)","" |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/data/FullCoverageDataGenerator.java | ||
---|---|---|
828 | 828 |
preservation.setTemperature(22.4); |
829 | 829 |
mediaSpecimen.setPreservation(preservation); |
830 | 830 |
mediaSpecimen.setOriginalLabelInfo("Original Label Info"); |
831 |
mediaSpecimen.addStatus(DefinedTerm.getTermByUuid(DefinedTerm.uuidDestroyed), getReference(), "123"); |
|
831 | 832 |
handleIdentifiableEntity(mediaSpecimen); |
832 | 833 |
|
833 | 834 |
//DerivationEvent |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/CdmUpdater.java | ||
---|---|---|
17 | 17 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
18 | 18 |
import eu.etaxonomy.cdm.database.CdmDataSource; |
19 | 19 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
20 |
import eu.etaxonomy.cdm.database.update.v525_527.SchemaUpdater_5270_5271;
|
|
20 |
import eu.etaxonomy.cdm.database.update.v527_529.SchemaUpdater_5271_5290;
|
|
21 | 21 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData; |
22 | 22 |
|
23 | 23 |
/** |
... | ... | |
66 | 66 |
private static final Logger logger = Logger.getLogger(CdmUpdater.class); |
67 | 67 |
|
68 | 68 |
private static final ISchemaUpdater getCurrentSchemaUpdater() { |
69 |
return SchemaUpdater_5270_5271.NewInstance();
|
|
69 |
return SchemaUpdater_5271_5290.NewInstance();
|
|
70 | 70 |
} |
71 | 71 |
|
72 | 72 |
public static CdmUpdater NewInstance(){ |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/MapTableCreator.java | ||
---|---|---|
31 | 31 |
} |
32 | 32 |
|
33 | 33 |
protected MapTableCreator(List<ISchemaUpdaterStep> stepList, String stepName, String MN_tableName, String firstTableName, String firstTableAlias, String secondTableName, String secondTableAlias, String mapKeyTableName, boolean includeAudTable) { |
34 |
super(stepList, stepName, MN_tableName, new ArrayList<>(), new ArrayList<>(), new ArrayList<Object>(), new ArrayList<Boolean>(), new ArrayList<String>(), includeAudTable, false, false, false, false); |
|
34 |
super(stepList, stepName, MN_tableName, new ArrayList<>(), new ArrayList<>(), new ArrayList<Object>(), new ArrayList<Boolean>(), new ArrayList<String>(), includeAudTable, false, false, false, false, false);
|
|
35 | 35 |
this.firstTableName = firstTableName; |
36 | 36 |
this.secondTableName = secondTableName; |
37 | 37 |
this.firstTableAlias = (firstTableAlias != null )? firstTableAlias : firstTableName ; |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/MnTableCreator.java | ||
---|---|---|
102 | 102 |
super(stepList, stepName, makeAlias(firstTableName, firstTableAlias) + "_" + makeAlias(secondTableName, secondTableAlias), |
103 | 103 |
Arrays.asList(columnNames), Arrays.asList(columnTypes), defaultValues, |
104 | 104 |
isNull, new ArrayList<>(), includeAudTable, |
105 |
includeCdmBaseAttributes, includeAnnotatableEntity, includeIdentifiableEntity, false); |
|
105 |
includeCdmBaseAttributes, includeAnnotatableEntity, includeIdentifiableEntity, false, false);
|
|
106 | 106 |
this.firstTableName = firstTableName; |
107 | 107 |
this.secondTableName = secondTableName; |
108 | 108 |
this.firstTableAlias = makeAlias(firstTableName, firstTableAlias) ; |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/TableCreator.java | ||
---|---|---|
39 | 39 |
private final boolean includeCdmBaseAttributes; |
40 | 40 |
private final boolean includeIdentifiableEntity; |
41 | 41 |
private final boolean includeAnnotatableEntity; |
42 |
private final boolean includeSingleSourcedEntity; |
|
42 | 43 |
private boolean includeEventBase; |
43 | 44 |
private final boolean excludeVersionableAttributes; |
44 | 45 |
protected List<ColumnAdder> columnAdders = new ArrayList<>(); |
... | ... | |
50 | 51 |
|
51 | 52 |
|
52 | 53 |
public static final TableCreator NewInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, List<String> columnNames, List<String> columnTypes, boolean includeAudTable, boolean includeCdmBaseAttributes){ |
53 |
return new TableCreator(stepList, stepName, tableName, columnNames, columnTypes, null, null, null, includeAudTable, includeCdmBaseAttributes, false, false, false); |
|
54 |
return new TableCreator(stepList, stepName, tableName, columnNames, columnTypes, null, null, null, includeAudTable, includeCdmBaseAttributes, false, false, false, false);
|
|
54 | 55 |
} |
55 | 56 |
|
56 | 57 |
public static final TableCreator NewInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable, boolean includeCdmBaseAttributes){ |
57 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, includeCdmBaseAttributes, false, false, false); |
|
58 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, includeCdmBaseAttributes, false, false, false, false);
|
|
58 | 59 |
} |
59 | 60 |
|
60 | 61 |
public static final TableCreator NewAuditedCdmBaseInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables){ |
61 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), true, true, false, false, true); |
|
62 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), true, true, false, false, true, false);
|
|
62 | 63 |
} |
63 | 64 |
|
64 | 65 |
public static final TableCreator NewNonVersionableInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables){ |
65 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), false, true, false, false, true); |
|
66 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), false, true, false, false, true, false);
|
|
66 | 67 |
} |
67 | 68 |
|
68 | 69 |
public static final TableCreator NewVersionableInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
69 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, false, false, false); |
|
70 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, false, false, false, false);
|
|
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
public static final TableCreator NewAnnotatableInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
73 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false); |
|
74 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false, false); |
|
75 |
} |
|
76 |
|
|
77 |
public static final TableCreator NewSingleSourcedInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
|
78 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false, true); |
|
74 | 79 |
} |
75 | 80 |
|
76 | 81 |
public static final TableCreator NewEventInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
77 |
TableCreator result = new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false); |
|
82 |
TableCreator result = new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, false, false, false);
|
|
78 | 83 |
result.includeEventBase = true; |
79 | 84 |
return result; |
80 | 85 |
} |
81 | 86 |
|
82 | 87 |
public static final TableCreator NewIdentifiableInstance(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, String[] columnNames, String[] columnTypes, String[] referencedTables, boolean includeAudTable){ |
83 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, true, false); |
|
88 |
return new TableCreator(stepList, stepName, tableName, Arrays.asList(columnNames), Arrays.asList(columnTypes), null, null, Arrays.asList(referencedTables), includeAudTable, true, true, true, false, false);
|
|
84 | 89 |
} |
85 | 90 |
|
86 | 91 |
protected TableCreator(List<ISchemaUpdaterStep> stepList, String stepName, String tableName, List<String> columnNames, List<String> columnTypes, List<Object> defaultValues, List<Boolean> isNotNull, List<String> referencedTables, |
87 |
boolean includeAudTable, boolean includeCdmBaseAttributes, boolean includeAnnotatableEntity, boolean includeIdentifiableEntity, boolean excludeVersionableAttributes) { |
|
92 |
boolean includeAudTable, boolean includeCdmBaseAttributes, boolean includeAnnotatableEntity, boolean includeIdentifiableEntity, boolean excludeVersionableAttributes, boolean includeSingleSourcedEntity) {
|
|
88 | 93 |
super(stepList, stepName, tableName, includeAudTable); |
89 | 94 |
this.columnNames = columnNames; |
90 | 95 |
this.columnTypes = columnTypes; |
... | ... | |
95 | 100 |
this.includeAnnotatableEntity = includeAnnotatableEntity; |
96 | 101 |
this.includeIdentifiableEntity = includeIdentifiableEntity; |
97 | 102 |
this.excludeVersionableAttributes = excludeVersionableAttributes; |
103 |
this.includeSingleSourcedEntity = includeSingleSourcedEntity; |
|
98 | 104 |
makeColumnAdders(); |
99 | 105 |
makeMnTables(mnTablesStepList, this.tableName, this.includeAnnotatableEntity, this.includeIdentifiableEntity); |
100 | 106 |
} |
... | ... | |
220 | 226 |
if (this.includeIdentifiableEntity){ |
221 | 227 |
updateQuery += "lsid_authority varchar(255), lsid_lsid varchar(255), lsid_namespace varchar(255), lsid_object varchar(255), lsid_revision varchar(255), protectedtitlecache bit not null, titleCache varchar(255),"; |
222 | 228 |
} |
229 |
if (this.includeSingleSourcedEntity){ |
|
230 |
updateQuery += "source_id integer, "; |
|
231 |
} |
|
223 | 232 |
//specific columns |
224 | 233 |
updateQuery += getColumnsSql(tableName, datasource, monitor); |
225 | 234 |
|
... | ... | |
302 | 311 |
makeForeignKey(tableName, datasource, monitor, attribute, |
303 | 312 |
referencedTable, caseType, result); |
304 | 313 |
} |
314 |
if (this.includeSingleSourcedEntity){ |
|
315 |
//source |
|
316 |
String attribute = "source_id"; |
|
317 |
String referencedTable = "OriginalSourceBase"; |
|
318 |
makeForeignKey(tableName, datasource, monitor, attribute, |
|
319 |
referencedTable, caseType, result); |
|
320 |
} |
|
321 |
|
|
305 | 322 |
for (ColumnAdder adder : this.columnAdders){ |
306 | 323 |
if (adder.getReferencedTable() != null){ |
307 | 324 |
makeForeignKey(tableName, datasource, monitor, adder.getNewColumnName(), |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v527_529/SchemaUpdater_5271_5290.java | ||
---|---|---|
16 | 16 |
import eu.etaxonomy.cdm.database.update.ISchemaUpdater; |
17 | 17 |
import eu.etaxonomy.cdm.database.update.ISchemaUpdaterStep; |
18 | 18 |
import eu.etaxonomy.cdm.database.update.SchemaUpdaterBase; |
19 |
import eu.etaxonomy.cdm.database.update.TableCreator; |
|
19 | 20 |
import eu.etaxonomy.cdm.database.update.v525_527.SchemaUpdater_5270_5271; |
20 | 21 |
import eu.etaxonomy.cdm.model.metadata.CdmMetaData.CdmVersion; |
21 | 22 |
|
... | ... | |
29 | 30 |
private static final Logger logger = Logger.getLogger(SchemaUpdater_5271_5290.class); |
30 | 31 |
|
31 | 32 |
private static final CdmVersion startSchemaVersion = CdmVersion.V_05_27_01; |
32 |
private static final CdmVersion endSchemaVersion = CdmVersion.V_05_27_01;
|
|
33 |
private static final CdmVersion endSchemaVersion = CdmVersion.V_05_29_00;
|
|
33 | 34 |
|
34 | 35 |
// ********************** FACTORY METHOD ************************************* |
35 | 36 |
|
... | ... | |
50 | 51 |
protected List<ISchemaUpdaterStep> getUpdaterList() { |
51 | 52 |
|
52 | 53 |
String stepName; |
54 |
String tableName; |
|
53 | 55 |
|
54 | 56 |
List<ISchemaUpdaterStep> stepList = new ArrayList<>(); |
55 | 57 |
|
58 |
//#2506 status for specimen |
|
59 |
stepName = "Add status for specimen"; |
|
60 |
tableName = "OccurrenceStatus"; |
|
61 |
String[] columnNames = new String[]{"unit_id","type_id"}; |
|
62 |
String[] columnTypes = new String[]{"int","int"}; |
|
63 |
String[] referencedTables = new String[]{"SpecimenAndObservationBase","DefinedTermBase"}; |
|
64 |
TableCreator.NewSingleSourcedInstance(stepList, stepName, tableName, columnNames, columnTypes, referencedTables, INCLUDE_AUDIT); |
|
65 |
|
|
56 | 66 |
return stepList; |
57 | 67 |
} |
58 | 68 |
} |
cdmlib-persistence/src/main/resources/eu/etaxonomy/cdm/hibernate.cfg.xml | ||
---|---|---|
168 | 168 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivationEvent"/> |
169 | 169 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivationEventType"/> |
170 | 170 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivedUnit"/> |
171 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent"/> |
|
172 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MediaSpecimen"/> |
|
173 | 171 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DeterminationEvent"/> |
174 | 172 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.FieldUnit"/> |
175 | 173 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.GatheringEvent"/> |
174 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent"/> |
|
175 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MediaSpecimen"/> |
|
176 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.OccurrenceStatus"/> |
|
176 | 177 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.PreservationMethod"/> |
177 | 178 |
|
178 | 179 |
<!-- Permission Package --> |
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/TestModelUpdate.java | ||
---|---|---|
47 | 47 |
DbSchemaValidation schema = DbSchemaValidation.VALIDATE; |
48 | 48 |
|
49 | 49 |
DatabaseTypeEnum dbType = DatabaseTypeEnum.MySQL; |
50 |
String database = (schema == DbSchemaValidation.VALIDATE ? "cdm523" : "cdm527");
|
|
50 |
String database = (schema == DbSchemaValidation.VALIDATE ? "cdm527" : "cdm529");
|
|
51 | 51 |
// database = "cdm_test1"; |
52 | 52 |
|
53 | 53 |
CdmDataSource dataSource = getDatasource(dbType, database); |
cdmlib-test/src/test/resources/eu/etaxonomy/cdm/hibernate.cfg.xml | ||
---|---|---|
168 | 168 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivationEvent"/> |
169 | 169 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivationEventType"/> |
170 | 170 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DerivedUnit"/> |
171 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent"/> |
|
172 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MediaSpecimen"/> |
|
173 | 171 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.DeterminationEvent"/> |
174 | 172 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.FieldUnit"/> |
175 | 173 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.GatheringEvent"/> |
174 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MaterialOrMethodEvent"/> |
|
175 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.MediaSpecimen"/> |
|
176 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.OccurrenceStatus"/> |
|
176 | 177 |
<mapping class="eu.etaxonomy.cdm.model.occurrence.PreservationMethod"/> |
177 | 178 |
|
178 | 179 |
<!-- Permission Package --> |
Also available in: Unified diff
ref #2506 model change and update script for occurrence status