001package org.biopax.paxtools.impl.level3; 002 003import org.biopax.paxtools.model.BioPAXElement; 004import org.biopax.paxtools.model.level3.ModificationFeature; 005import org.biopax.paxtools.model.level3.SequenceModificationVocabulary; 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/** 018 */ 019@Entity 020@Proxy(proxyClass= ModificationFeature.class) 021@Indexed 022@DynamicUpdate @DynamicInsert 023@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) 024public class ModificationFeatureImpl extends EntityFeatureImpl 025 implements ModificationFeature 026{ 027 private SequenceModificationVocabulary modificationType; 028 029 public ModificationFeatureImpl() { 030 } 031 032 @Override 033 public String toString() 034 { 035 StringBuilder sb = new StringBuilder(); 036 037 if(modificationType!=null) 038 sb.append("ModificationFeature: ").append(modificationType.getTerm()); 039 040 if(getFeatureLocation() != null) { 041 if(sb.length() == 0) 042 sb.append("ModificationFeature: "); 043 sb.append("@"+getFeatureLocation()); 044 } 045 046 if(sb.length() == 0) 047 sb.append(super.toString()); 048 049 return sb.toString(); 050 } 051 052 @Transient 053 public Class<? extends ModificationFeature> getModelInterface() 054 { 055 return ModificationFeature.class; 056 } 057 058 059 @ManyToOne(targetEntity = SequenceModificationVocabularyImpl.class) 060 public SequenceModificationVocabulary getModificationType() 061 { 062 return modificationType; 063 } 064 065 public void setModificationType(SequenceModificationVocabulary featureType) 066 { 067 this.modificationType = featureType; 068 } 069 070 @Override 071 protected boolean semanticallyEquivalent(BioPAXElement element) 072 { 073 if(!(element instanceof ModificationFeature)) 074 return false; 075 076 ModificationFeature that = (ModificationFeature) element; 077 boolean value = super.atEquivalentLocation(that); 078 if (value) 079 { 080 SequenceModificationVocabulary yourType = that.getModificationType(); 081 SequenceModificationVocabulary myType = getModificationType(); 082 value = (yourType == null) ? 083 myType == null : 084 yourType.isEquivalent(myType); 085 } 086 087 return value; 088 } 089 090 @Override 091 public int equivalenceCode() 092 { 093 SequenceModificationVocabulary myType = this.getModificationType(); 094 int code = myType == null ?0:myType.hashCode(); 095 return code+13*super.locationCode(); 096 } 097}