2013-12-16 11:59:47 -04:00
|
|
|
<?php
|
|
|
|
|
namespace BusinessModel;
|
|
|
|
|
|
|
|
|
|
class InputDocument
|
|
|
|
|
{
|
2014-02-12 12:32:04 -04:00
|
|
|
private $arrayFieldDefinition = array(
|
|
|
|
|
"INP_DOC_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "inputDocumentUid"),
|
|
|
|
|
|
|
|
|
|
"INP_DOC_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "inputDocumentTitle"),
|
|
|
|
|
"INP_DOC_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentDescription"),
|
|
|
|
|
"INP_DOC_FORM_NEEDED" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("VIRTUAL", "REAL", "VREAL"), "fieldNameAux" => "inputDocumentFormNeeded"),
|
|
|
|
|
"INP_DOC_ORIGINAL" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("ORIGINAL", "COPY", "COPYLEGAL"), "fieldNameAux" => "inputDocumentOriginal"),
|
|
|
|
|
"INP_DOC_PUBLISHED" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("PRIVATE"), "fieldNameAux" => "inputDocumentPublished"),
|
|
|
|
|
"INP_DOC_VERSIONING" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "inputDocumentVersioning"),
|
|
|
|
|
"INP_DOC_DESTINATION_PATH" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentDestinationPath"),
|
|
|
|
|
"INP_DOC_TAGS" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentTags")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
private $formatFieldNameInUppercase = true;
|
|
|
|
|
|
|
|
|
|
private $arrayFieldNameForException = array(
|
|
|
|
|
"processUid" => "PRO_UID"
|
|
|
|
|
);
|
|
|
|
|
|
2013-12-16 11:59:47 -04:00
|
|
|
/**
|
2014-02-12 12:32:04 -04:00
|
|
|
* Constructor of the class
|
2013-12-16 11:59:47 -04:00
|
|
|
*
|
2014-02-12 12:32:04 -04:00
|
|
|
* return void
|
|
|
|
|
*/
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
foreach ($this->arrayFieldDefinition as $key => $value) {
|
|
|
|
|
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the format of the fields name (uppercase, lowercase)
|
|
|
|
|
*
|
|
|
|
|
* @param bool $flag Value that set the format
|
|
|
|
|
*
|
|
|
|
|
* return void
|
|
|
|
|
*/
|
|
|
|
|
public function setFormatFieldNameInUppercase($flag)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$this->formatFieldNameInUppercase = $flag;
|
|
|
|
|
|
|
|
|
|
$this->setArrayFieldNameForException($this->arrayFieldNameForException);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set exception messages for fields
|
|
|
|
|
*
|
|
|
|
|
* @param array $arrayData Data with the fields
|
|
|
|
|
*
|
|
|
|
|
* return void
|
|
|
|
|
*/
|
|
|
|
|
public function setArrayFieldNameForException($arrayData)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
foreach ($arrayData as $key => $value) {
|
|
|
|
|
$this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value);
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the name of the field according to the format
|
|
|
|
|
*
|
|
|
|
|
* @param string $fieldName Field name
|
|
|
|
|
*
|
|
|
|
|
* return string Return the field name according the format
|
|
|
|
|
*/
|
|
|
|
|
public function getFieldNameByFormatFieldName($fieldName)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify if exists the title of a InputDocument
|
|
|
|
|
*
|
|
|
|
|
* @param string $processUid Unique id of Process
|
|
|
|
|
* @param string $inputDocumentTitle Title
|
2013-12-16 11:59:47 -04:00
|
|
|
* @param string $inputDocumentUidExclude Unique id of InputDocument to exclude
|
|
|
|
|
*
|
2014-02-12 12:32:04 -04:00
|
|
|
* return bool Return true if exists the title of a InputDocument, false otherwise
|
2013-12-16 11:59:47 -04:00
|
|
|
*/
|
2014-02-12 12:32:04 -04:00
|
|
|
public function existsTitle($processUid, $inputDocumentTitle, $inputDocumentUidExclude = "")
|
2013-12-16 11:59:47 -04:00
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$delimiter = \DBAdapter::getStringDelimiter();
|
|
|
|
|
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID);
|
|
|
|
|
|
2013-12-18 15:02:23 -04:00
|
|
|
$criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
$arrayCondition = array();
|
|
|
|
|
$arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CT.CON_ID", \Criteria::EQUAL);
|
|
|
|
|
$arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "INP_DOC_TITLE" . $delimiter, \Criteria::EQUAL);
|
|
|
|
|
$arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
|
|
|
|
|
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
|
|
|
|
|
|
|
|
|
|
$criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
if ($inputDocumentUidExclude != "") {
|
|
|
|
|
$criteria->add(\InputDocumentPeer::INP_DOC_UID, $inputDocumentUidExclude, \Criteria::NOT_EQUAL);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
$criteria->add("CT.CON_VALUE", $inputDocumentTitle, \Criteria::EQUAL);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
$rsCriteria = \InputDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteria->next()) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
/**
|
2014-02-20 17:16:00 -04:00
|
|
|
* Verify if doesn't exists the InputDocument in table INPUT_DOCUMENT
|
2014-02-12 12:32:04 -04:00
|
|
|
*
|
|
|
|
|
* @param string $inputDocumentUid Unique id of InputDocument
|
|
|
|
|
* @param string $processUid Unique id of Process
|
|
|
|
|
* @param string $fieldNameForException Field name for the exception
|
|
|
|
|
*
|
2014-02-20 17:16:00 -04:00
|
|
|
* return void Throw exception if doesn't exists the InputDocument in table INPUT_DOCUMENT
|
2014-02-12 12:32:04 -04:00
|
|
|
*/
|
|
|
|
|
public function throwExceptionIfNotExistsInputDocument($inputDocumentUid, $processUid, $fieldNameForException)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID);
|
|
|
|
|
|
|
|
|
|
if ($processUid != "") {
|
|
|
|
|
$criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$criteria->add(\InputDocumentPeer::INP_DOC_UID, $inputDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \InputDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
|
|
|
|
|
if (!$rsCriteria->next()) {
|
2014-03-05 11:17:44 -04:00
|
|
|
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $inputDocumentUid), "The Input Document with {0}: {1} does not exist");
|
2014-02-12 12:32:04 -04:00
|
|
|
|
|
|
|
|
throw (new \Exception($msg));
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify if exists the title of a InputDocument
|
|
|
|
|
*
|
|
|
|
|
* @param string $processUid Unique id of Process
|
|
|
|
|
* @param string $inputDocumentTitle Title
|
|
|
|
|
* @param string $fieldNameForException Field name for the exception
|
|
|
|
|
* @param string $inputDocumentUidExclude Unique id of InputDocument to exclude
|
|
|
|
|
*
|
|
|
|
|
* return void Throw exception if exists the title of a InputDocument
|
|
|
|
|
*/
|
|
|
|
|
public function throwExceptionIfExistsTitle($processUid, $inputDocumentTitle, $fieldNameForException, $inputDocumentUidExclude = "")
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
if ($this->existsTitle($processUid, $inputDocumentTitle, $inputDocumentUidExclude)) {
|
2014-03-05 11:17:44 -04:00
|
|
|
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $inputDocumentTitle), "The Input Document title with {0}: \"{1}\" already exists");
|
2014-02-12 12:32:04 -04:00
|
|
|
|
|
|
|
|
throw (new \Exception($msg));
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-16 11:59:47 -04:00
|
|
|
/**
|
|
|
|
|
* Create InputDocument for a Process
|
|
|
|
|
*
|
|
|
|
|
* @param string $processUid Unique id of Process
|
|
|
|
|
* @param array $arrayData Data
|
|
|
|
|
*
|
|
|
|
|
* return array Return data of the new InputDocument created
|
|
|
|
|
*/
|
|
|
|
|
public function create($processUid, $arrayData)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
|
|
|
|
|
|
|
|
|
unset($arrayData["INP_DOC_UID"]);
|
|
|
|
|
|
|
|
|
|
//Verify data
|
2014-02-12 12:32:04 -04:00
|
|
|
$process = new \BusinessModel\Process();
|
2013-12-16 11:59:47 -04:00
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
$process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
|
2014-01-17 15:20:11 -04:00
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
$this->throwExceptionIfExistsTitle($processUid, $arrayData["INP_DOC_TITLE"], $this->arrayFieldNameForException["inputDocumentTitle"]);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
2014-01-17 15:20:11 -04:00
|
|
|
//Flags
|
|
|
|
|
$flagDataDestinationPath = (isset($arrayData["INP_DOC_DESTINATION_PATH"]))? 1 : 0;
|
|
|
|
|
$flagDataTags = (isset($arrayData["INP_DOC_TAGS"]))? 1 : 0;
|
|
|
|
|
|
2013-12-16 11:59:47 -04:00
|
|
|
//Create
|
2014-01-17 15:20:11 -04:00
|
|
|
$inputDocument = new \InputDocument();
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
$arrayData["PRO_UID"] = $processUid;
|
|
|
|
|
|
2014-01-17 15:20:11 -04:00
|
|
|
$arrayData["INP_DOC_DESTINATION_PATH"] = ($flagDataDestinationPath == 1)? $arrayData["INP_DOC_DESTINATION_PATH"] : "";
|
|
|
|
|
$arrayData["INP_DOC_TAGS"] = ($flagDataTags == 1)? $arrayData["INP_DOC_TAGS"] : "";
|
|
|
|
|
|
|
|
|
|
$inputDocumentUid = $inputDocument->create($arrayData);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
unset($arrayData["PRO_UID"]);
|
|
|
|
|
|
2014-01-17 15:20:11 -04:00
|
|
|
if ($flagDataDestinationPath == 0) {
|
|
|
|
|
unset($arrayData["INP_DOC_DESTINATION_PATH"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($flagDataTags == 0) {
|
|
|
|
|
unset($arrayData["INP_DOC_TAGS"]);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
$arrayData = array_merge(array("INP_DOC_UID" => $inputDocumentUid), $arrayData);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
if (!$this->formatFieldNameInUppercase) {
|
|
|
|
|
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
|
|
|
|
}
|
2013-12-16 11:59:47 -04:00
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
return $arrayData;
|
2013-12-16 11:59:47 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update InputDocument
|
|
|
|
|
*
|
|
|
|
|
* @param string $inputDocumentUid Unique id of InputDocument
|
|
|
|
|
* @param array $arrayData Data
|
|
|
|
|
*
|
|
|
|
|
* return array Return data of the InputDocument updated
|
|
|
|
|
*/
|
|
|
|
|
public function update($inputDocumentUid, $arrayData)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
|
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
//Verify data
|
|
|
|
|
$this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]);
|
|
|
|
|
|
|
|
|
|
//Load InputDocument
|
2014-01-17 15:20:11 -04:00
|
|
|
$inputDocument = new \InputDocument();
|
2013-12-16 11:59:47 -04:00
|
|
|
|
2014-01-17 15:20:11 -04:00
|
|
|
$arrayInputDocumentData = $inputDocument->load($inputDocumentUid);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
2014-01-17 15:20:11 -04:00
|
|
|
$processUid = $arrayInputDocumentData["PRO_UID"];
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
//Verify data
|
2014-02-12 12:32:04 -04:00
|
|
|
$process = new \BusinessModel\Process();
|
2014-01-17 15:20:11 -04:00
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false);
|
2014-01-17 15:20:11 -04:00
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
if (isset($arrayData["INP_DOC_TITLE"])) {
|
|
|
|
|
$this->throwExceptionIfExistsTitle($processUid, $arrayData["INP_DOC_TITLE"], $this->arrayFieldNameForException["inputDocumentTitle"], $inputDocumentUid);
|
2013-12-16 11:59:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Update
|
|
|
|
|
$arrayData["INP_DOC_UID"] = $inputDocumentUid;
|
|
|
|
|
|
2014-01-17 15:20:11 -04:00
|
|
|
$result = $inputDocument->update($arrayData);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
unset($arrayData["INP_DOC_UID"]);
|
|
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
if (!$this->formatFieldNameInUppercase) {
|
|
|
|
|
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $arrayData;
|
2013-12-16 11:59:47 -04:00
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete InputDocument
|
|
|
|
|
*
|
|
|
|
|
* @param string $inputDocumentUid Unique id of InputDocument
|
|
|
|
|
*
|
|
|
|
|
* return void
|
|
|
|
|
*/
|
|
|
|
|
public function delete($inputDocumentUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Verify data
|
2014-02-12 12:32:04 -04:00
|
|
|
$this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
//Delete
|
|
|
|
|
//StepSupervisor
|
|
|
|
|
$stepSupervisor = new \StepSupervisor();
|
|
|
|
|
|
|
|
|
|
$arrayData = $stepSupervisor->loadInfo($inputDocumentUid);
|
|
|
|
|
$result = $stepSupervisor->remove($arrayData["STEP_UID"]);
|
|
|
|
|
|
|
|
|
|
//ObjectPermission
|
|
|
|
|
$objectPermission = new \ObjectPermission();
|
|
|
|
|
|
|
|
|
|
$arrayData = $objectPermission->loadInfo($inputDocumentUid);
|
|
|
|
|
|
|
|
|
|
if (is_array($arrayData)) {
|
|
|
|
|
$result = $objectPermission->remove($arrayData["OP_UID"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//InputDocument
|
2014-01-17 15:20:11 -04:00
|
|
|
$inputDocument = new \InputDocument();
|
2013-12-16 11:59:47 -04:00
|
|
|
|
2014-01-17 15:20:11 -04:00
|
|
|
$result = $inputDocument->remove($inputDocumentUid);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
//Step
|
|
|
|
|
$step = new \Step();
|
|
|
|
|
|
|
|
|
|
$step->removeStep("INPUT_DOCUMENT", $inputDocumentUid);
|
|
|
|
|
|
|
|
|
|
//ObjectPermission
|
|
|
|
|
$objectPermission = new \ObjectPermission();
|
|
|
|
|
|
|
|
|
|
$objectPermission->removeByObject("INPUT", $inputDocumentUid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get criteria for InputDocument
|
|
|
|
|
*
|
|
|
|
|
* return object
|
|
|
|
|
*/
|
|
|
|
|
public function getInputDocumentCriteria()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$delimiter = \DBAdapter::getStringDelimiter();
|
|
|
|
|
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID);
|
|
|
|
|
$criteria->addAsColumn("INP_DOC_TITLE", "CT.CON_VALUE");
|
|
|
|
|
$criteria->addAsColumn("INP_DOC_DESCRIPTION", "CD.CON_VALUE");
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_FORM_NEEDED);
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_ORIGINAL);
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_PUBLISHED);
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_VERSIONING);
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_DESTINATION_PATH);
|
|
|
|
|
$criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_TAGS);
|
|
|
|
|
|
2013-12-18 15:02:23 -04:00
|
|
|
$criteria->addAlias("CT", \ContentPeer::TABLE_NAME);
|
|
|
|
|
$criteria->addAlias("CD", \ContentPeer::TABLE_NAME);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
$arrayCondition = array();
|
|
|
|
|
$arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CT.CON_ID", \Criteria::EQUAL);
|
|
|
|
|
$arrayCondition[] = array("CT.CON_CATEGORY", $delimiter . "INP_DOC_TITLE" . $delimiter, \Criteria::EQUAL);
|
|
|
|
|
$arrayCondition[] = array("CT.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
|
|
|
|
|
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
|
|
|
|
|
|
|
|
|
|
$arrayCondition = array();
|
|
|
|
|
$arrayCondition[] = array(\InputDocumentPeer::INP_DOC_UID, "CD.CON_ID", \Criteria::EQUAL);
|
|
|
|
|
$arrayCondition[] = array("CD.CON_CATEGORY", $delimiter . "INP_DOC_DESCRIPTION" . $delimiter, \Criteria::EQUAL);
|
|
|
|
|
$arrayCondition[] = array("CD.CON_LANG", $delimiter . SYS_LANG . $delimiter, \Criteria::EQUAL);
|
|
|
|
|
$criteria->addJoinMC($arrayCondition, \Criteria::LEFT_JOIN);
|
|
|
|
|
|
|
|
|
|
return $criteria;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get data of an InputDocument from a record
|
|
|
|
|
*
|
|
|
|
|
* @param array $record Record
|
|
|
|
|
*
|
2014-02-12 12:32:04 -04:00
|
|
|
* return array Return an array with data InputDocument
|
2013-12-16 11:59:47 -04:00
|
|
|
*/
|
|
|
|
|
public function getInputDocumentDataFromRecord($record)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2013-12-23 17:14:04 -04:00
|
|
|
if ($record["INP_DOC_TITLE"] . "" == "") {
|
2014-02-12 12:32:04 -04:00
|
|
|
//Load InputDocument
|
2014-01-17 15:20:11 -04:00
|
|
|
$inputDocument = new \InputDocument();
|
|
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
$arrayInputDocumentData = $inputDocument->load($record["INP_DOC_UID"]);
|
2013-12-23 17:14:04 -04:00
|
|
|
|
2014-02-12 12:32:04 -04:00
|
|
|
//There is no transaltion for this Document name, try to get/regenerate the label
|
|
|
|
|
$record["INP_DOC_TITLE"] = $arrayInputDocumentData["INP_DOC_TITLE"];
|
|
|
|
|
$record["INP_DOC_DESCRIPTION"] = $arrayInputDocumentData["INP_DOC_DESCRIPTION"];
|
2013-12-23 17:14:04 -04:00
|
|
|
}
|
|
|
|
|
|
2013-12-16 11:59:47 -04:00
|
|
|
return array(
|
2014-02-12 12:32:04 -04:00
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_UID") => $record["INP_DOC_UID"],
|
|
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_TITLE") => $record["INP_DOC_TITLE"],
|
|
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_DESCRIPTION") => $record["INP_DOC_DESCRIPTION"] . "",
|
|
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_FORM_NEEDED") => $record["INP_DOC_FORM_NEEDED"] . "",
|
|
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_ORIGINAL") => $record["INP_DOC_ORIGINAL"] . "",
|
|
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_PUBLISHED") => $record["INP_DOC_PUBLISHED"] . "",
|
|
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_VERSIONING") => (int)($record["INP_DOC_VERSIONING"]),
|
|
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_DESTINATION_PATH") => $record["INP_DOC_DESTINATION_PATH"] . "",
|
|
|
|
|
$this->getFieldNameByFormatFieldName("INP_DOC_TAGS") => $record["INP_DOC_TAGS"] . ""
|
2013-12-16 11:59:47 -04:00
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get data of an InputDocument
|
|
|
|
|
*
|
|
|
|
|
* @param string $inputDocumentUid Unique id of InputDocument
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data of an InputDocument
|
|
|
|
|
*/
|
|
|
|
|
public function getInputDocument($inputDocumentUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Verify data
|
2014-02-12 12:32:04 -04:00
|
|
|
$this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]);
|
2013-12-16 11:59:47 -04:00
|
|
|
|
|
|
|
|
//Get data
|
|
|
|
|
$criteria = $this->getInputDocumentCriteria();
|
|
|
|
|
|
|
|
|
|
$criteria->add(\InputDocumentPeer::INP_DOC_UID, $inputDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \InputDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
$rsCriteria->next();
|
|
|
|
|
|
|
|
|
|
$row = $rsCriteria->getRow();
|
|
|
|
|
|
|
|
|
|
return $this->getInputDocumentDataFromRecord($row);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|