Project

General

Profile

Revision 5a36818d

ID5a36818d6cb61f98977ba4405c371d6abfabb698
Parent 35a4f2f3
Child 700aa970

Added by Andreas Müller 8 months ago

ref #8724 handle taxon in CdmLinkSource

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/CdmLinkBase.java
9 9
package eu.etaxonomy.cdm.model.common;
10 10

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

  
19 24
import org.hibernate.envers.Audited;
20 25

  
26
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
27

  
21 28
/**
22 29
 * Base class for subclasses linking to other CDM objects.
23 30
 *
......
35 42

  
36 43
    private static final long serialVersionUID = -1418100748281536524L;
37 44

  
45
    @XmlElement(name = "Taxon")
46
    @XmlIDREF
47
    @XmlSchemaType(name = "IDREF")
48
    @ManyToOne(fetch = FetchType.LAZY)
49
    protected TaxonBase<?> taxon;
50

  
38 51
// ************************* CLONE *******************/
39 52

  
40 53
    @Override
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IntextReference.java
68 68
    @ManyToOne(fetch = FetchType.LAZY)
69 69
	private TaxonName taxonName;
70 70

  
71
    @XmlElement(name = "Taxon")
72
    @XmlIDREF
73
    @XmlSchemaType(name = "IDREF")
74
    @ManyToOne(fetch = FetchType.LAZY)
75
	private TaxonBase<?> taxon;
76

  
77 71
    @XmlElement(name = "Occurrence")
78 72
    @XmlIDREF
79 73
    @XmlSchemaType(name = "IDREF")
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/CdmLinkSource.java
25 25
import eu.etaxonomy.cdm.model.common.CdmLinkBase;
26 26
import eu.etaxonomy.cdm.model.common.IntextReference;
27 27
import eu.etaxonomy.cdm.model.description.DescriptionBase;
28
import eu.etaxonomy.cdm.model.taxon.Taxon;
28 29

  
29 30
/**
30 31
 * Class to link to other CdmBase objects within the context of
......
86 87
     * @see IntextReference#getTarget()
87 88
     */
88 89
    public ICdmTarget getTarget() {
89
        if (description != null){
90
        if (taxon != null){
91
            return (Taxon)taxon;
92
        }else if (description != null){
90 93
            return description;
91 94
        }else{
92 95
            throw new IllegalStateException("CdmSource has no target object defined");
......
97 100
        target = CdmBase.deproxy(target);
98 101
        if (target instanceof DescriptionBase<?>){
99 102
            this.description = (DescriptionBase<?>)target;
103
        }else if (target instanceof Taxon){
104
            this.taxon = (Taxon)target;
100 105
        }else{
101 106
            throw new IllegalArgumentException("Target class not supported by CdmSource");
102 107
        }

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)