Verified Commit df6f5e12 authored by Alexandre Morin's avatar Alexandre Morin
Browse files

fix (#11395) : max results

parent fc9e749d
......@@ -551,7 +551,16 @@ class digitalSafe
$queryParts['archive'] = "status != 'disposed'";
$queryString = \laabs\implode(' AND ', $queryParts);
$archives = $this->sdoFactory->find('recordsManagement/archive', $queryString, $queryParams, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
$archives = $this->sdoFactory->find(
'recordsManagement/archive',
$queryString,
$queryParams,
false,
false,
$maxResults
);
$replyMessage->archiveIds = [];
foreach ($archives as $archive) {
......
......@@ -312,8 +312,15 @@ class journal
*
* @return object[] The result of the request
*/
public function searchEvent($eventType = null, $objectClass = null, $objectId = null, $minDate = null, $maxDate = null, $sortBy = ">timestamp", $numberOfResult = 300)
{
public function searchEvent(
$eventType = null,
$objectClass = null,
$objectId = null,
$minDate = null,
$maxDate = null,
$sortBy = ">timestamp",
$numberOfResult = null
) {
$query = array();
$queryParams = array();
......@@ -349,7 +356,18 @@ class journal
$queryString = implode(' AND ', $query);
$events = $this->sdoFactory->find('lifeCycle/event', $queryString, $queryParams, $sortBy, null, $numberOfResult);
if (!$numberOfResult) {
$numberOfResult = \laabs::configuration('presentation.maarchRM')['maxResults'];
}
$events = $this->sdoFactory->find(
'lifeCycle/event',
$queryString,
$queryParams,
$sortBy,
null,
$numberOfResult
);
$userAccountController = \laabs::newController('auth/userAccount');
$users = $userAccountController->index();
......@@ -746,12 +764,16 @@ class journal
*
* @return object[] Array of life cycle event
*/
public function readJournal($journalId, $offset = 0, $limit = 300)
public function readJournal($journalId, $offset = 0, $limit = null)
{
$this->openJournal($journalId);
$events = array();
if (!$limit) {
$limit = \laabs::configuration('presentation.maarchRM')['maxResults'];
}
while ($limit > 0 && $event = $this->getNextEvent(null, false)) {
$events[] = $event;
$limit--;
......
......@@ -44,7 +44,7 @@ interface journalInterface
* @action lifeCycle/journal/readJournal
*
*/
public function read_journalId_($journalId, $offset = 0, $limit = 300);
public function read_journalId_($journalId, $offset = 0, $limit = null);
/**
* Chain the last journal
......
......@@ -158,6 +158,14 @@ class ArchiveConversionRequest extends abstractMessage
$queryParts[] = "type='ArchiveConversionRequest'";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults
);
}
}
......@@ -50,7 +50,15 @@ class ArchiveDeliveryRequest extends abstractMessage
$queryParts[] = "status = 'sent'";
$queryParts[] = "active=true";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults
);
}
/**
......@@ -67,9 +75,27 @@ class ArchiveDeliveryRequest 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 = null)
{
return $this->search("ArchiveDelivery", $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $status);
public function history(
$reference = null,
$archiver = null,
$originator = null,
$depositor = null,
$archivalAgreement = null,
$fromDate = null,
$toDate = null,
$status = null
) {
return $this->search(
"ArchiveDelivery",
$reference,
$archiver,
$originator,
$depositor,
$archivalAgreement,
$fromDate,
$toDate,
$status
);
}
/**
......@@ -122,7 +148,12 @@ class ArchiveDeliveryRequest extends abstractMessage
$messages = array();
foreach ($archiveIds as $archiveId) {
$archive = $this->archiveController->retrieve($archiveId, $withBinary = false, $checkAccess = true, $isCommunication = true);
$archive = $this->archiveController->retrieve(
$archiveId,
$withBinary = false,
$checkAccess = true,
$isCommunication = true
);
if (!isset($archivesByOriginator[$archive->originatorOrgRegNumber])) {
$archivesByOriginator[$archive->originatorOrgRegNumber] = array();
......@@ -152,7 +183,14 @@ class ArchiveDeliveryRequest extends abstractMessage
$archiverOrgRegNumber = $archives[0]->archiverOrgRegNumber;
$message = $this->send($reference, $archives, $derogation, $comment, $requesterOrgRegNumber, $archiverOrgRegNumber);
$message = $this->send(
$reference,
$archives,
$derogation,
$comment,
$requesterOrgRegNumber,
$archiverOrgRegNumber
);
$messages[] = $message;
}
......@@ -172,8 +210,15 @@ class ArchiveDeliveryRequest extends abstractMessage
*
* @return The reply message generated
*/
public function send($reference, $archives, $derogation = false, $comment = false, $requesterOrgRegNumber = false, $archiverOrgRegNumber = false, $userName = false)
{
public function send(
$reference,
$archives,
$derogation = false,
$comment = false,
$requesterOrgRegNumber = false,
$archiverOrgRegNumber = false,
$userName = false
) {
if (!is_array($archives)) {
$archives = array($archives);
}
......@@ -354,7 +399,10 @@ class ArchiveDeliveryRequest extends abstractMessage
{
$results = array();
$messages = $this->sdoFactory->find("medona/message", "status='accepted' AND type='ArchiveDeliveryRequest' AND active=true");
$messages = $this->sdoFactory->find(
"medona/message",
"status='accepted' AND type='ArchiveDeliveryRequest' AND active=true"
);
foreach ($messages as $message) {
$this->changeStatus($message->messageId, "processing");
$this->readOrgs($message);
......
......@@ -51,7 +51,14 @@ class ArchiveDeliveryRequestReply extends abstractMessage
$queryParts[] = "status = 'sent'";
$queryParts[] = "active=true";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults);
}
/**
......@@ -68,7 +75,15 @@ class ArchiveDeliveryRequestReply extends abstractMessage
$queryParts[] = "active=true";
$queryParts[] = "status = ['sent']";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults
);
}
/**
......@@ -87,7 +102,10 @@ class ArchiveDeliveryRequestReply extends abstractMessage
$requestMessage = $this->sdoFactory->read('medona/message', $messageId);
}
$authorizationMessage = $this->sdoFactory->find('medona/message', "authorizationReference='$requestMessage->reference'");
$authorizationMessage = $this->sdoFactory->find(
'medona/message',
"authorizationReference='$requestMessage->reference'"
);
$message = \laabs::newInstance('medona/message');
$message->messageId = \laabs::newId();
......
......@@ -41,9 +41,21 @@ class ArchiveDestructionRequest extends abstractMessage
$queryParts[] = "recipientOrgRegNumber=$registrationNumber";
$queryParts[] = "type='ArchiveDestructionRequest'";
$queryParts[] = "active=true";
$queryParts[] = "status != 'processed' AND status != 'error' AND status != 'sent' AND status != 'validated' AND status != 'rejected'";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$queryParts[] = "status != 'processed'
AND status != 'error'
AND status != 'sent'
AND status != 'validated'
AND status != 'rejected'";
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults
);
}
/**
......@@ -60,9 +72,27 @@ class ArchiveDestructionRequest 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 = null)
{
return $this->search("ArchiveDestruction", $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $status);
public function history(
$reference = null,
$archiver = null,
$originator = null,
$depositor = null,
$archivalAgreement = null,
$fromDate = null,
$toDate = null,
$status = null
) {
return $this->search(
"ArchiveDestruction",
$reference,
$archiver,
$originator,
$depositor,
$archivalAgreement,
$fromDate,
$toDate,
$status
);
}
/**
......@@ -181,15 +211,14 @@ class ArchiveDestructionRequest extends abstractMessage
if ($senderOrg->registrationNumber == $message->recipientOrgRegNumber) {
$authorizationOriginatingAgencyRequestController = \laabs::newController('medona/AuthorizationOriginatingAgencyRequest');
$authorizationOriginatingAgencyRequestController->send($message, $originatorOrgRegNumber);
$message->status == "originator_authorization_wait";
$message->status = "originator_authorization_wait";
} else {
// Requested by originator
$controlAuthorities = $this->orgController->getOrgsByRole('controlAuthority');
// Check if control authority is set on system
if (count($controlAuthorities)) {
$message->status == "control_authorization_wait";
$message->status = "control_authorization_wait";
$authorizationControlAuthorityRequestController = \laabs::newController('medona/AuthorizationControlAuthorityRequest');
$authorizationControlAuthorityRequestController->send($message, $originatorOrgRegNumber);
}
......
......@@ -138,7 +138,15 @@ class ArchiveModificationRequest extends abstractMessage
$queryParts[] = "type='ArchiveModificationRequest' and status='received'";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults
);
}
/**
......@@ -153,9 +161,25 @@ class ArchiveModificationRequest extends abstractMessage
*
* @return array Array of medona/message object
*/
public function history($reference = null, $archiver = null, $requester = null, $fromDate = null, $toDate = null, $status = null)
{
return $this->search("ArchiveModificationRequest", $reference, $archiver, $requester, null, null, $fromDate, $toDate, $status);
public function history(
$reference = null,
$archiver = null,
$requester = null,
$fromDate = null,
$toDate = null,
$status = null
) {
return $this->search(
"ArchiveModificationRequest",
$reference,
$archiver,
$requester,
null,
null,
$fromDate,
$toDate,
$status
);
}
......
......@@ -40,16 +40,33 @@ class ArchiveNotification extends abstractMessage
*
* @return array Array of medona/message object
*/
public function listReception($reference = null, $archiver = null, $originator = null, $depositor = null, $archivalAgreement = null, $fromDate = null, $toDate = null)
{
public function listReception(
$reference = null,
$archiver = null,
$originator = null,
$depositor = null,
$archivalAgreement = null,
$fromDate = null,
$toDate = null
) {
$registrationNumber = $this->getCurrentRegistrationNumber();
$queryParts = [];
$queryParts[] = "recipientOrgRegNumber=$registrationNumber OR senderOrgRegNumber=$registrationNumber";
$queryParts[] = "type='ArchiveModificationNotification' OR type='ArchiveDestructionNotification' OR type='ArchivalProfileModificationNotification'";
$queryParts[] = "type='ArchiveModificationNotification'
OR type='ArchiveDestructionNotification'
OR type='ArchivalProfileModificationNotification'";
$queryParts[] = "active=true";
return $this->sdoFactory->find('medona/message', '('.implode(') and (', $queryParts).')', null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
'('.implode(') and (', $queryParts).')',
null,
false,
false,
$maxResults
);
}
/**
......@@ -66,9 +83,28 @@ class ArchiveNotification 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 = null)
{
return $this->search("ArchiveNotification", $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $status, false);
public function history(
$reference = null,
$archiver = null,
$originator = null,
$depositor = null,
$archivalAgreement = null,
$fromDate = null,
$toDate = null,
$status = null
) {
return $this->search(
"ArchiveNotification",
$reference,
$archiver,
$originator,
$depositor,
$archivalAgreement,
$fromDate,
$toDate,
$status,
false
);
}
/**
......@@ -82,7 +118,9 @@ class ArchiveNotification extends abstractMessage
$res = array();
$queryParts = array();
$queryParts[] = "(type='ArchiveModificationNotification' OR type='ArchiveDestructionNotification' OR type='ArchivalProfileModificationNotification')";
$queryParts[] = "(type='ArchiveModificationNotification'
OR type='ArchiveDestructionNotification'
OR type='ArchivalProfileModificationNotification')";
$queryParts[] = "recipientOrgRegNumber=$registrationNumber OR senderOrgRegNumber=$registrationNumber";
$queryParts[] = "active=true";
$res['received'] = $this->sdoFactory->count('medona/message', implode(' and ', $queryParts));
......
......@@ -44,7 +44,15 @@ class ArchiveRestitution extends abstractMessage
$queryParts[] = "status=['sent', 'received']";
$queryParts[] = "active=true";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults
);
}
/**
......@@ -62,7 +70,15 @@ class ArchiveRestitution extends abstractMessage
$queryParts[] = "status='acknowledge'";
$queryParts[] = "active=true";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults
);
}
/**
......@@ -79,9 +95,27 @@ class ArchiveRestitution 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 = null)
{
return $this->search("ArchiveRestitution", $reference, $archiver, $originator, $depositor, $archivalAgreement, $fromDate, $toDate, $status);
public function history(
$reference = null,
$archiver = null,
$originator = null,
$depositor = null,
$archivalAgreement = null,
$fromDate = null,
$toDate = null,
$status = null
) {
return $this->search(
"ArchiveRestitution",
$reference,
$archiver,
$originator,
$depositor,
$archivalAgreement,
$fromDate,
$toDate,
$status
);
}
/**
......@@ -143,7 +177,9 @@ class ArchiveRestitution extends abstractMessage
//$this->load($message);
}
$replyMessage = $this->sdoFactory->find('medona/message', "type='".$requestMessage->type."Reply' AND recipientOrgRegNumber='".$requestMessage->senderOrgRegNumber."' AND senderOrgRegNumber='".$requestMessage->recipientOrgRegNumber."' AND requestReference='".$requestMessage->reference."'");
$replyMessage = $this->sdoFactory->find(
'medona/message',
"type='".$requestMessage->type."Reply' AND recipientOrgRegNumber='".$requestMessage->senderOrgRegNumber."' AND senderOrgRegNumber='".$requestMessage->recipientOrgRegNumber."' AND requestReference='".$requestMessage->reference."'");
if (count($replyMessage) > 0) {
$replyMessage = $replyMessage[0];
} else {
......@@ -267,7 +303,6 @@ class ArchiveRestitution extends abstractMessage
$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"]);
......@@ -298,7 +333,14 @@ class ArchiveRestitution extends abstractMessage
$recipientOrgRegNumber = $archivesForRestitution[0]->archiverOrgRegNumber;
$archiveRestitutionRequestController->send($reference, $archivesForRestitution, $comment, $senderOrgRegNumber, $recipientOrgRegNumber, $userName);
$archiveRestitutionRequestController->send(
$reference,
$archivesForRestitution,
$comment,
$senderOrgRegNumber,
$recipientOrgRegNumber,
$userName
);
}
return $result;
......@@ -337,7 +379,9 @@ class ArchiveRestitution extends abstractMessage
$this->changeStatus($messageId, "acknowledge");
$message = $this->sdoFactory->read('medona/message', array('messageId' => $messageId));
$requestMessage = $this->sdoFactory->find('medona/message', "type='ArchiveRestitutionRequest' AND senderOrgRegNumber='".$message->recipientOrgRegNumber."' AND replyReference='".$message->relatedReference."'")[0];
$requestMessage = $this->sdoFactory->find(
'medona/message',
"type='ArchiveRestitutionRequest' AND senderOrgRegNumber='".$message->recipientOrgRegNumber."' AND replyReference='".$message->relatedReference."'")[0];
$requestMessage->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $requestMessage);
......@@ -373,7 +417,9 @@ class ArchiveRestitution extends abstractMessage
$this->changeStatus($messageId, "rejected");
$message = $this->sdoFactory->read('medona/message', $messageId);
$requestMessage = $this->sdoFactory->find('medona/message', "type='ArchiveRestitutionRequest' AND senderOrgRegNumber='".$message->recipientOrgRegNumber."' AND replyReference='".$message->relatedReference."'")[0];
$requestMessage = $this->sdoFactory->find(
'medona/message',
"type='ArchiveRestitutionRequest' AND senderOrgRegNumber='".$message->recipientOrgRegNumber."' AND replyReference='".$message->relatedReference."'")[0];
$requestMessage->unitIdentifier = $this->sdoFactory->readChildren('medona/unitIdentifier', $requestMessage);
foreach ($requestMessage->unitIdentifier as $unitIdentifier) {
......
......@@ -43,7 +43,15 @@ class ArchiveRestitutionRequest extends abstractMessage
$queryParts[] = "active=true";
$queryParts[] = "status != 'processed' AND status != 'error' AND status != 'rejected'";
return $this->sdoFactory->find('medona/message', implode(' and ', $queryParts), null, false, false, 300);
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
return $this->sdoFactory->find(
'medona/message',
implode(' and ', $queryParts),
null,
false,
false,
$maxResults
);
}
/**
......@@ -61,7 +69,15 @@ class ArchiveRestitutionRequest extends abstractMessage
$queryParts[] = "active=true";