Changeset 1758
- Timestamp:
- Nov 30, 2012, 8:43:12 AM (10 years ago)
- Location:
- extensions/net.sf.basedb.reggie/branches/ticket-422
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/branches/ticket-422/resources/index.jsp
r1757 r1758 292 292 <li><a href="libprep/mrna_protocol.jsp?ID=<%=ID%>">Lab tracking protocol for mRNA and cDNA preparation</a> 293 293 <li><a href="?ID=<%=ID%>">Export files for mRNA quality control</a> 294 <li><a href=" ?ID=<%=ID%>">Import mRNA quality control results</a>294 <li><a href="libprep/mrna_registration.jsp?ID=<%=ID%>">Import mRNA quality control results</a> 295 295 <li><a href="?ID=<%=ID%>">cDNA registration</a> 296 296 </ul> -
extensions/net.sf.basedb.reggie/branches/ticket-422/resources/reggie.js
r1726 r1758 24 24 { 25 25 if (event.keyCode == 9) 26 { 27 setTimeout(method, 200); 28 } 29 return true; 30 } 31 32 /** 33 Execute the given method when the ENTER key is pressed. A short 34 delay is added so the method doesn't interfer with normal event 35 handling. 36 37 @param event The event object with information about what happened 38 @param method The method to execute when ENTER is pressed 39 */ 40 function doOnEnter(event, method) 41 { 42 if (event.keyCode == 13) 26 43 { 27 44 setTimeout(method, 200); -
extensions/net.sf.basedb.reggie/branches/ticket-422/src/net/sf/basedb/reggie/dao/ReactionPlate.java
r1695 r1758 10 10 import net.sf.basedb.core.BioMaterial; 11 11 import net.sf.basedb.core.BioPlate; 12 import net.sf.basedb.core.BioPlateEvent; 12 13 import net.sf.basedb.core.BioPlateType; 13 14 import net.sf.basedb.core.BioWell; 14 15 import net.sf.basedb.core.DbControl; 15 16 import net.sf.basedb.core.HasAnnotationRestriction; 17 import net.sf.basedb.core.Include; 16 18 import net.sf.basedb.core.InvalidDataException; 19 import net.sf.basedb.core.Item; 17 20 import net.sf.basedb.core.ItemQuery; 18 21 import net.sf.basedb.core.ItemSubtype; … … 267 270 } 268 271 272 /** 273 Find all bioplate events for the current bioplate. If 274 a role is specified, the list is filter to only 275 include events where the bioplate has the given role. 276 @since 2.x 277 */ 278 public List<BioPlateEvent> findEvents(DbControl dc, String role) 279 { 280 ItemQuery<BioPlateEvent> query = getItem().getEvents(); 281 if (role != null) 282 { 283 // Restrict on role 284 query.restrict(Restrictions.eq( 285 Hql.property(Item.BIOPLATEEVENTPARTICIPANT.getAlias(), "role"), Expressions.string(role))); 286 } 287 query.setIncludes(Include.ALL); 288 return query.list(dc); 289 } 269 290 270 291 @SuppressWarnings("unchecked") -
extensions/net.sf.basedb.reggie/branches/ticket-422/src/net/sf/basedb/reggie/servlet/MRnaServlet.java
r1745 r1758 2 2 3 3 import java.io.IOException; 4 import java.util.Date; 4 5 import java.util.HashMap; 5 6 import java.util.List; … … 15 16 import org.json.simple.parser.JSONParser; 16 17 18 import net.sf.basedb.core.AnyToAny; 17 19 import net.sf.basedb.core.Application; 20 import net.sf.basedb.core.BioMaterialEvent; 18 21 import net.sf.basedb.core.BioMaterialEventSource; 19 22 import net.sf.basedb.core.BioPlate; … … 25 28 import net.sf.basedb.core.DbControl; 26 29 import net.sf.basedb.core.Extract; 30 import net.sf.basedb.core.File; 27 31 import net.sf.basedb.core.Include; 32 import net.sf.basedb.core.InvalidDataException; 28 33 import net.sf.basedb.core.ItemQuery; 29 34 import net.sf.basedb.core.ItemSubtype; 30 35 import net.sf.basedb.core.PlateGeometry; 36 import net.sf.basedb.core.Protocol; 31 37 import net.sf.basedb.core.SessionControl; 32 38 import net.sf.basedb.core.Type; … … 39 45 import net.sf.basedb.reggie.dao.BioplateType; 40 46 import net.sf.basedb.reggie.dao.MRna; 47 import net.sf.basedb.reggie.dao.ReactionPlate; 41 48 import net.sf.basedb.reggie.dao.Rna; 42 49 import net.sf.basedb.reggie.dao.Subtype; … … 280 287 jsonMessages.add("Created " + mRnaPlate.getName() + " with " + jsonWells.size() + " mRNA child items"); 281 288 } 289 290 else if ("ImportMRnaQCResults".equals(cmd)) 291 { 292 JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader()); 293 294 Number bioPlateId = (Number)jsonReq.get("bioplate"); 295 Number pdfId = (Number)jsonReq.get("pdf"); 296 Number mrnaProtocolId = (Number)jsonReq.get("mrnaProtocol"); 297 298 dc = sc.newDbControl(); 299 300 // Load mRNA plate and the creation event 301 ReactionPlate mrnaReactionPlate = ReactionPlate.getById(dc, bioPlateId.intValue(), BioplateType.MRNA); 302 BioPlate mrnaPlate = mrnaReactionPlate.getBioPlate(); 303 304 // Find the creation event for the mRNA plate 305 List<BioPlateEvent> events = mrnaReactionPlate.findEvents(dc, "destination"); 306 if (events.size() > 1) 307 { 308 throw new InvalidDataException("Found > 1 creation event for mRNA plate: " + mrnaReactionPlate.getName()); 309 } 310 // ...it may not exist if a plate has been created with a batch import... 311 BioPlateEvent mrnaPlateCreationEvent = events.size() == 0 ? null : events.get(0); 312 313 // Set creation date and protocol 314 Date mrnaDate = Reggie.CONVERTER_STRING_TO_DATE.convert((String)jsonReq.get("mrnaDate")); 315 mrnaPlate.setEventDate(mrnaDate); 316 Protocol mrnaProtocol = mrnaProtocolId == null ? null : Protocol.getById(dc, mrnaProtocolId.intValue()); 317 if (mrnaPlateCreationEvent != null) 318 { 319 // This automatically propagated to all mRNA items on the plate 320 mrnaPlateCreationEvent.setEventDate(mrnaDate); 321 mrnaPlateCreationEvent.setProtocol(mrnaProtocol); 322 } 323 324 // Link PDF file with the mRNA plate 325 File pdf = File.getById(dc, pdfId.intValue()); 326 AnyToAny ata = AnyToAny.getNewOrExisting(dc, mrnaPlate, "PDF printout", pdf, true); 327 if (!ata.isInDatabase()) dc.saveItem(ata); 328 jsonMessages.add("Attached file '" + pdf.getName() + "' to plate " + mrnaPlate.getName()); 329 330 // Operator is an annotation 331 String operator = Values.getStringOrNull((String)jsonReq.get("mrnaOperator")); 332 Annotationtype.QC_OPERATOR.setAnnotationValue(dc, mrnaPlate, operator); 333 334 335 // Comment about the plate 336 mrnaPlate.setDescription((String)jsonReq.get("comment")); 337 338 // Flag so that it will not appear in the wizards next time 339 mrnaPlate.setDestroyed(true); 340 341 // Prepare cDNA child plate 342 String cdnaPlateName = mrnaPlate.getName().replace("mRNA", "cDNA"); 343 BioPlate cdnaPlate = BioPlate.getNew(dc, BioplateType.CDNA.getPlateGeometry(dc), BioplateType.CDNA.load(dc)); 344 cdnaPlate.setName(cdnaPlateName); 345 dc.saveItem(cdnaPlate); 346 347 // Create plate event... 348 BioPlateEventType eventType = BioPlateEventType.getById(dc, BioPlateEventType.CREATE_BIOMATERIAL); 349 BioPlateEvent event = BioPlateEvent.getNew(dc, eventType); 350 event.setName("Create cDNA child plate"); 351 dc.saveItem(event); 352 353 //... with parent (mRNA) and child (cDNA) plate 354 BioPlateEventParticipant cdnaCreation = event.addParticipant(cdnaPlate, "child", 1); 355 event.addParticipant(mrnaPlate, "parent", 1); 356 dc.saveItem(cdnaCreation); 357 358 List<BioWell> wells = mrnaPlate.getBioWells().list(dc); 359 int numCdna = 0; 360 ItemSubtype cdnaType = Subtype.CDNA.load(dc); 361 for (BioWell well : wells) 362 { 363 if (!well.isEmpty()) 364 { 365 Extract mrna = (Extract)well.getBioMaterial(); 366 if (mrnaPlateCreationEvent == null) 367 { 368 // If no plate event existed, we must set protocol and date on all mRNA items 369 BioMaterialEvent evt = mrna.getCreationEvent(); 370 evt.setEventDate(mrnaDate); 371 evt.setProtocol(mrnaProtocol); 372 } 373 Extract cdna = Extract.getNew(dc, cdnaCreation); 374 cdna.setName(mrna.getName()+".c"); 375 cdna.setItemSubtype(cdnaType); 376 cdna.setBioWell(cdnaPlate.getBioWell(well.getPlateCoordinate())); 377 cdna.getCreationEvent().setSource(mrna); 378 dc.saveItem(cdna); 379 numCdna++; 380 } 381 } 382 383 jsonMessages.add(numCdna + " cDNA items created"); 384 385 jsonMessages.add("Prepared child cDNA plate '" + cdnaPlateName + "' for future processing"); 386 387 dc.commit(); 388 } 282 389 283 390 json.put("messages", jsonMessages); 391 284 392 } 285 393 catch (Throwable t)
Note: See TracChangeset
for help on using the changeset viewer.