Commit 05493fb4 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Merge branch 'release/2.3' into 'develop'

Release/2.3

See merge request maarch/thirdPartyArchiving!46
parents f57be716 88d7d203
......@@ -131,12 +131,28 @@ class ArchiveDeliveryRequest extends abstractMessage
$archivesByOriginator[$archive->originatorOrgRegNumber][] = $archive;
}
$counter = 0;
if (!$identifier) {
$identifier = "archiveDeliveryRequest_".date("Y-m-d-H-i-s");
}
$reference = $identifier;
foreach ($archivesByOriginator as $originatorOrgRegNumber => $archives) {
$messageIdentifier = $identifier ? $identifier."_".++$counter : "archiveDeliveryRequest_".\laabs::newId();
$i = 1;
$unique = array(
'type' => 'ArchiveDeliveryRequest',
'senderOrgRegNumber' => $requesterOrgRegNumber,
'reference' => $reference,
);
while ($this->sdoFactory->exists("medona/message", $unique)) {
$i++;
$unique['reference'] = $reference = $identifier.'_'.$i;
}
$archiverOrgRegNumber = $archives[0]->archiverOrgRegNumber;
$message = $this->send($messageIdentifier, $archives, $derogation, $comment, $requesterOrgRegNumber, $archiverOrgRegNumber);
$message = $this->send($reference, $archives, $derogation, $comment, $requesterOrgRegNumber, $archiverOrgRegNumber);
$messages[] = $message;
}
......@@ -316,7 +332,7 @@ class ArchiveDeliveryRequest extends abstractMessage
{
$this->changeStatus($messageId, "rejected");
$archiveDeliveryRequestReplyController = \laabs::newController('medona/ArchiveDeliveryRequestReply');
//$archiveDeliveryRequestReplyController = \laabs::newController('medona/ArchiveDeliveryRequestReply');
$message = $this->sdoFactory->read('medona/message', array('messageId' => $messageId));
......@@ -327,8 +343,6 @@ class ArchiveDeliveryRequest extends abstractMessage
$message,
true
);
return $archiveDeliveryRequestReplyController->send($messageId, "rejected", $comment);
}
/**
......
......@@ -80,7 +80,7 @@ class ArchiveDeliveryRequestReply extends abstractMessage
*
* @return The reply message generated
*/
public function send($requestMessage, $archives, $replyCode = "000", $comment = null)
public function send($requestMessage, $archives = null, $replyCode = "000", $comment = null)
{
if (is_scalar($requestMessage)) {
$messageId = $requestMessage;
......
......@@ -70,18 +70,27 @@ class ArchiveDestruction
}
$requesterOrgRegNumber = $requesterOrg->registrationNumber;
$i = 0;
if (!$identifier) {
$identifier = "archiveDestructionRequest_".date("Y-m-d-H-i-s");
}
$reference = $identifier;
foreach ($archivesByOriginator as $originatorOrgRegNumber => $archives) {
$i = 1;
$recipientOrgRegNumber = $archives[0]->archiverOrgRegNumber;
$i++;
if (!$identifier) {
$identifier = "archiveDestructionRequest_".\laabs::newId();
} else {
$identifier .= "_".$i;
$unique = array(
'type' => 'ArchiveDestructionRequest',
'senderOrgRegNumber' => $requesterOrgRegNumber,
'reference' => $reference,
);
while ($this->sdoFactory->exists("medona/message", $unique)) {
$i++;
$unique['reference'] = $reference = $identifier.'_'.$i;
}
$archiveDestructionRequestController->send($identifier, $archives, $comment, $requesterOrgRegNumber, $recipientOrgRegNumber, $originatorOrgRegNumber);
$archiveDestructionRequestController->send($reference, $archives, $comment, $requesterOrgRegNumber, $recipientOrgRegNumber, $originatorOrgRegNumber);
}
return $archiveList;
......
......@@ -150,16 +150,23 @@ class ArchiveDestructionRequest extends abstractMessage
$this->generate($message);
$this->save($message);
}
$this->create($message);
$operationResult = true;
} catch (\Exception $e) {
$message->status = "error";
$this->create($message);
$operationResult = false;
throw $e;
}
$event = $this->lifeCycleJournalController->logEvent(
'medona/sending',
'medona/message',
$message->messageId,
$message,
$operationResult
);
$this->create($message);
$senderOrg = \laabs::getToken('ORGANIZATION');
// Requested by archiver: send auth request to originator
......@@ -216,6 +223,14 @@ class ArchiveDestructionRequest extends abstractMessage
$message->status = "accepted";
$event = $this->lifeCycleJournalController->logEvent(
'medona/acceptance',
'medona/message',
$message->messageId,
$message,
true
);
$this->sdoFactory->update($message);
}
......@@ -302,8 +317,10 @@ class ArchiveDestructionRequest extends abstractMessage
$message->status = "processed";
$message->operationDate = \laabs::newDatetime(null, "UTC");
$operationResult = true;
$this->update($message);
} catch (\Exception $e) {
$operationResult = false;
throw $e;
}
......@@ -311,6 +328,14 @@ class ArchiveDestructionRequest extends abstractMessage
$this->sdoFactory->commit();
}
$this->lifeCycleJournalController->logEvent(
'medona/processing',
'medona/message',
$message->messageId,
$message,
$operationResult
);
$archiveDestructionNotificationController = \laabs::newController("medona/ArchiveDestructionNotification");
// TO DO : Write destruction failures in comments
......
......@@ -169,17 +169,29 @@ class ArchiveModification
}
$archiveModificationNotificationController = \laabs::newController("medona/ArchiveModificationNotification");
$i = 0;
if (!$identifier) {
$identifier = "archiveModificationNotification_".date("Y-m-d-H-i-s");
}
$reference = $identifier;
foreach ($archivesByOriginator as $originatorOrgRegNumber => $archives) {
$i = 1;
$senderOrg = $archives[0]->archiverOrgRegNumber;
$recipientOrg = $originatorOrgRegNumber;
if ($identifier) {
$unique = array(
'type' => 'ArchiveModificationNotification',
'senderOrgRegNumber' => $senderOrg,
'reference' => $reference,
);
while ($this->sdoFactory->exists("medona/message", $unique)) {
$i++;
$identifier .= "_".$i;
$message = $archiveModificationNotificationController->send((string) $identifier, $archives, $senderOrg, $recipientOrg, $comment);
} else {
$message = $archiveModificationNotificationController->send((string) \laabs::newId(), $archives, $senderOrg, $recipientOrg, $comment);
$unique['reference'] = $reference = $identifier.'_'.$i;
}
$message = $archiveModificationNotificationController->send($reference, $archives, $senderOrg, $recipientOrg, $comment);
}
}
}
......@@ -253,17 +253,15 @@ class ArchiveRestitution extends abstractMessage
}
$result = array('success' => array(), 'error' => array());
$counter = 0;
$archiveRestitutionRequestController = \laabs::newController("medona/ArchiveRestitutionRequest");
foreach ($archivesIdsByOriginator as $originatorOrgRegNumber => $archiveIds) {
$communicable = $this->archiveController->accessVerification(($archiveIds[0]));
if (!$communicable) {
$result["error"] = array_merge($result["error"], $archiveIds);
continue;
}
if (!$identifier) {
$identifier = "archiveRestitutionRequest_".date("Y-m-d-H-i-s");
}
$reference = $identifier;
foreach ($archivesIdsByOriginator as $originatorOrgRegNumber => $archiveIds) {
$candidates = $this->archiveController->setForRestitution($archiveIds);
$result["success"] = array_merge($result["success"], $candidates["success"]);
$result["error"] = array_merge($result["error"], $candidates["error"]);
......@@ -280,11 +278,21 @@ class ArchiveRestitution extends abstractMessage
continue;
}
$messageIdentifier = $identifier ? $identifier."_".++$counter : "archiveRestitutionRequest_".\laabs::newId();
$i = 1;
$unique = array(
'type' => 'ArchiveRestitutionRequest',
'senderOrgRegNumber' => $senderOrgRegNumber,
'reference' => $reference,
);
while ($this->sdoFactory->exists("medona/message", $unique)) {
$i++;
$unique['reference'] = $reference = $identifier.'_'.$i;
}
$recipientOrgRegNumber = $archivesForRestitution[0]->archiverOrgRegNumber;
$archiveRestitutionRequestController->send($messageIdentifier, $archivesForRestitution, $comment, $senderOrgRegNumber, $recipientOrgRegNumber, $userName);
$archiveRestitutionRequestController->send($reference, $archivesForRestitution, $comment, $senderOrgRegNumber, $recipientOrgRegNumber, $userName);
}
return $result;
......
......@@ -81,7 +81,7 @@ class ArchiveTransferSending extends abstractMessage
*
* @return array Array of medona/message object
*/
public function history($reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $status)
public function history($reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $status = null)
{
return $this->search("ArchiveTransfer", $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $status, false);
}
......@@ -119,23 +119,44 @@ class ArchiveTransferSending extends abstractMessage
$counter = 0;
foreach ($archiveIds as $archiveId) {
$archive = $this->archiveController->retrieve($archiveId);
$archive = $this->archiveController->retrieve($archiveId, true);
$transferable = $this->isTransferable($archive);
try {
if (!$transferable) {
$transferable = $this->isTransferable($archive);
} catch (\ext\thirdPartyArchiving\bundle\medona\notTransferableArchiveException $notTransferableArchiveException) {
$result["error"][] = $archive->archiveId;
} else {
$result["success"][] = $archive->archiveId;
$archives[] = $archive;
continue;
}
$result["success"][] = $archive->archiveId;
$archives[] = $archive;
}
if (!empty($archives)) {
$messageIdentifier = $identifier ? $identifier : "archiveTransfer_".\laabs::newId();
if (!$identifier) {
$identifier = "archiveTransfer_".date("Y-m-d-H-i-s");
}
$reference = $identifier;
$i = 1;
$unique = array(
'type' => 'ArchiveTransfer',
'senderOrgRegNumber' => $senderOrgRegNumber,
'reference' => $reference,
);
while ($this->sdoFactory->exists("medona/message", $unique)) {
$i++;
$unique['reference'] = $reference = $identifier.'_'.$i;
}
$recipientOrgReqNumber = $archiverOrgRegNumber;
$this->send($messageIdentifier, $archives, $senderOrgRegNumber, $recipientOrgReqNumber, $comment);
$this->send($reference, $archives, $senderOrgRegNumber, $recipientOrgReqNumber, $comment);
}
return $result;
}
......@@ -366,7 +387,7 @@ class ArchiveTransferSending extends abstractMessage
);
}
private function isTransferable($archive)
protected function isTransferable($archive)
{
$currentDate = \laabs::newTimestamp();
$this->archiveController->checkRights($archive);
......@@ -391,6 +412,12 @@ class ArchiveTransferSending extends abstractMessage
throw \laabs::Bundle('medona')->newException('notTransferableArchiveException', 'Disposal date not reached.');
}
//if finaldisposition is not null or empty
if (empty($archive->finalDisposition)) {
throw \laabs::Bundle('medona')->newException('notTransferableArchiveException', "Final disposition must be advised for this action");
}
return $archive;
}
}
\ No newline at end of file
......@@ -48,13 +48,6 @@ interface archiveDeliveryInterface extends messageInterface
*/
public function readCount();
/**
* Get deliveries request replies
*
* @action medona/ArchiveDeliveryRequestReply/getDeliveries
*/
public function readReplies();
/**
* Export archive delivery request reply
*
......
......@@ -118,13 +118,6 @@ interface archiveTransferInterface
*/
public function updateRequestacceptance_messageId_();
/**
* Modify archive transfer
*
* @action medona/ArchiveTransfer/modify
*/
public function updateRequestmodify_messageId_();
/**
* Reject archive transfer
* @param string $messageId The message identifier
......@@ -180,7 +173,7 @@ interface archiveTransferInterface
*
* @action medona/ArchiveTransferSending/history
*/
public function readOutgoingtransferHistory($reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null);
public function readOutgoingtransferHistory($reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $status = null);
/**
* Export outgoing transfer
......
......@@ -58,7 +58,7 @@ class message
\dependency\html\Document $view,
\dependency\sdo\Factory $sdoFactory,
\dependency\json\JsonObject $json,
\dependency\localisation\TranslatorInterface $translator
\dependency\localisation\TranslatorInterface $translator
) {
$this->view = $view;
$this->sdoFactory = $sdoFactory;
......@@ -79,7 +79,7 @@ class message
public function index()
{
$this->view->addContentFile("medona/message/menu.html");
$menu = $this->dashboardPresenter->filterMenuAuth($this->menu);
$this->view->translate();
......@@ -755,20 +755,24 @@ class message
$messageObject->acknowledgeButton = "/restitution/".$messageId."/Acknowledge";
}
$messageObject->validateButton = "/transferValidate/" . $messageId;
$messageObject->exportButton = "/medona/message/".$messageId."/Export";
} elseif ($message->status == "valid") {
$messageObject->acceptButton = "/transferAcceptance/".$messageId;
$messageObject->rejectButton = "/transferRejection/".$messageId;
$messageObject->exportButton = "/medona/message/".$messageId."/Export";
} elseif ($message->status == "toBeModified") {
$messageObject->rejectButton = "/transferRejection/".$messageId;
$messageObject->retryButton = "/medona/message/". $message->messageId . "/retry";
$messageObject->modifyButton = "/transferModify/". $message->messageId;
} elseif ($message->status == "accepted") {
$messageObject->processButton = "/transferProcess/".$messageId;
$messageObject->exportButton = "/medona/message/".$messageId."/Export";
} elseif ($message->status == "sent") {
$messageObject->exportButton = "/outgoingTransfer/".$messageId."/Export";
} elseif ($message->status == "downloaded") {
$messageObject->acknowledgeButton = "/outgoingTransfer/".$messageId."/Acknowledge";
$messageObject->rejectButton = "/outgoingTransfer/".$messageId."/Reject";
$messageObject->exportButton = "/medona/message/".$messageId."/Export";
} elseif ($message->status == "processing") {
$messageObject->retryButton = "/medona/message/". $message->messageId . "/retry";
}
......@@ -814,6 +818,7 @@ class message
$messageObject->acknowledgeButton = "/restitution/".$messageId."/Acknowledge";
} elseif ($message->status == "acknowledge") {
$messageObject->validationButton = "/restitution/".$messageId."/process";
$messageObject->exportButton = "/medona/message/".$messageId."/Export";
}
break;
......@@ -1032,4 +1037,22 @@ class message
return $messagesCount;
}
}
\ No newline at end of file
/**
* Wrong archive infos exceptions
* @param object $exception The exception
*
* @return string String serialized in JSON
*/
public function notDisposableArchiveException($exception)
{
$this->translator->setCatalog('recordsManagement/messages');
// Manage errors
$this->json->status = false;
$this->json->message = $this->translator->getText($exception->getMessage());
return $this->json->save();
}
}
......@@ -366,8 +366,6 @@ var zipContent = "";
gritter.show(response.message, response.status, response.errors);
$('#messageImport_erreur').addClass('hide');
$('#messageImport_cancel').click();
} else {
gritter.show(response.message, response.status);
var arg = "";
......@@ -388,7 +386,21 @@ var zipContent = "";
$('#messageImport_submit').attr('disabled',false);
},
error : function (response) {
gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
gritter.show(response.responseJSON.message, response.responseJSON.status);
var arg = "";
$.each(response.responseJSON.errors,function (key,error) {
arg += "<br/>";
if (error.variables != null && error.variables.property != null) {
arg += error.variables.property + ': ';
}
arg += error.message;
});
$('#messageImport_errorTitle').text(response.responseJSON.message);
$('#messageImport_errorDetail').html(arg);
$('#messageImport_erreur').removeClass('hide');
$('#messageImport_cancel').click();
$('#messageImport_submit').attr('disabled',false);
}
});
}
......
......@@ -92,6 +92,8 @@
<option value="processed">processed</option>
<option value="error">error</option>
<option value="invalid">invalid</option>
<option value="toBeModified">To be modified</option>
<option value="Modified">Modifié</option>
</select>
</div>
</div>
......
......@@ -104,7 +104,8 @@
dataType : 'html',
success : function (response) {
medonaMenu.currentHref = href;
$('.tab-content').empty().html(response);
$('.tab-content').empty();
$('.tab-content').html(response);
},
error : function (response) {
gritter.show(response.responseText, false);
......
......@@ -149,14 +149,12 @@
$('#infoModal').modal("hide");
$('#infoModal').one('hidden.bs.modal', function() {
trigger('reload.medonaMenu');
//trigger('reload.medonaMenu');
});
},
error : function(response) {
$('#infoModal').modal("hide");
$('#infoModal').one('hidden.bs.modal', function() {
trigger('reload.medonaMenu');
//trigger('reload.medonaMenu');
});
gritter.show(response.responseJSON.message, response.responseJSON.status, response.responseJSON.errors);
}
......
......@@ -34,9 +34,10 @@ interface outgoingTransferHistoryInterface
* @param string $archivalAgreement
* @param date $fromDate
* @param date $toDate
* @param string $status
*
* @uses medona/archiveTransfer/readOutgoingtransferHistory
* @return medona/message/outgoingTransferHistory
*/
public function readOutgoingtransferHistory($reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null);
public function readOutgoingtransferHistory($reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null, $status = null);
}
\ No newline at end of file
......@@ -48,7 +48,7 @@ interface deliveryValidationInterface
* @param string $messageId The message identifier
* @param string $comment The message comment
*
* @uses medona/archiveDelivery/updateRequestyrejection
* @uses medona/archiveDelivery/updateRequestrejection
* @return medona/message/rejectDeliveryRequest
*/
public function updateDelivery_messageId_Reject($messageId, $comment = null);
......
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