Project

General

Profile

« Previous | Next » 

Revision 63228380

Added by Andreas Müller almost 9 years ago

more getters/adders, update script, vocabulary and test vocabulary for TaxonNodeAgentRelation #3583

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonNodeAgentRelation.java
12 12
import javax.persistence.Entity;
13 13
import javax.persistence.FetchType;
14 14
import javax.persistence.ManyToOne;
15
import javax.validation.constraints.NotNull;
15 16
import javax.xml.bind.annotation.XmlAccessType;
16 17
import javax.xml.bind.annotation.XmlAccessorType;
17 18
import javax.xml.bind.annotation.XmlElement;
......
29 30
import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
30 31
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
31 32
import eu.etaxonomy.cdm.model.common.DefinedTerm;
33
import eu.etaxonomy.cdm.model.common.TermType;
32 34

  
33 35
/**
34 36
 * This class relates a TaxonNode (Taxon within it's given publication context)
......
58 60
    @XmlSchemaType(name = "IDREF")
59 61
    @ManyToOne(fetch = FetchType.LAZY)
60 62
//    @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})  //the
63
    @NotNull
61 64
    private TaxonNode taxonNode;
62 65

  
63 66
    @XmlElement(name = "Agent")
......
65 68
    @XmlSchemaType(name = "IDREF")
66 69
    @ManyToOne(fetch = FetchType.LAZY)
67 70
    @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE})
71
    @NotNull
68 72
    private TeamOrPersonBase<?> agent;
69 73

  
70 74
    @XmlElement(name = "Type")
......
73 77
    @ManyToOne(fetch = FetchType.EAGER)
74 78
    private DefinedTerm type;
75 79

  
76
    private TaxonNodeAgentRelation(){};
80
    protected static TaxonNodeAgentRelation NewInstance(TaxonNode taxonNode, TeamOrPersonBase<?> agent, DefinedTerm type){
81
        TaxonNodeAgentRelation result = new TaxonNodeAgentRelation();
82
        result.taxonNode = taxonNode;
83
        result.agent = agent;
84
        result.setType(type);
85
        taxonNode.addAgent(result);
86
        return result;
87
    }
88

  
89
    private TaxonNodeAgentRelation(){}
77 90

  
78 91
//********************* GETTER / SETTER **********************/
79 92

  
80 93
    public TaxonNode getTaxonNode() {
81 94
        return taxonNode;
82 95
    }
83
    public void setTaxonNode(TaxonNode taxonNode) {
96
    protected void setTaxonNode(TaxonNode taxonNode) {
84 97
        this.taxonNode = taxonNode;
85 98
    }
86 99

  
......
95 108
        return type;
96 109
    }
97 110
    public void setType(DefinedTerm type) {
111
        if (type.getTermType() != TermType.TaxonNodeAgentRelationType){
112
            throw new IllegalArgumentException("Only TaxonNode Agent Relation Type terms are allowed as TaxonNodeAgentRelation.type");
113
        }
98 114
        this.type = type;
99 115
    }
100 116

  
117
//************************ to String **********************************/
118

  
119

  
120
    @Override
121
    public String toString() {
122
        return "TaxonNodeAgentRelation [taxonNode=" + taxonNode +
123
                ", agent=" + agent + ", type=" + type + "]";
124
    }
125

  
101 126

  
102 127
//************************** clone *******************************************/
103 128

  

Also available in: Unified diff