function GLExchange::getPreliminaryTargets in GlobalLink Connect for Drupal 7.7
File
- gl_ws/
glc/ GLExchange.php, line 734
Class
Code
function getPreliminaryTargets($submissionWorkflowInfo) {
$repositoryItems = array();
// 1. Claim
$workflowRequestForClaim = $this
->_createWorkflowRequest($submissionWorkflowInfo);
$this->workflowService
->claim($workflowRequestForClaim);
$submissionTickets = array();
$submissionTickets[0] = $submissionWorkflowInfo->submissionTicket;
// 2. Wait until all claimed become available for download
$availableSubmissionWorkflowInfosForDownload = $this->workflowService
->findAvailableWorkflowInfosForDownloadBySubmissionTickets($submissionTickets)->return;
while (count($availableSubmissionWorkflowInfosForDownload) != 1) {
sleep(DELAY_TIME);
$availableSubmissionWorkflowInfosForDownload = $this->workflowService
->findAvailableWorkflowInfosForDownloadBySubmissionTickets($submissionTickets)->return;
}
// 3. Send download preview requests
$workflowRequestTickets = array();
foreach ($availableSubmissionWorkflowInfosForDownload as &$availableSubmissionWorkflowInfo) {
$workflowRequestForDownload = $this
->_createWorkflowRequest($availableSubmissionWorkflowInfo);
$workflowRequestTicket = $this->workflowService
->downloadPreview($workflowRequestForDownload)->return;
array_push($workflowRequestTickets, $workflowRequestTicket);
}
// 4. Download
while (count($workflowRequestTickets) > 0) {
foreach ($workflowRequestTickets as &$workflowRequestTicket) {
$downloadActionResult = $this->workflowService
->checkDownloadAction($workflowRequestTicket)->return;
if ($downloadActionResult->processingFinished->booleanValue) {
$repositoryItem = $downloadActionResult->repositoryItem;
array_push($repositoryItems, $repositoryItem);
unset($workflowRequestTickets[$workflowRequestTicket]);
}
}
}
return $repositoryItems;
}