Skip to content
Snippets Groups Projects
Organism.xml 3.57 KiB
Newer Older
  • Learn to ignore specific revisions
  • tjc's avatar
    tjc committed
    <?xml version="1.0" encoding="UTF-8" ?> 
     
    <!DOCTYPE sqlMap 
        PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" 
        "http://ibatis.apache.org/dtd/sql-map-2.dtd"> 
     
    <sqlMap namespace="Organism"> 
    
    tjc's avatar
    tjc committed
          
    
        <cacheModel id="organism-cache" type ="LRU" readOnly="true"> 
          <flushInterval hours="24"/>  
    
    tjc's avatar
    tjc committed
          <property name="cache-size" value="85" /> 
    
        </cacheModel> 
    
    tjc's avatar
    tjc committed
        
        <resultMap id="map-organism" class="org.gmod.schema.organism.Organism">
           <result property="organismId" column="organismId"/>
           <result property="abbreviation" column="abbreviation"/>
           <result property="commonName" column="commonName"/>
           <result property="genus" column="genus"/>
           <result property="species" column="species"/>
           <result property="comment" column="comment"/>
           <result property="organismProps" column="organismId" select="getOrganismPropByOrganismIdLazy"/>
        </resultMap>
        
    
    tjc's avatar
    tjc committed
        <select id="getOrganism" resultMap="map-organism" cacheModel="organism-cache"> 
    
    tjc's avatar
    tjc committed
          SELECT organism_id AS organismId, abbreviation, genus, species, common_name AS commonName, comment 
    
    tjc's avatar
    tjc committed
          FROM organism
    
    tjc's avatar
    tjc committed
          <dynamic>
    
    tjc's avatar
    tjc committed
            <isNotNull property="organismId">
    			<isGreaterThan property="organismId" compareValue="0"> 
    				WHERE organism_id=#organismId#
    
    tjc's avatar
    tjc committed
    			    <isNotNull prepend="AND" property="commonName">
                        common_name=#commonName#
                    </isNotNull>
    
    tjc's avatar
    tjc committed
    			</isGreaterThan>
    
    tjc's avatar
    tjc committed
    			
    			<isLessEqual property="organismId" compareValue="0">
    				<isNotNull prepend="WHERE" property="commonName">
                      common_name=#commonName#
                    </isNotNull>
    			</isLessEqual>
    
    tjc's avatar
    tjc committed
            </isNotNull>
    
    tjc's avatar
    tjc committed
    		
    		<isNull property="organismId">
    	  	   <isNotNull prepend="WHERE" property="commonName">
                 common_name=#commonName#
               </isNotNull>
    		</isNull>
    
    tjc's avatar
    tjc committed
    		  
    
    tjc's avatar
    tjc committed
            <isNull prepend="ORDER BY" property="organismId">
               commonName
            </isNull>
          </dynamic>
    
    tjc's avatar
    tjc committed
        </select> 
    
    tjc's avatar
    tjc committed
        <select id="getOrganismIdBySrcFeatureIdOrFeatureId" resultClass="java.lang.Integer" 
    
                parameterClass="org.gmod.schema.sequence.Feature" cacheModel="organism-cache">
          SELECT organism_id AS organismId FROM feature f WHERE
    
    tjc's avatar
    tjc committed
            <isGreaterThan property="featureLoc.featureBySrcFeatureId.featureId" compareValue="0"> 
    
                 f.feature_id=$featureLoc.featureBySrcFeatureId.featureId$
    
    tjc's avatar
    tjc committed
            </isGreaterThan>
    
    tjc's avatar
    tjc committed
    		<isEqual property="featureLoc.featureBySrcFeatureId.featureId" compareValue="0">
    			<isGreaterThan property="featureId" compareValue="0"> 
    				f.feature_id=$featureId$
    			</isGreaterThan>
    		</isEqual>
    
    tjc's avatar
    tjc committed
    		<isNull property="featureLoc.featureBySrcFeatureId">
    			f.feature_id=$featureId$
    		</isNull>
    
    tjc's avatar
    tjc committed
    	<select id="getOrganismsContainingSrcFeatures" resultMap="map-organism">
    
    	  SELECT DISTINCT ON( feature.organism_id )  
    		organism.organism_id AS organismId, abbreviation, genus, species, common_name AS commonName, comment
    		FROM feature 
    		join  organism using (organism_id) 
    		join cvterm on feature.type_id = cvterm.cvterm_id 
    		WHERE residues notnull AND residues != '' 
    		AND ( <include refid="source_feature_cvterm_names"/> ) 
    	</select>
    	
    
    tjc's avatar
    tjc committed
    	<select id="getTopLevelOrganisms" resultMap="map-organism">
    
    	  SELECT organism.organism_id AS organismId, abbreviation, genus, species, common_name AS commonName, comment
          FROM organism
          WHERE exists (
            SELECT *
            FROM organismprop
            JOIN cvterm on organismprop.type_id = cvterm.cvterm_id
            JOIN cv using (cv_id)
            WHERE organism_id = organism.organism_id
            AND cv.name = 'genedb_misc' and cvterm.name = 'populated' )
    
    tjc's avatar
    tjc committed
     
    </sqlMap>