Skip to content

Commit f7780e9

Browse files
ndg63276Mark WilliamsgfrnJPHall-DLS
authored
Merge pre-release/2024-R4.4 into master (#849)
* LIMS-1003: Fix searching of container inspections (#825) Co-authored-by: Mark Williams <[email protected]> * LIMS-380: Fix position of autoPROC images (#831) * LIMS-380: Fix position of autoPROC images * LIMS-380: Just use iframe size of 98% * Set width/height to percentage value (#838) --------- Co-authored-by: Mark Williams <[email protected]> Co-authored-by: Guilherme Francisco <[email protected]> * LIMS-1430: Fix bugs on prepare for data collection page (#829) * LIMS-1430: Allow queuing even if no visible samples * LIMS-1430: Show number of samples to queue * LIMS-1430: Watch all subsamples for changes * LIMS-1430: Remove TODO list * LIMS-1430: Display number is of data collections, not samples * LIMS-1430: Dont allow queueing if hidden data collections are invalid * Update client/src/js/modules/imaging/views/queuecontainer.js Co-authored-by: Guilherme Francisco <[email protected]> --------- Co-authored-by: Mark Williams <[email protected]> Co-authored-by: Guilherme Francisco <[email protected]> * LIMS-1390: Fix searching of data collection groups (#833) Co-authored-by: Mark Williams <[email protected]> * LIMS-1286: Show ERA status on calendar and visits list (#834) Co-authored-by: Mark Williams <[email protected]> * LIMS-1354: Migrate from ActiveMQ to RabbitMQ (#826) * LIMS-1354: Migrate from ActiveMQ to RabbitMQ * Unwrap try...catch * Add routing_key and vhost * Add polyfill for BCMath as php-bcmath extension is not installed but required by php-amqplib for AMQP --------- Co-authored-by: Mark Williams <[email protected]> Co-authored-by: Guilherme Francisco <[email protected]> Co-authored-by: James Hall <[email protected]>
1 parent 087beda commit f7780e9

File tree

12 files changed

+134
-82
lines changed

12 files changed

+134
-82
lines changed

api/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
"mpdf/mpdf": "8.1.2",
2222
"ralouphie/getallheaders": "2.0.5",
2323
"slim/slim": "2.6.2",
24-
"stomp-php/stomp-php": "3.0.6",
24+
"php-amqplib/php-amqplib": "^2.0",
2525
"symfony/http-foundation": "^5.4",
2626
"symfony/filesystem": "^5.4",
2727
"mpdf/qrcode": "^1.2",
2828
"mtcmedia/dhl-api": "dev-master#9b4b6315",
29-
"maennchen/zipstream-php": "2.1.0"
29+
"maennchen/zipstream-php": "2.1.0",
30+
"phpseclib/bcmath_compat": "^2.0"
3031
},
3132
"autoload": {
3233
"psr-4": {

api/src/Page.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,14 +1109,16 @@ function _submit_zocalo_recipe($recipe, $parameters, $error_code = 500)
11091109
}
11101110

11111111

1112-
function _send_zocalo_message($zocalo_queue, $zocalo_message, $error_code = 500)
1112+
function _send_zocalo_message($rabbitmq_zocalo_vhost, $zocalo_message, $error_code = 500)
11131113
{
11141114
global
1115-
$zocalo_server,
1116-
$zocalo_username,
1117-
$zocalo_password;
1115+
$rabbitmq_zocalo_host,
1116+
$rabbitmq_zocalo_port,
1117+
$rabbitmq_zocalo_username,
1118+
$rabbitmq_zocalo_password,
1119+
$rabbitmq_zocalo_routing_key;
11181120

1119-
if (empty($zocalo_server) || empty($zocalo_queue))
1121+
if (empty($rabbitmq_zocalo_host) || empty($rabbitmq_zocalo_vhost))
11201122
{
11211123
$message = 'Zocalo server or queue not specified.';
11221124
error_log($message);
@@ -1129,8 +1131,8 @@ function _send_zocalo_message($zocalo_queue, $zocalo_message, $error_code = 500)
11291131
try
11301132
{
11311133
error_log("Sending message" . var_export($zocalo_message, true));
1132-
$queue = new Queue($zocalo_server, $zocalo_username, $zocalo_password);
1133-
$queue->send($zocalo_queue, $zocalo_message, true, $this->user->loginId);
1134+
$queue = new Queue($rabbitmq_zocalo_host, $rabbitmq_zocalo_port, $rabbitmq_zocalo_username, $rabbitmq_zocalo_password, $rabbitmq_zocalo_vhost);
1135+
$queue->send($zocalo_message, $rabbitmq_zocalo_routing_key);
11341136
}
11351137
catch (Exception $e)
11361138
{

api/src/Page/DC.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,14 @@ function _data_collections($single = null)
368368
$s = str_replace('_', '$_', $this->arg('s'));
369369

370370
$st = sizeof($args) + 1;
371-
$where .= " AND (lower(dc.filetemplate) LIKE lower(CONCAT(CONCAT('%',:$st),'%')) ESCAPE '$' OR lower(dc.imagedirectory) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 1) . "), '%')) ESCAPE '$' OR lower(smp.name) LIKE lower(CONCAT(CONCAT('%', :" . ($st + 2) . "), '%')) ESCAPE '$')";
372-
$where2 .= " AND (lower(es.comments) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 3) . "), '%')) ESCAPE '$' OR lower(es.element) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 4) . "), '%')) ESCAPE '$' OR lower(smp.name) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 5) . "), '%')) ESCAPE '$')";
371+
$where .= " AND (dc.filetemplate LIKE CONCAT('%',:$st,'%') ESCAPE '$' OR dc.imagedirectory LIKE CONCAT('%',:" . ($st + 1) . ",'%') ESCAPE '$' OR smp.name LIKE CONCAT('%', :" . ($st + 2) . ",'%') ESCAPE '$')";
372+
$where2 .= " AND (es.comments LIKE CONCAT('%',:" . ($st + 3) . ",'%') ESCAPE '$' OR es.element LIKE CONCAT('%',:" . ($st + 4) . ",'%') ESCAPE '$' OR smp.name LIKE CONCAT('%',:" . ($st + 5) . ",'%') ESCAPE '$')";
373373
$where3 .= ' AND r.robotactionid < 0';
374-
$where4 .= " AND (lower(xrf.filename) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 6) . "), '%')) ESCAPE '$' OR lower(smp.name) LIKE lower(CONCAT(CONCAT('%',:" . ($st + 7) . "), '%')) ESCAPE '$')";
374+
$where4 .= " AND (xrf.filename LIKE CONCAT('%',:" . ($st + 6) . ",'%') ESCAPE '$' OR smp.name LIKE CONCAT('%',:" . ($st + 7) . ",'%') ESCAPE '$')";
375375

