Project

General

Profile

« Previous | Next » 

Revision 95449e99

Added by Andreas Müller about 16 years ago

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonNameBase.java
651 651
		return this.getHomotypicalGroup().getTypeDesignations();
652 652
	}
653 653
	
654
	// Rank comparison shortcuts
654
// ***********
655
	public boolean isHomotypic(TaxonNameBase homoTypicName) {
656
		if (homoTypicName == null) {
657
			return false;
658
		}
659
		HomotypicalGroup homotypicGroup = homoTypicName.getHomotypicalGroup();
660
		if (homotypicGroup == null || this.getHomotypicalGroup() == null) {
661
			return false;
662
		}
663
		if (homotypicGroup.equals(this.getHomotypicalGroup())) {
664
			return true;
665
		}
666
		return false;
667
	}
668
	
669
	
670
	
671
//*********  Rank comparison shortcuts   ********************//
655 672
	@Transient
656 673
	public boolean isSupraGeneric() {
657 674
		return getRank().isSupraGeneric();
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DerivationEvent.java
74 74
		this.derivatives = derivatives;
75 75
	}
76 76
	public void addDerivative(DerivedUnitBase derivative) {
77
		derivative.setDerivedFrom(this);
77
		if (derivative != null){
78
			derivative.setDerivedFrom(this);
79
		}
78 80
	}
79 81
	public void removeDerivative(DerivedUnitBase derivative) {
80
		this.derivatives.remove(derivative);
82
		if (derivative != null){
83
			derivative.setDerivedFrom(null);
84
		}
81 85
	}
82 86

  
83 87
	
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/DerivedUnitBase.java
71 71
	
72 72
	
73 73
	@ManyToOne
74
	@Deprecated //only for bidirectional and persistence use
75
	private DerivationEvent getDerivationEvent() {
76
		return getDerivedFrom();
77
	}
78
	@Deprecated //only for bidirectional and persistence use
79
	private void setDerivationEvent(DerivationEvent derivationEvent) {
80
		this.derivedFrom = derivationEvent;
81
	}
82
	@Transient
74 83
	public DerivationEvent getDerivedFrom() {
75 84
		return derivedFrom;
76 85
	}
77
	public void setDerivedFrom(DerivationEvent derivedFrom) {
78
		if(this.derivedFrom == derivedFrom) {
79
			return;
80
		}
81
		//delete old
82
		if (this.derivedFrom != null) { 
83
			derivedFrom.derivatives.remove(this);
84
		}
85
		//add new
86
		if (derivedFrom != null) { 
87
			//hack for avoiding org.hibernate.LazyInitializationException: illegal access to loading collection
88
			if (derivedFrom.derivatives instanceof PersistentSet){
89
				//
90
			}else{
91
				derivedFrom.derivatives.add(this);
92
			}
86
	public void setDerivedFrom(DerivationEvent derivedFrom){
87
		if (getDerivedFrom() != null){
88
			getDerivedFrom().getDerivatives().remove(derivedFrom);
93 89
		}
94 90
		this.derivedFrom = derivedFrom;
91
		if (derivedFrom != null){
92
			derivedFrom.getDerivatives().add(this);
93
		}
95 94
	}
96 95
	
97 96
	@Transient
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/Taxon.java
84 84
	 * @param description
85 85
	 */
86 86
	public void addDescription(TaxonDescription description) {
87
		descriptionSetTaxon(description);
87
		initMethods();
88
		this.invokeSetMethod(methodDescriptionSetTaxon, description);
88 89
		descriptions.add(description);
89 90
	}
90 91
	public void removeDescription(TaxonDescription description) {
91
		descriptionSetTaxon(null);
92
		descriptions.remove(description);
93
	}
94
	private void descriptionSetTaxon(TaxonDescription description){
95 92
		initMethods();
96
		try {
97
			methodDescriptionSetTaxon.invoke(description, this);
98
		} catch (Exception e) {
99
			e.printStackTrace();
100
			//TODO handle exceptioin;
101
		}
93
		this.invokeSetMethod(methodDescriptionSetTaxon, null);
94
		descriptions.remove(description);
102 95
	}
96

  
103 97
	private void initMethods(){
104 98
		if (methodDescriptionSetTaxon == null){
105 99
			try {

Also available in: Unified diff