Commit 2bf003db authored by Benjamin Rousselière's avatar Benjamin Rousselière
Browse files

feat/9754 : add possibility to chose message format

parent 6c759a1b
Pipeline #7399 failed with stages
......@@ -39,10 +39,11 @@ interface archiveModificationRequestInterface extends messageInterface
* @param mixed $archiveIds The identifier of archive or a list of identifiers
* @param string $identifier The medona message reference
* @param string $comment The message comment
* @param string $format Message format
*
* @action medona/ArchiveModificationRequest/send
*/
public function create($archiveIds, $identifier = null, $comment = null);
public function create($archiveIds, $identifier = null, $comment = null, $format = null);
/**
* Reject archive modification request
......
......@@ -127,12 +127,13 @@ class ArchiveDeliveryRequest extends abstractMessage
* @param string $identifier The medona message reference
* @param boolean $derogation Ask for an authorization
* @param string $comment The message comment
* @param string $format The message format
*
* @return array Array of message
*
* @throws \bundle\recordsManagement\Exception\notCommunicableException
*/
public function requestDelivery($archiveIds, $identifier = null, $derogation = false, $comment = null)
public function requestDelivery($archiveIds, $identifier = null, $derogation = false, $comment = null, $format = null)
{
$requesterOrg = \laabs::getToken('ORGANIZATION');
if (!$requesterOrg) {
......@@ -189,7 +190,9 @@ class ArchiveDeliveryRequest extends abstractMessage
$derogation,
$comment,
$requesterOrgRegNumber,
$archiverOrgRegNumber
$archiverOrgRegNumber,
null,
$format
);
$messages[] = $message;
......@@ -207,6 +210,7 @@ class ArchiveDeliveryRequest extends abstractMessage
* @param object $requesterOrgRegNumber The requesting org reg number
* @param string $archiverOrgRegNumber The archiver org registration number
* @param string $userName The requester user name
* @param string $format The message format
*
* @return The reply message generated
*/
......@@ -217,7 +221,8 @@ class ArchiveDeliveryRequest extends abstractMessage
$comment = false,
$requesterOrgRegNumber = false,
$archiverOrgRegNumber = false,
$userName = false
$userName = false,
$format = null
) {
if (!is_array($archives)) {
$archives = array($archives);
......@@ -227,7 +232,9 @@ class ArchiveDeliveryRequest extends abstractMessage
$message->messageId = \laabs::newId();
$schema = "mades";
if ($archives[0]->descriptionClass === 'seda2') {
if ($format) {
$schema = $format;
} elseif ($archives[0]->descriptionClass === 'seda2') {
$schema = "seda2";
} elseif (\laabs::hasBundle('seda')) {
$schema = "seda";
......
......@@ -35,14 +35,16 @@ class ArchiveDestructionNotification extends ArchiveNotification
*
* @return The message generated
*/
public function send($destructionRequest, $archives)
public function send($destructionRequest, $archives, $format = null)
{
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->type = "ArchiveDestructionNotification";
$schema = "mades";
if ($archives[0]->descriptionClass === 'seda2') {
if ($format) {
$schema = $format;
} elseif ($archives[0]->descriptionClass === 'seda2') {
$schema = 'seda2';
} elseif (\laabs::hasBundle('seda')) {
$schema = "seda";
......
......@@ -134,7 +134,8 @@ class ArchiveDestructionRequest extends abstractMessage
$comment = null,
$requesterOrgRegNumber = null,
$archiverOrgRegNumber = null,
$originatorOrgRegNumber = null
$originatorOrgRegNumber = null,
$format = null
) {
if (!is_array($archives)) {
$archives = array($archives);
......@@ -144,7 +145,9 @@ class ArchiveDestructionRequest extends abstractMessage
$message->messageId = \laabs::newId();
$schema = "mades";
if ($archives[0]->descriptionClass === 'seda2') {
if ($format) {
$schema = $format;
} elseif ($archives[0]->descriptionClass === 'seda2') {
$schema = 'seda2';
} elseif (\laabs::hasBundle('seda')) {
$schema = "seda";
......
......@@ -36,17 +36,20 @@ class ArchiveModificationNotification extends ArchiveNotification
* @param string $senderOrg The identifier of sender
* @param string $recipientOrg The identifier of recipient
* @param string $comment The comment of modification
* @param string $format The message format
*
* @return The message generated
*/
public function send($reference, $archives = array(), $senderOrg, $recipientOrg, $comment = false)
public function send($reference, $archives = array(), $senderOrg, $recipientOrg, $comment = false, $format = null)
{
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->type = "ArchiveModificationNotification";
$schema = "mades";
if ($archives[0]->descriptionClass === 'seda2') {
if ($format) {
$schema = $format;
} elseif ($archives[0]->descriptionClass === 'seda2') {
$schema = 'seda2';
} elseif (\laabs::hasBundle('seda')) {
$schema = "seda";
......
......@@ -264,10 +264,11 @@ class ArchiveRestitution extends abstractMessage
* @param array $archiveIds Array of archive identifier
* @param string $identifier The medona message reference
* @param string $comment The message comment
* @param string $format The message format
*
* @return array The result of the operation
*/
public function setForRestitution($archiveIds, $identifier = null, $comment = null)
public function setForRestitution($archiveIds, $identifier = null, $comment = null, $format = null)
{
$senderOrg = \laabs::getToken('ORGANIZATION');
if (!$senderOrg) {
......@@ -341,7 +342,8 @@ class ArchiveRestitution extends abstractMessage
$comment,
$senderOrgRegNumber,
$recipientOrgRegNumber,
$userName
$userName,
$format
);
}
......
......@@ -146,6 +146,7 @@ class ArchiveRestitutionRequest extends abstractMessage
* @param string $senderOrg The requesting org
* @param string $recipientOrg The requesting org
* @param string $userName The requester user name
* @param string $format The message format
*
* @return The reply message generated
*/
......@@ -155,7 +156,8 @@ class ArchiveRestitutionRequest extends abstractMessage
$comment = false,
$senderOrg = false,
$recipientOrg = false,
$userName = false
$userName = false,
$format = null
) {
if (!is_array($archives)) {
$archives = array($archives);
......@@ -165,7 +167,9 @@ class ArchiveRestitutionRequest extends abstractMessage
$message->messageId = \laabs::newId();
$message->schema = "medona";
if ($archives[0]->descriptionClass === 'seda2') {
if ($format) {
$message->schema = $format;
} elseif ($archives[0]->descriptionClass === 'seda2') {
$message->schema = 'seda2';
} elseif (\laabs::hasBundle('seda')) {
$message->schema = "seda";
......
......@@ -109,10 +109,11 @@ class ArchiveTransferSending extends abstractMessage
* @param string $archiverOrgRegNumber The archival agency
* @param string $comment The message comment
* @param string $identifier The medona message reference
* @param string $format The message format
*
* @return array The result of the operation
*/
public function setForTransfer($archiveIds, $archiverOrgRegNumber, $comment, $identifier = null)
public function setForTransfer($archiveIds, $archiverOrgRegNumber, $comment, $identifier = null, $format = null)
{
$senderOrg = \laabs::getToken('ORGANIZATION');
if (!$senderOrg) {
......@@ -174,19 +175,21 @@ class ArchiveTransferSending extends abstractMessage
$recipientOrgReqNumber = $archiverOrgRegNumber;
$this->send($reference, $archives, $senderOrgRegNumber, $recipientOrgReqNumber, $comment);
$this->send($reference, $archives, $senderOrgRegNumber, $recipientOrgReqNumber, $comment, $format);
}
return $result;
}
public function send($reference, $archives, $senderOrg, $recipientOrg, $comment = null)
public function send($reference, $archives, $senderOrg, $recipientOrg, $comment = null, $format = null)
{
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
$message->schema = "medona";
if ($archives[0]->descriptionClass === 'seda2') {
if ($format) {
$message->schema = $format;
} elseif ($archives[0]->descriptionClass === 'seda2') {
$message->schema = 'seda2';
} elseif (\laabs::hasBundle('seda')) {
$message->schema = "seda";
......
......@@ -125,8 +125,9 @@ interface archiveDeliveryInterface extends messageInterface
* @param mixed $archiveIds The identifier of archive or a list of identifiers
* @param string $identifier The medona message reference
* @param string $comment The message comment
* @param string $format The message format
*
* @action medona/ArchiveDeliveryRequest/requestDelivery
*/
public function createDelivery($archiveIds, $identifier = null, $derogation = false, $comment = null);
public function createDelivery($archiveIds, $identifier = null, $derogation = false, $comment = null, $format = null);
}
......@@ -86,12 +86,12 @@ interface archiveDestructionInterface extends messageInterface
* @param array $archiveIds The archives ids
* @param string $comment The comment of modification
* @param string $identifier Message identifier
*
* @param string $format Message format
* @return boolean
*
* @request UPDATE medona/dispose
* @action medona/ArchiveDestruction/dispose
*
*/
public function updateDisposearchives($archiveIds, $comment = null, $identifier = null);
public function updateDisposearchives($archiveIds, $comment = null, $identifier = null, $format = null);
}
......@@ -166,9 +166,10 @@ interface archiveRestitutionInterface extends messageInterface
* @param array $archiveIds Array of archive identifier
* @param string $identifier The reference for message
* @param string $comment A comment
* @param string $format Message format
*
* @action medona/ArchiveRestitution/setForRestitution
*
*/
public function updateSetforrestitution($archiveIds, $identifier = null, $comment = null);
public function updateSetforrestitution($archiveIds, $identifier = null, $comment = null, $format = null);
}
......@@ -138,14 +138,15 @@ interface archiveTransferInterface
/**
* Create outgoing transfer
* @param array $archiveIds List of archives
* @param array $archiveIds List of archives
* @param string $archiverOrgRegNumber An Archiver
* @param string $comment A comment
* @param string $identifier An identifier
* @param string $format The message format
*
* @action medona/ArchiveTransferSending/setForTransfer
*/
public function updateOutgoingtransferSending($archiveIds, $archiverOrgRegNumber, $comment, $identifier = null);
public function updateOutgoingtransferSending($archiveIds, $archiverOrgRegNumber, $comment, $identifier = null, $format = null);
/**
* Get ingoing transfer messages
......
......@@ -29,13 +29,15 @@ trait archiveDestructionTrait
/**
* Flag for disposal
*
* @param array $archiveIds The archives ids
* @param array $archiveIds The archives ids
* @param string $identifier
* @param string $comment
* @param string $format The message format
*
* @return mixed
* @throws \bundle\recordsManagement\Exception\notDisposableArchiveException
*/
public function dispose($archiveIds, $identifier = null, $comment = null)
public function dispose($archiveIds, $identifier = null, $comment = null, $format = null)
{
$archives = [];
......@@ -77,7 +79,7 @@ trait archiveDestructionTrait
}
if (isset(\laabs::configuration("medona")['transaction']) && \laabs::configuration("medona")['transaction']) {
$this->sendDestructionRequest($archives, $identifier, $comment);
$this->sendDestructionRequest($archives, $identifier, $comment, $format);
}
return $res;
......@@ -90,10 +92,12 @@ trait archiveDestructionTrait
* @param $archives
* @param null $identifier
* @param null $comment
* @param string $format
*
* @return mixed
* @throws \Exception
*/
protected function sendDestructionRequest($archives, $identifier = null, $comment = null)
protected function sendDestructionRequest($archives, $identifier = null, $comment = null, $format = null)
{
$archiveDestructionRequestController = \laabs::newController("medona/ArchiveDestructionRequest");
......@@ -140,7 +144,8 @@ trait archiveDestructionTrait
$comment,
$requesterOrgRegNumber,
$recipientOrgRegNumber,
$originatorOrgRegNumber
$originatorOrgRegNumber,
$format
);
}
......
......@@ -74,10 +74,12 @@ trait archiveModificationTrait
* @param mixed $archiveIds The archives ids
* @param null $comment
* @param null $identifier
* @param string $format
*
* @return array
* @throws \Exception
*/
public function modifyRetentionRule($retentionRule, $archiveIds, $comment = null, $identifier = null)
public function modifyRetentionRule($retentionRule, $archiveIds, $comment = null, $identifier = null, $format = null)
{
// #10629 Get finalDisposition and duration from ref when empty and code is received
if ((empty($retentionRule->finalDisposition)
......@@ -180,7 +182,7 @@ trait archiveModificationTrait
}
if (isset(\laabs::configuration("medona")['transaction']) && \laabs::configuration("medona")['transaction']) {
$this->sendModificationNotification($archives, $comment, $identifier);
$this->sendModificationNotification($archives, $comment, $identifier, $format);
}
return $res;
......@@ -193,9 +195,11 @@ trait archiveModificationTrait
* @param array $archiveIds The archives ids
* @param null $comment
* @param null $identifier
* @param string $format
*
* @return array
*/
public function modifyAccessRule($accessRule, $archiveIds, $comment = null, $identifier = null)
public function modifyAccessRule($accessRule, $archiveIds, $comment = null, $identifier = null, $format = null)
{
if (!is_array($archiveIds)) {
$archiveIds = array($archiveIds);
......@@ -271,7 +275,7 @@ trait archiveModificationTrait
}
if (isset(\laabs::configuration("medona")['transaction']) && \laabs::configuration("medona")['transaction']) {
$this->sendModificationNotification($archives, $comment, $identifier);
$this->sendModificationNotification($archives, $comment, $identifier, $format);
}
return $res;
......@@ -282,10 +286,11 @@ trait archiveModificationTrait
* @param mixed $archiveIds Array of archive identifier
* @param null $comment
* @param null $identifier
* @param string $format
*
* @return array
*/
public function freeze($archiveIds, $comment = null, $identifier = null)
public function freeze($archiveIds, $comment = null, $identifier = null, $format = null)
{
if (!is_array($archiveIds)) {
$archiveIds = array($archiveIds);
......@@ -319,7 +324,7 @@ trait archiveModificationTrait
}
if (isset(\laabs::configuration("medona")['transaction']) && \laabs::configuration("medona")['transaction']) {
$this->sendModificationNotification($archives, $comment, $identifier);
$this->sendModificationNotification($archives, $comment, $identifier, $format);
}
return $res;
......@@ -330,10 +335,11 @@ trait archiveModificationTrait
* @param mixed $archiveIds Array of archive identifier
* @param null $comment
* @param null $identifier
* @param string $format
*
* @return array
*/
public function unfreeze($archiveIds, $comment = null, $identifier = null)
public function unfreeze($archiveIds, $comment = null, $identifier = null, $format = null)
{
if (!is_array($archiveIds)) {
$archiveIds = array($archiveIds);
......@@ -366,7 +372,7 @@ trait archiveModificationTrait
}
if (isset(\laabs::configuration("medona")['transaction']) && \laabs::configuration("medona")['transaction']) {
$this->sendModificationNotification($archives, $comment, $identifier);
$this->sendModificationNotification($archives, $comment, $identifier, $format);
}
return $res;
......@@ -762,7 +768,7 @@ trait archiveModificationTrait
$this->sdoFactory->update($archiveUserOrgRegNumbers);
}
protected function sendModificationNotification($archives, $comment = null, $identifier = null)
protected function sendModificationNotification($archives, $comment = null, $identifier = null, $format = null)
{
$currentOrg = \laabs::getToken("ORGANIZATION");
......@@ -804,7 +810,8 @@ trait archiveModificationTrait
$archives,
$senderOrg,
$recipientOrg,
$comment
$comment,
$format
);
}
}
......
......@@ -152,21 +152,23 @@ interface archivesInterface
* @param array $archiveIds Array of archive identifier
* @param string $comment The comment of modification
* @param string $identifier Message identifier
* @param string $format Message format
*
* @action recordsManagement/archive/freeze
*
*/
public function updateFreeze($archiveIds, $comment = null, $identifier = null);
public function updateFreeze($archiveIds, $comment = null, $identifier = null, $format = null);
/**
* Change the status of an archive
* @param mixed $archiveIds Array of archive identifier
* @param string $comment The comment of modification
* @param string $identifier Message identifier
* @param string $format Message format
*
* @action recordsManagement/archive/unfreeze
*/
public function updateUnfreeze($archiveIds, $comment = null, $identifier = null);
public function updateUnfreeze($archiveIds, $comment = null, $identifier = null, $format = null);
/**
* Read the retention rule of multiple archives
......@@ -181,12 +183,15 @@ interface archivesInterface
* Update a retention rule
* @param recordsManagement/archiveRetentionRule $retentionRule The retention rule object
* @param array $archiveIds The archives ids
* @param string $comment The comment of modification
* @param string $identifier Message identifier
* @param string $format Message format
*
* @action recordsManagement/archive/modifyRetentionRule
* @example /public/tests/updateArchivesRetentionRule-standard.json example-standard
*
*/
public function updateRetentionrule($retentionRule, $archiveIds, $comment = null, $identifier = null);
public function updateRetentionrule($retentionRule, $archiveIds, $comment = null, $identifier = null, $format = null);
/**
* Find archives
......@@ -215,11 +220,12 @@ interface archivesInterface
* @param array $archiveIds The archives ids
* @param string $comment The comment of modification
* @param string $identifier Message identifier
* @param string $format Message format
*
* @action recordsManagement/archive/modifyAccessRule
*
*/
public function updateAccessrule($accessRule, $archiveIds = null, $comment = null, $identifier = null);
public function updateAccessrule($accessRule, $archiveIds = null, $comment = null, $identifier = null, $format = null);
/*
RESTITUTION
......@@ -229,11 +235,12 @@ interface archivesInterface
* @param array $archiveIds Array of archive identifier
* @param string $identifier The message reference
* @param string $comment A comment
* @param string $format The message format
*
* @action recordsManagement/archive/setForRestitution
*
*/
public function updateSetforrestitution($archiveIds, $identifier = null, $comment = null);
public function updateSetforrestitution($archiveIds, $identifier = null, $comment = null, $format = null);
/*
DESTRUCTION
......@@ -243,6 +250,7 @@ interface archivesInterface
* @param array $archiveIds The archives ids
* @param string $comment The comment of modification
* @param string $identifier Message identifier
* @param string $format The message format
*
* @return boolean
*
......@@ -250,7 +258,7 @@ interface archivesInterface
* @action recordsManagement/archive/dispose
*
*/
public function updateDisposearchives($archiveIds, $comment = null, $identifier = null);
public function updateDisposearchives($archiveIds, $comment = null, $identifier = null, $format = null);
/**
* Delete disposable archives
......
......@@ -188,6 +188,9 @@ msgstr "Date de fin"
msgid "Message identifier"
msgstr "Identifiant du bordereau"
msgid "Message format"
msgstr "Format du bordereau"
msgid "Message"
msgstr "Bordereau"
......
......@@ -22,6 +22,15 @@
<td><strong>Message identifier</strong></td>
<td><input class="form-control" name="identifier" id="identifier" placeholder="Identifier"></td>
<tr>
<tr>
<td><strong>Message format</strong></td>
<td>
<select class="form-control" name="format" id="format">
<option value="seda">Seda 1</option>
<option value="seda2">Seda 2</option>
</select>
</td>
<tr>
<tr>
<td><strong>Comment <span style="color:red">*</span></strong></td>
<td><div>
......
......@@ -90,6 +90,7 @@
if (transaction) {
parameter.identifier = this.modal.find('[name="identifier"]').val();
parameter.comment = this.modal.find('[name="comment"]').val();
parameter.format = this.modal.find('[name="format"]').val()
if (parameter!=-1 && !parameter.comment) {
gritter.show($('#empty_text').html(), false);
......
......@@ -272,6 +272,8 @@
} else {
type = 'PUT';
}
console.log(this.actionsList[this.modalType]);
$.ajax({
url : this.actionsList[this.modalType],
......
......@@ -45,9 +45,10 @@ interface modificationRequestSendInterface
* @param array $archiveIds List of archives
* @param string $comment A comment
* @param string $identifier An identifier
* @param string $format The message format
*
* @uses medona/archiveModificationRequest/create
* @return medona/archiveModification/modificationRequestSent
*/
public function createModificationrequest($archiveIds, $comment, $identifier = null);
public function createModificationrequest($archiveIds, $comment, $identifier = null, $format = null);
}