Skip to content

Commit

Permalink
Merge c64e776 into 3058e02
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlLevik committed Oct 4, 2018
2 parents 3058e02 + c64e776 commit 4e3a45b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
41 changes: 40 additions & 1 deletion conf/routines.sql
Expand Up @@ -2764,6 +2764,45 @@ 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_processing_program_attachments_for_dc_group_and_program` */;
/*!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_processing_program_attachments_for_dc_group_and_program`(p_id int unsigned, p_program varchar(255))
READS SQL DATA
COMMENT 'Returns a multi-row result-set with the processing program attachments for the given DC group ID'
BEGIN
IF p_id IS NOT NULL AND p_program IS NOT NULL THEN
SELECT dc.dataCollectionId, app.autoProcProgramId,
app.processingStatus,
concat('[', group_concat(json_object('fileType', appa.fileType, 'fullFilePath', concat(appa.filePath, '/', appa.fileName))), ']') "processingAttachments"
FROM DataCollection dc
INNER JOIN AutoProcIntegration api
ON api.dataCollectionId = dc.dataCollectionId
INNER JOIN AutoProcProgram app
ON app.autoProcProgramId = api.autoProcProgramId
INNER JOIN AutoProcProgramAttachment appa
ON appa.autoProcProgramId = api.autoProcProgramId
WHERE
dc.dataCollectionGroupId = p_id AND app.processingPrograms = p_program
GROUP BY
dc.dataCollectionId, app.autoProcProgramId, app.processingStatus;
ELSE
SIGNAL SQLSTATE '45000' SET MYSQL_ERRNO=1644,
MESSAGE_TEXT='Mandatory arguments p_id and p_program can not be 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_reprocessing_by_dc` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
Expand Down Expand Up @@ -5898,4 +5937,4 @@ DELIMITER ;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2018-09-21 14:35:28
-- Dump completed on 2018-10-01 11:37:57
4 changes: 4 additions & 0 deletions ispyb/sp/mxprocessing.py
Expand Up @@ -184,6 +184,10 @@ def retrieve_programs_for_job_id(self, id):
'''Retrieve the processing instances associated with the given processing job ID'''
return self.get_connection().call_sp_retrieve(procname='retrieve_processing_programs_for_job_id', args=(id,))

def retrieve_program_attachments_for_data_collection_group_and_program(self, id, program):
'''Retrieve the processing program attachments associated with the given data collection group and processing program'''
return self.get_connection().call_sp_retrieve(procname='retrieve_processing_program_attachments_for_dc_group_and_program', args=(id,program))

def upsert_job(self, values):
'''Update or insert a new processing job entry'''
return self.get_connection().call_sp_write(procname='upsert_processing_job', args=values)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_mxprocessing.py
Expand Up @@ -146,6 +146,9 @@ def test_processing(testconfig):
assert rs is not None
assert len(rs) > 0

pa = mxprocessing.retrieve_program_attachments_for_data_collection_group_and_program(996311, 'xia2')
assert len(pa) > 0

# Find program using the processing job ID and verify stored values
programs = mxprocessing.get_processing_job(5).programs
assert programs
Expand Down

0 comments on commit 4e3a45b

Please sign in to comment.