376376
for ($i = 0; $i < 8; $i++)
377377
array_push($args, $s);
378+
378379
}
379380

380381
# Set Count field
@@ -511,9 +512,9 @@ function _data_collections($single = null)
511512
// $this->db->set_debug(True);
512513

513514
// will want to support these too at some point
514-
$where2 = ' AND es.energyscanid < 0';
515-
$where3 = ' AND r.robotactionid < 0';
516-
$where4 = ' AND xrf.xfefluorescencespectrumid < 0';
515+
$where2 .= ' AND es.energyscanid < 0';
516+
$where3 .= ' AND r.robotactionid < 0';
517+
$where4 .= ' AND xrf.xfefluorescencespectrumid < 0';
517518

518519
if ($this->has_arg('dcg')) {
519520
$where .= ' AND dc.datacollectiongroupid=:' . (sizeof($args) + 1);

api/src/Page/Imaging.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ function _get_inspections()
376376
$where .= " AND i.state='Completed'";
377377
}
378378

379+
if ($this->has_arg('s')) {
380+
$where .= " AND (CONCAT(p.proposalcode, p.proposalnumber) LIKE CONCAT('%', :" . (sizeof($args) + 1) . ", '%') OR c.code LIKE CONCAT('%', :" . (sizeof($args) + 2) . ", '%'))";
381+
array_push($args, $this->arg('s'), $this->arg('s'));
382+
}
383+
379384
$tot = $this->db->pq("SELECT count(i.containerinspectionid) as tot FROM containerinspection i
380385
INNER JOIN container c ON c.containerid = i.containerid
381386
INNER JOIN dewar d ON d.dewarid = c.dewarid
@@ -422,12 +427,6 @@ function _get_inspections()
422427
$order = $cols[$this->arg('sort_by')] . ' ' . $dir;
423428
}
424429

