001package org.biopax.paxtools.impl.level3;
002
003import org.apache.commons.logging.Log;
004import org.apache.commons.logging.LogFactory;
005import org.biopax.paxtools.model.level3.Entity;
006import org.biopax.paxtools.model.level3.Interaction;
007import org.biopax.paxtools.model.level3.InteractionVocabulary;
008import org.biopax.paxtools.util.BPCollections;
009import org.hibernate.annotations.*;
010import org.hibernate.search.annotations.Boost;
011import org.hibernate.search.annotations.Indexed;
012
013import javax.persistence.JoinTable;
014import javax.persistence.ManyToMany;
015import javax.persistence.Transient;
016import java.util.Set;
017
018/**
019 *
020 */
021
022@javax.persistence.Entity
023@Proxy(proxyClass= Interaction.class)
024@Indexed
025@Boost(1.5f)
026@DynamicUpdate @DynamicInsert
027@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
028public class InteractionImpl extends ProcessImpl implements Interaction
029{
030// ------------------------------ FIELDS ------------------------------
031
032        Set<Entity> participant;
033        private Set<InteractionVocabulary> interactionType;
034    private final Log log = LogFactory.getLog(InteractionImpl.class);
035
036// --------------------------- CONSTRUCTORS ---------------------------
037
038        public InteractionImpl()
039        {
040                this.interactionType = BPCollections.I.createSafeSet();
041                this.participant = BPCollections.I.createSafeSet();
042        }
043
044// ------------------------ INTERFACE METHODS ------------------------
045
046
047// --------------------- Interface BioPAXElement ---------------------
048
049
050
051        @Transient
052        public Class<? extends Interaction> getModelInterface()
053        {
054                return Interaction.class;
055        }
056
057// --------------------- Interface Interaction ---------------------
058
059// --------------------- ACCESORS and MUTATORS---------------------
060
061    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
062        @ManyToMany(targetEntity = InteractionVocabularyImpl.class)
063        @JoinTable(name="interactionType")
064        public Set<InteractionVocabulary> getInteractionType()
065        {
066           return interactionType;
067        }
068
069        public void addInteractionType(
070                InteractionVocabulary newinteractionType)
071        {
072           if(newinteractionType != null)
073                        this.interactionType.add(newinteractionType);
074        }
075
076        public void removeInteractionType(
077                InteractionVocabulary oldinteractionType)
078        {
079                if(oldinteractionType != null)
080                        this.interactionType.remove(oldinteractionType);
081        }
082
083        public void setInteractionType(
084                Set<InteractionVocabulary> interactionType)
085        {
086           this.interactionType = interactionType;
087        }
088
089
090        @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
091        @ManyToMany(targetEntity = EntityImpl.class)
092        @JoinTable(name="participant")
093        public Set<Entity> getParticipant()
094        {
095                return participant;
096        }
097
098        protected void setParticipant(Set<Entity> participant)
099        {
100        this.participant = participant;
101    }
102
103        public void addParticipant(Entity aParticipant)
104        {
105                if (aParticipant != null) {
106                        if (aParticipant != null) {
107                                this.participant.add(aParticipant);
108                                aParticipant.getParticipantOf().add(this);
109                        } else {
110                                if (log.isWarnEnabled())
111                                        log.warn("Null object passed to addParticipant @"
112                                                        + this.getRDFId());
113                        }
114                }
115    }
116
117        public void removeParticipant(Entity aParticipant)
118        {
119                if (aParticipant != null) {
120                        this.participant.remove(aParticipant);
121                        aParticipant.getParticipantOf().remove(this);
122                }
123        }
124    
125}