Skip to content
Snippets Groups Projects
CvTerm.xml 2.72 KiB
Newer Older
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"> 
 

tjc's avatar
tjc committed
<sqlMap namespace="CvTerm"> 
tjc's avatar
tjc committed

tjc's avatar
tjc committed
    <cacheModel id="cvterm-cache" type ="LRU" readOnly="true"> 
      <flushInterval hours="24"/>  
      <property name="cache-size" value="100" /> 
    </cacheModel> 
    
tjc's avatar
tjc committed
    <typeAlias alias="CvTerm"
        type="org.gmod.schema.cv.CvTerm"/>
tjc's avatar
tjc committed
 
tjc's avatar
tjc committed
    <resultMap id="select-cvterm-names-result" class="CvTerm">
   	  <result property="cvTermId" column="cvterm_id"/>
tjc's avatar
tjc committed
      <result property="cv.cvId" column="cv_id"/>
   	  <result property="cv.name" column="cv_name"/>
  	  <result property="name" column="name"/>
      <result property="definition" column="definition"/>
      <result property="dbXRef" column="dbxref_id" select="getDbXRefByDbXRefId"/>
tjc's avatar
tjc committed
      <result property="isObsolete" column="is_obsolete"/>
      <result property="isRelationshipType" column="is_relationshiptype"/>
tjc's avatar
tjc committed
    </resultMap>
tjc's avatar
tjc committed
    
tjc's avatar
tjc committed
    <resultMap id="lazy-cvterm" class="CvTerm">
   	  <result property="cvTermId" column="cvterm_id"/>
tjc's avatar
tjc committed
   	  <result property="cv" column="cv_id" select="selectCv"/>
tjc's avatar
tjc committed
  	  <result property="name" column="name"/>
      <result property="definition" column="definition"/>
      <result property="dbXRef" column="dbxref_id" select="getDbXRefByDbXRefId"/>
tjc's avatar
tjc committed
      <result property="isObsolete" column="is_obsolete"/>
      <result property="isRelationshipType" column="is_relationshiptype"/>
tjc's avatar
tjc committed
    </resultMap>
    
tjc's avatar
tjc committed

    <!-- look up cvterms names and id -->
     <select id="getCvterm" resultMap="select-cvterm-names-result"> 
   	SELECT  
tjc's avatar
tjc committed
	  cvterm.*, cv.name as cv_name
tjc's avatar
tjc committed
        FROM cvterm, cv
        WHERE 
            <dynamic>
             <isNotNull property="name">
tjc's avatar
tjc committed
               cvterm.name LIKE #name# AND
tjc's avatar
tjc committed
             </isNotNull>
tjc's avatar
tjc committed
             <isNotNull property="cv.name">
               cv.name=#cv.name# AND
tjc's avatar
tjc committed
             </isNotNull>
tjc's avatar
tjc committed
			 <isNotNull property="cvTermId">
               <isGreaterThan property="cvTermId" compareValue="0">
                 cvterm_id=$cvTermId$ AND
               </isGreaterThan>
			</isNotNull>
            </dynamic>	
tjc's avatar
tjc committed
	    cv.cv_id = cvterm.cv_id
tjc's avatar
tjc committed
     </select> 
tjc's avatar
tjc committed
     
      <!-- look up cvterms names and id -->
     <select id="getCvtermByCvTermId" 
tjc's avatar
tjc committed
             resultMap="lazy-cvterm" cacheModel="cvterm-cache"> 
tjc's avatar
tjc committed
       SELECT *
tjc's avatar
tjc committed
       FROM cvterm
       WHERE cvterm_id=#value# 
     </select> 
tjc's avatar
tjc committed

tjc's avatar
tjc committed
	  <!-- WRITE BACK -->
  <insert id="insertCvTerm" parameterClass="CvTerm">
    INSERT INTO cvterm ( cv_id, name <isNotNull property="definition">, definition</isNotNull>, dbxref_id ) 
           VALUES ($cv.cvId$, #name# <isNotNull property="definition"> ,#definition# </isNotNull>, $dbXRef.dbXRefId$)
  </insert> 
tjc's avatar
tjc committed
</sqlMap>