Changeset 1503


Ignore:
Timestamp:
Jan 18, 2012, 1:10:02 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #334: Use item subtypes - step 2

Make sure that the subtype id has been loaded before it is used by a filter. Otherwise the query will not find any items.

Location:
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Case.java

    r1492 r1503  
    4949    // Look for a case with the given name (primary case)
    5050    ItemQuery<Sample> caseQuery = Sample.getQuery();
    51     Subtype.CASE.addFilter(caseQuery);
     51    Subtype.CASE.addFilter(dc, caseQuery);
    5252    caseQuery.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("name", name, Type.STRING)));
    5353    List<Sample> cases = caseQuery.list(dc);
     
    6767      merged = true;
    6868      caseQuery = Sample.getQuery();
    69       Subtype.CASE.addFilter(caseQuery);
     69      Subtype.CASE.addFilter(dc, caseQuery);
    7070      caseQuery.join(Hql.innerJoin("childCreationEvents", "cce"));
    7171      caseQuery.join(Hql.innerJoin("cce", "event", "evt"));
    7272      caseQuery.join(Hql.innerJoin("evt", "bioMaterial", "sp")); // 'sp' should now reference a specimen tube
    73       Subtype.SPECIMEN.addFilter(caseQuery, "sp");
     73      Subtype.SPECIMEN.addFilter(dc, caseQuery, "sp");
    7474      caseQuery.restrict(Restrictions.like(Hql.property("sp", "name"), Expressions.parameter("name", name + ".%", Type.STRING)));
    7575      caseQuery.setDistinct(true);
     
    9292        AnnotationType reasonIfNoSpecimenType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN, true);
    9393        caseQuery = Sample.getQuery();
    94         Subtype.CASE.addFilter(caseQuery);
     94        Subtype.CASE.addFilter(dc, caseQuery);
    9595        caseQuery.restrict(Annotations.like(null, reasonIfNoSpecimenType, "[" + name + "]%", false));
    9696        cases = caseQuery.list(dc);
     
    126126  {
    127127    ItemQuery<Sample> caseQuery = patient.getBioSource().getSamples();
    128     Subtype.CASE.addFilter(caseQuery);
     128    Subtype.CASE.addFilter(dc, caseQuery);
    129129    caseQuery.include(Include.ALL);
    130130    caseQuery.order(Orders.asc(Hql.property("name")));
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Patient.java

    r1492 r1503  
    3838    AnnotationType pnrType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true);
    3939    ItemQuery<BioSource> patientQuery = BioSource.getQuery();
    40     Subtype.PATIENT.addFilter(patientQuery);
     40    Subtype.PATIENT.addFilter(dc, patientQuery);
    4141    patientQuery.restrict(Annotations.eq(null, pnrType, pnr, false));
    4242    List<BioSource> patients = patientQuery.list(dc);
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/SpecimenTube.java

    r1492 r1503  
    3838  {
    3939    ItemQuery<Sample> specimenQuery = theCase.getSample().getChildSamples();
    40     Subtype.SPECIMEN.addFilter(specimenQuery);
     40    Subtype.SPECIMEN.addFilter(dc, specimenQuery);
    4141    if (limitToOriginal)
    4242    {
     
    6363  {
    6464    ItemQuery<Sample> specimenQuery = Sample.getQuery();
    65     Subtype.SPECIMEN.addFilter(specimenQuery);
     65    Subtype.SPECIMEN.addFilter(dc, specimenQuery);
    6666    specimenQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.parameter("name", name + ".%", Type.STRING)));
    6767    specimenQuery.order(Orders.asc(Hql.property("name")));
     
    8585   
    8686    ItemQuery<Sample> tubeQuery = Sample.getQuery();
    87     Subtype.SPECIMEN.addFilter(tubeQuery);
     87    Subtype.SPECIMEN.addFilter(dc, tubeQuery);
    8888    tubeQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.string(tubeName)));
    8989    tubeQuery.order(Orders.desc(Hql.property("name")));       
     
    114114   
    115115    ItemQuery<Sample> tubeQuery = Sample.getQuery();
    116     Subtype.SPECIMEN.addFilter(tubeQuery);
     116    Subtype.SPECIMEN.addFilter(dc, tubeQuery);
    117117    tubeQuery.restrict(Restrictions.eq(Hql.property("originalQuantity"), null));
    118118    tubeQuery.order(Orders.desc(Hql.property("id")));
    119119    tubeQuery.include(Include.ALL);
    120120    tubeQuery.exclude(Include.REMOVED);
    121    
    122121    List<Sample> tubes = tubeQuery.list(dc);
    123122    for (Sample tube : tubes)
     
    125124      BioWell well = tube.getBioWell();
    126125      String boxNamePrefix = null;
     126
    127127      if (well != null)
    128128      {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java

    r1492 r1503  
    110110    @since 2.1
    111111  */
    112   public void addFilter(ItemQuery<? extends Subtypable> query)
     112  public void addFilter(DbControl dc, ItemQuery<? extends Subtypable> query)
    113113  {
    114     addFilter(query, null);
     114    addFilter(dc, query, null);
    115115  }
    116116
     
    127127    @since 2.1
    128128  */
    129   public void addFilter(ItemQuery<? extends Subtypable> query, String alias)
     129  public void addFilter(DbControl dc, ItemQuery<? extends Subtypable> query, String alias)
    130130  {
     131    if (id==0) load(dc); // Ensure that the subtype has been loaded
    131132    query.restrict(Restrictions.eq(Hql.property(alias, "itemSubtype"), Expressions.integer(id)));
    132133  }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java

    r1492 r1503  
    193193          // No patient was found -- try to find the highest existing patient number
    194194          ItemQuery<BioSource> patientQuery = BioSource.getQuery();
    195           Subtype.PATIENT.addFilter(patientQuery);
     195          Subtype.PATIENT.addFilter(dc, patientQuery);
    196196          patientQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.string("PAT%")));
    197197          patientQuery.order(Orders.desc(Hql.property("name")));
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SampleReportServlet.java

    r1500 r1503  
    112112       
    113113        sampleQuery.restrict(Restrictions.and(restr));
    114         Subtype.SPECIMEN.addFilter(sampleQuery);
     114        Subtype.SPECIMEN.addFilter(dc, sampleQuery);
    115115
    116116        sampleQuery.include(Include.ALL);
Note: See TracChangeset for help on using the changeset viewer.