From ab987450ca9c3e31276f53e45ce29743e9a3720d Mon Sep 17 00:00:00 2001
From: tjc <tjc@ee4ac58c-ac51-4696-9907-e4b3aa274f04>
Date: Thu, 6 Aug 2009 16:16:58 +0000
Subject: [PATCH] use srcfeature_id when updating and add
 getFeatureLocBySrcFeatureId

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@11508 ee4ac58c-ac51-4696-9907-e4b3aa274f04
---
 artemis_sqlmap/FeatureLoc.xml | 39 +++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/artemis_sqlmap/FeatureLoc.xml b/artemis_sqlmap/FeatureLoc.xml
index c9b4daa11..9989f7de8 100644
--- a/artemis_sqlmap/FeatureLoc.xml
+++ b/artemis_sqlmap/FeatureLoc.xml
@@ -7,8 +7,6 @@
 
 <sqlMap namespace="FeatureLoc"> 
  
-
-     
      <typeAlias alias="FeatureLoc"
         type="org.gmod.schema.sequence.FeatureLoc"/>
         
@@ -37,26 +35,32 @@
        WHERE featureloc.feature_id=#id#
      </select>
      
+     <select id="getFeatureLocBySrcFeatureId" resultMap="map-location-lazy">
+       SELECT feature_id, srcfeature_id, fmin, fmax, strand, phase, residue_info, locgroup, rank, is_fmin_partial, is_fmax_partial
+       FROM  featureloc
+       WHERE srcfeature_id=#id#
+     </select>
+     
 	 <select id="getFeatureLocsByListOfIds" resultMap ="map-location-lazy">
 	   SELECT feature_id, srcfeature_id, fmin, fmax, strand, phase, residue_info, locgroup, rank, is_fmin_partial, is_fmax_partial
        FROM  featureloc
        WHERE featureloc.feature_id IN <iterate open="(" close=")" conjunction=","> $[]$ </iterate>
      </select>
 	
-     <!-- used to find match meature from the subject and query featureId -->
+     <!-- used to find match feature from the subject and query featureId -->
      <select id="getFeatureIdBySrcFeatureId" parameterClass="Feature" resultClass="java.lang.Integer">
         <iterate property="featureLocsForFeatureId" conjunction="INTERSECT" >
            SELECT feature_id FROM featureloc WHERE srcfeature_id=#featureLocsForFeatureId[].featureBySrcFeatureId.featureId#  
         </iterate>
      </select>
      
-    <!--  WRITE BACK METHODS  -->
+   <!--  WRITE BACK METHODS  -->
     
-    <!--  UPDATE  -->
-    <update id="updateFeatureLoc" 
+   <!--  UPDATE  -->
+   <update id="updateFeatureLoc" 
             parameterClass="FeatureLoc">
       UPDATE featureloc
-      SET fmin=$fmin$, fmax=$fmax$, rank=$rank$, strand=$strand$,
+      SET fmin=$fmin$, fmax=$fmax$, strand=$strand$,
           is_fmin_partial=#fminPartial#,
           is_fmax_partial=#fmaxPartial#
       <isNotNull property="phase">
@@ -66,15 +70,18 @@
         , phase=NULL
       </isNull>
       WHERE
-        <isGreaterThan property="featureByFeatureId.featureId" compareValue="0">
-          feature_id=$featureByFeatureId.featureId$
-        </isGreaterThan>
-        <isLessEqual property="featureByFeatureId.featureId" compareValue="0">
-           <isNotNull property="featureByFeatureId.uniqueName">
-             feature_id=(SELECT feature_id FROM feature WHERE uniquename=#featureByFeatureId.uniqueName#)
-           </isNotNull>
-        </isLessEqual>
-    </update>
+      <isGreaterThan property="featureByFeatureId.featureId" compareValue="0">
+        feature_id=$featureByFeatureId.featureId$
+      </isGreaterThan>
+      <isLessEqual property="featureByFeatureId.featureId" compareValue="0">
+         <isNotNull property="featureByFeatureId.uniqueName">
+           feature_id=(SELECT feature_id FROM feature WHERE uniquename=#featureByFeatureId.uniqueName#)
+         </isNotNull>
+      </isLessEqual>
+      <isGreaterThan property="featureBySrcFeatureId.featureId" compareValue="0" prepend="AND">
+        srcfeature_id=$featureBySrcFeatureId.featureId$
+      </isGreaterThan>
+   </update>
    
    <update id="updateFeatureLocByChangingSequence" 
             parameterClass="uk.ac.sanger.artemis.chado.FeatureForUpdatingResidues">
-- 
GitLab