Changeset 1976


Ignore:
Timestamp:
May 15, 2013, 2:28:40 PM (9 years ago)
Author:
Nicklas Nordborg
Message:

References #480: Register pooled libraries

Set creation date on .dil items so that we know they have been created.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PoolServlet.java

    r1975 r1976  
    374374              libSrc.setUsedQuantity(usedQuantityForExtra);
    375375              dil.setOriginalQuantity(usedQuantityForExtra);
     376              dil.setTag(lib.getTag());
    376377              dc.saveItem(dil);
    377378             
     
    403404       
    404405        Protocol poolProtocol = poolProtocolId == null ? null : Protocol.getById(dc, poolProtocolId.intValue());
     406
     407        ItemQuery<Extract> dilQuery = Extract.getQuery();
     408        dilQuery.restrict(Restrictions.eq(Hql.property("name"), Expressions.parameter("dilName", Type.STRING)));
     409        dilQuery.restrict(Restrictions.eq(Hql.property("creationEvent.eventDate"), null));
     410        dilQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    405411       
    406412        JSONArray jsonPools = (JSONArray)jsonReq.get("pools");       
     
    408414        {
    409415          Number poolId = (Number)jsonPools.get(i);
    410           Extract pool = Extract.getById(dc, poolId.intValue());
    411           BioMaterialEvent creationEvent = pool.getCreationEvent();
     416          PooledLibrary pool = PooledLibrary.getById(dc, poolId.intValue());
     417          Extract poolExtract = pool.getExtract();
     418          BioMaterialEvent creationEvent = poolExtract.getCreationEvent();
    412419         
    413420          creationEvent.setEventDate(poolDate);
    414421          creationEvent.setProtocol(poolProtocol);
    415           pool.setDescription(comment);
    416          
     422          poolExtract.setDescription(comment);
     423         
     424          // Check if there are any .dil items
     425          List<Library> libs = Library.getByPool(dc, pool);
     426          for (Library lib : libs)
     427          {
     428            dilQuery.setParameter("dilName", lib.getName()+".dil", Type.STRING);
     429            List<Extract> result = dilQuery.list(dc);
     430            if (result.size() == 1)
     431            {
     432              Extract dil = result.get(0);
     433              BioMaterialEvent dilEvent = dil.getCreationEvent();
     434              dilEvent.setEventDate(poolDate);
     435              dilEvent.setProtocol(poolProtocol);
     436              //jsonMessages.add(dil.getName() + " registered");
     437            }
     438          }         
    417439          jsonMessages.add("Pool '" + pool.getName() + "' registered as completed.");
    418440        }
Note: See TracChangeset for help on using the changeset viewer.