From d51f939381d19c5591453fae568726d9cfe79e8d Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 15 Aug 2019 09:53:25 +0100 Subject: [PATCH 1/6] SP to retrieve samples not yet loaded for a registered container barcode --- grants/ispyb_processing.sql | 1 + schema/routines.sql | 54 +++++++++++++++++-- ...s_not_loaded_for_container_reg_barcode.sql | 37 +++++++++++++ 3 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 schema/stored_programs/sp_retrieve_samples_not_loaded_for_container_reg_barcode.sql diff --git a/grants/ispyb_processing.sql b/grants/ispyb_processing.sql index 80897e0d..13b63da4 100644 --- a/grants/ispyb_processing.sql +++ b/grants/ispyb_processing.sql @@ -110,3 +110,4 @@ GRANT EXECUTE ON PROCEDURE retrieve_grid_info_for_dcg_v2 TO 'ispyb_processing'; GRANT EXECUTE ON PROCEDURE retrieve_dewars_for_proposal_code_number_v2 TO 'ispyb_processing'; GRANT EXECUTE ON PROCEDURE retrieve_dc_main_v2 TO 'ispyb_processing'; GRANT EXECUTE ON PROCEDURE retrieve_dc TO 'ispyb_processing'; +GRANT EXECUTE ON PROCEDURE retrieve_samples_not_loaded_for_container_reg_barcode TO 'ispyb_processing'; diff --git a/schema/routines.sql b/schema/routines.sql index 169e173c..6a182270 100644 --- a/schema/routines.sql +++ b/schema/routines.sql @@ -1,8 +1,8 @@ --- MariaDB dump 10.17 Distrib 10.4.6-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.17 Distrib 10.4.7-MariaDB, for Linux (x86_64) -- -- Host: localhost Database: ispyb_build -- ------------------------------------------------------ --- Server version 10.4.6-MariaDB +-- Server version 10.4.7-MariaDB /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -3816,6 +3816,54 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `retrieve_samples_not_loaded_for_container_reg_barcode` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE PROCEDURE `retrieve_samples_not_loaded_for_container_reg_barcode`(p_barcode varchar(20)) +BEGIN + IF NOT (p_barcode IS NULL) THEN + + WITH most_recent_container AS ( + SELECT max(c.containerId) as containerId + FROM Container c + INNER JOIN ContainerRegistry cr USING(containerRegistryId) + WHERE cr.barcode=p_barcode + ) + SELECT bls.blSampleId "sampleId", + bls.containerId "containerId", + bls.name "sampleName", + bls.code "sampleCode", + bls.comments "sampleComments", + bls.location "sampleLocation", + max(ra.robotActionId) as rId + FROM BLSample bls + INNER JOIN most_recent_container mrc ON bls.containerId = mrc.containerId + LEFT OUTER JOIN RobotAction ra ON bls.blSampleId = ra.blSampleId + GROUP BY bls.blSampleId, + bls.containerId, + bls.name, + bls.code, + bls.comments, + bls.location + HAVING rId IS NULL + ORDER BY bls.blSampleId; + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_barcode'; + END IF; + +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `retrieve_sample_groups_for_sample` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7394,4 +7442,4 @@ DELIMITER ; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-07-02 11:48:59 +-- Dump completed on 2019-08-15 9:49:01 diff --git a/schema/stored_programs/sp_retrieve_samples_not_loaded_for_container_reg_barcode.sql b/schema/stored_programs/sp_retrieve_samples_not_loaded_for_container_reg_barcode.sql new file mode 100644 index 00000000..a0f12d6d --- /dev/null +++ b/schema/stored_programs/sp_retrieve_samples_not_loaded_for_container_reg_barcode.sql @@ -0,0 +1,37 @@ +DELIMITER ;; + +CREATE OR REPLACE PROCEDURE retrieve_samples_not_loaded_for_container_reg_barcode(p_barcode varchar(20)) +BEGIN + IF NOT (p_barcode IS NULL) THEN + + WITH most_recent_container AS ( + SELECT max(c.containerId) as containerId + FROM Container c + INNER JOIN ContainerRegistry cr USING(containerRegistryId) + WHERE cr.barcode=p_barcode + ) + SELECT bls.blSampleId "sampleId", + bls.containerId "containerId", + bls.name "sampleName", + bls.code "sampleCode", + bls.comments "sampleComments", + bls.location "sampleLocation", + max(ra.robotActionId) as rId + FROM BLSample bls + INNER JOIN most_recent_container mrc ON bls.containerId = mrc.containerId + LEFT OUTER JOIN RobotAction ra ON bls.blSampleId = ra.blSampleId + GROUP BY bls.blSampleId, + bls.containerId, + bls.name, + bls.code, + bls.comments, + bls.location + HAVING rId IS NULL + ORDER BY bls.blSampleId; + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_barcode'; + END IF; + +END;; + +DELIMITER ; From 8329bea8f8a97d0bd5acedf41164140085b1322b Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 15 Aug 2019 09:54:51 +0100 Subject: [PATCH 2/6] Sleeve table: track ice-filled plate sleeves --- schema/data.sql | 15 ++++++++++++--- schema/lookups.sql | 8 ++++---- schema/tables.sql | 22 +++++++++++++++++++--- schema/updates/2019_08_15_Sleeve.sql | 10 ++++++++++ 4 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 schema/updates/2019_08_15_Sleeve.sql diff --git a/schema/data.sql b/schema/data.sql index e16da18e..a1f3226c 100644 --- a/schema/data.sql +++ b/schema/data.sql @@ -1,8 +1,8 @@ --- MySQL dump 10.17 Distrib 10.3.14-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.17 Distrib 10.4.7-MariaDB, for Linux (x86_64) -- -- Host: localhost Database: ispyb_build -- ------------------------------------------------------ --- Server version 10.3.14-MariaDB +-- Server version 10.4.7-MariaDB /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -1591,6 +1591,15 @@ INSERT INTO `ShippingHasSession` (`shippingId`, `sessionId`) VALUES (474,339525) /*!40000 ALTER TABLE `ShippingHasSession` ENABLE KEYS */; UNLOCK TABLES; +-- +-- Dumping data for table `Sleeve` +-- + +LOCK TABLES `Sleeve` WRITE; +/*!40000 ALTER TABLE `Sleeve` DISABLE KEYS */; +/*!40000 ALTER TABLE `Sleeve` ENABLE KEYS */; +UNLOCK TABLES; + -- -- Dumping data for table `SpaceGroup` -- @@ -1774,4 +1783,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-04-23 11:38:32 +-- Dump completed on 2019-08-15 9:49:01 diff --git a/schema/lookups.sql b/schema/lookups.sql index f60c322a..4d9b4467 100644 --- a/schema/lookups.sql +++ b/schema/lookups.sql @@ -1,8 +1,8 @@ --- MariaDB dump 10.17 Distrib 10.4.6-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.17 Distrib 10.4.7-MariaDB, for Linux (x86_64) -- -- Host: localhost Database: ispyb_build -- ------------------------------------------------------ --- Server version 10.4.6-MariaDB +-- Server version 10.4.7-MariaDB /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -30,7 +30,7 @@ UNLOCK TABLES; LOCK TABLES `SchemaStatus` WRITE; /*!40000 ALTER TABLE `SchemaStatus` DISABLE KEYS */; -INSERT INTO `SchemaStatus` (`schemaStatusId`, `scriptName`, `schemaStatus`, `recordTimeStamp`) VALUES (6,'20180213_BLSample_subLocation.sql','DONE','2018-02-13 13:27:19'),(12,'20180213_DataCollectionFileAttachment_fileType.sql','DONE','2018-02-13 15:12:54'),(16,'20180303_v_run_to_table.sql','DONE','2018-07-25 15:11:18'),(19,'20180328_ImageQualityIndicators_alter_table.sql','DONE','2018-07-25 15:11:18'),(22,'20180410_BeamLineSetup_alter.sql','DONE','2018-07-25 15:11:18'),(25,'20180413_BeamLineSetup_and_Detector_alter.sql','DONE','2018-07-25 15:11:18'),(28,'20180501_DataCollectionGroup_experimentType_enum.sql','DONE','2018-07-25 15:11:18'),(31,'20180531_ScreeningOutput_alignmentSuccess.sql','DONE','2018-07-25 15:11:18'),(34,'20180629_DataCollection_imageContainerSubPath.sql','DONE','2018-07-25 15:11:18'),(35,'20180913_BeamCalendar.sql','DONE','2018-09-19 09:52:45'),(36,'2018_09_19_DataCollection_imageDirectory_comment.sql','DONE','2018-09-19 12:38:01'),(37,'2018_09_27_increase_schema_version.sql','DONE','2018-09-27 13:17:15'),(38,'2018_11_01_XrayCenteringResult.sql','DONE','2018-11-01 13:36:53'),(39,'2018_11_01_AutoProcProgram_dataCollectionId.sql','DONE','2018-11-01 15:10:38'),(40,'2018_11_01_AutoProcProgramMessage.sql','DONE','2018-11-01 15:28:17'),(44,'2018_11_01_DiffractionPlan_centeringMethod.sql','DONE','2018-11-01 22:51:36'),(45,'2018_11_02_DataCollectionGroup_experimentType_enum.sql','DONE','2018-11-02 11:54:15'),(47,'2018_11_05_spelling_of_centring.sql','DONE','2018-11-05 15:31:38'),(48,'2018_11_09_AutoProcProgram_update_processing_program.sql','DONE','2018-11-09 16:38:34'),(49,'2018_11_14_AutoProcProgramMessage_autoinc.sql','DONE','2018-11-14 10:15:27'),(50,'2018_11_22_AutoProcProgram_processingStatus_update.sql','DONE','2018-11-22 16:11:15'),(51,'2018_12_04_EnergyScan_and_XFEFluorescenceSpectrum_add_axisPosition.sql','DONE','2018-12-04 14:13:23'),(52,'2018_12_20_DataCollectionGroup_scanParameters.sql','DONE','2018-12-20 17:30:04'),(53,'2019_01_14_Proposal_state.sql','DONE','2019-01-14 12:13:31'),(54,'2019_01_14_ProcessingJobParameter_parameterValue.sql','DONE','2019-01-14 14:00:02'),(57,'2019_01_15_Detector_localName.sql','DONE','2019-01-15 23:01:15'),(58,'2019_02_04_BLSession_unique_index.sql','DONE','2019-02-04 13:52:19'),(59,'2019_03_29_BLSession_archived.sql','DONE','2019-04-03 14:43:08'),(60,'2019_04_03_UserGroup_and_Permission.sql','DONE','2019-04-03 14:51:04'),(61,'2019_04_07_AdminVar_bump_version.sql','DONE','2019-04-07 11:35:06'),(62,'2019_04_08_AdminVar_bump_version.sql','DONE','2019-04-08 15:38:01'),(63,'2019_04_23_AdminVar_bump_version.sql','DONE','2019-04-23 11:13:27'),(64,'2019_04_23_drop_v_run_view.sql','DONE','2019-04-23 11:13:35'),(67,'2019_04_23_v_run_additional_runs.sql','DONE','2019-04-23 12:39:47'),(68,'2019_05_28_AdminVar_bump_version.sql','DONE','2019-05-28 13:29:27'),(72,'2019_07_17_BLSample_crystalId_default.sql','DONE','2019-07-17 15:21:59'); +INSERT INTO `SchemaStatus` (`schemaStatusId`, `scriptName`, `schemaStatus`, `recordTimeStamp`) VALUES (6,'20180213_BLSample_subLocation.sql','DONE','2018-02-13 13:27:19'),(12,'20180213_DataCollectionFileAttachment_fileType.sql','DONE','2018-02-13 15:12:54'),(16,'20180303_v_run_to_table.sql','DONE','2018-07-25 15:11:18'),(19,'20180328_ImageQualityIndicators_alter_table.sql','DONE','2018-07-25 15:11:18'),(22,'20180410_BeamLineSetup_alter.sql','DONE','2018-07-25 15:11:18'),(25,'20180413_BeamLineSetup_and_Detector_alter.sql','DONE','2018-07-25 15:11:18'),(28,'20180501_DataCollectionGroup_experimentType_enum.sql','DONE','2018-07-25 15:11:18'),(31,'20180531_ScreeningOutput_alignmentSuccess.sql','DONE','2018-07-25 15:11:18'),(34,'20180629_DataCollection_imageContainerSubPath.sql','DONE','2018-07-25 15:11:18'),(35,'20180913_BeamCalendar.sql','DONE','2018-09-19 09:52:45'),(36,'2018_09_19_DataCollection_imageDirectory_comment.sql','DONE','2018-09-19 12:38:01'),(37,'2018_09_27_increase_schema_version.sql','DONE','2018-09-27 13:17:15'),(38,'2018_11_01_XrayCenteringResult.sql','DONE','2018-11-01 13:36:53'),(39,'2018_11_01_AutoProcProgram_dataCollectionId.sql','DONE','2018-11-01 15:10:38'),(40,'2018_11_01_AutoProcProgramMessage.sql','DONE','2018-11-01 15:28:17'),(44,'2018_11_01_DiffractionPlan_centeringMethod.sql','DONE','2018-11-01 22:51:36'),(45,'2018_11_02_DataCollectionGroup_experimentType_enum.sql','DONE','2018-11-02 11:54:15'),(47,'2018_11_05_spelling_of_centring.sql','DONE','2018-11-05 15:31:38'),(48,'2018_11_09_AutoProcProgram_update_processing_program.sql','DONE','2018-11-09 16:38:34'),(49,'2018_11_14_AutoProcProgramMessage_autoinc.sql','DONE','2018-11-14 10:15:27'),(50,'2018_11_22_AutoProcProgram_processingStatus_update.sql','DONE','2018-11-22 16:11:15'),(51,'2018_12_04_EnergyScan_and_XFEFluorescenceSpectrum_add_axisPosition.sql','DONE','2018-12-04 14:13:23'),(52,'2018_12_20_DataCollectionGroup_scanParameters.sql','DONE','2018-12-20 17:30:04'),(53,'2019_01_14_Proposal_state.sql','DONE','2019-01-14 12:13:31'),(54,'2019_01_14_ProcessingJobParameter_parameterValue.sql','DONE','2019-01-14 14:00:02'),(57,'2019_01_15_Detector_localName.sql','DONE','2019-01-15 23:01:15'),(58,'2019_02_04_BLSession_unique_index.sql','DONE','2019-02-04 13:52:19'),(59,'2019_03_29_BLSession_archived.sql','DONE','2019-04-03 14:43:08'),(60,'2019_04_03_UserGroup_and_Permission.sql','DONE','2019-04-03 14:51:04'),(61,'2019_04_07_AdminVar_bump_version.sql','DONE','2019-04-07 11:35:06'),(62,'2019_04_08_AdminVar_bump_version.sql','DONE','2019-04-08 15:38:01'),(63,'2019_04_23_AdminVar_bump_version.sql','DONE','2019-04-23 11:13:27'),(64,'2019_04_23_drop_v_run_view.sql','DONE','2019-04-23 11:13:35'),(67,'2019_04_23_v_run_additional_runs.sql','DONE','2019-04-23 12:39:47'),(68,'2019_05_28_AdminVar_bump_version.sql','DONE','2019-05-28 13:29:27'),(72,'2019_07_17_BLSample_crystalId_default.sql','DONE','2019-07-17 15:21:59'),(73,'2019_08_15_Sleeve.sql','DONE','2019-08-15 08:34:34'); /*!40000 ALTER TABLE `SchemaStatus` ENABLE KEYS */; UNLOCK TABLES; @@ -195,4 +195,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-07-17 16:23:11 +-- Dump completed on 2019-08-15 9:49:01 diff --git a/schema/tables.sql b/schema/tables.sql index 2823c2a0..4199bda5 100644 --- a/schema/tables.sql +++ b/schema/tables.sql @@ -1,8 +1,8 @@ --- MariaDB dump 10.17 Distrib 10.4.6-MariaDB, for Linux (x86_64) +-- MariaDB dump 10.17 Distrib 10.4.7-MariaDB, for Linux (x86_64) -- -- Host: localhost Database: ispyb_build -- ------------------------------------------------------ --- Server version 10.4.6-MariaDB +-- Server version 10.4.7-MariaDB /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -4381,6 +4381,22 @@ CREATE TABLE `ShippingHasSession` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `Sleeve` +-- + +DROP TABLE IF EXISTS `Sleeve`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `Sleeve` ( + `sleeveId` tinyint(3) unsigned NOT NULL COMMENT 'The unique sleeve id 1...255 which also identifies its home location in the freezer', + `location` tinyint(3) unsigned DEFAULT NULL COMMENT 'NULL == freezer, 1...255 for local storage locations', + `lastMovedToFreezer` timestamp NOT NULL DEFAULT current_timestamp(), + `lastMovedFromFreezer` timestamp NULL DEFAULT current_timestamp(), + PRIMARY KEY (`sleeveId`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Registry of ice-filled sleeves used to cool plates whilst on the goniometer'; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `SpaceGroup` -- @@ -5673,4 +5689,4 @@ SET character_set_client = @saved_cs_client; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-07-17 16:23:11 +-- Dump completed on 2019-08-15 9:49:00 diff --git a/schema/updates/2019_08_15_Sleeve.sql b/schema/updates/2019_08_15_Sleeve.sql new file mode 100644 index 00000000..237e17ef --- /dev/null +++ b/schema/updates/2019_08_15_Sleeve.sql @@ -0,0 +1,10 @@ +INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2019_08_15_Sleeve.sql', 'ONGOING'); + +CREATE TABLE Sleeve ( + sleeveId tinyint unsigned PRIMARY KEY COMMENT 'The unique sleeve id 1...255 which also identifies its home location in the freezer', + location tinyint unsigned COMMENT 'NULL == freezer, 1...255 for local storage locations', + lastMovedToFreezer timestamp NOT NULL DEFAULT current_timestamp, + lastMovedFromFreezer timestamp NULL DEFAULT current_timestamp +) COMMENT='Registry of ice-filled sleeves used to cool plates whilst on the goniometer'; + +UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2019_08_15_Sleeve.sql'; From 77c7140f989e162831c810307e569fc4b791b138 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 15 Aug 2019 09:59:35 +0100 Subject: [PATCH 3/6] Bump version to 1.6.0 --- schema/lookups.sql | 6 +++--- schema/updates/2019_08_15_AdminVar_bump_version.sql | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 schema/updates/2019_08_15_AdminVar_bump_version.sql diff --git a/schema/lookups.sql b/schema/lookups.sql index 4d9b4467..f6d5b940 100644 --- a/schema/lookups.sql +++ b/schema/lookups.sql @@ -20,7 +20,7 @@ LOCK TABLES `AdminVar` WRITE; /*!40000 ALTER TABLE `AdminVar` DISABLE KEYS */; -INSERT INTO `AdminVar` (`varId`, `name`, `value`) VALUES (4,'schemaVersion','1.5.2'); +INSERT INTO `AdminVar` (`varId`, `name`, `value`) VALUES (4,'schemaVersion','1.6.0'); /*!40000 ALTER TABLE `AdminVar` ENABLE KEYS */; UNLOCK TABLES; @@ -30,7 +30,7 @@ UNLOCK TABLES; LOCK TABLES `SchemaStatus` WRITE; /*!40000 ALTER TABLE `SchemaStatus` DISABLE KEYS */; -INSERT INTO `SchemaStatus` (`schemaStatusId`, `scriptName`, `schemaStatus`, `recordTimeStamp`) VALUES (6,'20180213_BLSample_subLocation.sql','DONE','2018-02-13 13:27:19'),(12,'20180213_DataCollectionFileAttachment_fileType.sql','DONE','2018-02-13 15:12:54'),(16,'20180303_v_run_to_table.sql','DONE','2018-07-25 15:11:18'),(19,'20180328_ImageQualityIndicators_alter_table.sql','DONE','2018-07-25 15:11:18'),(22,'20180410_BeamLineSetup_alter.sql','DONE','2018-07-25 15:11:18'),(25,'20180413_BeamLineSetup_and_Detector_alter.sql','DONE','2018-07-25 15:11:18'),(28,'20180501_DataCollectionGroup_experimentType_enum.sql','DONE','2018-07-25 15:11:18'),(31,'20180531_ScreeningOutput_alignmentSuccess.sql','DONE','2018-07-25 15:11:18'),(34,'20180629_DataCollection_imageContainerSubPath.sql','DONE','2018-07-25 15:11:18'),(35,'20180913_BeamCalendar.sql','DONE','2018-09-19 09:52:45'),(36,'2018_09_19_DataCollection_imageDirectory_comment.sql','DONE','2018-09-19 12:38:01'),(37,'2018_09_27_increase_schema_version.sql','DONE','2018-09-27 13:17:15'),(38,'2018_11_01_XrayCenteringResult.sql','DONE','2018-11-01 13:36:53'),(39,'2018_11_01_AutoProcProgram_dataCollectionId.sql','DONE','2018-11-01 15:10:38'),(40,'2018_11_01_AutoProcProgramMessage.sql','DONE','2018-11-01 15:28:17'),(44,'2018_11_01_DiffractionPlan_centeringMethod.sql','DONE','2018-11-01 22:51:36'),(45,'2018_11_02_DataCollectionGroup_experimentType_enum.sql','DONE','2018-11-02 11:54:15'),(47,'2018_11_05_spelling_of_centring.sql','DONE','2018-11-05 15:31:38'),(48,'2018_11_09_AutoProcProgram_update_processing_program.sql','DONE','2018-11-09 16:38:34'),(49,'2018_11_14_AutoProcProgramMessage_autoinc.sql','DONE','2018-11-14 10:15:27'),(50,'2018_11_22_AutoProcProgram_processingStatus_update.sql','DONE','2018-11-22 16:11:15'),(51,'2018_12_04_EnergyScan_and_XFEFluorescenceSpectrum_add_axisPosition.sql','DONE','2018-12-04 14:13:23'),(52,'2018_12_20_DataCollectionGroup_scanParameters.sql','DONE','2018-12-20 17:30:04'),(53,'2019_01_14_Proposal_state.sql','DONE','2019-01-14 12:13:31'),(54,'2019_01_14_ProcessingJobParameter_parameterValue.sql','DONE','2019-01-14 14:00:02'),(57,'2019_01_15_Detector_localName.sql','DONE','2019-01-15 23:01:15'),(58,'2019_02_04_BLSession_unique_index.sql','DONE','2019-02-04 13:52:19'),(59,'2019_03_29_BLSession_archived.sql','DONE','2019-04-03 14:43:08'),(60,'2019_04_03_UserGroup_and_Permission.sql','DONE','2019-04-03 14:51:04'),(61,'2019_04_07_AdminVar_bump_version.sql','DONE','2019-04-07 11:35:06'),(62,'2019_04_08_AdminVar_bump_version.sql','DONE','2019-04-08 15:38:01'),(63,'2019_04_23_AdminVar_bump_version.sql','DONE','2019-04-23 11:13:27'),(64,'2019_04_23_drop_v_run_view.sql','DONE','2019-04-23 11:13:35'),(67,'2019_04_23_v_run_additional_runs.sql','DONE','2019-04-23 12:39:47'),(68,'2019_05_28_AdminVar_bump_version.sql','DONE','2019-05-28 13:29:27'),(72,'2019_07_17_BLSample_crystalId_default.sql','DONE','2019-07-17 15:21:59'),(73,'2019_08_15_Sleeve.sql','DONE','2019-08-15 08:34:34'); +INSERT INTO `SchemaStatus` (`schemaStatusId`, `scriptName`, `schemaStatus`, `recordTimeStamp`) VALUES (6,'20180213_BLSample_subLocation.sql','DONE','2018-02-13 13:27:19'),(12,'20180213_DataCollectionFileAttachment_fileType.sql','DONE','2018-02-13 15:12:54'),(16,'20180303_v_run_to_table.sql','DONE','2018-07-25 15:11:18'),(19,'20180328_ImageQualityIndicators_alter_table.sql','DONE','2018-07-25 15:11:18'),(22,'20180410_BeamLineSetup_alter.sql','DONE','2018-07-25 15:11:18'),(25,'20180413_BeamLineSetup_and_Detector_alter.sql','DONE','2018-07-25 15:11:18'),(28,'20180501_DataCollectionGroup_experimentType_enum.sql','DONE','2018-07-25 15:11:18'),(31,'20180531_ScreeningOutput_alignmentSuccess.sql','DONE','2018-07-25 15:11:18'),(34,'20180629_DataCollection_imageContainerSubPath.sql','DONE','2018-07-25 15:11:18'),(35,'20180913_BeamCalendar.sql','DONE','2018-09-19 09:52:45'),(36,'2018_09_19_DataCollection_imageDirectory_comment.sql','DONE','2018-09-19 12:38:01'),(37,'2018_09_27_increase_schema_version.sql','DONE','2018-09-27 13:17:15'),(38,'2018_11_01_XrayCenteringResult.sql','DONE','2018-11-01 13:36:53'),(39,'2018_11_01_AutoProcProgram_dataCollectionId.sql','DONE','2018-11-01 15:10:38'),(40,'2018_11_01_AutoProcProgramMessage.sql','DONE','2018-11-01 15:28:17'),(44,'2018_11_01_DiffractionPlan_centeringMethod.sql','DONE','2018-11-01 22:51:36'),(45,'2018_11_02_DataCollectionGroup_experimentType_enum.sql','DONE','2018-11-02 11:54:15'),(47,'2018_11_05_spelling_of_centring.sql','DONE','2018-11-05 15:31:38'),(48,'2018_11_09_AutoProcProgram_update_processing_program.sql','DONE','2018-11-09 16:38:34'),(49,'2018_11_14_AutoProcProgramMessage_autoinc.sql','DONE','2018-11-14 10:15:27'),(50,'2018_11_22_AutoProcProgram_processingStatus_update.sql','DONE','2018-11-22 16:11:15'),(51,'2018_12_04_EnergyScan_and_XFEFluorescenceSpectrum_add_axisPosition.sql','DONE','2018-12-04 14:13:23'),(52,'2018_12_20_DataCollectionGroup_scanParameters.sql','DONE','2018-12-20 17:30:04'),(53,'2019_01_14_Proposal_state.sql','DONE','2019-01-14 12:13:31'),(54,'2019_01_14_ProcessingJobParameter_parameterValue.sql','DONE','2019-01-14 14:00:02'),(57,'2019_01_15_Detector_localName.sql','DONE','2019-01-15 23:01:15'),(58,'2019_02_04_BLSession_unique_index.sql','DONE','2019-02-04 13:52:19'),(59,'2019_03_29_BLSession_archived.sql','DONE','2019-04-03 14:43:08'),(60,'2019_04_03_UserGroup_and_Permission.sql','DONE','2019-04-03 14:51:04'),(61,'2019_04_07_AdminVar_bump_version.sql','DONE','2019-04-07 11:35:06'),(62,'2019_04_08_AdminVar_bump_version.sql','DONE','2019-04-08 15:38:01'),(63,'2019_04_23_AdminVar_bump_version.sql','DONE','2019-04-23 11:13:27'),(64,'2019_04_23_drop_v_run_view.sql','DONE','2019-04-23 11:13:35'),(67,'2019_04_23_v_run_additional_runs.sql','DONE','2019-04-23 12:39:47'),(68,'2019_05_28_AdminVar_bump_version.sql','DONE','2019-05-28 13:29:27'),(72,'2019_07_17_BLSample_crystalId_default.sql','DONE','2019-07-17 15:21:59'),(73,'2019_08_15_Sleeve.sql','DONE','2019-08-15 08:34:34'),(74,'2019_08_15_AdminVar_bump_version.sql','DONE','2019-08-15 08:57:37'); /*!40000 ALTER TABLE `SchemaStatus` ENABLE KEYS */; UNLOCK TABLES; @@ -195,4 +195,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-08-15 9:49:01 +-- Dump completed on 2019-08-15 9:58:13 diff --git a/schema/updates/2019_08_15_AdminVar_bump_version.sql b/schema/updates/2019_08_15_AdminVar_bump_version.sql new file mode 100644 index 00000000..7f2cb797 --- /dev/null +++ b/schema/updates/2019_08_15_AdminVar_bump_version.sql @@ -0,0 +1,5 @@ +INSERT IGNORE INTO SchemaStatus (scriptName, schemaStatus) VALUES ('2019_08_15_AdminVar_bump_version.sql', 'ONGOING'); + +UPDATE AdminVar SET `value` = '1.6.0' WHERE `name` = 'schemaVersion'; + +UPDATE SchemaStatus SET schemaStatus = 'DONE' WHERE scriptName = '2019_08_15_AdminVar_bump_version.sql'; From 680220e455cd7648d52c2561781fd44909b1b418 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 15 Aug 2019 10:01:50 +0100 Subject: [PATCH 4/6] Updated lists for tables + procs --- docs/list_of_procs.rst | 1 + docs/list_of_tables_and_columns.rst | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/docs/list_of_procs.rst b/docs/list_of_procs.rst index 3fc5505e..31f0a8ac 100644 --- a/docs/list_of_procs.rst +++ b/docs/list_of_procs.rst @@ -71,6 +71,7 @@ "**retrieve_reprocessing_by_dc**","p_dcId int(11) unsigned","Retrieves reprocessing requests for a data collection (p_dcId)." "**retrieve_samples_assigned_for_proposal**","IN p_proposalCode varchar(3), IN p_proposalNumber int","Retrieve the user friendly name and ID of all assigned instances" "**retrieve_samples_for_sample_group**","IN p_sampleGroupId int unsigned","Return multi-row result set with sample IDs, order in the group" + "**retrieve_samples_not_loaded_for_container_reg_barcode**","p_barcode varchar(20)","" "**retrieve_sample_groups_for_sample**","IN p_sampleId int unsigned","Return multi-row result-set with sample group IDs, order in the" "**retrieve_sample_type_for_sample**","IN p_sampleId int unsigned","Return single-row result set with sample type columns for sample" "**retrieve_sessions_for_beamline_and_run**","IN p_beamline varchar(15), IN p_run varchar(7)","Returns a multi-row result-set with the sessions (mx12345-123), their start and end dates for beamline p_beamline and run p_run" diff --git a/docs/list_of_tables_and_columns.rst b/docs/list_of_tables_and_columns.rst index c53b9da9..76a80041 100644 --- a/docs/list_of_tables_and_columns.rst +++ b/docs/list_of_tables_and_columns.rst @@ -1786,6 +1786,11 @@ **ShippingHasSession**,table,"" ``shippingId``,int,"" ``sessionId``,int,"" + **Sleeve**,table,"Registry of ice-filled sleeves used to cool plates whilst on the goniometer" + ``sleeveId``,tinyint,"The unique sleeve id 1...255 which also identifies its home location in the freezer" + ``location``,tinyint,"NULL == freezer, 1...255 for local storage locations" + ``lastMovedToFreezer``,timestamp,"" + ``lastMovedFromFreezer``,timestamp,"" **SpaceGroup**,table,"" ``spaceGroupId``,int,"Primary key" ``spaceGroupNumber``,int,"ccp4 number pr IUCR" From 9e7b3adf3d51aa09bcabcd7e6b3e76b2acfa1690 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 15 Aug 2019 12:00:36 +0100 Subject: [PATCH 5/6] New SPs: upsert_sleeve + retrieve_sleeve --- docs/list_of_procs.rst | 2 + schema/routines.sql | 87 ++++++++++++++----- schema/stored_programs/sp_retrieve_sleeve.sql | 15 ++++ schema/stored_programs/sp_upsert_sleeve.sql | 18 ++++ 4 files changed, 101 insertions(+), 21 deletions(-) create mode 100644 schema/stored_programs/sp_retrieve_sleeve.sql create mode 100644 schema/stored_programs/sp_upsert_sleeve.sql diff --git a/docs/list_of_procs.rst b/docs/list_of_procs.rst index 31f0a8ac..527f3b44 100644 --- a/docs/list_of_procs.rst +++ b/docs/list_of_procs.rst @@ -78,6 +78,7 @@ "**retrieve_sessions_for_person_login**","p_login varchar(45)","Returns a multi-row result-set with info about the sessions associated with a person with login=p_login" "**retrieve_session_id**","p_session varchar(15), OUT p_id int","" "**retrieve_session_id_v2**","p_session varchar(15), p_authLogin varchar(45)","Returns the session ID (an integer) for p_session (e.g. mx12345-123)" + "**retrieve_sleeve**","p_id tinyint unsigned","" "**retrieve_test**","","For testing the connection" "**update_container_assign**","IN p_beamline varchar(20), IN p_registry_barcode varchar(45), IN p_position int","Toggles assign status of container (p_barcode).Sets the s.c. position and beamline.If assigned then: 1) Also assign its dewar and shipping. 2) Unassigns other containers in the same proposal on that beamline and s.c. position.If unassign then:" "**update_container_ls_position**","IN p_barcode varchar(45), IN p_position int","Updates container sampleChangerLocation for barcode = p_barcode," @@ -133,6 +134,7 @@ "**upsert_sample_image_analysis**","INOUT p_id int(11) unsigned, p_containerBarcode varchar(45), p_sampleLocation varchar(45), p_oavSnapshotBefore varchar(255), p_oavSnapshotAfter varchar(255), p_deltaX int, p_deltaY int, p_goodnessOfFit float, p_scaleFactor float, p_resultCode varchar(15), p_matchStartTS timestamp, p_matchEndTS timestamp","Insert or update info about the sample image analysis for the mo" "**upsert_session_for_proposal_code_number**","INOUT p_id int(11) unsigned, p_proposalCode varchar(3), p_proposalNumber int(11), p_visitNumber int(10) unsigned, p_beamLineSetupId int(10) unsigned, p_startDate datetime, p_endDate datetime, p_beamlineName varchar(45), p_title varchar(255), p_beamlineOperator varchar(45), p_nbShifts int(10) unsigned, p_scheduled tinyint(1), p_usedFlag tinyint(1), p_comments varchar(255), p_externalPkId int(11) unsigned, p_externalPkUUID varchar(32)","Inserts or updates a session for a proposal with given code and" "**upsert_session_has_person**","p_sessionId int(10) unsigned, p_personId int(10) unsigned, p_role varchar(100), p_remote tinyint(1)","Inserts or updates info about a session - person association (p_sessionId, p_personId).Mandatory columns:For insert: p_sessionId, p_personIdFor update: p_sessionId, p_personIdReturns: Nothing." + "**upsert_sleeve**","p_id tinyint unsigned, p_location tinyint unsigned, p_lastMovedToFreezer datetime, p_lastMovedFromFreezer datetime","" "**upsert_xfe_fluo_spectrum**","INOUT p_id int(11) unsigned, p_sessionId int(10) unsigned, p_sampleId int(10) unsigned, p_subSampleId int(11) unsigned, p_startTime datetime, p_endTime datetime, p_energy float, p_fileName varchar(255), p_annotatedPymcaSpectrum varchar(255), p_fittedDataFileFullPath varchar(255), p_jpegScanFileFullPath varchar(255), p_scanFileFullPath varchar(255), p_beamSizeHorizontal float, p_beamSizeVertical float, p_exposureTime float, p_transmission float, p_flux double, p_fluxEnd double, p_comments varchar(1024)","Inserts or updates info about a fluorescence spectrum measuremen" "**upsert_xray_centring_result**","INOUT p_id int(11) unsigned, p_gridInfoId int(11) unsigned, p_method varchar(15), p_status varchar(45), p_x float, p_y float","Inserts or updates info about an x-ray centring result (p_id).Mandatory columns:For insert: p_gridInfoId and p_statusFor update: p_id Returns: Record ID in p_id." "**Warnings**","","" diff --git a/schema/routines.sql b/schema/routines.sql index 6a182270..84f95d7a 100644 --- a/schema/routines.sql +++ b/schema/routines.sql @@ -27,8 +27,7 @@ /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `insert_scaling`( - p_parentId integer, +CREATE FUNCTION `insert_scaling`(p_parentId integer, p_Type1 enum('overall','innerShell','outerShell'), p_Comments1 varchar(255), @@ -210,8 +209,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_dc`( - p_Id int(11) unsigned, +CREATE FUNCTION `upsert_dc`(p_Id int(11) unsigned, p_parentId int(11) unsigned, p_visitId int(11) unsigned, p_sampleId int(11) unsigned, @@ -409,8 +407,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_dcgroup`( - p_id int(11) unsigned, +CREATE FUNCTION `upsert_dcgroup`(p_id int(11) unsigned, p_parentId int(10) unsigned, p_sampleId int(10) unsigned, p_experimenttype varchar(45), @@ -465,8 +462,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_image`( - p_Id int(11) unsigned, +CREATE FUNCTION `upsert_image`(p_Id int(11) unsigned, p_parentId int(11) unsigned, p_imageNumber int(10) unsigned, p_filename varchar(255), @@ -521,8 +517,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_integration`( - p_id integer, +CREATE FUNCTION `upsert_integration`(p_id integer, p_parentId integer, p_datacollectionId integer, p_programRunId integer, @@ -610,8 +605,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_mrrun`( - p_id integer, +CREATE FUNCTION `upsert_mrrun`(p_id integer, p_parentId integer, p_success boolean, p_message varchar(255), @@ -695,8 +689,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_mrrun_blob`( - p_Id integer, +CREATE FUNCTION `upsert_mrrun_blob`(p_Id integer, p_parentId integer, p_view1 varchar(255), p_view2 varchar(255), @@ -732,8 +725,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_processing`( - p_id int(10), +CREATE FUNCTION `upsert_processing`(p_id int(10), p_parentId int(10), p_spacegroup varchar(45), p_refinedcell_a float, @@ -778,8 +770,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_program_run`( - p_Id int(10) unsigned, +CREATE FUNCTION `upsert_program_run`(p_Id int(10) unsigned, p_cmd_line varchar(255), p_programs varchar(255), p_status tinyint(1) , @@ -866,8 +857,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE FUNCTION `upsert_sample`( - p_id int(10) unsigned, +CREATE FUNCTION `upsert_sample`(p_id int(10) unsigned, p_crystalId int(10) unsigned, p_containerId int(10) unsigned, p_name varchar(45), @@ -4050,6 +4040,32 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `retrieve_sleeve` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE PROCEDURE `retrieve_sleeve`(p_id tinyint unsigned) +BEGIN + IF NOT (p_id IS NULL) THEN + SELECT sleeveId "id", location "location", lastMovedToFreezer "lastMovedToFreezer", lastMovedFromFreezer "lastMovedFromFreezer" + FROM Sleeve + WHERE sleeveId = p_id; + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_id must be non-NULL.'; + + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `retrieve_test` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7295,6 +7311,35 @@ DELIMITER ; /*!50003 SET character_set_client = @saved_cs_client */ ; /*!50003 SET character_set_results = @saved_cs_results */ ; /*!50003 SET collation_connection = @saved_col_connection */ ; +/*!50003 DROP PROCEDURE IF EXISTS `upsert_sleeve` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ; +DELIMITER ;; +CREATE PROCEDURE `upsert_sleeve`(p_id tinyint unsigned, p_location tinyint unsigned, p_lastMovedToFreezer datetime, p_lastMovedFromFreezer datetime) +BEGIN + IF NOT (p_id IS NULL) THEN + INSERT INTO Sleeve (sleeveId, location, lastMovedToFreezer, lastMovedFromFreezer) VALUES (p_id, p_location, p_lastMovedToFreezer, p_lastMovedFromFreezer) + ON DUPLICATE KEY UPDATE + location = IFNULL(p_location, location), + lastMovedToFreezer = IFNULL(p_lastMovedToFreezer, lastMovedToFreezer), + lastMovedFromFreezer = IFNULL(p_lastMovedFromFreezer, lastMovedFromFreezer); + + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_id must be non-NULL.'; + + END IF; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; /*!50003 DROP PROCEDURE IF EXISTS `upsert_xfe_fluo_spectrum` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -7442,4 +7487,4 @@ DELIMITER ; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2019-08-15 9:49:01 +-- Dump completed on 2019-08-15 11:55:50 diff --git a/schema/stored_programs/sp_retrieve_sleeve.sql b/schema/stored_programs/sp_retrieve_sleeve.sql new file mode 100644 index 00000000..4547b02e --- /dev/null +++ b/schema/stored_programs/sp_retrieve_sleeve.sql @@ -0,0 +1,15 @@ +DELIMITER ;; + +CREATE OR REPLACE PROCEDURE retrieve_sleeve(p_id tinyint unsigned) +BEGIN + IF NOT (p_id IS NULL) THEN + SELECT sleeveId "id", location "location", lastMovedToFreezer "lastMovedToFreezer", lastMovedFromFreezer "lastMovedFromFreezer" + FROM Sleeve + WHERE sleeveId = p_id; + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_id must be non-NULL.'; + + END IF; +END;; + +DELIMITER ; diff --git a/schema/stored_programs/sp_upsert_sleeve.sql b/schema/stored_programs/sp_upsert_sleeve.sql new file mode 100644 index 00000000..1ef7ba2a --- /dev/null +++ b/schema/stored_programs/sp_upsert_sleeve.sql @@ -0,0 +1,18 @@ +DELIMITER ;; + +CREATE OR REPLACE PROCEDURE upsert_sleeve(p_id tinyint unsigned, p_location tinyint unsigned, p_lastMovedToFreezer datetime, p_lastMovedFromFreezer datetime) +BEGIN + IF NOT (p_id IS NULL) THEN + INSERT INTO Sleeve (sleeveId, location, lastMovedToFreezer, lastMovedFromFreezer) VALUES (p_id, p_location, p_lastMovedToFreezer, p_lastMovedFromFreezer) + ON DUPLICATE KEY UPDATE + location = IFNULL(p_location, location), + lastMovedToFreezer = IFNULL(p_lastMovedToFreezer, lastMovedToFreezer), + lastMovedFromFreezer = IFNULL(p_lastMovedFromFreezer, lastMovedFromFreezer); + + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_id must be non-NULL.'; + + END IF; +END;; + +DELIMITER ; From 60178474af1fa492e7d66b4e3d112e4d1d6cedb4 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 15 Aug 2019 12:05:39 +0100 Subject: [PATCH 6/6] Grants for upsert_sleeve + retrieve_sleeve --- grants/ispyb_acquisition.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grants/ispyb_acquisition.sql b/grants/ispyb_acquisition.sql index 06b5c3e9..a2e28dcd 100644 --- a/grants/ispyb_acquisition.sql +++ b/grants/ispyb_acquisition.sql @@ -45,3 +45,6 @@ GRANT EXECUTE ON PROCEDURE `retrieve_container_subsamples_v2` TO 'ispyb_acquisit GRANT EXECUTE ON PROCEDURE upsert_dc_group_v3 TO 'ispyb_acquisition'; GRANT EXECUTE ON PROCEDURE retrieve_dc_group TO 'ispyb_acquisition'; GRANT EXECUTE ON PROCEDURE retrieve_dc_group_v2 TO 'ispyb_acquisition'; + +GRANT EXECUTE ON PROCEDURE retrieve_sleeve TO 'ispyb_acquisition'; +GRANT EXECUTE ON PROCEDURE upsert_sleeve TO 'ispyb_acquisition';