Project

General

Profile

Revision 027f931b

ID027f931b6395fe09f2fd314857ae913b2d5d75fd
Parent cbdcc8dd
Child 046711ec

Added by Andreas Müller 2 months ago

ref #9004, ref #6581 link TaxonNode to OriginalSource, not Reference and micro reference String

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNode.java
34 34
import javax.xml.bind.annotation.XmlIDREF;
35 35
import javax.xml.bind.annotation.XmlRootElement;
36 36
import javax.xml.bind.annotation.XmlSchemaType;
37
import javax.xml.bind.annotation.XmlTransient;
37 38
import javax.xml.bind.annotation.XmlType;
38 39
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
39 40

  
41
import org.apache.commons.lang3.StringUtils;
40 42
import org.apache.log4j.Logger;
41 43
import org.hibernate.LazyInitializationException;
42 44
import org.hibernate.annotations.Cascade;
......
59 61
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
60 62
import eu.etaxonomy.cdm.model.common.CdmBase;
61 63
import eu.etaxonomy.cdm.model.common.ITreeNode;
64
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
62 65
import eu.etaxonomy.cdm.model.common.Language;
63 66
import eu.etaxonomy.cdm.model.common.LanguageString;
64 67
import eu.etaxonomy.cdm.model.common.MultilanguageText;
65 68
import eu.etaxonomy.cdm.model.name.Rank;
66 69
import eu.etaxonomy.cdm.model.name.TaxonName;
70
import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
67 71
import eu.etaxonomy.cdm.model.reference.Reference;
68 72
import eu.etaxonomy.cdm.model.term.DefinedTerm;
69 73
import eu.etaxonomy.cdm.validation.Level3;
......
83 87
    "treeIndex",
84 88
    "sortIndex",
85 89
    "childNodes",
86
    "referenceForParentChildRelation",
87
    "microReferenceForParentChildRelation",
90
    "source",
91
//    "referenceForParentChildRelation",
92
//    "microReferenceForParentChildRelation",
88 93
    "countChildren",
89 94
    "agentRelations",
90 95
    "synonymToBeUsed",
......
151 156
    //see https://dev.e-taxonomy.eu/trac/ticket/4200
152 157
    private Integer sortIndex = -1;
153 158

  
154
	@XmlElement(name = "reference")
159
    //the source for this placement
160
    @XmlElement(name = "source")
155 161
    @XmlIDREF
156 162
    @XmlSchemaType(name = "IDREF")
157 163
    @ManyToOne(fetch = FetchType.LAZY)
164
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE, CascadeType.DELETE})
165
    private IdentifiableSource source;
166

  
167
//    @XmlElement(name = "reference")
168
//    @XmlIDREF
169
//    @XmlSchemaType(name = "IDREF")
170
    @XmlTransient
171
    @ManyToOne(fetch = FetchType.LAZY)
158 172
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
159 173
    private Reference referenceForParentChildRelation;
160 174

  
161
    @XmlElement(name = "microReference")
175
//    @XmlElement(name = "microReference")
176
    @XmlTransient
162 177
    private String microReferenceForParentChildRelation;
163 178

  
164 179
    @XmlElement(name = "countChildren")
......
296 311
        this.classification = classification;
297 312
    }
298 313

  
314
//************************* SOURCE *********************/
315

  
299 316
    @Override
317
    @XmlTransient
300 318
    public String getMicroReference() {
301
        return microReferenceForParentChildRelation;
319
        return source == null ? null : this.source.getCitationMicroReference();
302 320
    }
303 321
    public void setMicroReference(String microReference) {
304
        this.microReferenceForParentChildRelation = microReference;
322
        this.getSource(true).setCitationMicroReference(StringUtils.isBlank(microReference)? null : microReference);
323
        checkNullSource();
305 324
    }
306 325

  
307 326
    @Override
327
    @XmlTransient
308 328
    public Reference getReference() {
309
        return referenceForParentChildRelation;
329
        return (this.source == null) ? null : source.getCitation();
310 330
    }
331

  
311 332
    public void setReference(Reference reference) {
312
        this.referenceForParentChildRelation = reference;
333
        getSource(true).setCitation(reference);
334
        checkNullSource();
335
    }
336

  
337
    public IdentifiableSource getSource() {
338
        return source;
339
    }
340
    public void setSource(IdentifiableSource source) {
341
        this.source = source;
313 342
    }
314 343

  
344
    private void checkNullSource() {
345
        if (this.source != null && this.source.isEmpty()){
346
            this.source = null;
347
        }
348
    }
349

  
350
    private IdentifiableSource getSource(boolean createIfNotExist){
351
        if (this.source == null && createIfNotExist){
352
            this.source = IdentifiableSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource);
353
        }
354
        return source;
355
    }
356

  
357
//************************************************************/
358

  
315 359
    //countChildren
316 360
    public int getCountChildren() {
317 361
        return countChildren;
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v512_515/SchemaUpdater_5151_5152.java
62 62
		referencedTable = "ExternalLink";
63 63
		ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
64 64

  
65
        //9004
66
        stepName = "Add source to TaxonNode";
67
        tableName = "TaxonNode";
68
        newColumnName = "source_id";
69
        referencedTable = "OriginalSourceBase";
70
        ColumnAdder.NewIntegerInstance(stepList, stepName, tableName, newColumnName, INCLUDE_AUDIT, !NOT_NULL, referencedTable);
71

  
65 72
        return stepList;
66 73
    }
67 74

  
cdmlib-test/src/main/resources/dbscripts/001-cdm.h2.sql
4894 4894
    SORTINDEX INTEGER,
4895 4895
    TREEINDEX VARCHAR(255),
4896 4896
    COUNTCHILDREN INTEGER NOT NULL,
4897
    MICROREFERENCEFORPARENTCHILDRELATION VARCHAR(255),
4898
	STATUS VARCHAR(10),
4897
    STATUS VARCHAR(10),
4899 4898
	CREATEDBY_ID INTEGER,
4900 4899
    UPDATEDBY_ID INTEGER,
4901 4900
    CLASSIFICATION_ID INTEGER,
4902 4901
    PARENT_ID INTEGER,
4903
    REFERENCEFORPARENTCHILDRELATION_ID INTEGER,
4902
    MICROREFERENCEFORPARENTCHILDRELATION VARCHAR(255),
4903
	REFERENCEFORPARENTCHILDRELATION_ID INTEGER,
4904
    SOURCE_ID INTEGER,
4904 4905
    SYNONYMTOBEUSED_ID INTEGER,
4905 4906
    TAXON_ID INTEGER
4906 4907
);
......
4965 4966
    SORTINDEX INTEGER,
4966 4967
    TREEINDEX VARCHAR(255),
4967 4968
    COUNTCHILDREN INTEGER,
4968
    MICROREFERENCEFORPARENTCHILDRELATION VARCHAR(255),
4969 4969
	STATUS VARCHAR(10),
4970 4970
	CREATEDBY_ID INTEGER,
4971 4971
    UPDATEDBY_ID INTEGER,
4972 4972
    CLASSIFICATION_ID INTEGER,
4973 4973
    PARENT_ID INTEGER,
4974
    REFERENCEFORPARENTCHILDRELATION_ID INTEGER,
4974
    MICROREFERENCEFORPARENTCHILDRELATION VARCHAR(255),
4975
	REFERENCEFORPARENTCHILDRELATION_ID INTEGER,
4976
    SOURCE_ID INTEGER,
4975 4977
    SYNONYMTOBEUSED_ID INTEGER,
4976 4978
    TAXON_ID INTEGER
4977 4979
);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)