|
|
|
|
@@ -1,14 +1,15 @@
|
|
|
|
|
<?php
|
|
|
|
|
namespace ProcessMaker\BusinessModel;
|
|
|
|
|
|
|
|
|
|
class MessageEventTaskRelation
|
|
|
|
|
class ElementTaskRelation
|
|
|
|
|
{
|
|
|
|
|
private $arrayFieldDefinition = array(
|
|
|
|
|
"MSGETR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "messageEventTaskRelationUid"),
|
|
|
|
|
"ETR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "elementTaskRelationUid"),
|
|
|
|
|
|
|
|
|
|
"PRJ_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectUid"),
|
|
|
|
|
"EVN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUid"),
|
|
|
|
|
"TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid")
|
|
|
|
|
"PRJ_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "projectUid"),
|
|
|
|
|
"ELEMENT_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "elementUid"),
|
|
|
|
|
"ELEMENT_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "elementType"),
|
|
|
|
|
"TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid")
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
private $formatFieldNameInUppercase = true;
|
|
|
|
|
@@ -84,16 +85,16 @@ class MessageEventTaskRelation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify if exists the Message-Event-Task-Relation
|
|
|
|
|
* Verify if exists the Element-Task-Relation
|
|
|
|
|
*
|
|
|
|
|
* @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation
|
|
|
|
|
* @param string $elementTaskRelationUid Unique id of Element-Task-Relation
|
|
|
|
|
*
|
|
|
|
|
* return bool Return true if exists the Message-Event-Task-Relation, false otherwise
|
|
|
|
|
* return bool Return true if exists the Element-Task-Relation, false otherwise
|
|
|
|
|
*/
|
|
|
|
|
public function exists($messageEventTaskRelationUid)
|
|
|
|
|
public function exists($elementTaskRelationUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$obj = \MessageEventTaskRelationPeer::retrieveByPK($messageEventTaskRelationUid);
|
|
|
|
|
$obj = \ElementTaskRelationPeer::retrieveByPK($elementTaskRelationUid);
|
|
|
|
|
|
|
|
|
|
return (!is_null($obj))? true : false;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
@@ -102,18 +103,18 @@ class MessageEventTaskRelation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify if does not exists the Message-Event-Task-Relation
|
|
|
|
|
* Verify if does not exists the Element-Task-Relation
|
|
|
|
|
*
|
|
|
|
|
* @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation
|
|
|
|
|
* @param string $fieldNameForException Field name for the exception
|
|
|
|
|
* @param string $elementTaskRelationUid Unique id of Element-Task-Relation
|
|
|
|
|
* @param string $fieldNameForException Field name for the exception
|
|
|
|
|
*
|
|
|
|
|
* return void Throw exception if does not exists the Message-Event-Task-Relation
|
|
|
|
|
* return void Throw exception if does not exists the Element-Task-Relation
|
|
|
|
|
*/
|
|
|
|
|
public function throwExceptionIfNotExistsMessageEventTaskRelation($messageEventTaskRelationUid, $fieldNameForException)
|
|
|
|
|
public function throwExceptionIfNotExistsElementTaskRelation($elementTaskRelationUid, $fieldNameForException)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
if (!$this->exists($messageEventTaskRelationUid)) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_TASK_RELATION_DOES_NOT_EXIST", array($fieldNameForException, $messageEventTaskRelationUid)));
|
|
|
|
|
if (!$this->exists($elementTaskRelationUid)) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_TASK_RELATION_DOES_NOT_EXIST", array($fieldNameForException, $elementTaskRelationUid)));
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
@@ -123,20 +124,20 @@ class MessageEventTaskRelation
|
|
|
|
|
/**
|
|
|
|
|
* Validate the data if they are invalid (INSERT and UPDATE)
|
|
|
|
|
*
|
|
|
|
|
* @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation
|
|
|
|
|
* @param string $projectUid Unique id of Project
|
|
|
|
|
* @param array $arrayData Data
|
|
|
|
|
* @param string $elementTaskRelationUid Unique id of Element-Task-Relation
|
|
|
|
|
* @param string $projectUid Unique id of Project
|
|
|
|
|
* @param array $arrayData Data
|
|
|
|
|
*
|
|
|
|
|
* return void Throw exception if data has an invalid value
|
|
|
|
|
*/
|
|
|
|
|
public function throwExceptionIfDataIsInvalid($messageEventTaskRelationUid, $projectUid, array $arrayData)
|
|
|
|
|
public function throwExceptionIfDataIsInvalid($elementTaskRelationUid, $projectUid, array $arrayData)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Set variables
|
|
|
|
|
$arrayMessageEventTaskRelationData = ($messageEventTaskRelationUid == "")? array() : $this->getMessageEventTaskRelation($messageEventTaskRelationUid, true);
|
|
|
|
|
$flagInsert = ($messageEventTaskRelationUid == "")? true : false;
|
|
|
|
|
$arrayElementTaskRelationData = ($elementTaskRelationUid == "")? array() : $this->getElementTaskRelation($elementTaskRelationUid, true);
|
|
|
|
|
$flagInsert = ($elementTaskRelationUid == "")? true : false;
|
|
|
|
|
|
|
|
|
|
$arrayFinalData = array_merge($arrayMessageEventTaskRelationData, $arrayData);
|
|
|
|
|
$arrayFinalData = array_merge($arrayElementTaskRelationData, $arrayData);
|
|
|
|
|
|
|
|
|
|
//Verify data - Field definition
|
|
|
|
|
$process = new \ProcessMaker\BusinessModel\Process();
|
|
|
|
|
@@ -148,12 +149,12 @@ class MessageEventTaskRelation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create Message-Event-Task-Relation for a Project
|
|
|
|
|
* Create Element-Task-Relation for a Project
|
|
|
|
|
*
|
|
|
|
|
* @param string $projectUid Unique id of Project
|
|
|
|
|
* @param array $arrayData Data
|
|
|
|
|
*
|
|
|
|
|
* return array Return data of the new Message-Event-Task-Relation created
|
|
|
|
|
* return array Return data of the new Element-Task-Relation created
|
|
|
|
|
*/
|
|
|
|
|
public function create($projectUid, array $arrayData)
|
|
|
|
|
{
|
|
|
|
|
@@ -168,7 +169,7 @@ class MessageEventTaskRelation
|
|
|
|
|
//Set data
|
|
|
|
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
|
|
|
|
|
|
|
|
|
unset($arrayData["MSGETR_UID"]);
|
|
|
|
|
unset($arrayData["ETR_UID"]);
|
|
|
|
|
unset($arrayData["PRJ_UID"]);
|
|
|
|
|
|
|
|
|
|
//Verify data
|
|
|
|
|
@@ -180,28 +181,28 @@ class MessageEventTaskRelation
|
|
|
|
|
$cnn = \Propel::getConnection("workflow");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$messageEventTaskRelation = new \MessageEventTaskRelation();
|
|
|
|
|
$elementTaskRelation = new \ElementTaskRelation();
|
|
|
|
|
|
|
|
|
|
$messageEventTaskRelationUid = \ProcessMaker\Util\Common::generateUID();
|
|
|
|
|
$elementTaskRelationUid = \ProcessMaker\Util\Common::generateUID();
|
|
|
|
|
|
|
|
|
|
$messageEventTaskRelation->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
|
|
|
|
|
$elementTaskRelation->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
|
|
|
|
|
|
|
|
|
|
$messageEventTaskRelation->setMsgetrUid($messageEventTaskRelationUid);
|
|
|
|
|
$messageEventTaskRelation->setPrjUid($projectUid);
|
|
|
|
|
$elementTaskRelation->setEtrUid($elementTaskRelationUid);
|
|
|
|
|
$elementTaskRelation->setPrjUid($projectUid);
|
|
|
|
|
|
|
|
|
|
if ($messageEventTaskRelation->validate()) {
|
|
|
|
|
if ($elementTaskRelation->validate()) {
|
|
|
|
|
$cnn->begin();
|
|
|
|
|
|
|
|
|
|
$result = $messageEventTaskRelation->save();
|
|
|
|
|
$result = $elementTaskRelation->save();
|
|
|
|
|
|
|
|
|
|
$cnn->commit();
|
|
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
return $this->getMessageEventTaskRelation($messageEventTaskRelationUid);
|
|
|
|
|
return $this->getElementTaskRelation($elementTaskRelationUid);
|
|
|
|
|
} else {
|
|
|
|
|
$msg = "";
|
|
|
|
|
|
|
|
|
|
foreach ($messageEventTaskRelation->getValidationFailures() as $validationFailure) {
|
|
|
|
|
foreach ($elementTaskRelation->getValidationFailures() as $validationFailure) {
|
|
|
|
|
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -218,7 +219,7 @@ class MessageEventTaskRelation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete Message-Event-Task-Relation
|
|
|
|
|
* Delete Element-Task-Relation
|
|
|
|
|
*
|
|
|
|
|
* @param array $arrayCondition Conditions
|
|
|
|
|
*
|
|
|
|
|
@@ -238,26 +239,27 @@ class MessageEventTaskRelation
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = \MessageEventTaskRelationPeer::doDelete($criteria);
|
|
|
|
|
$result = \ElementTaskRelationPeer::doDelete($criteria);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get criteria for Message-Event-Task-Relation
|
|
|
|
|
* Get criteria for Element-Task-Relation
|
|
|
|
|
*
|
|
|
|
|
* return object
|
|
|
|
|
*/
|
|
|
|
|
public function getMessageEventTaskRelationCriteria()
|
|
|
|
|
public function getElementTaskRelationCriteria()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::MSGETR_UID);
|
|
|
|
|
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::PRJ_UID);
|
|
|
|
|
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::EVN_UID);
|
|
|
|
|
$criteria->addSelectColumn(\MessageEventTaskRelationPeer::TAS_UID);
|
|
|
|
|
$criteria->addSelectColumn(\ElementTaskRelationPeer::ETR_UID);
|
|
|
|
|
$criteria->addSelectColumn(\ElementTaskRelationPeer::PRJ_UID);
|
|
|
|
|
$criteria->addSelectColumn(\ElementTaskRelationPeer::ELEMENT_UID);
|
|
|
|
|
$criteria->addSelectColumn(\ElementTaskRelationPeer::ELEMENT_TYPE);
|
|
|
|
|
$criteria->addSelectColumn(\ElementTaskRelationPeer::TAS_UID);
|
|
|
|
|
|
|
|
|
|
return $criteria;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
@@ -266,19 +268,20 @@ class MessageEventTaskRelation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get data of a Message-Event-Task-Relation from a record
|
|
|
|
|
* Get data of a Element-Task-Relation from a record
|
|
|
|
|
*
|
|
|
|
|
* @param array $record Record
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data Message-Event-Task-Relation
|
|
|
|
|
* return array Return an array with data Element-Task-Relation
|
|
|
|
|
*/
|
|
|
|
|
public function getMessageEventTaskRelationDataFromRecord(array $record)
|
|
|
|
|
public function getElementTaskRelationDataFromRecord(array $record)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return array(
|
|
|
|
|
$this->getFieldNameByFormatFieldName("MSGETR_UID") => $record["MSGETR_UID"],
|
|
|
|
|
$this->getFieldNameByFormatFieldName("EVN_UID") => $record["EVN_UID"],
|
|
|
|
|
$this->getFieldNameByFormatFieldName("TAS_UID") => $record["TAS_UID"]
|
|
|
|
|
$this->getFieldNameByFormatFieldName("ETR_UID") => $record["ETR_UID"],
|
|
|
|
|
$this->getFieldNameByFormatFieldName("ELEMENT_UID") => $record["ELEMENT_UID"],
|
|
|
|
|
$this->getFieldNameByFormatFieldName("ELEMENT_TYPE") => $record["ELEMENT_TYPE"],
|
|
|
|
|
$this->getFieldNameByFormatFieldName("TAS_UID") => $record["TAS_UID"]
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
@@ -286,25 +289,25 @@ class MessageEventTaskRelation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get data of a Message-Event-Task-Relation
|
|
|
|
|
* Get data of a Element-Task-Relation
|
|
|
|
|
*
|
|
|
|
|
* @param string $messageEventTaskRelationUid Unique id of Message-Event-Task-Relation
|
|
|
|
|
* @param bool $flagGetRecord Value that set the getting
|
|
|
|
|
* @param string $elementTaskRelationUid Unique id of Element-Task-Relation
|
|
|
|
|
* @param bool $flagGetRecord Value that set the getting
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data of a Message-Event-Task-Relation
|
|
|
|
|
* return array Return an array with data of a Element-Task-Relation
|
|
|
|
|
*/
|
|
|
|
|
public function getMessageEventTaskRelation($messageEventTaskRelationUid, $flagGetRecord = false)
|
|
|
|
|
public function getElementTaskRelation($elementTaskRelationUid, $flagGetRecord = false)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Verify data
|
|
|
|
|
$this->throwExceptionIfNotExistsMessageEventTaskRelation($messageEventTaskRelationUid, $this->arrayFieldNameForException["messageEventTaskRelationUid"]);
|
|
|
|
|
$this->throwExceptionIfNotExistsElementTaskRelation($elementTaskRelationUid, $this->arrayFieldNameForException["elementTaskRelationUid"]);
|
|
|
|
|
|
|
|
|
|
//Get data
|
|
|
|
|
$criteria = $this->getMessageEventTaskRelationCriteria();
|
|
|
|
|
$criteria = $this->getElementTaskRelationCriteria();
|
|
|
|
|
|
|
|
|
|
$criteria->add(\MessageEventTaskRelationPeer::MSGETR_UID, $messageEventTaskRelationUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\ElementTaskRelationPeer::ETR_UID, $elementTaskRelationUid, \Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \MessageEventTaskRelationPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria = \ElementTaskRelationPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
$rsCriteria->next();
|
|
|
|
|
@@ -312,25 +315,25 @@ class MessageEventTaskRelation
|
|
|
|
|
$row = $rsCriteria->getRow();
|
|
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
return (!$flagGetRecord)? $this->getMessageEventTaskRelationDataFromRecord($row) : $row;
|
|
|
|
|
return (!$flagGetRecord)? $this->getElementTaskRelationDataFromRecord($row) : $row;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get data of a Message-Event-Task-Relation
|
|
|
|
|
* Get data of a Element-Task-Relation
|
|
|
|
|
*
|
|
|
|
|
* @param array $arrayCondition Conditions
|
|
|
|
|
* @param bool $flagGetRecord Value that set the getting
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data of a Message-Event-Task-Relation, otherwise null
|
|
|
|
|
* return array Return an array with data of a Element-Task-Relation, otherwise null
|
|
|
|
|
*/
|
|
|
|
|
public function getMessageEventTaskRelationWhere(array $arrayCondition, $flagGetRecord = false)
|
|
|
|
|
public function getElementTaskRelationWhere(array $arrayCondition, $flagGetRecord = false)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Get data
|
|
|
|
|
$criteria = $this->getMessageEventTaskRelationCriteria();
|
|
|
|
|
$criteria = $this->getElementTaskRelationCriteria();
|
|
|
|
|
|
|
|
|
|
foreach ($arrayCondition as $key => $value) {
|
|
|
|
|
if (is_array($value)) {
|
|
|
|
|
@@ -340,14 +343,14 @@ class MessageEventTaskRelation
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \MessageEventTaskRelationPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria = \ElementTaskRelationPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteria->next()) {
|
|
|
|
|
$row = $rsCriteria->getRow();
|
|
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
return (!$flagGetRecord)? $this->getMessageEventTaskRelationDataFromRecord($row) : $row;
|
|
|
|
|
return (!$flagGetRecord)? $this->getElementTaskRelationDataFromRecord($row) : $row;
|
|
|
|
|
} else {
|
|
|
|
|
//Return
|
|
|
|
|
return null;
|