Changeset 1546 for extensions/net.sf.basedb.reggie
- Timestamp:
- Mar 2, 2012, 1:19:02 PM (10 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/css/reggie.css
r1544 r1546 109 109 list-style-image: url('../images/ok.png'); 110 110 } 111 .failure ul 112 { 113 list-style-image: url('../images/error.png'); 114 } 111 115 112 116 .reporttable -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java
r1543 r1546 221 221 */ 222 222 public static final String ANNOTATION_QC_OPERATOR = "QCOperator"; 223 224 /** 225 The name of the "BA_RIN" annotation, used 226 for extract (RNAQC). It is a float annotation type 227 @since 2.4 228 */ 229 public static final String ANNOTATION_BA_RIN = "BA_RIN"; 230 223 231 224 232 /** -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java
r1543 r1546 25 25 import net.sf.basedb.core.ItemKey; 26 26 import net.sf.basedb.core.ItemSubtype; 27 import net.sf.basedb.core.MimeType; 27 28 import net.sf.basedb.core.MultiPermissions; 28 29 import net.sf.basedb.core.Permission; … … 34 35 import net.sf.basedb.reggie.Reggie; 35 36 import net.sf.basedb.reggie.dao.BioplateType; 37 import net.sf.basedb.reggie.dao.Mimetype; 36 38 import net.sf.basedb.reggie.dao.Subtype; 37 39 import net.sf.basedb.util.EqualsHelper; … … 117 119 jsonChecks.add(checkBioplateType(dc, BioplateType.CALIPER_RNAQC, createIfMissing)); 118 120 121 // MIME types 122 jsonChecks.add(checkMimeType(dc, Mimetype.GDX, createIfMissing)); 123 119 124 // Annotation type checks 120 125 // -- the first batch need to be shared to the PatientCurator group … … 179 184 null, effectiveOptions, createIfMissing)); 180 185 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_QC_OPERATOR, new Item[] { Item.BIOPLATE}, Type.STRING, 1, 186 null, effectiveOptions, createIfMissing)); 187 jsonChecks.add(checkAnnotationType(dc, Reggie.ANNOTATION_BA_RIN, new Item[] { Item.EXTRACT }, Type.FLOAT, 1, 181 188 null, effectiveOptions, createIfMissing)); 182 189 … … 209 216 Reggie.ANNOTATION_QC_RUN_DATE, Reggie.ANNOTATION_QC_OPERATOR)); 210 217 211 212 218 jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.DNA, createIfMissing)); 213 219 214 jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.RNAQC, createIfMissing)); 220 jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.RNAQC, createIfMissing, 221 Reggie.ANNOTATION_BA_RIN)); 215 222 216 223 json.put("checks", jsonChecks); … … 854 861 } 855 862 863 /** 864 Create a MIME type with the given options. The type is created in 865 a separate transaction. 866 @since 2.4 867 */ 868 public MimeType createMimeType(SessionControl sc, Mimetype def) 869 { 870 MimeType type = null; 871 DbControl dc = sc.newDbControl(); 872 try 873 { 874 type = MimeType.getNew(dc); 875 type.setName(def.getMimeType()); 876 type.setExtension(def.getExtension()); 877 type.setDescription(def.getDescription()); 878 if (def.getFileType() != null) 879 { 880 type.setFileType(def.getFileType().load(dc)); 881 } 882 883 dc.saveItem(type); 884 dc.commit(); 885 } 886 finally 887 { 888 if (dc != null) dc.close(); 889 } 890 return type; 891 } 892 893 894 /** 895 Check for an existing MIME type with the given options. 896 A JSONObject is returned with the result. The following 897 keys are used: 898 <ul> 899 <li>itemType: MIMETYPE 900 <li>name: The name of the subtype 901 <li>id: The id of the subtype if it exists 902 <li>mainType: The main item type that the subtype applies to 903 <li>status: ok, error, or missing 904 <li>message: A descriptive message in case of an error 905 </ul> 906 @since 2.4 907 */ 908 @SuppressWarnings("unchecked") 909 public JSONObject checkMimeType(DbControl dc, Mimetype mimeType, 910 boolean createIfMissing) 911 { 912 913 JSONObject json = new JSONObject(); 914 JSONArray jsonMessages = new JSONArray(); 915 json.put("itemType", Item.MIMETYPE.name()); 916 json.put("name", mimeType.getDescription()); 917 json.put("mimeType", mimeType.getMimeType()); 918 json.put("extension", mimeType.getExtension()); 919 920 List<MimeType> result = mimeType.list(dc); 921 if (result.size() == 0) 922 { 923 if (createIfMissing) 924 { 925 MimeType type = createMimeType(dc.getSessionControl(), mimeType); 926 json.put("id", type.getId()); 927 json.put("status", "ok"); 928 jsonMessages.add("Created"); 929 } 930 else 931 { 932 json.put("status", "missing"); 933 jsonMessages.add("Not found"); 934 } 935 } 936 else if (result.size() > 1) 937 { 938 json.put("status", "error"); 939 jsonMessages.add("Found > 1 MIME type"); 940 } 941 else 942 { 943 MimeType s = result.get(0); 944 json.put("id", s.getId()); 945 json.put("status", "ok"); // For now -- more checks below 946 947 if (!s.getName().equals(mimeType.getMimeType())) 948 { 949 json.put("status", "error"); 950 jsonMessages.add("Should have '" + mimeType.getMimeType() + "' as MIME type."); 951 } 952 953 } 954 if (jsonMessages.size() == 0) jsonMessages.add("Ok"); 955 json.put("messages", jsonMessages); 956 return json; 957 958 } 959 856 960 857 961 /** -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/RnaQcServlet.java
r1544 r1546 15 15 import org.json.simple.parser.JSONParser; 16 16 17 import net.sf.basedb.core.AnnotationSet; 18 import net.sf.basedb.core.AnnotationType; 17 19 import net.sf.basedb.core.Application; 18 20 import net.sf.basedb.core.BioPlate; … … 23 25 import net.sf.basedb.core.DbControl; 24 26 import net.sf.basedb.core.Extract; 27 import net.sf.basedb.core.File; 28 import net.sf.basedb.core.Item; 25 29 import net.sf.basedb.core.ItemNotFoundException; 26 30 import net.sf.basedb.core.ItemQuery; … … 33 37 import net.sf.basedb.reggie.dao.Rna; 34 38 import net.sf.basedb.reggie.dao.Subtype; 39 import net.sf.basedb.reggie.plugins.CaliperPlateImporter; 35 40 import net.sf.basedb.reggie.plugins.CaliperSampleNameExporter; 36 41 import net.sf.basedb.util.Coordinate; … … 267 272 } 268 273 274 dc.commit(); 275 } 276 else if ("PreValidateCaliperResults".equals(cmd)) 277 { 278 int csvId = Values.getInt(req.getParameter("csv")); 279 280 dc = sc.newDbControl(); 281 File csv = File.getById(dc, csvId); 282 283 CaliperPlateImporter cpi = new CaliperPlateImporter(); 284 cpi.setAnnotationMapping("RNA Quality Score", null); // safe to use 'null' when validating 285 286 if (cpi.doPreValidate(dc, csv.getDownloadStream(0))) 287 { 288 // The validation was ok 289 BioPlate plate = cpi.getBioPlate(); 290 ReactionPlate rnaQc = ReactionPlate.getById(dc, plate.getId()); 291 AnnotationType qcRunDate = Reggie.findAnnotationType(dc, Item.BIOPLATE, Reggie.ANNOTATION_QC_RUN_DATE, false); 292 AnnotationType qcOperator = Reggie.findAnnotationType(dc, Item.BIOPLATE, Reggie.ANNOTATION_QC_OPERATOR, false); 293 if (qcRunDate != null) 294 { 295 rnaQc.loadAnnotations("QCRunDate", qcRunDate, Reggie.CONVERTER_DATE_TO_STRING); 296 } 297 if (qcOperator != null) 298 { 299 rnaQc.loadAnnotations("QCOperator", qcOperator, null); 300 } 301 JSONObject jsonPlate = rnaQc.asJSONObject(); 302 303 json.put("plate", jsonPlate); 304 } 305 else 306 { 307 json.put("status", "error"); 308 json.put("message", "Validation failed"); 309 jsonMessages.addAll(cpi.getErrorMessages()); 310 } 311 312 } 313 else if ("ImportCaliperResults".equals(cmd)) 314 { 315 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 316 317 Number csvId = (Number)jsonReq.get("csv"); 318 Number gxdId = (Number)jsonReq.get("gxd"); 319 Number pdfId = (Number)jsonReq.get("pdf"); 320 321 dc = sc.newDbControl(); 322 AnnotationType qcRunDate = Reggie.findAnnotationType(dc, Item.BIOPLATE, Reggie.ANNOTATION_QC_RUN_DATE, true); 323 AnnotationType qcOperator = Reggie.findAnnotationType(dc, Item.BIOPLATE, Reggie.ANNOTATION_QC_OPERATOR, true); 324 AnnotationType rin = Reggie.findAnnotationType(dc, Item.EXTRACT, Reggie.ANNOTATION_BA_RIN, true); 325 326 File csv = File.getById(dc, csvId.intValue()); 327 328 CaliperPlateImporter cpi = new CaliperPlateImporter(); 329 cpi.setAnnotationMapping("RNA Quality Score", rin); 330 331 if (cpi.doImport(dc, csv.getDownloadStream(0))) 332 { 333 // The import was successful 334 BioPlate plate = cpi.getBioPlate(); 335 jsonMessages.add("Imported data to " + cpi.getNumImported() + " extracts on plate " + plate.getName()); 336 337 // Attach the files we used to the bioplate 338 cpi.attachFile(dc, csv, "CSV file"); 339 jsonMessages.add("Attached file '" + csv.getName() + "' to plate " + plate.getName()); 340 if (gxdId != null) 341 { 342 File gxd = File.getById(dc, gxdId.intValue()); 343 cpi.attachFile(dc, gxd, "LabView GX raw data"); 344 jsonMessages.add("Attached file '" + gxd.getName() + "' to plate " + plate.getName()); 345 } 346 if (pdfId != null) 347 { 348 File pdf = File.getById(dc, pdfId.intValue()); 349 cpi.attachFile(dc, pdf, "PDF printout"); 350 jsonMessages.add("Attached file '" + pdf.getName() + "' to plate " + plate.getName()); 351 } 352 353 AnnotationSet as = plate.getAnnotationSet(); 354 as.getAnnotation(qcRunDate).setValue(Reggie.CONVERTER_STRING_TO_DATE.convert((String)jsonReq.get("QCRunDate"))); 355 as.getAnnotation(qcOperator).setValue(jsonReq.get("QCOperator")); 356 357 plate.setDestroyed(true); 358 dc.commit(); 359 360 } 361 else 362 { 363 jsonMessages.addAll(cpi.getErrorMessages()); 364 json.put("status", "error"); 365 json.put("message", "Import failed from file: " + csv.getName()); 366 } 367 269 368 } 270 369 271 dc.commit(); 370 272 371 json.put("messages", jsonMessages); 273 274 372 275 373 }
Note: See TracChangeset
for help on using the changeset viewer.