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 ...@@ -92,7 +92,7 @@ class ArchiveRestitution extends abstractMessage
{ {
$message = $this->sdoFactory->read('medona/message', $messageId); $message = $this->sdoFactory->read('medona/message', $messageId);
$exportResult = $this->export($messageId); $exportResult = \laabs::newController("medona/message")->export($messageId);
$this->lifeCycleJournalController->logEvent( $this->lifeCycleJournalController->logEvent(
'medona/reception', 'medona/reception',
...@@ -377,7 +377,7 @@ class ArchiveRestitution extends abstractMessage ...@@ -377,7 +377,7 @@ class ArchiveRestitution extends abstractMessage
$requestMessage->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $requestMessage); $requestMessage->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $requestMessage);
foreach ($requestMessage->unitIdentifier as $unitIdentifier) { foreach ($requestMessage->unitIdentifier as $unitIdentifier) {
$this->archiveController->setStatus($unitIdentifier, 'disposed'); $this->archiveController->setStatus($unitIdentifier->objectId, 'disposed');
} }
$this->changeStatus($messageId, "processed"); $this->changeStatus($messageId, "processed");
......
...@@ -159,6 +159,7 @@ class ArchiveRestitutionRequest extends abstractMessage ...@@ -159,6 +159,7 @@ class ArchiveRestitutionRequest extends abstractMessage
if ($message->schema != 'medona') { if ($message->schema != 'medona') {
$archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest'); $archiveRestitutionRequestController = \laabs::newController($message->schema.'/ArchiveRestitutionRequest');
$archiveRestitutionRequestController->send($message); $archiveRestitutionRequestController->send($message);
} else { } else {
$archiveRestitutionRequest = $this->sendMessage($message); $archiveRestitutionRequest = $this->sendMessage($message);
$message->object = $archiveRestitutionRequest; $message->object = $archiveRestitutionRequest;
...@@ -364,9 +365,51 @@ class ArchiveRestitutionRequest extends abstractMessage ...@@ -364,9 +365,51 @@ class ArchiveRestitutionRequest extends abstractMessage
$operationResult $operationResult
); );
$message->status = "processed"; $message->status = "validated";
$this->sdoFactory->update($message); $this->sdoFactory->update($message);
return true; 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;
}
} }
...@@ -33,14 +33,14 @@ interface archiveRestitutionInterface extends messageInterface ...@@ -33,14 +33,14 @@ interface archiveRestitutionInterface extends messageInterface
* @action medona/ArchiveRestitutionRequest/requestValidationList * @action medona/ArchiveRestitutionRequest/requestValidationList
*/ */
public function readRequestValidationList(); public function readRequestValidationList();
/** /**
* Get request process restitution messages * Get request process restitution messages
* *
* @action medona/ArchiveRestitutionRequest/requestProcessList * @action medona/ArchiveRestitutionRequest/requestProcessList
*/ */
public function readRequestProcessList(); public function readRequestProcessList();
/** /**
* Get validation restitution messages * Get validation restitution messages
* *
...@@ -54,15 +54,14 @@ interface archiveRestitutionInterface extends messageInterface ...@@ -54,15 +54,14 @@ interface archiveRestitutionInterface extends messageInterface
* @action medona/ArchiveRestitution/processList * @action medona/ArchiveRestitution/processList
*/ */
public function readProcessList(); public function readProcessList();
/** /**
* Export archive delivery request reply * Export archive delivery request reply
* *
* @action medona/ArchiveRestitution/export * @action medona/ArchiveRestitution/export
*/ */
public function read_messageId_exportArchive(); public function read_messageId_exportArchive();
/** /**
* Get outgoing restitution messages * Get outgoing restitution messages
* *
...@@ -97,7 +96,7 @@ interface archiveRestitutionInterface extends messageInterface ...@@ -97,7 +96,7 @@ interface archiveRestitutionInterface extends messageInterface
* @action medona/ArchiveRestitutionRequest/accept * @action medona/ArchiveRestitutionRequest/accept
*/ */
public function updateRequestacceptance_messageId_(); public function updateRequestacceptance_messageId_();
/** /**
* Reject archive restitution request * Reject archive restitution request
* *
...@@ -108,22 +107,6 @@ interface archiveRestitutionInterface extends messageInterface ...@@ -108,22 +107,6 @@ interface archiveRestitutionInterface extends messageInterface
*/ */
public function updateRequestrejection($messageId, $comment); 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 * Validate archive restitution
* *
...@@ -146,7 +129,7 @@ interface archiveRestitutionInterface extends messageInterface ...@@ -146,7 +129,7 @@ interface archiveRestitutionInterface extends messageInterface
* @action medona/ArchiveRestitution/acknowledge * @action medona/ArchiveRestitution/acknowledge
*/ */
public function update_messageId_acknowledge(); public function update_messageId_acknowledge();
/** /**
* Process archive restitution * Process archive restitution
* *
...@@ -155,11 +138,11 @@ interface archiveRestitutionInterface extends messageInterface ...@@ -155,11 +138,11 @@ interface archiveRestitutionInterface extends messageInterface
public function update_messageId_Process(); 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 * Process archive restitution
...@@ -168,13 +151,6 @@ interface archiveRestitutionInterface extends messageInterface ...@@ -168,13 +151,6 @@ interface archiveRestitutionInterface extends messageInterface
*/ */
public function updateProcess_message_(); public function updateProcess_message_();
/**
* Validate archive restitution
*
* @action medona/ArchiveRestitutionRequestReply/processBatch
*/
public function updateValidateBatch();
/** /**
* Flag archives for restitution * Flag archives for restitution
* @param array $archiveIds Array of archive identifier * @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