diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php new file mode 100644 index 000000000..648ac3bcc --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCases.php @@ -0,0 +1,686 @@ +categoryUid = $categoryUid; + } + + /** + * Get Category Uid value + * + * @return string + */ + public function getCategoryUid() + { + return $this->categoryUid; + } + + /** + * Set Process Uid value + * + * @param string $processUid + */ + public function setProcessUid($processUid) + { + $this->processUid = $processUid; + } + + /** + * Get Process Uid value + * + * @return string + */ + public function getProcessUid() + { + return $this->processUid; + } + + /** + * Set Process Id value + * + * @param int $processId + */ + public function setProcessId($processId) + { + $this->processId = $processId; + } + + /** + * Get Process Id value + * + * @return int + */ + public function getProcessId() + { + return $this->processId; + } + + /** + * Set User Uid value + * + * @param string $userUid + */ + public function setUserUid($userUid) + { + $this->userUid = $userUid; + } + + /** + * Get User Uid value + * + * @return string + */ + public function getUserUid() + { + return $this->userUid; + } + + /** + * Set User Id value + * + * @param int $userId + */ + public function setUserId($userId) + { + $this->userId = $userId; + } + + /** + * Get User Id value + * + * @return int + */ + public function getUserId() + { + return $this->userId; + } + + /** + * Set value to search + * + * @param string $valueToSearch + */ + public function setValueToSearch($valueToSearch) + { + $this->valueToSearch = $valueToSearch; + } + + /** + * Get value to search + * + * @return string + */ + public function getValueToSearch() + { + return $this->valueToSearch; + } + + /** + * Set inbox status + * + * @param string $inboxStatus + * + * @throws Exception + */ + public function setInboxStatus($inboxStatus) + { + // Convert the value to upper case + $inboxStatus = strtoupper($inboxStatus); + + // Validate the inbox status + if (!in_array($inboxStatus, self::INBOX_STATUSES)) { + throw new Exception("Inbox status '{$inboxStatus}' is not valid."); + } + + // If empty string is sent, use value 'ALL' + if ($inboxStatus === '') { + $inboxStatus = 'ALL'; + } + + $this->inboxStatus = $inboxStatus; + } + + /** + * Get inbox status + * + * @return string + */ + public function getInboxStatus() + { + return $this->inboxStatus; + } + + /** + * Set participated status + * + * @param string $participatedStatus + * + * @throws Exception + */ + public function setParticipatedStatus($participatedStatus) + { + // Convert the value to upper case + $participatedStatus = strtoupper($participatedStatus); + + // Validate the participated status + if (!in_array($participatedStatus, self::PARTICIPATED_STATUSES)) { + throw new Exception("Participated status '{$participatedStatus}' is not valid."); + } + + // If empty string is sent, use value 'ALL' + if ($participatedStatus === '') { + $participatedStatus = 'ALL'; + } + + $this->participatedStatus = $participatedStatus; + } + + /** + * Get participated status + * + * @return string + */ + public function getParticipatedStatus() + { + return $this->participatedStatus; + } + + /** + * Set risk status + * + * @param string $riskStatus + * + * @throws Exception + */ + public function setRiskStatus($riskStatus) + { + // Convert the value to upper case + $riskStatus = strtoupper($riskStatus); + + // Validate the risk status + if (!in_array($riskStatus, self::RISK_STATUSES)) { + throw new Exception("Risk status '{$riskStatus}' is not valid."); + } + + // If empty string is sent, use value 'ALL' + if ($riskStatus === '') { + $riskStatus = 'ALL'; + } + + $this->riskStatus = $riskStatus; + } + + /** + * Get risk status + * + * @return string + */ + public function getRiskStatus() + { + return $this->riskStatus; + } + + /** + * Set Case status + * + * @param string $caseStatus + * + * @throws Exception + */ + public function setCaseStatus($caseStatus) + { + // Convert the value to upper case + $caseStatus = strtoupper($caseStatus); + + // Validate the case status + if (!in_array($caseStatus, self::CASE_STATUSES)) { + throw new Exception("Case status '{$caseStatus}' is not valid."); + } + + // If empty string is sent, use value 'ALL' + if ($caseStatus === '') { + $caseStatus = 'ALL'; + } + + // Fix the canceled status, this is a legacy code error + if ($caseStatus === self::INCORRECT_CANCELED_STATUS) { + $caseStatus = self::CORRECT_CANCELED_STATUS; + } + + $this->caseStatus = $caseStatus; + } + + /** + * Get Case Status + * + * @return string + */ + public function getCaseStatus() + { + return $this->caseStatus; + } + + /** + * Set Case Uid + * + * @param string $caseUid + */ + public function setCaseUid($caseUid) + { + $this->caseUid = $caseUid; + } + + /** + * Get Case Uid + * + * @return string + */ + public function getCaseUid() + { + return $this->caseUid; + } + + /** + * Set Case Number + * + * @param int $caseNumber + */ + public function setCaseNumber($caseNumber) + { + $this->caseNumber = $caseNumber; + } + + /** + * Get Case Number + * + * @return int + */ + public function getCaseNumber() + { + return $this->caseNumber; + } + + /** + * Set Cases Uids + * + * @param array $casesUid + */ + public function setCasesUids(array $casesUid) + { + $this->casesUids = $casesUid; + } + + /** + * Get Cases Uids + * + * @return array + */ + public function getCasesUids() + { + return $this->casesUids; + } + + /** + * Set Cases Numbers + * + * @param array $casesNumbers + */ + public function setCasesNumbers(array $casesNumbers) + { + $this->casesNumbers = $casesNumbers; + } + + /** + * Get Cases Numbers + * + * @return array + */ + public function getCasesNumbers() + { + return $this->casesNumbers; + } + + /** + * Set Newest Than value + * + * @param string $newestThan + * + * @throws Exception + */ + public function setNewestThan($newestThan) + { + if (!Validator::isDate($newestThan, 'Y-m-d')) { + throw new Exception("Value '{$newestThan}' is not a valid date."); + } + $this->newestThan = $newestThan; + } + + /** + * Get Newest Than value + * + * @return string + */ + public function getNewestThan() + { + return $this->newestThan; + } + + /** + * Set Oldest Than value + * + * @param string $oldestThan + * + * @throws Exception + */ + public function setOldestThan($oldestThan) + { + if (!Validator::isDate($oldestThan, 'Y-m-d')) { + throw new Exception("Value '{$oldestThan}' is not a valid date."); + } + $this->oldestThan = $oldestThan; + } + + /** + * Set order by column + * + * @param string $orderByColumn + */ + public function setOrderByColumn($orderByColumn) + { + // Convert the value to upper case + $orderByColumn = strtoupper($orderByColumn); + + $this->orderByColumn = $orderByColumn; + } + + /** + * Get order by column + * + * @return string + */ + public function getOrderByColumn() + { + return $this->orderByColumn; + } + + /** + * Get Oldest Than value + * + * @return string + */ + public function getOldestThan() + { + return $this->oldestThan; + } + + /** + * Set order direction + * + * @param string $orderDirection + * + * @throws Exception + */ + public function setOrderDirection($orderDirection) + { + // Convert the value to upper case + $orderDirection = strtoupper($orderDirection); + + // Validate the order direction + if (!in_array($orderDirection, self::ORDER_DIRECTIONS)) { + throw new Exception("Order direction '{$orderDirection}' is not valid."); + } + + $this->orderDirection = $orderDirection; + } + + /** + * Get order direction + * + * @return string + */ + public function getOrderDirection() + { + return $this->orderDirection; + } + + /** + * Set if is paged + * + * @param bool $paged + */ + public function setPaged($paged) + { + $this->paged = (bool) $paged; + } + + /** + * Get if is paged + * + * @return bool + */ + public function getPaged() + { + return $this->paged; + } + + /** + * Set offset value + * + * @param int $offset + */ + public function setOffset($offset) + { + $this->offset = (int) $offset; + } + + /** + * Get offset value + * + * @return int + */ + public function getOffset() + { + return $this->offset; + } + + /** + * Set limit value + * + * @param int $limit + */ + public function setLimit($limit) + { + $this->limit = (int) $limit; + } + + /** + * Get limit value + * + * @return int + */ + public function getLimit() + { + return $this->limit; + } + + /** + * Set all properties + * + * @param array $properties + */ + public function setProperties(array $properties) + { + if (!empty($properties['category'])) { + $this->setCategoryUid($properties['category']); + } + + if (!empty($properties['process'])) { + $this->setProcessUid($properties['process']); + } + + if (!empty($properties['user'])) { + $this->setUserUid($properties['user']); + } + + if (!empty($properties['search'])) { + $this->setValueToSearch($properties['search']); + } + + if (!empty($properties['filter']) && get_class($this) === Inbox::class) { + $this->setInboxStatus($properties['filter']); + } + + if (!empty($properties['filter']) && get_class($this) === Participated::class) { + $this->setParticipatedStatus($properties['filter']); + } + + if (!empty($properties['filterStatus']) && get_class($this) === Inbox::class) { + $this->setRiskStatus($properties['filterStatus']); + } + + if (!empty($properties['filterStatus']) && get_class($this) === Participated::class) { + $this->setCaseStatus($properties['filterStatus']); + } + + if (!empty($properties['caseLink'])) { + $this->setCaseUid($properties['caseLink']); + } + + if (!empty($properties['appUidCheck'])) { + $this->setCasesUids($properties['appUidCheck']); + } + + if (!empty($properties['newestthan'])) { + $this->setNewestThan($properties['newestthan']); + } + + if (!empty($properties['oldestthan'])) { + $this->setOldestThan($properties['oldestthan']); + } + + if (!empty($properties['sort'])) { + $this->setOrderByColumn($properties['sort']); + } + + if (!empty($properties['dir'])) { + $this->setOrderDirection($properties['dir']); + } + + if (!empty($properties['paged'])) { + $this->setPaged($properties['paged']); + } + + if (!empty($properties['start'])) { + $this->setOffset($properties['start']); + } + + if (!empty($properties['limit'])) { + $this->setLimit($properties['limit']); + } + } + + /** + * Get the list data + * + * @throws Exception + */ + public function getData() + { + throw new Exception("Method '" . __FUNCTION__ . "' should be implemented in the extended class '" . get_class($this) . "'."); + } + + /** + * Get the list counter + * + * @throws Exception + */ + public function getCounter() + { + throw new Exception("Method '" . __FUNCTION__ . "' should be implemented in the extended class '" . get_class($this) . "'."); + } +} diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php new file mode 100644 index 000000000..208b92cb6 --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Draft.php @@ -0,0 +1,8 @@ +setProperties($filters); + + return $instance; + } +} diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Interfaces/CasesInterface.php b/workflow/engine/src/ProcessMaker/BusinessModel/Interfaces/CasesInterface.php new file mode 100644 index 000000000..6fa89cf3e --- /dev/null +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Interfaces/CasesInterface.php @@ -0,0 +1,10 @@ +