From ba7938d838c586d3905313bc223db7487f1aee9f Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Fri, 19 Jan 2018 14:29:37 +0000 Subject: [PATCH 01/11] 2 new stored procedures + bug fixes to older stored functions --- src/test/resources/schema.sql | 223 +++++++++++++++++++++++++++++----- 1 file changed, 190 insertions(+), 33 deletions(-) diff --git a/src/test/resources/schema.sql b/src/test/resources/schema.sql index 1cf7128..ca30c3b 100644 --- a/src/test/resources/schema.sql +++ b/src/test/resources/schema.sql @@ -7278,21 +7278,21 @@ CREATE FUNCTION `upsert_dc`( p_focalSpotSizeAtSampleY float, p_polarisation float, p_flux float, - +-- new params p_processedDataFile varchar(255), p_datFullPath varchar(255), p_magnification int(11), p_totalAbsorbedDose float, - p_binning tinyint(1), - p_particleDiameter float, + p_binning tinyint(1), -- 1x or 2x + p_particleDiameter float, -- in nm p_boxSize_CTF float, - p_minResolution float, - p_minDefocus float, - p_maxDefocus float, - p_defocusStepSize float, - p_amountAstigmatism float, - p_extractSize float, - p_bgRadius float, + p_minResolution float, -- in A + p_minDefocus float, -- in A + p_maxDefocus float, -- in A + p_defocusStepSize float, -- in A + p_amountAstigmatism float, -- in A + p_extractSize float, -- in nm + p_bgRadius float, -- in nm p_voltage float, p_objAperture float, p_c1aperture float, @@ -7400,10 +7400,10 @@ BEGIN c2lens = IFNULL(p_c2lens, c2lens), c3lens = IFNULL(p_c3lens, c3lens); - IF LAST_INSERT_ID() = 0 THEN - RETURN p_id; - ELSE + IF p_id IS NULL THEN RETURN LAST_INSERT_ID(); + ELSE + RETURN p_id; END IF; END ;; DELIMITER ; @@ -7425,7 +7425,7 @@ CREATE FUNCTION `upsert_dcgroup`( p_id int(11) unsigned, p_parentId int(10) unsigned, p_sampleId int(10) unsigned, - p_experimenttype varchar(45), + p_experimenttype varchar(45), -- values controlled by enum on the table p_starttime datetime, p_endtime datetime, p_crystalClass varchar(20), @@ -7456,10 +7456,10 @@ BEGIN actualContainerSlotInSC = IFNULL(p_actualContainerSlotInSC, actualContainerSlotInSC), comments = IFNULL(p_comments, comments); - IF LAST_INSERT_ID() = 0 THEN - RETURN p_id; - ELSE + IF p_id IS NULL THEN RETURN LAST_INSERT_ID(); + ELSE + RETURN p_id; END IF; END ;; DELIMITER ; @@ -7512,10 +7512,10 @@ BEGIN comments = IFNULL(p_comments, comments), machineMessage = IFNULL(p_machineMessage, machineMessage); - IF LAST_INSERT_ID() = 0 THEN - RETURN p_id; - ELSE + IF p_id IS NULL THEN RETURN LAST_INSERT_ID(); + ELSE + RETURN p_id; END IF; END ;; DELIMITER ; @@ -7645,7 +7645,7 @@ CREATE FUNCTION `upsert_mrrun`( MODIFIES SQL DATA BEGIN - + -- Insert a new row, using all the parameters INSERT INTO MXMRRun (mxMRRunId, autoProcScalingId, success, message, pipeline, inputCoordFile, outputCoordFile, inputMTZFile, outputMTZFile, runDirectory, logFile, commandLine, rValueStart, rValueEnd, rFreeValueStart, rFreeValueEnd, starttime, endtime) VALUES ( @@ -7686,10 +7686,10 @@ BEGIN starttime = IFNULL(p_starttime, starttime), endtime = IFNULL(p_endtime, endtime); - IF LAST_INSERT_ID() = 0 THEN - RETURN p_id; - ELSE + IF p_id IS NULL THEN RETURN LAST_INSERT_ID(); + ELSE + RETURN p_id; END IF; END ;; DELIMITER ; @@ -7723,10 +7723,10 @@ BEGIN view2 = IFNULL(p_view2, view2), view3 = IFNULL(p_view3, view3); - IF LAST_INSERT_ID() = 0 THEN - RETURN p_id; - ELSE + IF p_id IS NULL THEN RETURN LAST_INSERT_ID(); + ELSE + RETURN p_id; END IF; END ;; DELIMITER ; @@ -7910,10 +7910,10 @@ BEGIN blSampleStatus = IFNULL(p_blSampleStatus, blSampleStatus), isInSampleChanger = IFNULL(p_isInSampleChanger, isInSampleChanger); - IF LAST_INSERT_ID() = 0 THEN - RETURN p_id; - ELSE + IF p_id IS NULL THEN RETURN LAST_INSERT_ID(); + ELSE + RETURN p_id; END IF; END ;; DELIMITER ; @@ -9379,6 +9379,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 `retrieve_pdb_for_component` */; +/*!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 = '' */ ; +DELIMITER ;; +CREATE PROCEDURE `retrieve_pdb_for_component`(IN p_componentId int unsigned) + READS SQL DATA + COMMENT 'Return multi-row result set with PDB columns for component p_componentId' +BEGIN + IF NOT (p_componentId IS NULL) THEN + SELECT pdb.pdbId "pdbId", pdb.name "name", pdb.contents "contents", pdb.code "code" + FROM PDB pdb + INNER JOIN Protein_has_PDB php ON pdb.pdbId = php.pdbId + WHERE php.proteinId = p_componentId + ORDER BY pdb.pdbId; + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_componentId'; + 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_persons_for_proposal` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -9663,6 +9692,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 `retrieve_sample_type_for_sample` */; +/*!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 = '' */ ; +DELIMITER ;; +CREATE PROCEDURE `retrieve_sample_type_for_sample`(IN p_sampleId int unsigned) + READS SQL DATA + COMMENT 'Return single-row result set with sample type columns for sample p_sampleId' +BEGIN + IF NOT (p_sampleId IS NULL) THEN + SELECT c.crystalId "sampleTypeId", c.proteinId "componentId", c.name "name", c.comments "comments" + FROM Crystal c + INNER JOIN BLSample bls ON c.crystalId = bls.crystalId + WHERE bls.blSampleId = p_sampleId + ORDER BY c.crystalId; + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument is NULL: p_sampleId'; + 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_session_id` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -10397,7 +10455,7 @@ DELIMITER ; /*!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' */ ; +/*!50003 SET sql_mode = '' */ ; DELIMITER ;; CREATE PROCEDURE `upsert_dc_group`( INOUT p_id int(11) unsigned, @@ -10418,6 +10476,7 @@ CREATE PROCEDURE `upsert_dc_group`( p_comments varchar(1024) ) MODIFIES SQL DATA + COMMENT 'Inserts or updates info about data collection group (p_id).\nMandatory columns:\nFor insert: p_proposalCode, p_proposalNumber, p_sessionNumber\nFor update: p_id \nIn order to associate the data collection group with a sample, one of the following sets of parameters are required:\n* p_sampleId\n* p_proposalCode, p_proposalNumber, p_sessionNumber + p_sampleBarcode\n* p_actualContainerBarcode + p_actualSampleSlotInContainer' BEGIN DECLARE row_session_id int(10) unsigned DEFAULT NULL; @@ -10467,7 +10526,7 @@ BEGIN actualContainerSlotInSC = IFNULL(p_actualContainerSlotInSC, actualContainerSlotInSC), comments = IFNULL(p_comments, comments); - IF LAST_INSERT_ID() <> 0 THEN + IF p_id IS NULL THEN SET p_id = LAST_INSERT_ID(); END IF; END IF; @@ -10477,6 +10536,104 @@ 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_dc_group_v2` */; +/*!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 = '' */ ; +DELIMITER ;; +CREATE PROCEDURE `upsert_dc_group_v2`( + INOUT p_id int(11) unsigned, + p_sessionId int(10) unsigned, + p_proposalCode varchar(3), + p_proposalNumber int(10), + p_sessionNumber int(10), + p_sampleId int(10) unsigned, + p_sampleBarcode varchar(45), + p_experimenttype varchar(45), -- values controlled by enum on the table + p_starttime datetime, + p_endtime datetime, + p_crystalClass varchar(20), + p_detectorMode varchar(255), + p_actualSampleBarcode varchar(45), + p_actualSampleSlotInContainer integer(10), + p_actualContainerBarcode varchar(45), + p_actualContainerSlotInSC integer(10), + p_comments varchar(1024), + p_xtalSnapshotFullPath varchar(255) + ) + MODIFIES SQL DATA + COMMENT 'Inserts or updates info about data collection group (p_id).\nMandatory columns:\nFor insert: Either p_sessionId or a valid session described by (p_proposalCode, p_proposalNumber, p_sessionNumber)\nFor update: p_id \nNote: In order to associate the data collection group with a sample, one of the following sets of parameters are required:\n* p_sampleId\n* p_proposalCode, p_proposalNumber, p_sessionNumber + p_sampleBarcode\n* p_actualContainerBarcode + p_actualSampleSlotInContainer\nReturns: Record ID in p_id.' +BEGIN + DECLARE row_proposal_id int(10) unsigned DEFAULT NULL; + DECLARE row_sample_id int(10) unsigned DEFAULT NULL; + + IF p_sessionId IS NULL AND p_proposalCode IS NOT NULL AND p_proposalNumber IS NOT NULL AND p_sessionNumber IS NOT NULL THEN + SELECT max(bs.sessionid), p.proposalId INTO p_sessionId, row_proposal_id + FROM Proposal p INNER JOIN BLSession bs ON p.proposalid = bs.proposalid + WHERE p.proposalCode = p_proposalCode AND p.proposalNumber = p_proposalNumber AND bs.visit_number = p_sessionNumber; + END IF; + + IF p_id IS NOT NULL OR p_sessionId IS NOT NULL THEN + -- set p_sampleId if not already set + IF p_sessionId IS NOT NULL AND p_sampleId IS NULL AND p_sampleBarcode IS NOT NULL THEN + IF row_proposal_id IS NULL THEN + SELECT proposalId INTO row_proposal_id + FROM BLSession + WHERE sessionId = p_sessionId; + END IF; + SELECT max(bls.blSampleId) INTO p_sampleId + FROM BLSample bls + INNER JOIN Container c on c.containerId = bls.containerId + INNER JOIN Dewar d on d.dewarId = c.dewarId + INNER JOIN Shipping s on s.shippingId = d.shippingId + WHERE bls.code = p_sampleBarcode AND s.proposalId = row_proposal_id; + END IF; + + IF p_sampleId IS NULL AND (p_actualContainerBarcode IS NOT NULL) AND (p_actualSampleSlotInContainer IS NOT NULL) THEN + SELECT max(bls.blSampleId) INTO p_sampleId + FROM BLSample bls + INNER JOIN Container c on c.containerId = bls.containerId + WHERE c.barcode = p_actualContainerBarcode AND bls.location = p_actualSampleSlotInContainer; + END IF; + + INSERT INTO DataCollectionGroup (datacollectionGroupId, sessionId, blsampleId, experimenttype, starttime, endtime, + crystalClass, detectorMode, actualSampleBarcode, actualSampleSlotInContainer, actualContainerBarcode, actualContainerSlotInSC, + comments, xtalSnapshotFullPath) + VALUES (p_id, p_sessionId, p_sampleId, p_experimenttype, p_starttime, p_endtime, p_crystalClass, p_detectorMode, + p_actualSampleBarcode, p_actualSampleSlotInContainer, p_actualContainerBarcode, p_actualContainerSlotInSC, + p_comments, p_xtalSnapshotFullPath) + ON DUPLICATE KEY UPDATE + sessionId = IFNULL(p_sessionId, sessionId), + blsampleId = IFNULL(p_sampleId, blsampleId), + experimenttype = IFNULL(p_experimenttype, experimenttype), + starttime = IFNULL(p_starttime, starttime), + endtime = IFNULL(p_endtime, endtime), + crystalClass = IFNULL(p_crystalClass, crystalClass), + detectorMode = IFNULL(p_detectorMode, detectorMode), + actualSampleBarcode = IFNULL(p_actualSampleBarcode, actualSampleBarcode), + actualSampleSlotInContainer = IFNULL(p_actualSampleSlotInContainer, actualSampleSlotInContainer), + actualContainerBarcode = IFNULL(p_actualContainerBarcode, actualContainerBarcode), + actualContainerSlotInSC = IFNULL(p_actualContainerSlotInSC, actualContainerSlotInSC), + comments = IFNULL(p_comments, comments), + xtalSnapshotFullPath = IFNULL(p_xtalSnapshotFullPath, xtalSnapshotFullPath); + + IF p_id IS NULL THEN + SET p_id = LAST_INSERT_ID(); + END IF; + ELSE + SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644, MESSAGE_TEXT='Mandatory argument(s) are NULL: p_id OR p_sessionId OR a valid session described by (p_proposalCode and p_proposalNumber and p_sessionNumber) 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_dc_main` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; @@ -11885,4 +12042,4 @@ DELIMITER ; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2017-12-07 17:16:16 +-- Dump completed on 2018-01-17 15:37:37 From 30c0e4353844f5fb7c3daeee940a493219d54813 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Fri, 19 Jan 2018 14:46:35 +0000 Subject: [PATCH 02/11] renamed one of the new stored procedures --- src/test/resources/schema.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/resources/schema.sql b/src/test/resources/schema.sql index ca30c3b..7f587e6 100644 --- a/src/test/resources/schema.sql +++ b/src/test/resources/schema.sql @@ -9379,7 +9379,7 @@ 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_pdb_for_component` */; +/*!50003 DROP PROCEDURE IF EXISTS `retrieve_pdbs_for_component` */; /*!50003 SET @saved_cs_client = @@character_set_client */ ; /*!50003 SET @saved_cs_results = @@character_set_results */ ; /*!50003 SET @saved_col_connection = @@collation_connection */ ; @@ -9389,7 +9389,7 @@ DELIMITER ; /*!50003 SET @saved_sql_mode = @@sql_mode */ ; /*!50003 SET sql_mode = '' */ ; DELIMITER ;; -CREATE PROCEDURE `retrieve_pdb_for_component`(IN p_componentId int unsigned) +CREATE PROCEDURE `retrieve_pdbs_for_component`(IN p_componentId int unsigned) READS SQL DATA COMMENT 'Return multi-row result set with PDB columns for component p_componentId' BEGIN @@ -12042,4 +12042,4 @@ DELIMITER ; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-01-17 15:37:37 +-- Dump completed on 2018-01-19 14:43:56 From 3fe310ee5a6275ffd3f2ec8277e90917873c9c6f Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Fri, 19 Jan 2018 15:50:38 +0000 Subject: [PATCH 03/11] New beans and methods for SPs retrieve_sample_type_for_sample, retrieve_pdbs_for_component --- .../uk/ac/diamond/ispyb/api/IspybXpdfApi.java | 2 + .../java/uk/ac/diamond/ispyb/api/PDB.java | 70 +++++++++++++++++++ .../uk/ac/diamond/ispyb/api/SampleType.java | 70 +++++++++++++++++++ .../uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java | 14 ++++ 4 files changed, 156 insertions(+) create mode 100644 src/main/java/uk/ac/diamond/ispyb/api/PDB.java create mode 100644 src/main/java/uk/ac/diamond/ispyb/api/SampleType.java diff --git a/src/main/java/uk/ac/diamond/ispyb/api/IspybXpdfApi.java b/src/main/java/uk/ac/diamond/ispyb/api/IspybXpdfApi.java index 5b747cf..56eea3e 100644 --- a/src/main/java/uk/ac/diamond/ispyb/api/IspybXpdfApi.java +++ b/src/main/java/uk/ac/diamond/ispyb/api/IspybXpdfApi.java @@ -28,4 +28,6 @@ public interface IspybXpdfApi extends Closeable { Optional retrieveDataCollectionPlanInfoForSample(Long sampleId); List retrieveComponentLatticesForComponent(Long componentId); Optional retrieveContainerInfoForId(Long containerId) throws SQLException; + Optional retrieveSampleTypeForSample(Long sampleId) throws SQLException; + List retrievePDBsForComponent(Long componentId) throws SQLException; } diff --git a/src/main/java/uk/ac/diamond/ispyb/api/PDB.java b/src/main/java/uk/ac/diamond/ispyb/api/PDB.java new file mode 100644 index 0000000..a05b366 --- /dev/null +++ b/src/main/java/uk/ac/diamond/ispyb/api/PDB.java @@ -0,0 +1,70 @@ +/*- + ******************************************************************************* + * Copyright (c) 2011, 2018 Diamond Light Source Ltd. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * See git history + *******************************************************************************/ +package uk.ac.diamond.ispyb.api; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +public class PDB { + private Long pdbId; + private String name; + private String contents; + private String code; + + public Long getPDBId() { + return pdbId; + } + + public void setPDBId(Long pdbId) { + this.pdbId = pdbId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getContents() { + return contents; + } + + public void setContents(String contents) { + this.contents = contents; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + + @Override + public boolean equals(Object that) { + return EqualsBuilder.reflectionEquals(this, that); + }; +} diff --git a/src/main/java/uk/ac/diamond/ispyb/api/SampleType.java b/src/main/java/uk/ac/diamond/ispyb/api/SampleType.java new file mode 100644 index 0000000..15aa07e --- /dev/null +++ b/src/main/java/uk/ac/diamond/ispyb/api/SampleType.java @@ -0,0 +1,70 @@ +/*- + ******************************************************************************* + * Copyright (c) 2011, 2018 Diamond Light Source Ltd. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * See git history + *******************************************************************************/ +package uk.ac.diamond.ispyb.api; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ReflectionToStringBuilder; + +public class SampleType { + private Long sampleTypeId; + private Long componentId; + private String name; + private String comments; + + public Long getSampleTypeId() { + return sampleTypeId; + } + + public void setSampleTypeId(Long sampleTypeId) { + this.sampleTypeId = sampleTypeId; + } + + public Long getComponentId() { + return componentId; + } + + public void setComponentId(Long componentId) { + this.componentId = componentId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getComments() { + return comments; + } + + public void setComments(String comments) { + this.comments = comments; + } + + @Override + public String toString() { + return ReflectionToStringBuilder.toString(this); + } + + @Override + public int hashCode() { + return HashCodeBuilder.reflectionHashCode(this); + } + + @Override + public boolean equals(Object that) { + return EqualsBuilder.reflectionEquals(this, that); + }; +} diff --git a/src/main/java/uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java b/src/main/java/uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java index 3800ede..9303a5e 100644 --- a/src/main/java/uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java +++ b/src/main/java/uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java @@ -83,6 +83,20 @@ public Optional retrieveContainerInfoForId(Long containerId) thro return templateWrapper.callIspybForBean("retrieve_container_info_for_id", ContainerInfo.class, map); } + @Override + public Optional retrieveSampleTypeForSample(Long sampleId) throws SQLException { + Map map = new HashMap<>(); + map.put("sampleId", sampleId); + return templateWrapper.callIspybForBean("retrieve_sample_type_for_sample", SampleType.class, map); + } + + @Override + public List retrievePDBsForComponent(Long componentId) throws SQLException { + Map map = new HashMap<>(); + map.put("componentId", componentId); + return templateWrapper.callIspybForListBeans("retrieve_pdbs_for_component", PDB.class, map); + } + @Override public void close() throws IOException { try { From 04e81805fc268b6fc47eff5589c5caf241399b11 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Fri, 19 Jan 2018 18:35:33 +0000 Subject: [PATCH 04/11] Test method testRetrieveSampleTypeForSample now working --- .../ispyb/test/XpdfIntegrationTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java b/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java index afc3d9d..aeea60e 100644 --- a/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java +++ b/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java @@ -114,6 +114,31 @@ public void testRetrieveComponentsForSampleType()throws SQLException, IOExceptio assertThat(components, is(equalTo(Arrays.asList(component)))); } + @Test + public void testRetrieveSampleTypeForSample() throws SQLException, IOException, InterruptedException { + Optional sampleType = helper.execute(api -> api.retrieveSampleTypeForSample(398827L)); + + SampleType expected = new SampleType(); + expected.setSampleTypeId(333308L); + expected.setComponentId(123497L); + expected.setName("SampleType01"); + expected.setComments("sample type comments ..."); + + assertThat(sampleType.get(), is(equalTo(expected))); + } + + // @Test + // public void testRetrievePDBsForComponent()throws SQLException, IOException, InterruptedException { + // List pdbs = helper.execute(api -> api.retrievePDBsForComponent(333308L)); + // + // PDB pdb = new PDB(); + // pdb.setComponentId(123497L); + // pdb.setComponentName("XPDF comp1"); + // + // assertThat(pdbs, is(equalTo(Arrays.asList(pdb)))); + // } + + @Test public void testRetrieveDataCollectionPlansForSample()throws SQLException, IOException, InterruptedException { List components = helper.execute(api -> api.retrieveDataCollectionPlansForSample(398824L)); From 383c169c458f6327c9ac2b36939cb9bf0ad9c347 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Mon, 22 Jan 2018 15:43:12 +0000 Subject: [PATCH 05/11] Adhere to naming convention for getters and setters --- src/main/java/uk/ac/diamond/ispyb/api/PDB.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/uk/ac/diamond/ispyb/api/PDB.java b/src/main/java/uk/ac/diamond/ispyb/api/PDB.java index a05b366..60cb1e9 100644 --- a/src/main/java/uk/ac/diamond/ispyb/api/PDB.java +++ b/src/main/java/uk/ac/diamond/ispyb/api/PDB.java @@ -21,11 +21,11 @@ public class PDB { private String contents; private String code; - public Long getPDBId() { + public Long getPdbId() { return pdbId; } - public void setPDBId(Long pdbId) { + public void setPdbId(Long pdbId) { this.pdbId = pdbId; } From cb48753b6cc794e37a3f6afcc11839b252365aed Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Mon, 22 Jan 2018 15:43:45 +0000 Subject: [PATCH 06/11] Include test data for PDBs/CIFs --- src/test/resources/schema.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/test/resources/schema.sql b/src/test/resources/schema.sql index 7f587e6..beeb1c0 100644 --- a/src/test/resources/schema.sql +++ b/src/test/resources/schema.sql @@ -3873,7 +3873,7 @@ CREATE TABLE `PDB` ( `contents` mediumtext DEFAULT NULL, `code` varchar(4) DEFAULT NULL, PRIMARY KEY (`pdbId`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -3882,6 +3882,7 @@ CREATE TABLE `PDB` ( LOCK TABLES `PDB` WRITE; /*!40000 ALTER TABLE `PDB` DISABLE KEYS */; +INSERT INTO `PDB` VALUES (6,'ceo2','\r\ndata_\r\n_chemical_name_mineral ?CeO2?\r\n_cell_length_a 5.411223\r\n_cell_length_b 5.411223\r\n_cell_length_c 5.411223\r\n_cell_angle_alpha 90\r\n_cell_angle_beta 90\r\n_cell_angle_gamma 90\r\n_cell_volume 158.4478\r\n_symmetry_space_group_name_H-M \'Fm3m\'\r\nloop_\r\n_symmetry_equiv_pos_as_xyz\r\n \'-x, -y, -z\'\r\n \'-x, -y, z\'\r\n \'-x, -y+1/2, -z+1/2\'\r\n \'-x, -y+1/2, z+1/2\'\r\n \'-x, -z, -y\'\r\n \'-x, -z, y\'\r\n \'-x, -z+1/2, -y+1/2\'\r\n \'-x, -z+1/2, y+1/2\'\r\n \'-x, z, -y\'\r\n \'-x, z, y\'\r\n \'-x, z+1/2, -y+1/2\'\r\n \'-x, z+1/2, y+1/2\'\r\n \'-x, y, -z\'\r\n \'-x, y, z\'\r\n \'-x, y+1/2, -z+1/2\'\r\n \'-x, y+1/2, z+1/2\'\r\n \'-x+1/2, -y, -z+1/2\'\r\n \'-x+1/2, -y, z+1/2\'\r\n \'-x+1/2, -y+1/2, -z\'\r\n \'-x+1/2, -y+1/2, z\'\r\n \'-x+1/2, -z, -y+1/2\'\r\n \'-x+1/2, -z, y+1/2\'\r\n \'-x+1/2, -z+1/2, -y\'\r\n \'-x+1/2, -z+1/2, y\'\r\n \'-x+1/2, z, -y+1/2\'\r\n \'-x+1/2, z, y+1/2\'\r\n \'-x+1/2, z+1/2, -y\'\r\n \'-x+1/2, z+1/2, y\'\r\n \'-x+1/2, y, -z+1/2\'\r\n \'-x+1/2, y, z+1/2\'\r\n \'-x+1/2, y+1/2, -z\'\r\n \'-x+1/2, y+1/2, z\'\r\n \'-y, -x, -z\'\r\n \'-y, -x, z\'\r\n \'-y, -x+1/2, -z+1/2\'\r\n \'-y, -x+1/2, z+1/2\'\r\n \'-y, -z, -x\'\r\n \'-y, -z, x\'\r\n \'-y, -z+1/2, -x+1/2\'\r\n \'-y, -z+1/2, x+1/2\'\r\n \'-y, z, -x\'\r\n \'-y, z, x\'\r\n \'-y, z+1/2, -x+1/2\'\r\n \'-y, z+1/2, x+1/2\'\r\n \'-y, x, -z\'\r\n \'-y, x, z\'\r\n \'-y, x+1/2, -z+1/2\'\r\n \'-y, x+1/2, z+1/2\'\r\n \'-y+1/2, -x, -z+1/2\'\r\n \'-y+1/2, -x, z+1/2\'\r\n \'-y+1/2, -x+1/2, -z\'\r\n \'-y+1/2, -x+1/2, z\'\r\n \'-y+1/2, -z, -x+1/2\'\r\n \'-y+1/2, -z, x+1/2\'\r\n \'-y+1/2, -z+1/2, -x\'\r\n \'-y+1/2, -z+1/2, x\'\r\n \'-y+1/2, z, -x+1/2\'\r\n \'-y+1/2, z, x+1/2\'\r\n \'-y+1/2, z+1/2, -x\'\r\n \'-y+1/2, z+1/2, x\'\r\n \'-y+1/2, x, -z+1/2\'\r\n \'-y+1/2, x, z+1/2\'\r\n \'-y+1/2, x+1/2, -z\'\r\n \'-y+1/2, x+1/2, z\'\r\n \'-z, -x, -y\'\r\n \'-z, -x, y\'\r\n \'-z, -x+1/2, -y+1/2\'\r\n \'-z, -x+1/2, y+1/2\'\r\n \'-z, -y, -x\'\r\n \'-z, -y, x\'\r\n \'-z, -y+1/2, -x+1/2\'\r\n \'-z, -y+1/2, x+1/2\'\r\n \'-z, y, -x\'\r\n \'-z, y, x\'\r\n \'-z, y+1/2, -x+1/2\'\r\n \'-z, y+1/2, x+1/2\'\r\n \'-z, x, -y\'\r\n \'-z, x, y\'\r\n \'-z, x+1/2, -y+1/2\'\r\n \'-z, x+1/2, y+1/2\'\r\n \'-z+1/2, -x, -y+1/2\'\r\n \'-z+1/2, -x, y+1/2\'\r\n \'-z+1/2, -x+1/2, -y\'\r\n \'-z+1/2, -x+1/2, y\'\r\n \'-z+1/2, -y, -x+1/2\'\r\n \'-z+1/2, -y, x+1/2\'\r\n \'-z+1/2, -y+1/2, -x\'\r\n \'-z+1/2, -y+1/2, x\'\r\n \'-z+1/2, y, -x+1/2\'\r\n \'-z+1/2, y, x+1/2\'\r\n \'-z+1/2, y+1/2, -x\'\r\n \'-z+1/2, y+1/2, x\'\r\n \'-z+1/2, x, -y+1/2\'\r\n \'-z+1/2, x, y+1/2\'\r\n \'-z+1/2, x+1/2, -y\'\r\n \'-z+1/2, x+1/2, y\'\r\n \'z, -x, -y\'\r\n \'z, -x, y\'\r\n \'z, -x+1/2, -y+1/2\'\r\n \'z, -x+1/2, y+1/2\'\r\n \'z, -y, -x\'\r\n \'z, -y, x\'\r\n \'z, -y+1/2, -x+1/2\'\r\n \'z, -y+1/2, x+1/2\'\r\n \'z, y, -x\'\r\n \'z, y, x\'\r\n \'z, y+1/2, -x+1/2\'\r\n \'z, y+1/2, x+1/2\'\r\n \'z, x, -y\'\r\n \'z, x, y\'\r\n \'z, x+1/2, -y+1/2\'\r\n \'z, x+1/2, y+1/2\'\r\n \'z+1/2, -x, -y+1/2\'\r\n \'z+1/2, -x, y+1/2\'\r\n \'z+1/2, -x+1/2, -y\'\r\n \'z+1/2, -x+1/2, y\'\r\n \'z+1/2, -y, -x+1/2\'\r\n \'z+1/2, -y, x+1/2\'\r\n \'z+1/2, -y+1/2, -x\'\r\n \'z+1/2, -y+1/2, x\'\r\n \'z+1/2, y, -x+1/2\'\r\n \'z+1/2, y, x+1/2\'\r\n \'z+1/2, y+1/2, -x\'\r\n \'z+1/2, y+1/2, x\'\r\n \'z+1/2, x, -y+1/2\'\r\n \'z+1/2, x, y+1/2\'\r\n \'z+1/2, x+1/2, -y\'\r\n \'z+1/2, x+1/2, y\'\r\n \'y, -x, -z\'\r\n \'y, -x, z\'\r\n \'y, -x+1/2, -z+1/2\'\r\n \'y, -x+1/2, z+1/2\'\r\n \'y, -z, -x\'\r\n \'y, -z, x\'\r\n \'y, -z+1/2, -x+1/2\'\r\n \'y, -z+1/2, x+1/2\'\r\n \'y, z, -x\'\r\n \'y, z, x\'\r\n \'y, z+1/2, -x+1/2\'\r\n \'y, z+1/2, x+1/2\'\r\n \'y, x, -z\'\r\n \'y, x, z\'\r\n \'y, x+1/2, -z+1/2\'\r\n \'y, x+1/2, z+1/2\'\r\n \'y+1/2, -x, -z+1/2\'\r\n \'y+1/2, -x, z+1/2\'\r\n \'y+1/2, -x+1/2, -z\'\r\n \'y+1/2, -x+1/2, z\'\r\n \'y+1/2, -z, -x+1/2\'\r\n \'y+1/2, -z, x+1/2\'\r\n \'y+1/2, -z+1/2, -x\'\r\n \'y+1/2, -z+1/2, x\'\r\n \'y+1/2, z, -x+1/2\'\r\n \'y+1/2, z, x+1/2\'\r\n \'y+1/2, z+1/2, -x\'\r\n \'y+1/2, z+1/2, x\'\r\n \'y+1/2, x, -z+1/2\'\r\n \'y+1/2, x, z+1/2\'\r\n \'y+1/2, x+1/2, -z\'\r\n \'y+1/2, x+1/2, z\'\r\n \'x, -y, -z\'\r\n \'x, -y, z\'\r\n \'x, -y+1/2, -z+1/2\'\r\n \'x, -y+1/2, z+1/2\'\r\n \'x, -z, -y\'\r\n \'x, -z, y\'\r\n \'x, -z+1/2, -y+1/2\'\r\n \'x, -z+1/2, y+1/2\'\r\n \'x, z, -y\'\r\n \'x, z, y\'\r\n \'x, z+1/2, -y+1/2\'\r\n \'x, z+1/2, y+1/2\'\r\n \'x, y, -z\'\r\n \'x, y, z\'\r\n \'x, y+1/2, -z+1/2\'\r\n \'x, y+1/2, z+1/2\'\r\n \'x+1/2, -y, -z+1/2\'\r\n \'x+1/2, -y, z+1/2\'\r\n \'x+1/2, -y+1/2, -z\'\r\n \'x+1/2, -y+1/2, z\'\r\n \'x+1/2, -z, -y+1/2\'\r\n \'x+1/2, -z, y+1/2\'\r\n \'x+1/2, -z+1/2, -y\'\r\n \'x+1/2, -z+1/2, y\'\r\n \'x+1/2, z, -y+1/2\'\r\n \'x+1/2, z, y+1/2\'\r\n \'x+1/2, z+1/2, -y\'\r\n \'x+1/2, z+1/2, y\'\r\n \'x+1/2, y, -z+1/2\'\r\n \'x+1/2, y, z+1/2\'\r\n \'x+1/2, y+1/2, -z\'\r\n \'x+1/2, y+1/2, z\'\r\nloop_\r\n_atom_site_label\r\n_atom_site_type_symbol\r\n_atom_site_symmetry_multiplicity\r\n_atom_site_fract_x\r\n_atom_site_fract_y\r\n_atom_site_fract_z\r\n_atom_site_occupancy\r\n_atom_site_B_iso_or_equiv\r\nCe1 Ce 0 0 0 0 1 0.127911\r\nO1 O 0 0.25 0.25 0.25 1 0.07795472',NULL); /*!40000 ALTER TABLE `PDB` ENABLE KEYS */; UNLOCK TABLES; @@ -4903,7 +4904,7 @@ CREATE TABLE `Protein_has_PDB` ( KEY `Protein_Has_PDB_fk2` (`pdbid`), CONSTRAINT `Protein_Has_PDB_fk1` FOREIGN KEY (`proteinid`) REFERENCES `Protein` (`proteinId`), CONSTRAINT `Protein_Has_PDB_fk2` FOREIGN KEY (`pdbid`) REFERENCES `PDB` (`pdbId`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -4912,6 +4913,7 @@ CREATE TABLE `Protein_has_PDB` ( LOCK TABLES `Protein_has_PDB` WRITE; /*!40000 ALTER TABLE `Protein_has_PDB` DISABLE KEYS */; +INSERT INTO `Protein_has_PDB` VALUES (5,123497,6); /*!40000 ALTER TABLE `Protein_has_PDB` ENABLE KEYS */; UNLOCK TABLES; @@ -12042,4 +12044,4 @@ DELIMITER ; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-01-19 14:43:56 +-- Dump completed on 2018-01-22 15:03:26 From 3117ed54e258a9cd2b79d3fd74de3263baa5e305 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Mon, 22 Jan 2018 15:44:36 +0000 Subject: [PATCH 07/11] Include a CIF file for testing --- src/test/resources/ceo2.cif | 216 ++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 src/test/resources/ceo2.cif diff --git a/src/test/resources/ceo2.cif b/src/test/resources/ceo2.cif new file mode 100644 index 0000000..6d58f08 --- /dev/null +++ b/src/test/resources/ceo2.cif @@ -0,0 +1,216 @@ + +data_ +_chemical_name_mineral ?CeO2? +_cell_length_a 5.411223 +_cell_length_b 5.411223 +_cell_length_c 5.411223 +_cell_angle_alpha 90 +_cell_angle_beta 90 +_cell_angle_gamma 90 +_cell_volume 158.4478 +_symmetry_space_group_name_H-M 'Fm3m' +loop_ +_symmetry_equiv_pos_as_xyz + '-x, -y, -z' + '-x, -y, z' + '-x, -y+1/2, -z+1/2' + '-x, -y+1/2, z+1/2' + '-x, -z, -y' + '-x, -z, y' + '-x, -z+1/2, -y+1/2' + '-x, -z+1/2, y+1/2' + '-x, z, -y' + '-x, z, y' + '-x, z+1/2, -y+1/2' + '-x, z+1/2, y+1/2' + '-x, y, -z' + '-x, y, z' + '-x, y+1/2, -z+1/2' + '-x, y+1/2, z+1/2' + '-x+1/2, -y, -z+1/2' + '-x+1/2, -y, z+1/2' + '-x+1/2, -y+1/2, -z' + '-x+1/2, -y+1/2, z' + '-x+1/2, -z, -y+1/2' + '-x+1/2, -z, y+1/2' + '-x+1/2, -z+1/2, -y' + '-x+1/2, -z+1/2, y' + '-x+1/2, z, -y+1/2' + '-x+1/2, z, y+1/2' + '-x+1/2, z+1/2, -y' + '-x+1/2, z+1/2, y' + '-x+1/2, y, -z+1/2' + '-x+1/2, y, z+1/2' + '-x+1/2, y+1/2, -z' + '-x+1/2, y+1/2, z' + '-y, -x, -z' + '-y, -x, z' + '-y, -x+1/2, -z+1/2' + '-y, -x+1/2, z+1/2' + '-y, -z, -x' + '-y, -z, x' + '-y, -z+1/2, -x+1/2' + '-y, -z+1/2, x+1/2' + '-y, z, -x' + '-y, z, x' + '-y, z+1/2, -x+1/2' + '-y, z+1/2, x+1/2' + '-y, x, -z' + '-y, x, z' + '-y, x+1/2, -z+1/2' + '-y, x+1/2, z+1/2' + '-y+1/2, -x, -z+1/2' + '-y+1/2, -x, z+1/2' + '-y+1/2, -x+1/2, -z' + '-y+1/2, -x+1/2, z' + '-y+1/2, -z, -x+1/2' + '-y+1/2, -z, x+1/2' + '-y+1/2, -z+1/2, -x' + '-y+1/2, -z+1/2, x' + '-y+1/2, z, -x+1/2' + '-y+1/2, z, x+1/2' + '-y+1/2, z+1/2, -x' + '-y+1/2, z+1/2, x' + '-y+1/2, x, -z+1/2' + '-y+1/2, x, z+1/2' + '-y+1/2, x+1/2, -z' + '-y+1/2, x+1/2, z' + '-z, -x, -y' + '-z, -x, y' + '-z, -x+1/2, -y+1/2' + '-z, -x+1/2, y+1/2' + '-z, -y, -x' + '-z, -y, x' + '-z, -y+1/2, -x+1/2' + '-z, -y+1/2, x+1/2' + '-z, y, -x' + '-z, y, x' + '-z, y+1/2, -x+1/2' + '-z, y+1/2, x+1/2' + '-z, x, -y' + '-z, x, y' + '-z, x+1/2, -y+1/2' + '-z, x+1/2, y+1/2' + '-z+1/2, -x, -y+1/2' + '-z+1/2, -x, y+1/2' + '-z+1/2, -x+1/2, -y' + '-z+1/2, -x+1/2, y' + '-z+1/2, -y, -x+1/2' + '-z+1/2, -y, x+1/2' + '-z+1/2, -y+1/2, -x' + '-z+1/2, -y+1/2, x' + '-z+1/2, y, -x+1/2' + '-z+1/2, y, x+1/2' + '-z+1/2, y+1/2, -x' + '-z+1/2, y+1/2, x' + '-z+1/2, x, -y+1/2' + '-z+1/2, x, y+1/2' + '-z+1/2, x+1/2, -y' + '-z+1/2, x+1/2, y' + 'z, -x, -y' + 'z, -x, y' + 'z, -x+1/2, -y+1/2' + 'z, -x+1/2, y+1/2' + 'z, -y, -x' + 'z, -y, x' + 'z, -y+1/2, -x+1/2' + 'z, -y+1/2, x+1/2' + 'z, y, -x' + 'z, y, x' + 'z, y+1/2, -x+1/2' + 'z, y+1/2, x+1/2' + 'z, x, -y' + 'z, x, y' + 'z, x+1/2, -y+1/2' + 'z, x+1/2, y+1/2' + 'z+1/2, -x, -y+1/2' + 'z+1/2, -x, y+1/2' + 'z+1/2, -x+1/2, -y' + 'z+1/2, -x+1/2, y' + 'z+1/2, -y, -x+1/2' + 'z+1/2, -y, x+1/2' + 'z+1/2, -y+1/2, -x' + 'z+1/2, -y+1/2, x' + 'z+1/2, y, -x+1/2' + 'z+1/2, y, x+1/2' + 'z+1/2, y+1/2, -x' + 'z+1/2, y+1/2, x' + 'z+1/2, x, -y+1/2' + 'z+1/2, x, y+1/2' + 'z+1/2, x+1/2, -y' + 'z+1/2, x+1/2, y' + 'y, -x, -z' + 'y, -x, z' + 'y, -x+1/2, -z+1/2' + 'y, -x+1/2, z+1/2' + 'y, -z, -x' + 'y, -z, x' + 'y, -z+1/2, -x+1/2' + 'y, -z+1/2, x+1/2' + 'y, z, -x' + 'y, z, x' + 'y, z+1/2, -x+1/2' + 'y, z+1/2, x+1/2' + 'y, x, -z' + 'y, x, z' + 'y, x+1/2, -z+1/2' + 'y, x+1/2, z+1/2' + 'y+1/2, -x, -z+1/2' + 'y+1/2, -x, z+1/2' + 'y+1/2, -x+1/2, -z' + 'y+1/2, -x+1/2, z' + 'y+1/2, -z, -x+1/2' + 'y+1/2, -z, x+1/2' + 'y+1/2, -z+1/2, -x' + 'y+1/2, -z+1/2, x' + 'y+1/2, z, -x+1/2' + 'y+1/2, z, x+1/2' + 'y+1/2, z+1/2, -x' + 'y+1/2, z+1/2, x' + 'y+1/2, x, -z+1/2' + 'y+1/2, x, z+1/2' + 'y+1/2, x+1/2, -z' + 'y+1/2, x+1/2, z' + 'x, -y, -z' + 'x, -y, z' + 'x, -y+1/2, -z+1/2' + 'x, -y+1/2, z+1/2' + 'x, -z, -y' + 'x, -z, y' + 'x, -z+1/2, -y+1/2' + 'x, -z+1/2, y+1/2' + 'x, z, -y' + 'x, z, y' + 'x, z+1/2, -y+1/2' + 'x, z+1/2, y+1/2' + 'x, y, -z' + 'x, y, z' + 'x, y+1/2, -z+1/2' + 'x, y+1/2, z+1/2' + 'x+1/2, -y, -z+1/2' + 'x+1/2, -y, z+1/2' + 'x+1/2, -y+1/2, -z' + 'x+1/2, -y+1/2, z' + 'x+1/2, -z, -y+1/2' + 'x+1/2, -z, y+1/2' + 'x+1/2, -z+1/2, -y' + 'x+1/2, -z+1/2, y' + 'x+1/2, z, -y+1/2' + 'x+1/2, z, y+1/2' + 'x+1/2, z+1/2, -y' + 'x+1/2, z+1/2, y' + 'x+1/2, y, -z+1/2' + 'x+1/2, y, z+1/2' + 'x+1/2, y+1/2, -z' + 'x+1/2, y+1/2, z' +loop_ +_atom_site_label +_atom_site_type_symbol +_atom_site_symmetry_multiplicity +_atom_site_fract_x +_atom_site_fract_y +_atom_site_fract_z +_atom_site_occupancy +_atom_site_B_iso_or_equiv +Ce1 Ce 0 0 0 0 1 0.127911 +O1 O 0 0.25 0.25 0.25 1 0.07795472 \ No newline at end of file From 71e18b133aa7a418eb5a42f7e014a22faf027f36 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Mon, 22 Jan 2018 15:45:48 +0000 Subject: [PATCH 08/11] Test for retrievePDBsForComponent() --- .../ispyb/test/XpdfIntegrationTest.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java b/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java index aeea60e..69d1a09 100644 --- a/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java +++ b/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java @@ -27,6 +27,9 @@ import java.util.List; import java.util.ArrayList; +import java.nio.file.Files; +import java.nio.file.Paths; + import uk.ac.diamond.ispyb.api.*; import uk.ac.diamond.ispyb.dao.IspybXpdfDaoFactory; @@ -127,16 +130,17 @@ public void testRetrieveSampleTypeForSample() throws SQLException, IOException, assertThat(sampleType.get(), is(equalTo(expected))); } - // @Test - // public void testRetrievePDBsForComponent()throws SQLException, IOException, InterruptedException { - // List pdbs = helper.execute(api -> api.retrievePDBsForComponent(333308L)); - // - // PDB pdb = new PDB(); - // pdb.setComponentId(123497L); - // pdb.setComponentName("XPDF comp1"); - // - // assertThat(pdbs, is(equalTo(Arrays.asList(pdb)))); - // } + @Test + public void testRetrievePDBsForComponent()throws SQLException, IOException, InterruptedException { + List pdbs = helper.execute(api -> api.retrievePDBsForComponent(123497L)); + + PDB pdb = new PDB(); + pdb.setPdbId(6L); + pdb.setName("ceo2"); + pdb.setContents(new String(Files.readAllBytes(Paths.get(System.getProperty("user.dir").toString(), "src", "test", "resources", "ceo2.cif")))); + + assertThat(pdbs, is(equalTo(Arrays.asList(pdb)))); + } @Test From e98cee391565d5a38a719e1969ac163f22693d19 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 25 Jan 2018 16:06:20 +0000 Subject: [PATCH 09/11] SP retrieve_samples_for_sample_group: return sample and sampleType properties as well --- src/test/resources/schema.sql | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/test/resources/schema.sql b/src/test/resources/schema.sql index beeb1c0..05dc858 100644 --- a/src/test/resources/schema.sql +++ b/src/test/resources/schema.sql @@ -9654,8 +9654,16 @@ CREATE PROCEDURE `retrieve_samples_for_sample_group`(IN p_sampleGroupId int unsi COMMENT 'Return multi-row result set with sample IDs, order in the group and type for sample group p_sampleGroupId' BEGIN IF NOT (p_sampleGroupId IS NULL) THEN - SELECT bhb.blSampleId "sampleId", bhb.type "type", bhb.groupOrder "order" - FROM BLSampleGroup_has_BLSample bhb + SELECT bls.blSampleId "sampleId", bls.containerId "containerId", bls.crystalId "sampleTypeId", bls.name "sampleName", + bls.code "sampleCode", bls.comments "sampleComments", bls.location "sampleLocation", + bls.packingFraction "samplePackingFraction", + bls.dimension1 "dimension1", bls.dimension2 "dimension2", bls.dimension3 "dimension3", + bls.shape "shape", + c.name "sampleTypeName", c.comments "sampleTypeComments", c.spaceGroup "sampleTypeSpaceGroup", c.proteinId "componentId", + bhb.type "typeInGroup", bhb.groupOrder "orderInGroup" + FROM BLSampleGroup_has_BLSample bhb + INNER JOIN BLSample bls ON bls.blSampleId = bhb.blSampleId + INNER JOIN Crystal c ON c.crystalId = bls.crystalId WHERE bhb.blSampleGroupId = p_sampleGroupId ORDER BY bhb.blSampleId; ELSE @@ -12044,4 +12052,4 @@ DELIMITER ; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2018-01-22 15:03:26 +-- Dump completed on 2018-01-22 16:53:05 From d67b98bf899a631ec43d7a25437a8d97513251b4 Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 25 Jan 2018 16:09:14 +0000 Subject: [PATCH 10/11] Return Sample list rather than SampleGroup list from retrieveSamplesForSampleGroup, make test work with changes --- .../uk/ac/diamond/ispyb/api/IspybXpdfApi.java | 2 +- .../java/uk/ac/diamond/ispyb/api/Sample.java | 19 ++++++- .../uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java | 4 +- .../ispyb/test/XpdfIntegrationTest.java | 54 +++++++++++++------ 4 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/main/java/uk/ac/diamond/ispyb/api/IspybXpdfApi.java b/src/main/java/uk/ac/diamond/ispyb/api/IspybXpdfApi.java index 56eea3e..a4a0cc9 100644 --- a/src/main/java/uk/ac/diamond/ispyb/api/IspybXpdfApi.java +++ b/src/main/java/uk/ac/diamond/ispyb/api/IspybXpdfApi.java @@ -22,7 +22,7 @@ public interface IspybXpdfApi extends Closeable { List retrieveSamplesAssignedForProposal(String proposalCode, Long proposalNumber); List retrieveSampleGroupsForSample(Long sampleId); - List retrieveSamplesForSampleGroup(Long sampleGroupId); + List retrieveSamplesForSampleGroup(Long sampleGroupId); List retrieveComponentsForSampleType(Long sampleTypeId); List retrieveDataCollectionPlansForSample(Long sampleId); Optional retrieveDataCollectionPlanInfoForSample(Long sampleId); diff --git a/src/main/java/uk/ac/diamond/ispyb/api/Sample.java b/src/main/java/uk/ac/diamond/ispyb/api/Sample.java index 4f04ab1..965860d 100644 --- a/src/main/java/uk/ac/diamond/ispyb/api/Sample.java +++ b/src/main/java/uk/ac/diamond/ispyb/api/Sample.java @@ -31,7 +31,8 @@ public class Sample { private String sampleTypeName; private String sampleTypeComments; private String sampleTypeSpaceGroup; - + private Long orderInGroup; + private String typeInGroup; public Long getSampleId() { return sampleId; @@ -153,6 +154,22 @@ public void setSampleTypeSpaceGroup(String sampleTypeSpaceGroup) { this.sampleTypeSpaceGroup = sampleTypeSpaceGroup; } + public Long getOrderInGroup() { + return orderInGroup; + } + + public void setOrderInGroup(Long orderInGroup) { + this.orderInGroup = orderInGroup; + } + + public String getTypeInGroup() { + return typeInGroup; + } + + public void setTypeInGroup(String typeInGroup) { + this.typeInGroup = typeInGroup; + } + @Override public String toString() { return ReflectionToStringBuilder.toString(this); diff --git a/src/main/java/uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java b/src/main/java/uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java index 9303a5e..531d88b 100644 --- a/src/main/java/uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java +++ b/src/main/java/uk/ac/diamond/ispyb/dao/IspybXpdfDAO.java @@ -41,10 +41,10 @@ public List retrieveSampleGroupsForSample(Long sampleId){ return templateWrapper.callIspybForListBeans("retrieve_sample_groups_for_sample", SampleGroup.class, map); } - public List retrieveSamplesForSampleGroup(Long sampleGroupId){ + public List retrieveSamplesForSampleGroup(Long sampleGroupId){ Map map = new HashMap<>(); map.put("sampleGroupId", sampleGroupId); - return templateWrapper.callIspybForListBeans("retrieve_samples_for_sample_group", SampleGroup.class, map); + return templateWrapper.callIspybForListBeans("retrieve_samples_for_sample_group", Sample.class, map); } public List retrieveComponentsForSampleType(Long sampleTypeId){ diff --git a/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java b/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java index 69d1a09..5465483 100644 --- a/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java +++ b/src/test/java/uk/ac/diamond/ispyb/test/XpdfIntegrationTest.java @@ -87,23 +87,43 @@ public void testRetrieveSampleGroupsForSample()throws SQLException, IOException, } @Test - public void testRetrieveSamplesForSampleGroups()throws SQLException, IOException, InterruptedException { - List groups = helper.execute(api -> api.retrieveSamplesForSampleGroup(5L)); - List sampleGroups = new ArrayList(); - - SampleGroup sampleGroup1 = new SampleGroup(); - sampleGroup1.setSampleId(398824L); - sampleGroup1.setOrder(1L); - sampleGroup1.setType(SampleGroupType.BACKGROUND.name()); - sampleGroups.add(sampleGroup1); - - SampleGroup sampleGroup2 = new SampleGroup(); - sampleGroup2.setSampleId(398827L); - sampleGroup2.setOrder(2L); - sampleGroup2.setType(SampleGroupType.SAMPLE.name()); - sampleGroups.add(sampleGroup2); - - assertThat(groups , is(equalTo(sampleGroups))); + public void testRetrieveSamplesForSampleGroup()throws SQLException, IOException, InterruptedException { + List samples = helper.execute(api -> api.retrieveSamplesForSampleGroup(5L)); + List expected = new ArrayList(); + + Sample sample1 = new Sample(); + sample1.setSampleId(398824L); + sample1.setContainerId(34883L); + sample1.setSampleTypeId(333308L); + sample1.setSampleName("XPDF-1"); + sample1.setSampleCode("XPDF-0001"); + sample1.setSampleComments("Test sample for XPDF"); + + sample1.setSampleTypeName("SampleType01"); + sample1.setSampleTypeComments("sample type comments ..."); + sample1.setSampleTypeSpaceGroup("P12121"); + + sample1.setTypeInGroup("background"); + sample1.setOrderInGroup(1L); + expected.add(sample1); + + Sample sample2 = new Sample(); + sample2.setSampleId(398827L); + sample2.setContainerId(34883L); + sample2.setSampleTypeId(333308L); + sample2.setSampleName("XPDF-2"); + sample2.setSampleCode("XPDF-0002"); + sample2.setSampleComments("Test sample for XPDF"); + + sample2.setSampleTypeName("SampleType01"); + sample2.setSampleTypeComments("sample type comments ..."); + sample2.setSampleTypeSpaceGroup("P12121"); + + sample2.setTypeInGroup("sample"); + sample2.setOrderInGroup(2L); + expected.add(sample2); + + assertThat(samples , is(equalTo(expected))); } @Test From b12b59b2edec501946ad81225014e1c1b420199f Mon Sep 17 00:00:00 2001 From: Karl Levik Date: Thu, 25 Jan 2018 16:19:10 +0000 Subject: [PATCH 11/11] Bump up version to 2.3.0 --- pom.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7cd06e4..d663b76 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ Diamond Light Source - 2.1.1 + 2.3.0 bundle @@ -147,4 +147,3 @@ -