Unverified Commit b445dc17 authored by Jerome Boucher's avatar Jerome Boucher
Browse files

fix/14312 : Add limit to search and update conf

parent 1aed8c0c
Pipeline #8703 failed with stages
......@@ -29,30 +29,31 @@ trait archiveAccessTrait
{
/**
* Search archives by profile / dates / agreement
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param string $processingStatus
* @param bool $checkAccess
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param string $processingStatus
* @param bool $checkAccess
* @param integer $maxResults
*
* @return recordsManagement/archive[] Array of recordsManagement/archive object
*/
......@@ -80,7 +81,8 @@ trait archiveAccessTrait
$originatingEndDate = null,
$archiverArchiveId = null,
$processingStatus = null,
$checkAccess = true
$checkAccess = true,
$maxResults = null
) {
$accountController = \laabs::newController('auth/userAccount');
$accountController->isAuthorized('user');
......@@ -134,7 +136,7 @@ trait archiveAccessTrait
}
}
foreach ($searchClasses as $descriptionClass => $descriptionController) {
$archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs, $checkAccess));
$archives = array_merge($archives, $descriptionController->search($description, $text, $archiveArgs, $checkAccess, $maxResults));
}
return $archives;
......
......@@ -120,20 +120,21 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip
return json_decode($descriptionObject->description);
} catch (\Exception $e) {
}
}
/**
* Search the description objects
* @param string $description The search args on description object
* @param string $text The search args on text
* @param array $archiveArgs The search args on archive std properties
* @param bool $checkAccess Use access control. If not, called MUST control access before or after retrieving data
* @param string $description The search args on description object
* @param string $text The search args on text
* @param array $archiveArgs The search args on archive std properties
* @param bool $checkAccess Use access control. If not, called MUST control access before or after retrieving data
* @param integer $maxResults Max results to display
*
* @return array The result of the research
*/
public function search($description = null, $text = null, array $archiveArgs = [], $checkAccess = true)
public function search($description = null, $text = null, array $archiveArgs = [], $checkAccess = true, $maxResults = null)
{
$queryParams = [];
$queryParts = ['(description!=null and text!=null)'];
......@@ -203,7 +204,7 @@ class description implements \bundle\recordsManagement\Controller\archiveDescrip
$queryString = \laabs\implode(' and ', $queryParts);
$archiveUnits = $this->sdoFactory->find('recordsManagement/archiveUnit', $queryString, $queryParams, false, false, \laabs::configuration('presentation.maarchRM')['maxResults']);
$archiveUnits = $this->sdoFactory->find('recordsManagement/archiveUnit', $queryString, $queryParams, false, false, $maxResults);
foreach ($archiveUnits as $archiveUnit) {
if (!empty($archiveUnit->description)) {
......
......@@ -138,15 +138,14 @@ class log implements archiveDescriptionInterface
*
* @return object Array of description objects
*/
public function search($description = null, $text = null, array $args = [])
public function search($description = null, $text = null, array $args = [], $checkAccess = null, $maxResults = null)
{
$archiveController = \laabs::newController('recordsManagement/archive');
$archives = [];
$sortBy = ">fromDate";
$numberOfResult = \laabs::configuration('presentation.maarchRM')['maxResults'];
$logs = $this->sdoFactory->find("recordsManagement/log", $description, [], $sortBy, 0, $numberOfResult);
$logs = $this->sdoFactory->find("recordsManagement/log", $description, [], $sortBy, 0, $maxResults);
foreach ($logs as $log) {
try {
$archive = $archiveController->read($log->archiveId);
......
......@@ -32,28 +32,29 @@ interface archivesInterface
*/
/**
* Search archives by profile / dates / agreement
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $originatorOwnerOrgId
* @param string $originatorArchiveId
* @param array $originatingDate
* @param string $filePlanPosition
* @param bool $hasParent
* @param string $description
* @param string $text
* @param bool $partialRetentionRule
* @param string $retentionRuleCode
* @param string $depositStartDate
* @param string $depositEndDate
* @param string $originatingStartDate
* @param string $originatingEndDate
* @param string $archiverArchiveId
* @param integer $maxResults
*
* @action recordsManagement/archive/search
*
......@@ -80,7 +81,8 @@ interface archivesInterface
$depositEndDate = null,
$originatingStartDate = null,
$originatingEndDate = null,
$archiverArchiveId = null
$archiverArchiveId = null,
$maxResults = null
);
/**
......
......@@ -94,6 +94,9 @@ class archive
$deleteDescription = (bool) \laabs::configuration("recordsManagement")['deleteDescription'];
}
$maxResults = \laabs::configuration('presentation.maarchRM')['maxResults'];
$this->view->setSource("maxResults", $maxResults);
$this->view->setSource("retentionRules", $retentionRules);
$this->view->setSource("emptyRole", $emptyRole);
$this->view->setSource("profiles", $profiles);
......@@ -198,6 +201,12 @@ class archive
}
}
$hasReachMaxResults = false;
if (isset(\laabs::configuration('presentation.maarchRM')['maxResults'])
&& count($archives) >= \laabs::configuration('presentation.maarchRM')['maxResults']) {
$hasReachMaxResults = true;
}
$dataTable = $this->view->getElementsByClass("dataTable")->item(0)->plugin['dataTable'];
$dataTable->setPaginationType("full_numbers");
......@@ -233,6 +242,8 @@ class archive
$this->readPrivilegesOnArchives();
$this->view->setSource('hasReachMaxResults', $hasReachMaxResults);
$this->view->setSource('maxResults', \laabs::configuration('presentation.maarchRM')['maxResults']);
$this->view->setSource("accessRules", $accessRules);
$this->view->setSource("retentionRules", $retentionRules);
$this->view->setSource('archive', $archives);
......
......@@ -1105,4 +1105,10 @@ msgid "* At least one field must be filled in."
msgstr "* Au moins un champ doit être renseigné."
msgid "Export to "
msgstr "Exporter en "
\ No newline at end of file
msgstr "Exporter en "
msgid "Your query returns too much results, only first"
msgstr "Votre recherche a retourné trop de résultats, seulement les"
msgid "results are displayed"
msgstr "premiers sont affichés"
......@@ -4,6 +4,8 @@
<div class="panel-heading clearfix">
<div class="pull-left">
<h4><?merge archive.count() ?> result(s)</h4>
<?merge hasReachMaxResults ?>
<h4><span>Your query returns too much results, only first</span>&nbsp;<?merge maxResults ?>&nbsp;<span>results are displayed</span></h4>
</div>
<div class="dropdown pull-right">
<button class="btn btn-warning dropdown-toggle" type="button" id="archiveList_actions" data-toggle="dropdown" aria-expanded="true" title="Actions" disabled="disabled">
......
......@@ -18,18 +18,19 @@
<div class="container-fluid" lang="en" data-translate-catalog="recordsManagement/messages">
<?merge emptyRole ?>
<h3><i class="fa fa-times"></i> You have to choose a working organization unit to proceed this action.</h3>
<?merge emptyRole.not() ?>
<?merge emptyRole.not() ?>
<div class="panel-group" id="accordionSearch">
<div class="panel panel-default">
<div class="panel-heading" data-toggle="collapse" data-parent="#accordionSearch" href="#collapseOne" style="cursor:pointer;">
<h4 class="panel-title" style="float:left;">
Search form
Search form
</h4>
<i class="fa fa-caret-down" style="float:right;"></i>
<div style="clear:both;"></div>
</div>
<div id="collapseOne" class="well panel-collapse collapse in" style="margin-bottom: 0px">
<form class="form-horizontal" id="archive_searchForm">
<input type="hidden" name="maxResults" id="maxResults" value="[?merge maxResults ?]"/>
<div class="col-md-12">
<div class="form-group">
<label class="col-sm-3 control-label">Archive identifier</label>
......@@ -274,7 +275,7 @@
function searchFormSerialize() {
var parameters = new Object();
$('#archive_searchForm').find('input[type="text"], input[type="number"], select').each(function(){
$('#archive_searchForm').find('input[type="text"], input[type="hidden"], input[type="number"], select').each(function(){
if(!$(this).hasClass('orgHide')) {
parameters[$(this).attr('name')] = $(this).val();
......
......@@ -57,16 +57,17 @@ interface retrieveInterface
/**
* Search archives by profile / dates / agreement
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $description
* @param string $text
* @param string $archiveId
* @param string $profileReference
* @param string $status
* @param string $archiveName
* @param string $agreementReference
* @param string $archiveExpired
* @param string $finalDisposition
* @param string $originatorOrgRegNumber
* @param string $description
* @param string $text
* @param integer $maxResults
*
* @return recordsManagement/archive/search
* @uses recordsManagement/archives/read
......@@ -81,7 +82,8 @@ interface retrieveInterface
$finalDisposition = null,
$originatorOrgRegNumber = null,
$description = null,
$text = null
$text = null,
$maxResults = 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