Changeset 5695


Ignore:
Timestamp:
Aug 12, 2011, 9:39:05 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #1153: Handling short read transcript sequence data

Fixes isUsed() and getUsingItems() method for extract and derived bioassay.

Location:
trunk/src/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r5685 r5695  
    11001100  </query>
    11011101
     1102  <query id="GET_DERIVEDBIOASSAYS_FOR_EXTRACT" type="HQL">
     1103    <sql>
     1104      SELECT {1}
     1105      FROM DerivedBioAssayData dba
     1106      WHERE dba.extract = :extract
     1107    </sql>
     1108    <description>
     1109      A Hibernate query that gets the derived bioassays
     1110      that are referencing a given extract.
     1111    </description>
     1112  </query>
     1113
     1114  <query id="GET_RAWBIOASSAYS_FOR_EXTRACT" type="HQL">
     1115    <sql>
     1116      SELECT {1}
     1117      FROM RawBioAssayData rba
     1118      WHERE rba.parentExtract = :extract
     1119    </sql>
     1120    <description>
     1121      A Hibernate query that gets the raw bioassays
     1122      that are referencing a given extract.
     1123    </description>
     1124  </query>
     1125
    11021126  <query id="COUNT_UNREAD_MESSAGES_FOR_USER" type="HQL">
    11031127    <sql>
     
    13811405    </description>
    13821406  </query>
     1407
     1408  <query id="GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL">
     1409    <sql>
     1410      SELECT {1}
     1411      FROM DerivedBioAssayData dba
     1412      WHERE dba.parent = :bioAssay
     1413    </sql>
     1414    <description>
     1415      A Hibernate query that gets child derived bioassays
     1416      created from a specific derived bioassay.
     1417    </description>
     1418  </query>
     1419
    13831420
    13841421  <query id="GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY" type="HQL">
  • trunk/src/core/net/sf/basedb/core/DerivedBioAssay.java

    r5689 r5695  
    166166  */
    167167  /**
    168    
    169    */
     168    Get all:
     169    <ul>
     170    <li>Child derived bioassays
     171    <li>Child raw bioassays
     172    </ul>
     173  */
    170174  @Override
    171175  public Set<ItemProxy> getUsingItems()
    172176  {
    173177    Set<ItemProxy> using = super.getUsingItems();
    174     // TODO - part of #1153
     178    org.hibernate.Session session = getDbControl().getHibernateSession();
     179   
     180    // Child derived bioassays
     181    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     182      "GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY", "dba.id");
     183      /*
     184        SELECT {1}
     185        FROM DerivedBioAssayData dba
     186        WHERE dba.parent = :bioAssay
     187      */
     188    query.setEntity("bioAssay", this.getData());
     189    addUsingItems(using, Item.DERIVEDBIOASSAY, query);
     190
     191    // Child raw bioassays
     192    query = HibernateUtil.getPredefinedQuery(session,
     193      "GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY", "rba.id");
     194      /*
     195        SELECT {1}
     196        FROM RawBioAssayData rba
     197        WHERE rba.parentBioAssay = :bioAssay
     198      */
     199    query.setEntity("bioAssay", this.getData());
     200    addUsingItems(using, Item.RAWBIOASSAY, query);
     201   
    175202    return using;
    176203  }
     
    183210    throws BaseException
    184211  {
    185     // TODO - part of #1153
    186     return super.isUsed();
    187   }
    188  
    189   /**
    190     Grant READ persmission to everyone that has read permision
    191     on the parent physical bioassay.
    192   */
    193   @Override
    194   void initPermissions(int granted, int denied)
    195     throws BaseException
    196   {
    197     // TODO Auto-generated method stub
    198     super.initPermissions(granted, denied);
     212    org.hibernate.Session session = getDbControl().getHibernateSession();
     213    boolean used = false;
     214   
     215    if (!used)
     216    {
     217      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     218        "GET_RAWBIOASSAYS_FOR_DERIVEDBIOASSAY", "count(*)");
     219      /*
     220        SELECT {1}
     221        FROM RawBioAssayData rba
     222        WHERE rba.parentBioAssay = :bioAssay
     223      */
     224      query.setEntity("bioAssay", this.getData());
     225      used = HibernateUtil.loadData(Long.class, query) > 0;
     226    }
     227
     228    if (!used)
     229    {
     230      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     231        "GET_CHILD_DERIVEDBIOASSAYS_FOR_DERIVEDBIOASSAY", "count(*)");
     232      /*
     233        SELECT {1}
     234        FROM DerivedBioAssayData dba
     235        WHERE dba.parent = :bioAssay
     236      */
     237      query.setEntity("bioAssay", this.getData());
     238      used = HibernateUtil.loadData(Long.class, query) > 0;
     239    }
     240   
     241    return used || super.isUsed();
    199242  }
    200243
  • trunk/src/core/net/sf/basedb/core/Extract.java

    r5663 r5695  
    165165    <li>no {@link PhysicalBioAssay}:s has been created from this item
    166166    <li>no {@link Extract}:s has been created from this item
     167    <li>no {@link DerivedBioAssay} is referencing this item
     168    <li>no {@link RawBioAssay} is referencing this item
    167169    </ul>
    168170  */
    169171  public boolean isUsed()
    170172    throws BaseException
    171   {   
    172     return super.isUsed();
    173   }
     173  {
     174    org.hibernate.Session session = getDbControl().getHibernateSession();
     175    boolean used = false;
     176   
     177    if (!used)
     178    {
     179      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     180        "GET_DERIVEDBIOASSAYS_FOR_EXTRACT", "count(*)");
     181      /*
     182        SELECT {1}
     183        FROM DerivedBioAssayData dba
     184        WHERE dba.extract = :extract
     185      */
     186      query.setEntity("extract", this.getData());
     187      used = HibernateUtil.loadData(Long.class, query) > 0;
     188    }
     189   
     190    if (!used)
     191    {
     192      org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
     193        "GET_RAWBIOASSAYS_FOR_EXTRACT", "count(*)");
     194      /*
     195        SELECT {1}
     196        FROM RawBioAssayData rba
     197        WHERE rba.parentExtract = :extract
     198      */
     199      query.setEntity("extract", this.getData());
     200      used = HibernateUtil.loadData(Long.class, query) > 0;
     201    }
     202   
     203    return used || super.isUsed();
     204  }
     205 
    174206  /**
    175207    Get all:
    176208    <ul>
     209    <li>Child extracts created from the extract
    177210    <li>{@link PhysicalBioAssay}:s created from this extract
     211    <li>{@link DerivedBioAssay}:s referencing the extract
     212    <li>{@link RawBioAssay}:s referencing the extract
    178213    <ul>
    179214    @since 2.2
     
    184219    Set<ItemProxy> using = super.getUsingItems();
    185220    org.hibernate.Session session = getDbControl().getHibernateSession();
     221   
     222    // Physical bioassays
    186223    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session,
    187224      "GET_SOURCEEVENTS_FOR_BIOMATERIAL", "bme.physicalBioAssay.id");
     
    190227        FROM BioMaterialEventData bme
    191228        JOIN bme.sources src
    192         WHERE index(src) = :bioMaterial
     229        WHERE src.bioMaterial = :bioMaterial
    193230      */
    194231    query.setEntity("bioMaterial", this.getData());
    195232    addUsingItems(using, Item.PHYSICALBIOASSAY, query);
     233   
     234    // Derived bioassays
     235    query = HibernateUtil.getPredefinedQuery(session,
     236        "GET_DERIVEDBIOASSAYS_FOR_EXTRACT", "dba.id");
     237        /*
     238          SELECT {1}
     239          FROM DerivedBioAssayData dba
     240          WHERE dba.extract = :extract
     241        */
     242    query.setEntity("extract", this.getData());
     243    addUsingItems(using, Item.DERIVEDBIOASSAY, query);
     244   
     245    // Raw bioassays
     246    query = HibernateUtil.getPredefinedQuery(session,
     247        "GET_RAWBIOASSAYS_FOR_EXTRACT", "rba.id");
     248        /*
     249          SELECT {1}
     250          FROM RawBioAssayData rba
     251          WHERE rba.parentExtract = :extract
     252        */
     253    query.setEntity("extract", this.getData());
     254    addUsingItems(using, Item.RAWBIOASSAY, query);
     255   
    196256    return using;
    197257  }
Note: See TracChangeset for help on using the changeset viewer.