425-
if ($this->has_arg('s')) {
426-
$where .= " AND (LOWER(CONCAT(p.proposalcode, p.proposalnumber)) LIKE LOWER(CONCAT(CONCAT('%', :" . (sizeof($args) + 1) . "), '%')) OR LOWER(c.code) LIKE LOWER(CONCAT(CONCAT('%', :" . (sizeof($args) + 2) . "), '%')))";
427-
array_push($args, $this->arg('s'));
428-
array_push($args, $this->arg('s'));
429-
}
430-
431430
if ($this->has_arg('ty')) {
432431
if ($this->arg('ty') == 'COMPLETED')
433432
$where .= " AND i.state = 'Completed' AND i.manual=0";

api/src/Page/Process.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ function _add_reprocessing_sweep($args) {
355355

356356
function _enqueue()
357357
{
358-
global $zocalo_mx_reprocess_queue;
358+
global $rabbitmq_zocalo_vhost;
359359

360360
if (!$this->has_arg('PROCESSINGJOBID')) $this->_error('No processing job specified');
361361

@@ -379,7 +379,7 @@ function _enqueue()
379379
'ispyb_process' => intval($this->arg('PROCESSINGJOBID')),
380380
)
381381
);
382-
$this->_send_zocalo_message($zocalo_mx_reprocess_queue, $message);
382+
$this->_send_zocalo_message($rabbitmq_zocalo_vhost, $message);
383383

384384
$this->_output(new \stdClass);
385385
}

api/src/Page/Proposal.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ function _get_visits($visit = null, $output = true)
456456
s.beamlineoperator AS lc,
457457
s.comments,
458458
s.scheduled,
459+
s.riskrating,
459460
st.typename AS sessiontype,
460461
DATE_FORMAT(s.startdate, '%d-%m-%Y %H:%i') AS startdate,
461462
DATE_FORMAT(s.enddate, '%d-%m-%Y %H:%i') AS enddate,

api/src/Queue.php

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,34 @@
22

33
namespace SynchWeb;
44

5-
use Stomp\Exception\StompException;
6-
use Stomp\Stomp;
5+
use PhpAmqpLib\Connection\AMQPStreamConnection;
6+
use PhpAmqpLib\Message\AMQPMessage;
77

88
class Queue
99
{
10-
private $server, $username, $password;
10+
private $host, $port, $username, $password, $vhost;
1111

12-
function __construct($server, $username, $password)
12+
function __construct($host, $port, $username, $password, $vhost)
1313
{
14-
$this->server = $server;
14+
$this->host = $host;
15+
$this->port = $port;
1516
$this->username = $username;
1617
$this->password = $password;
18+
$this->vhost = $vhost;
1719
}
1820

19-
function send($queue, array $message, $persistent = false, $login = null)
21+
function send(array $message, $routing_key)
2022
{
21-
try {
22-
$connection = new Stomp($this->server);
23-
24-
$connection->connect($this->username, $this->password);
25-
26-
$connection->send(
27-
$queue,
28-
json_encode($message, JSON_UNESCAPED_SLASHES),
29-
array(
30-
'persistent' => ($persistent === true),
31-
'synchweb.host' => gethostname(),
32-
'synchweb.user' => $login,
33-
)
34-
);
35-
36-
$connection->disconnect();
37-
} catch (StompException $e) {
38-
/** @noinspection PhpUnhandledExceptionInspection */
39-
40-
throw $e;
41-
}
23+
$connection = new AMQPStreamConnection($this->host, $this->port, $this->username, $this->password, $this->vhost);
24+
$channel = $connection->channel();
25+
26+
$msg = new AMQPMessage(
27+
json_encode($message, JSON_UNESCAPED_SLASHES)
28+
);
29+
30+
$channel->basic_publish($msg, null, $routing_key);
31+
32+
$channel->close();
33+
$connection->close();
4234
}
4335
}

client/src/js/modules/calendar/views/components/calendar-day-events.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@
2121
class="tw-no-underline tw-text-content-page-color"
2222
>
2323
{{ session['VISIT'] }}
24-
</router-link> <span> ({{ session['LEN'] }})</span>
24+
</router-link>
25+
<span v-if="session['RISKRATING'] == 'Low'" title="Risk Rating: Low">&#128994;</span>
26+
<span v-else-if="session['RISKRATING'] == 'Medium'" title="Risk Rating: Medium">&#128993;</span>
27+
<span v-else-if="session['RISKRATING'] == 'High'" title="Risk Rating: High">&#128308;</span>
28+
<span v-else title="No approved ERA">&#9899;</span>
29+
<span> ({{ session['LEN'] }})</span>
2530
</p>
2631
<p class="tw-ml-2">
2732
- {{ session['BEAMLINEOPERATOR'] }}
@@ -105,4 +110,4 @@ export default {
105110
}
106111
}
107112
</script>
108-
<style></style>
113+
<style></style>

0 commit comments

Comments
 (0)