Changeset 1762


Ignore:
Timestamp:
Dec 3, 2012, 12:27:11 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #441: Register cDNA plate as completed

Added a simple for for registering a cDNA plate:

  • Date
  • Operator
  • Protocol
  • Comments


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

    r1759 r1762  
    290290            <ul>
    291291            <li><a href="libprep/select_rna.jsp?ID=<%=ID%>">Create new mRNA plate</a>
    292             <li><a href="libprep/mrna_protocol.jsp?ID=<%=ID%>">Lab protocol and files for mRNA and cDNA preparation</a>
    293             <li><a href="libprep/mrna_registration.jsp?ID=<%=ID%>">Import mRNA quality control results</a>
    294             <li><a href="?ID=<%=ID%>">cDNA registration</a>
     292            <li><a href="libprep/mrna_protocol.jsp?ID=<%=ID%>">Lab protocols and files for mRNA and cDNA preparation</a>
     293            <li><a href="libprep/mrna_registration.jsp?ID=<%=ID%>">mRNA registration and quality control results</a>
     294            <li><a href="libprep/cdna_registration.jsp?ID=<%=ID%>">cDNA registration</a>
    295295            </ul>
    296296          </dd>
  • extensions/net.sf.basedb.reggie/branches/ticket-422/resources/libprep/mrna_registration.jsp

    r1758 r1762  
    8686  {
    8787    showLoadingAnimation('Loading histology work lists...');
    88     var url = '../MRna.servlet?ID=<%=ID%>&cmd=GetUnprocessedMRnaPlates';   
     88    var url = '../MRna.servlet?ID=<%=ID%>&cmd=GetUnprocessedPlates&plateType=MRNA';   
    8989    request.open("GET", url, false); 
    9090    request.send(null);
  • extensions/net.sf.basedb.reggie/branches/ticket-422/src/net/sf/basedb/reggie/dao/ReactionPlate.java

    r1758 r1762  
    1111import net.sf.basedb.core.BioPlate;
    1212import net.sf.basedb.core.BioPlateEvent;
     13import net.sf.basedb.core.BioPlateEventType;
    1314import net.sf.basedb.core.BioPlateType;
    1415import net.sf.basedb.core.BioWell;
     
    2223import net.sf.basedb.core.MeasuredBioMaterial;
    2324import net.sf.basedb.core.PlateGeometry;
     25import net.sf.basedb.core.SystemItems;
    2426import net.sf.basedb.core.Type;
    2527import net.sf.basedb.core.query.Expressions;
     
    276278    @since 2.x
    277279  */
    278   public List<BioPlateEvent> findEvents(DbControl dc, String role)
     280  public List<BioPlateEvent> findEvents(DbControl dc, String eventType, String role)
    279281  {
    280282    ItemQuery<BioPlateEvent> query = getItem().getEvents();
     283    if (eventType != null)
     284    {
     285      int eventTypeId = SystemItems.getId(eventType);
     286      if (eventTypeId != 0)
     287      {
     288        // Restrict on event type
     289        query.restrict(Restrictions.eq(Hql.property("eventType"), Expressions.integer(eventTypeId)));
     290      }
     291     
     292    }
    281293    if (role != null)
    282294    {
  • extensions/net.sf.basedb.reggie/branches/ticket-422/src/net/sf/basedb/reggie/servlet/MRnaServlet.java

    r1760 r1762  
    8989        json.put("name", bioPlateType.generateNextName(dc, 1));
    9090      }
    91       else if ("GetUnprocessedMRnaPlates".equals(cmd))
    92       {
    93         dc = sc.newDbControl();
     91      else if ("GetUnprocessedPlates".equals(cmd))
     92      {
     93        dc = sc.newDbControl();
     94        BioplateType plateType = BioplateType.getByCName(req.getParameter("plateType"));
    9495       
    9596        ItemQuery<BioPlate> query = BioPlate.getQuery();
    9697        query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    9798        query.restrict(Restrictions.eq(Hql.property("eventDate"), null));
    98         BioplateType.MRNA.addFilter(dc, query, true);
     99        plateType.addFilter(dc, query, true);
    99100        query.order(Orders.desc(Hql.property("id")));
    100101       
     
    366367       
    367368        // Find the creation event for the mRNA plate
    368         List<BioPlateEvent> events = mrnaReactionPlate.findEvents(dc, "destination");
     369        List<BioPlateEvent> events = mrnaReactionPlate.findEvents(dc, BioPlateEventType.CREATE_BIOMATERIAL, "destination");
    369370        if (events.size() > 1)
    370371        {
     
    447448       
    448449        jsonMessages.add("Prepared child cDNA plate '" + cdnaPlateName + "' for future processing");
     450       
     451        dc.commit();
     452      }
     453      else if ("ImportCDnaResults".equals(cmd))
     454      {
     455        JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader());
     456       
     457        Number bioPlateId = (Number)jsonReq.get("bioplate");
     458        Number cdnaProtocolId = (Number)jsonReq.get("cdnaProtocol");
     459
     460        dc = sc.newDbControl();
     461       
     462        // Load cDNA plate and the creation event
     463        ReactionPlate cdnaReactionPlate = ReactionPlate.getById(dc, bioPlateId.intValue(), BioplateType.CDNA);
     464        BioPlate cdnaPlate = cdnaReactionPlate.getBioPlate();
     465       
     466        // Find the creation event for the cDNA plate
     467        List<BioPlateEvent> events = cdnaReactionPlate.findEvents(dc, BioPlateEventType.CREATE_BIOMATERIAL, "child");
     468        if (events.size() > 1)
     469        {
     470          throw new InvalidDataException("Found > 1 creation event for cDNA plate: " + cdnaReactionPlate.getName());
     471        }
     472        // ...it may not exist if a plate has been created with a batch import...
     473        BioPlateEvent cdnaPlateCreationEvent = events.size() == 0 ? null : events.get(0);
     474       
     475        // Set creation date and protocol
     476        Date cdnaDate = Reggie.CONVERTER_STRING_TO_DATE.convert((String)jsonReq.get("cdnaDate"));
     477        cdnaPlate.setEventDate(cdnaDate);
     478        Protocol cdnaProtocol = cdnaProtocolId == null ? null : Protocol.getById(dc, cdnaProtocolId.intValue());
     479        if (cdnaPlateCreationEvent != null)
     480        {
     481          // This automatically propagated to all mRNA items on the plate
     482          cdnaPlateCreationEvent.setEventDate(cdnaDate);
     483          cdnaPlateCreationEvent.setProtocol(cdnaProtocol);
     484        }
     485 
     486        // Operator is an annotation
     487        String operator = Values.getStringOrNull((String)jsonReq.get("cdnaOperator"));
     488        Annotationtype.QC_OPERATOR.setAnnotationValue(dc, cdnaPlate, operator);
     489       
     490       
     491        // Comment about the plate
     492        cdnaPlate.setDescription((String)jsonReq.get("comment"));
     493       
     494        jsonMessages.add("cDNA plate registered: " + cdnaPlate.getName());
    449495       
    450496        dc.commit();
Note: See TracChangeset for help on using the changeset viewer.