Commit bd684e45 authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

FEAT Use descriptionLevel in search, combined with hasParent

parent 89bb9b07
......@@ -29,7 +29,7 @@ interface ContentInterface
/**
* Recherche d'un contenu d'archive
* @param string $query
* @param bool $hasParent
* @param string $descriptionLevel
* @param date $dateFrom
* @param date $dateTo
* @param string $originatorOrgRegNumber
......@@ -40,7 +40,7 @@ interface ContentInterface
*/
public function readSearch(
$query = null,
$hasParent = false,
$descriptionLevel = 'File',
$dateFrom = null,
$dateTo = null,
$originatorOrgRegNumber = null
......
......@@ -33,7 +33,7 @@ class Content
/**
* Recherche d'un contenu d'archive
* @param string $query
* @param bool $hasParent
* @param string $descriptionLevel
* @param date $dateFrom
* @param date $dateTo
* @param string $originatorOrgRegNumber
......@@ -42,12 +42,11 @@ class Content
*/
public function findCourrier(
$query = null,
$hasParent = false,
$descriptionLevel = 'File',
$dateFrom = null,
$dateTo = null,
$originatorOrgRegNumber = null)
{
var_dump(func_get_args());
$queryParts = array();
$queryParams = array();
......@@ -69,41 +68,63 @@ class Content
$queryParts['originatorOrgRegNumber'] = "originatorOrgRegNumber = :originatorOrgRegNumber";
}
// Search forlders
if ($hasParent === false) {
$queryParts['hasParent'] = "parentArchiveId=null";
if ($dateFrom && $dateTo) {
$queryParams['dateFrom'] = $dateFrom;
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "endDate >= :dateFrom AND startDate <= :dateTo";
} elseif ($dateFrom) {
$queryParams['dateFrom'] = $dateFrom;
$queryParts['date'] = "endDate >= :dateFrom";
} elseif ($dateTo) {
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "startDate <= :dateTo";
}
}
// Search mails and attachments
if ($hasParent === true) {
$queryParts['hasParent'] = "parentArchiveId!=null";
if ($dateFrom && $dateTo) {
$queryParams['dateFrom'] = $dateFrom;
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "sentDate >= :dateFrom AND sentDate <= :dateTo";
} elseif ($dateFrom) {
$queryParams['dateFrom'] = $dateFrom;
$queryParts['date'] = "sentDate >= :dateFrom";
} elseif ($dateTo) {
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "sentDate <= :dateTo";
}
$queryParams['descriptionLevel'] = $descriptionLevel;
$queryParts['descriptionLevel'] = "descriptionLevel=:descriptionLevel";
switch ($descriptionLevel) {
// Search record groups
case 'RecordGrp' :
$queryParts['hasParent'] = "parentArchiveId=null";
if ($dateFrom && $dateTo) {
$queryParams['dateFrom'] = $dateFrom;
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "endDate >= :dateFrom AND startDate <= :dateTo";
} elseif ($dateFrom) {
$queryParams['dateFrom'] = $dateFrom;
$queryParts['date'] = "endDate >= :dateFrom";
} elseif ($dateTo) {
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "startDate <= :dateTo";
}
break;
// Search mails
case 'File' :
$queryParts['hasParent'] = "parentArchiveId!=null";
if ($dateFrom && $dateTo) {
$queryParams['dateFrom'] = $dateFrom;
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "sentDate >= :dateFrom AND sentDate <= :dateTo";
} elseif ($dateFrom) {
$queryParams['dateFrom'] = $dateFrom;
$queryParts['date'] = "sentDate >= :dateFrom";
} elseif ($dateTo) {
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "sentDate <= :dateTo";
}
break;
// Search attachments
case 'Item':
$queryParts['hasParent'] = "parentArchiveId!=null";
if ($dateFrom && $dateTo) {
$queryParams['dateFrom'] = $dateFrom;
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "((createdDate >= :dateFrom AND createdDate <= :dateTo) OR createdDate=null)";
} elseif ($dateFrom) {
$queryParams['dateFrom'] = $dateFrom;
$queryParts['date'] = "(createdDate >= :dateFrom OR createdDate=null)";
} elseif ($dateTo) {
$queryParams['dateTo'] = $dateTo;
$queryParts['date'] = "(createdDate <= :dateTo OR createdDate=null)";
}
break;
}
$queryString = \laabs\implode(' AND ', $queryParts);
......
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