Verified Commit b13fa103 authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

Add Agent criteria

parent 607fe226
......@@ -442,6 +442,7 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
* @param bool $hasParent
* @param bool $partialRetentionRule
* @param integer $maxResults
* @param array $agent
*
* @return archivesPubliques/archiveDescription[] Liste de contenu d'archive
*/
......@@ -466,7 +467,8 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$isConverted = null,
$hasParent = null,
$partialRetentionRule = null,
$maxResults = null
$maxResults = null,
$agent = []
) {
list($queryParts, $queryParams) = $this->getQueryPartsAndParams(
$contentId,
......@@ -497,7 +499,8 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$startDate,
$endDate,
$term,
$keyword
$keyword,
$agent
);
$tableContentDescriptions = $this->sdoFactory->find("archivesPubliques/archiveDescription", $tableQueryString, $tableQueryParams, '>depositDate', 0, $maxResults);
......@@ -511,7 +514,8 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$startDate,
$endDate,
$term,
$keyword
$keyword,
$agent
);
$jsonContentDescriptions = $this->sdoFactory->find("recordsManagement/archive", $jsonQueryString, $jsonQueryParams, '>depositDate', 0, $maxResults);
......@@ -558,6 +562,7 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
* @param bool $isConverted
* @param bool $hasParent
* @param bool $partialRetentionRule
* @param array $agent
*
* @return integer Nombre d'archives
*/
......@@ -581,7 +586,8 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$originatorOrgRegNumber = null,
$isConverted = null,
$hasParent = null,
$partialRetentionRule = null
$partialRetentionRule = null,
$agent
) {
list($queryParts, $queryParams) = $this->getQueryPartsAndParams(
$contentId,
......@@ -612,7 +618,8 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$startDate,
$endDate,
$term,
$keyword
$keyword,
$agent
);
$countTableContentDescriptions = $this->sdoFactory->count("archivesPubliques/archiveDescription", $tableQueryString, $tableQueryParams);
......@@ -626,7 +633,8 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$startDate,
$endDate,
$term,
$keyword
$keyword,
$agent
);
$countJsonContentDescriptions = $this->sdoFactory->count("recordsManagement/archive", $jsonQueryString, $jsonQueryParams);
......@@ -654,7 +662,6 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
) {
$queryParts = [];
$queryParams = [];
$queryKeyword = [];
$currentDate = \laabs::newDate();
$currentDateString = $currentDate->format('Y-m-d');
......@@ -768,7 +775,8 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$startDate = null,
$endDate = null,
$term = null,
$keyword = array()
$keyword = array(),
$agent = []
) {
$queryParts['table'] = "descriptionClass = 'archivesPubliques/content'";
......@@ -823,6 +831,10 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$queryParts['keyword'] = "contentId=[READ archivesPubliques/keyword [contentId] ($queryStringKeyword)]";
}
if (is_array($agent) && !empty($agent)) {
$queryParts['agent'] = '0=1';
}
$queryString = \laabs\implode(' AND ', $queryParts);
return [$queryString, $queryParams];
......@@ -835,7 +847,8 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
$startDate = null,
$endDate = null,
$term = null,
$keyword = array()
$keyword = array(),
$agent = []
) {
$queryParts['json'] = "(descriptionClass = 'seda2' || descriptionClass = 'seda2/Content')";
......@@ -849,10 +862,13 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
}
}
$queryStringKeyword =
$queryParts['keyword'] = '<?SQL ('.implode(' OR ', $queryKeyword).') ?>';
}
if (is_array($agent) && !empty($agent)) {
$queryParts['agent'] = $this->getAgentAssert($agent);
}
if ($term) {
$queryTerm = [];
......@@ -888,6 +904,36 @@ class content implements \bundle\recordsManagement\Controller\archiveDescription
return [$queryString, $queryParams];
}
protected function getAgentAssert($agent)
{
// SEDA 2 and 2.1 named agent groups
// New SEDA 2.2 agents will use 'role' attribute
$namedAgents = ['authorizedAgent', 'writer', 'addressee', 'recipient', 'transmitter', 'sender'];
$queryAgent = [];
foreach ($agent as $agentObj) {
if (isset($agentObj->role) && in_array($agentObj->role, $namedAgents)) {
$properties = [$agentObj->role];
unset($agentObj->role);
} else {
$properties = array_merge($namedAgents, ['agent']);
}
$queryAgentParts = [];
foreach ($properties as $property) {
$queryAgentPropertyParts = [];
foreach ($agentObj as $name => $value) {
$queryAgentPropertyParts[] = '"description"->\''.$property.'\' @> \'[{"'.$name.'": "'.$value.'"}]\'';
}
$queryAgentParts[] = '('.implode (' AND ', $queryAgentPropertyParts).')';
}
$queryAgent[] = implode (' OR ', $queryAgentParts);
}
return '<?SQL ('.implode(' OR ', $queryAgent).') ?>';
}
protected function getAccessRuleAssert()
{
$currentDate = \laabs::newDate();
......
......@@ -49,6 +49,7 @@ interface contentInterface
* @param bool $hasParent
* @param bool $partialRetentionRule
* @param integer $maxResults
* @param array $agent
*
* @action archivesPubliques/content/find
*/
......@@ -73,7 +74,8 @@ interface contentInterface
$isConverted = null,
$hasParent = null,
$partialRetentionRule = null,
$maxResults = null
$maxResults = null,
$agent
);
/**
......@@ -177,6 +179,7 @@ interface contentInterface
* @param bool $hasParent
* @param bool $partialRetentionRule
* @param integer $maxResults
* @param array $agent
*
* @action archivesPubliques/content/count
*/
......@@ -201,6 +204,7 @@ interface contentInterface
$isConverted = null,
$hasParent = null,
$partialRetentionRule = null,
$maxResults = null
$maxResults = null,
$agent = null
);
}
......@@ -60,6 +60,7 @@ interface searchPublicArchiveInterface
* @param bool $partialRetentionRule
* @param string $archiverArchiveId
* @param integer $maxResults
* @param array $agent
*
* @uses archivesPubliques/content/createSearch
* @uses archivesPubliques/content/createCount
......@@ -89,7 +90,8 @@ interface searchPublicArchiveInterface
$hasParent,
$partialRetentionRule,
$archiverArchiveId,
$maxResults
$maxResults,
$agent
);
/**
......
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