001package org.biopax.paxtools.impl.level3;
002
003import org.biopax.paxtools.model.BioPAXElement;
004import org.biopax.paxtools.model.level3.RelationshipTypeVocabulary;
005import org.biopax.paxtools.model.level3.RelationshipXref;
006import org.hibernate.annotations.Cache;
007import org.hibernate.annotations.CacheConcurrencyStrategy;
008import org.hibernate.annotations.Proxy;
009import org.hibernate.annotations.DynamicInsert;
010import org.hibernate.annotations.DynamicUpdate; 
011import org.hibernate.search.annotations.Indexed;
012
013import javax.persistence.Entity;
014import javax.persistence.ManyToOne;
015import javax.persistence.Transient;
016
017@Entity
018@Proxy(proxyClass= RelationshipXref.class)
019@Indexed
020@DynamicUpdate @DynamicInsert
021@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
022public class RelationshipXrefImpl extends XrefImpl implements RelationshipXref
023{
024
025        private RelationshipTypeVocabulary relationshipType;
026
027        public RelationshipXrefImpl() {
028        }
029        
030        //
031        // BioPAXElement interface implementation
032        //
033        ////////////////////////////////////////////////////////////////////////////
034
035        @Transient
036    public Class<? extends RelationshipXref> getModelInterface()
037        {
038                return RelationshipXref.class;
039        }
040
041        //
042        // RelationshipXref interface implementation
043        //
044        ////////////////////////////////////////////////////////////////////////////
045
046    @ManyToOne(targetEntity = RelationshipTypeVocabularyImpl.class)
047        public RelationshipTypeVocabulary getRelationshipType()
048        {
049                return relationshipType;
050        }
051
052        public void setRelationshipType(RelationshipTypeVocabulary relationshipType)
053        {
054                this.relationshipType = relationshipType;
055        }
056        
057        @Override
058        protected boolean semanticallyEquivalent(BioPAXElement other) {
059                if(!(other instanceof RelationshipXref)) return false;
060                
061                RelationshipXref that = (RelationshipXref) other;
062                
063                return (
064                                (relationshipType != null) 
065                                ? relationshipType.isEquivalent(that.getRelationshipType()) 
066                                : that.getRelationshipType()==null
067                                ) && super.semanticallyEquivalent(other);
068        }
069}