Commit 0084c8b9 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Feat - Restitution destruction

parent 3d51eb6e
......@@ -92,7 +92,7 @@ class ArchiveRestitution extends abstractMessage
{
$message = $this->sdoFactory->read('medona/message', $messageId);
$exportResult = $this->export($messageId);
$exportResult = \laabs::newController("medona/message")->export($messageId);
$this->lifeCycleJournalController->logEvent(
'medona/reception',
......@@ -377,7 +377,7 @@ class ArchiveRestitution extends abstractMessage
$requestMessage->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $requestMessage);
foreach ($requestMessage->unitIdentifier as $unitIdentifier) {
$this->archiveController->setStatus($unitIdentifier, 'disposed');
$this->archiveController->setStatus($unitIdentifier->objectId, 'disposed');
}
$this->changeStatus($messageId, "processed");
......
......@@ -159,6 +159,7 @@ class ArchiveRestitutionRequest extends abstractMessage
if ($message->schema != 'medona') {
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message);
} else {
$archiveRestitutionRequest = $this->sendMessage($message);
$message->object = $archiveRestitutionRequest;
......@@ -364,9 +365,51 @@ class ArchiveRestitutionRequest extends abstractMessage
$operationResult
);
$message->status = "processed";
$message->status = "validated";
$this->sdoFactory->update($message);
return true;
}
/**
* Destruct all restitued archives of restitution message
*
* @return the result of process
*/
public function destructAll()
{
$results = array();
$restitutionIds = $this->sdoFactory->index('medona/message', array('messageId'), 'type = "ArchiveRestitution" AND status = "accepted"');
foreach ($restitutionIds as $restitutionId) {
$results[(string) $restitutionId] = $this->destruct($restitutionId);
$this->changeStatus($restitutionId, "processed");
}
return $results;
}
/**
* Destruction of restitued archive of message
* @param string $messageId The restitution message identifier
*
* @return array array of archive
*/
public function destruct($messageId)
{
$restitution = $this->sdoFactory->read('medona/message', array("messageId" => $messageId));
$restitutionRequest = $this->sdoFactory->find('medona/message', "type='ArchiveRestitutionRequest' AND senderOrgRegNumber='".$restitution->recipientOrgRegNumber."' AND replyReference='".$restitution->relatedReference."'")[0];
$restitutionRequest->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $restitutionRequest);
$removedArchiveIds = [];
foreach ($restitutionRequest->unitIdentifier as $unitIdentifier) {
$archive = $this->archiveController->destruct($unitIdentifier->objectId);
$removedArchiveIds[] = $archive->archiveId;
}
return $removedArchiveIds;
}
}
......@@ -62,7 +62,6 @@ interface archiveRestitutionInterface extends messageInterface
*/
public function read_messageId_exportArchive();
/**
* Get outgoing restitution messages
*
......@@ -108,22 +107,6 @@ interface archiveRestitutionInterface extends messageInterface
*/
public function updateRequestrejection($messageId, $comment);
/**
* Validate archive restitution request reply
*
* @action medona/ArchiveRestitutionRequestReply/validate
*/
//public function updateRequestreplyacceptance_messageId_();
/**
* Reject archive restitution request reply
* @param string $messageId The message identifier
* @param string $comment A comment
*
* @action medona/ArchiveRestitutionRequestReply/reject
*/
//public function updateRequestreplyrejection($messageId, $comment = null);
/**
* Validate archive restitution
*
......@@ -155,11 +138,11 @@ interface archiveRestitutionInterface extends messageInterface
public function update_messageId_Process();
/**
* Process archive restitution
* Destruct all restitued archives of restitution message
*
* @action medona/ArchiveRestitutionRequest/processBatch
* @action medona/ArchiveRestitutionRequest/destructAll
*/
public function updateProcessBatch();
public function updateDestructall();
/**
* Process archive restitution
......@@ -168,13 +151,6 @@ interface archiveRestitutionInterface extends messageInterface
*/
public function updateProcess_message_();
/**
* Validate archive restitution
*
* @action medona/ArchiveRestitutionRequestReply/processBatch
*/
public function updateValidateBatch();
/**
* Flag archives for restitution
* @param array $archiveIds Array of archive identifier
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment