Changeset 1492
- Timestamp:
- Dec 2, 2011, 1:43:29 PM (11 years ago)
- 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
r1463 r1492 49 49 // Look for a case with the given name (primary case) 50 50 ItemQuery<Sample> caseQuery = Sample.getQuery(); 51 Subtype.CASE.addFilter(caseQuery); 51 52 caseQuery.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("name", name, Type.STRING))); 52 53 List<Sample> cases = caseQuery.list(dc); … … 66 67 merged = true; 67 68 caseQuery = Sample.getQuery(); 69 Subtype.CASE.addFilter(caseQuery); 68 70 caseQuery.join(Hql.innerJoin("childCreationEvents", "cce")); 69 71 caseQuery.join(Hql.innerJoin("cce", "event", "evt")); 70 caseQuery.join(Hql.innerJoin("evt", "bioMaterial", "bm")); // 'bm' should now refernce a specimen tube 71 caseQuery.restrict(Restrictions.rlike(Hql.property("bm", "name"), Expressions.parameter("name", "^" + name + "\\.[0-9]+$", Type.STRING))); 72 caseQuery.join(Hql.innerJoin("evt", "bioMaterial", "sp")); // 'sp' should now reference a specimen tube 73 Subtype.SPECIMEN.addFilter(caseQuery, "sp"); 74 caseQuery.restrict(Restrictions.like(Hql.property("sp", "name"), Expressions.parameter("name", name + ".%", Type.STRING))); 72 75 caseQuery.setDistinct(true); 73 76 … … 85 88 if (cases.size() == 0) 86 89 { 87 // Still not found... last chance is to find a ReasonIfNoSpecimen comment90 // Still not found... last chance is to find a (merged) case with ReasonIfNoSpecimen comment 88 91 // that has [caseName] as prefix... 89 92 AnnotationType reasonIfNoSpecimenType = Reggie.findAnnotationType(dc, Item.SAMPLE, Reggie.ANNOTATION_REASON_IF_NO_SPECIMEN, true); 90 93 caseQuery = Sample.getQuery(); 94 Subtype.CASE.addFilter(caseQuery); 91 95 caseQuery.restrict(Annotations.like(null, reasonIfNoSpecimenType, "[" + name + "]%", false)); 92 96 cases = caseQuery.list(dc); … … 122 126 { 123 127 ItemQuery<Sample> caseQuery = patient.getBioSource().getSamples(); 128 Subtype.CASE.addFilter(caseQuery); 124 129 caseQuery.include(Include.ALL); 125 130 caseQuery.order(Orders.asc(Hql.property("name"))); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Patient.java
r1463 r1492 38 38 AnnotationType pnrType = Reggie.findAnnotationType(dc, Item.BIOSOURCE, Reggie.ANNOTATION_PERSONAL_NUMBER, true); 39 39 ItemQuery<BioSource> patientQuery = BioSource.getQuery(); 40 Subtype.PATIENT.addFilter(patientQuery); 40 41 patientQuery.restrict(Annotations.eq(null, pnrType, pnr, false)); 41 42 List<BioSource> patients = patientQuery.list(dc); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/SpecimenTube.java
r1488 r1492 9 9 import net.sf.basedb.core.InvalidDataException; 10 10 import net.sf.basedb.core.ItemQuery; 11 import net.sf.basedb.core.MeasuredBioMaterial; 11 12 import net.sf.basedb.core.Sample; 12 13 import net.sf.basedb.core.Type; … … 37 38 { 38 39 ItemQuery<Sample> specimenQuery = theCase.getSample().getChildSamples(); 40 Subtype.SPECIMEN.addFilter(specimenQuery); 39 41 if (limitToOriginal) 40 42 { 41 specimenQuery.restrict(Restrictions. rlike(Hql.property("name"), Expressions.parameter("name", "^" + theCase.getOriginalName() + "\\.[0-9]+$", Type.STRING)));43 specimenQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.parameter("name", theCase.getOriginalName() + ".%", Type.STRING))); 42 44 } 43 45 specimenQuery.order(Orders.asc(Hql.property("name"))); … … 61 63 { 62 64 ItemQuery<Sample> specimenQuery = Sample.getQuery(); 63 specimenQuery.restrict(Restrictions.rlike(Hql.property("name"), Expressions.parameter("name", "^" + name + "\\.[0-9]+$", Type.STRING))); 65 Subtype.SPECIMEN.addFilter(specimenQuery); 66 specimenQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.parameter("name", name + ".%", Type.STRING))); 64 67 specimenQuery.order(Orders.asc(Hql.property("name"))); 65 68 specimenQuery.include(Include.ALL); … … 73 76 } 74 77 75 78 /** 79 Find a specimen tube with the given name. 80 @return A specimen tube, or null if not found 81 */ 76 82 public static SpecimenTube findByTubeName(DbControl dc, String tubeName) 77 83 { … … 79 85 80 86 ItemQuery<Sample> tubeQuery = Sample.getQuery(); 87 Subtype.SPECIMEN.addFilter(tubeQuery); 81 88 tubeQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.string(tubeName))); 82 89 tubeQuery.order(Orders.desc(Hql.property("name"))); … … 98 105 99 106 /** 107 Find unpartitioned specimen tubes. A specimen tube that has not been partitioned 108 have a 'null' {@link MeasuredBioMaterial#getOriginalQuantity()}. 100 109 @since 1.6 101 110 */ 102 111 public static List<SpecimenTube> findUnPartitionedTubes(DbControl dc) 103 112 { … … 105 114 106 115 ItemQuery<Sample> tubeQuery = Sample.getQuery(); 107 tubeQuery.restrict(Restrictions.and(Restrictions.eq(Hql.property("originalQuantity"), null),108 Restrictions.rlike(Hql.property("name"), Expressions.parameter("name", "^.+\\.[0-9]+$", Type.STRING))));116 Subtype.SPECIMEN.addFilter(tubeQuery); 117 tubeQuery.restrict(Restrictions.eq(Hql.property("originalQuantity"), null)); 109 118 tubeQuery.order(Orders.desc(Hql.property("id"))); 110 119 tubeQuery.include(Include.ALL); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java
r1463 r1492 3 3 import net.sf.basedb.core.DbControl; 4 4 import net.sf.basedb.core.Item; 5 import net.sf.basedb.core.ItemQuery; 5 6 import net.sf.basedb.core.ItemSubtype; 7 import net.sf.basedb.core.Subtypable; 8 import net.sf.basedb.core.query.Expressions; 9 import net.sf.basedb.core.query.Hql; 10 import net.sf.basedb.core.query.Restrictions; 6 11 import net.sf.basedb.reggie.Reggie; 7 12 … … 98 103 } 99 104 105 /** 106 Add a filter restriction the given query so that it 107 only return items of this subtype. 108 109 @param query The query to filter 110 @since 2.1 111 */ 112 public void addFilter(ItemQuery<? extends Subtypable> query) 113 { 114 addFilter(query, null); 115 } 116 117 /** 118 Add a filter restriction to the given query based on the 119 given subtype. If no alias is specified, the filter is 120 applied to the root item, otherwise it is applied 121 to the alias of a joined (eg. parent or child) item 122 123 @param query The query to restrict 124 @param alias Specify an alias if the filter should be 125 placed on a joined (eg. child or parent) item instead 126 of the root item 127 @since 2.1 128 */ 129 public void addFilter(ItemQuery<? extends Subtypable> query, String alias) 130 { 131 query.restrict(Restrictions.eq(Hql.property(alias, "itemSubtype"), Expressions.integer(id))); 132 } 133 100 134 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PersonalRegistrationServlet.java
r1463 r1492 193 193 // No patient was found -- try to find the highest existing patient number 194 194 ItemQuery<BioSource> patientQuery = BioSource.getQuery(); 195 Subtype.PATIENT.addFilter(patientQuery); 195 196 patientQuery.restrict(Restrictions.like(Hql.property("name"), Expressions.string("PAT%"))); 196 197 patientQuery.order(Orders.desc(Hql.property("name"))); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SampleReportServlet.java
r1491 r1492 24 24 import net.sf.basedb.core.query.Restrictions; 25 25 import net.sf.basedb.reggie.converter.DateToStringConverter; 26 import net.sf.basedb.reggie.dao.Subtype; 26 27 import net.sf.basedb.util.Values; 27 28 import net.sf.basedb.util.error.ThrowableUtil; … … 64 65 String columnview = Values.getString(req.getParameter("columnview"), "MONTH"); 65 66 ItemQuery<Sample> sampleQuery = Sample.getQuery(); 66 sampleQuery.restrict(Restrictions.rlike(Hql.property("name"), Expressions.parameter("name", "^.+\\.[0-9]+$", Type.STRING)));67 Subtype.SPECIMEN.addFilter(sampleQuery); 67 68 sampleQuery.include(Include.ALL); 68 69 sampleQuery.setCacheResult(true);
Note: See TracChangeset
for help on using the changeset viewer.