@@ -93,8 +93,8 @@ class Sample extends Page
9393 'scid ' => '\d+-\d+ ' ,
9494
9595 'BLSAMPLEID ' => '\d+ ' ,
96- 'X ' => '\d+ (.\d+)? ' ,
97- 'Y ' => '\d+ (.\d+)? ' ,
96+ 'X ' => '\d* (.\d+)? ' ,
97+ 'Y ' => '\d* (.\d+)? ' ,
9898 'Z ' => '\d+(.\d+)? ' ,
9999 'X2 ' => '\d+(.\d+)? ' ,
100100 'Y2 ' => '\d+(.\d+)? ' ,
@@ -799,6 +799,9 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
799799 po2.posx as x2,
800800 po2.posy as y2,
801801 po2.posz as z2,
802+ bsp.posx as dispensex,
803+ bsp.posy as dispensey,
804+ bsp.posz as dispensez,
802805 IF(cqs.containerqueuesampleid IS NOT NULL AND cqs.containerqueueid IS NULL, 1, 0) as readyforqueue,
803806 cq.containerqueueid,
804807 count(distinct IF(dc.overlap != 0,
@@ -824,7 +827,7 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
824827 INNER JOIN shipping sh ON sh.shippingid = d.shippingid
825828 INNER JOIN proposal p ON p.proposalid = sh.proposalid
826829
827-
830+ LEFT OUTER JOIN blsampleposition bsp ON bsp.blsampleid = s.blsampleid
828831 LEFT OUTER JOIN containerqueuesample cqs ON cqs.blsubsampleid = ss.blsubsampleid
829832 LEFT OUTER JOIN containerqueue cq ON cqs.containerqueueid = cq.containerqueueid AND cq.completedtimestamp IS NULL
830833
@@ -1903,11 +1906,12 @@ function _update_sample()
19031906 if (!$ this ->has_arg ('sid ' ))
19041907 $ this ->_error ('No sampleid specified ' );
19051908
1906- $ samp = $ this ->db ->pq ("SELECT b.blsampleid, pr.proteinid,cr.crystalid,dp.diffractionplanid
1909+ $ samp = $ this ->db ->pq ("SELECT b.blsampleid, pr.proteinid,cr.crystalid,dp.diffractionplanid,bsp.blsamplepositionid
19071910 FROM blsample b
19081911 INNER JOIN crystal cr ON cr.crystalid = b.crystalid
19091912 INNER JOIN protein pr ON pr.proteinid = cr.proteinid
19101913 LEFT OUTER JOIN diffractionplan dp on dp.diffractionplanid = b.diffractionplanid
1914+ LEFT OUTER JOIN blsampleposition bsp ON bsp.blsampleid = b.blsampleid AND bsp.positiontype='dispensing'
19111915 WHERE pr.proposalid = :1 AND b.blsampleid = :2 " , array ($ this ->proposalid , $ this ->arg ('sid ' )));
19121916
19131917 if (!sizeof ($ samp ))
@@ -1980,6 +1984,34 @@ function _update_sample()
19801984 }
19811985 }
19821986 }
1987+
1988+ if ($ this ->has_arg ('X ' ) && $ this ->has_arg ('Y ' )) {
1989+ $ z = $ this ->has_arg ('Z ' ) ? $ this ->arg ('Z ' ) : null ;
1990+ $ pid = $ samp ['BLSAMPLEPOSITIONID ' ];
1991+ if ($ this ->arg ('X ' ) == '' && $ this ->arg ('Y ' ) == '' ) {
1992+ if (!empty ($ pid )) {
1993+ $ this ->db ->pq (
1994+ "UPDATE blsampleposition SET posx=null, posy=null, posz=null, recordtimestamp=CURRENT_TIMESTAMP WHERE blsamplepositionid=:1 " ,
1995+ array ($ pid )
1996+ );
1997+ }
1998+ } else {
1999+ if (empty ($ pid )) {
2000+ $ this ->db ->pq (
2001+ "INSERT INTO blsampleposition (blsampleid, posx, posy, posz, positiontype, recordtimestamp)
2002+ VALUES (:1, :2, :3, :4, 'dispensing', CURRENT_TIMESTAMP) RETURNING blsamplepositionid INTO :id " ,
2003+ array ($ this ->arg ('sid ' ), $ this ->arg ('X ' ), $ this ->arg ('Y ' ), $ z )
2004+ );
2005+ $ pid = $ this ->db ->id ();
2006+ } else {
2007+ $ this ->db ->pq (
2008+ "UPDATE blsampleposition SET posx=:1, posy=:2, posz=:3, recordtimestamp=CURRENT_TIMESTAMP WHERE blsamplepositionid=:4 " ,
2009+ array ($ this ->arg ('X ' ), $ this ->arg ('Y ' ), $ z , $ pid )
2010+ );
2011+ }
2012+ }
2013+ $ this ->_output (array ('BLSAMPLEPOSITIONID ' => $ pid ));
2014+ }
19832015 }
19842016
19852017
0 commit comments