Commit 316eadfb authored by Charlotte Bataille's avatar Charlotte Bataille
Browse files

feat/14349 : search digital resource

parent 743f3603
Pipeline #14164 failed with stages
in 1 minute and 15 seconds
...@@ -75,6 +75,93 @@ class digitalResource ...@@ -75,6 +75,93 @@ class digitalResource
$this->clusters = []; $this->clusters = [];
} }
/**
* Search documents
* @param string $archiveId
* @param integer $sizeMin
* @param integer $sizeMax
* @param string $puid
* @param string $mimetype
* @param string $hash
* @param string $hashAlgorithm
* @param string $fileName
* @param timestamp $startDate
* @param timestamp $endDate
*/
public function findDocument(
$archiveId = null,
$sizeMin = null,
$sizeMax = null,
$puid = null,
$mimetype = null,
$hash = null,
$hashAlgorithm = null,
$fileName = null,
$startDate = null,
$endDate = null
) {
$queryParts = array();
$queryParams = array();
if ($archiveId != null) {
$queryParams['archiveId'] = $archiveId;
$queryParts['archiveId'] = "archiveId = :archiveId";
}
if ($sizeMin) {
$queryParams['sizeMin'] = $sizeMin;
$queryParts['size'] = "size >= :sizeMin";
}
if ($sizeMax) {
$queryParams['sizeMax'] = $sizeMax;
$queryParts['size'] = "size <= :sizeMax";
}
if ($puid != null) {
$queryParams['puid'] = $puid;
$queryParts['puid'] = "puid = :puid";
}
if ($mimetype != null) {
$queryParams['mimetype'] = $mimetype;
$queryParts['mimetype'] = "mimetype = :mimetype";
}
if ($hash != null) {
$queryParams['hash'] = $hash;
$queryParts['hash'] = "hash = :hash";
}
if ($hashAlgorithm != null) {
$queryParams['hashAlgorithm'] = $hashAlgorithm;
$queryParts['hashAlgorithm'] = "hashAlgorithm = :hashAlgorithm";
}
if ($fileName != null) {
if (strpos($fileName,'*')!== false) {
$queryParams['fileName'] = str_replace('*','%',$fileName);
$queryParts['fileName'] = "fileName ~ :fileName";
} else {
$queryParams['fileName'] = $fileName;
$queryParts['fileName'] = "fileName = :fileName";
}
}
if ($startDate) {
$queryParams['startDate'] = $startDate;
$queryParts['created'] = "created >= :startDate";
}
if ($endDate) {
$queryParams['endDate'] = $endDate;
$queryParts['created'] = "created <= :endDate";
}
$queryString = implode(' AND ', $queryParts);
return $resources = $this->sdoFactory->find("digitalResource/digitalResource", $queryString, $queryParams);
}
/** /**
* Get file information about one file * Get file information about one file
* @param string $filename The file name * @param string $filename The file name
......
...@@ -32,4 +32,33 @@ interface digitalResourceInterface { ...@@ -32,4 +32,33 @@ interface digitalResourceInterface {
* @action digitalResource/digitalResource/isConvertible * @action digitalResource/digitalResource/isConvertible
*/ */
public function updateIsconvertible($digitalResource); public function updateIsconvertible($digitalResource);
/**
* Search documents
* @param string $archiveId
* @param integer $sizeMin
* @param integer $sizeMax
* @param string $puid
* @param string $mimetype
* @param string $hash
* @param string $hashAlgorithm
* @param string $fileName
* @param timestamp $startDate
* @param timestamp $endDate
*
* @action digitalResource/digitalResource/findDocument
*/
public function readFinddocuments(
$archiveId = null,
$sizeMin = null,
$sizeMax = null,
$puid = null,
$mimetype = null,
$hash = null,
$hashAlgorithm = null,
$fileName = null,
$startDate = null,
$endDate = 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