Merge branch 'master' of bitbucket.org:colosa/processmaker into PM-2039

This commit is contained in:
Victor Saisa Lopez
2015-04-20 11:50:39 -04:00
48 changed files with 2888 additions and 2157 deletions

View File

@@ -18,7 +18,7 @@ class ReportingIndicators
*
* return decimal value
*/
public function getPeiCompleteData($indicatorUid, $measureDate, $compareDate, $language)
public function getPeiCompleteData($indicatorUid, $compareDate, $measureDate, $language)
{
G::loadClass('indicatorsCalculator');
$calculator = new \IndicatorsCalculator();
@@ -30,7 +30,10 @@ class ReportingIndicators
$peiCost = current(reset($calculator->peiCostHistoric($processesId, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$peiCompare = current(reset($calculator->peiHistoric($processesId, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
$retval = array("efficiencyIndex" => $peiValue,
$retval = array(
"id" => $indicatorUid,
"efficiencyIndex" => $peiValue,
"efficiencyIndexCompare" => $peiCompare,
"efficiencyVariation" => ($peiValue-$peiCompare),
"inefficiencyCost" => $peiCost,
"data"=>$processes);
@@ -47,32 +50,22 @@ class ReportingIndicators
*
* return decimal value
*/
public function getUeiCompleteData($indicatorUid, $measureDate, $compareDate, $language)
public function getUeiCompleteData($indicatorUid, $compareDate, $measureDate,$language)
{
G::loadClass('indicatorsCalculator');
$calculator = new \IndicatorsCalculator();
$groups = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language);
$groupIds = array();
foreach($groups as $p) {
array_push($groupIds, $p['uid']);
}
if (sizeof($groupIds) == 0) {
$groupIds = null;
}
//TODO think what if each indicators has a group or user subset assigned. Now are all
$ueiValue = current(reset($calculator->ueiHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$arrCost = $calculator->ueiUserGroups($indicatorUid, $measureDate, $measureDate, $language);
$ueiCost = (sizeof($arrCost) > 0)
? $arrCost[0]['inefficiencyCost']
: null;
$ueiCost = current(reset($calculator->ueiCostHistoric(null, $measureDate, $measureDate, \ReportingPeriodicityEnum::NONE)));
$ueiCompare = current(reset($calculator->ueiHistoric(null, $compareDate, $compareDate, \ReportingPeriodicityEnum::NONE)));
$retval = array("efficiencyIndex" => $ueiValue,
$retval = array(
"id" => $indicatorUid,
"efficiencyIndex" => $ueiValue,
"efficiencyVariation" => ($ueiValue-$ueiCompare),
"inefficiencyCost" => $ueiCost,
"data"=>$groups);
@@ -296,5 +289,27 @@ class ReportingIndicators
);
return $returnValue;
}
/**
* Get list status indicator
*
* @access public
* @param array $options, Data for list
* @return array
*
* @author Marco Antonio Nina <marco.antonio.nina@colosa.com>
* @copyright Colosa - Bolivia
*/
public function getStatusIndicator($options = array())
{
Validator::isArray($options, '$options');
$usrUid = isset( $options["usrUid"] ) ? $options["usrUid"] : "";
G::loadClass('indicatorsCalculator');
$calculator = new \IndicatorsCalculator();
$result = $calculator->statusIndicator($usrUid);
return $result;
}
}

View File

@@ -321,7 +321,7 @@ class Task
}
//Validating TAS_TRANSFER_FLY value
if ($arrayProperty["TAS_TRANSFER_FLY"] == "TRUE") {
if ($arrayProperty["TAS_TRANSFER_FLY"] == "FALSE") {
if (!isset($arrayProperty["TAS_DURATION"])) {
throw (new \Exception("Invalid value specified for 'tas_duration'"));
}

View File

@@ -129,10 +129,13 @@ class Variable
$cnn = \Propel::getConnection("workflow");
try {
$variable = \ProcessVariablesPeer::retrieveByPK($variableUid);
$dbConnection = \DbSourcePeer::retrieveByPK($variable->getVarDbconnection(), $variable->getPrjUid());
$oldVariable = array(
"VAR_NAME" => $variable->getVarName(),
"VAR_FIELD_TYPE" => $variable->getVarFieldType(),
"VAR_DBCONNECTION" => $variable->getVarDbconnection(),
"VAR_DBCONNECTION_LABEL" => $dbConnection !== null ? '[' . $dbConnection->getDbsServer() . ':' . $dbConnection->getDbsPort() . '] ' . $dbConnection->getDbsType() . ': ' . $dbConnection->getDbsDatabaseName() : 'PM Database',
"VAR_SQL" => $variable->getVarSql(),
"VAR_ACCEPTED_VALUES" => $variable->getVarAcceptedValues()
);
@@ -170,10 +173,12 @@ class Variable
$variable->save();
$cnn->commit();
//update dynaforms
$dbConnection = \DbSourcePeer::retrieveByPK($variable->getVarDbconnection(), $variable->getPrjUid());
$newVariable = array(
"VAR_NAME" => $variable->getVarName(),
"VAR_FIELD_TYPE" => $variable->getVarFieldType(),
"VAR_DBCONNECTION" => $variable->getVarDbconnection(),
"VAR_DBCONNECTION_LABEL" => $dbConnection !== null ? '[' . $dbConnection->getDbsServer() . ':' . $dbConnection->getDbsPort() . '] ' . $dbConnection->getDbsType() . ': ' . $dbConnection->getDbsDatabaseName() : 'PM Database',
"VAR_SQL" => $variable->getVarSql(),
"VAR_ACCEPTED_VALUES" => $variable->getVarAcceptedValues()
);
@@ -265,9 +270,14 @@ class Variable
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NULL);
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_DEFAULT);
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_ACCEPTED_VALUES);
$criteria->addSelectColumn(\DbSourcePeer::DBS_SERVER);
$criteria->addSelectColumn(\DbSourcePeer::DBS_PORT);
$criteria->addSelectColumn(\DbSourcePeer::DBS_DATABASE_NAME);
$criteria->addSelectColumn(\DbSourcePeer::DBS_TYPE);
$criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL);
$criteria->add(\ProcessVariablesPeer::VAR_UID, $variableUid, \Criteria::EQUAL);
$criteria->addJoin(\ProcessVariablesPeer::VAR_DBCONNECTION, \DbSourcePeer::DBS_UID, \Criteria::LEFT_JOIN);
$rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria);
@@ -283,7 +293,8 @@ class Variable
'var_field_type' => $aRow['VAR_FIELD_TYPE'],
'var_field_size' => (int)$aRow['VAR_FIELD_SIZE'],
'var_label' => $aRow['VAR_LABEL'],
'var_dbconnection' => $aRow['VAR_DBCONNECTION'],
'var_dbconnection' => $aRow['VAR_DBCONNECTION'] === 'none' ? 'workflow' : $aRow['VAR_DBCONNECTION'],
'var_dbconnection_label' => $aRow['DBS_SERVER'] !== null ? '[' . $aRow['DBS_SERVER'] . ':' . $aRow['DBS_PORT'] . '] ' . $aRow['DBS_TYPE'] . ': ' . $aRow['DBS_DATABASE_NAME'] : 'PM Database',
'var_sql' => $aRow['VAR_SQL'],
'var_null' => (int)$aRow['VAR_NULL'],
'var_default' => $aRow['VAR_DEFAULT'],
@@ -326,8 +337,13 @@ class Variable
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_NULL);
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_DEFAULT);
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_ACCEPTED_VALUES);
$criteria->addSelectColumn(\DbSourcePeer::DBS_SERVER);
$criteria->addSelectColumn(\DbSourcePeer::DBS_PORT);
$criteria->addSelectColumn(\DbSourcePeer::DBS_DATABASE_NAME);
$criteria->addSelectColumn(\DbSourcePeer::DBS_TYPE);
$criteria->add(\ProcessVariablesPeer::PRJ_UID, $processUid, \Criteria::EQUAL);
$criteria->addJoin(\ProcessVariablesPeer::VAR_DBCONNECTION, \DbSourcePeer::DBS_UID, \Criteria::LEFT_JOIN);
$rsCriteria = \ProcessVariablesPeer::doSelectRS($criteria);
@@ -343,7 +359,8 @@ class Variable
'var_field_type' => $aRow['VAR_FIELD_TYPE'],
'var_field_size' => (int)$aRow['VAR_FIELD_SIZE'],
'var_label' => $aRow['VAR_LABEL'],
'var_dbconnection' => $aRow['VAR_DBCONNECTION'],
'var_dbconnection' => $aRow['VAR_DBCONNECTION'] === 'none' ? 'workflow' : $aRow['VAR_DBCONNECTION'],
'var_dbconnection_label' => $aRow['DBS_SERVER'] !== null ? '[' . $aRow['DBS_SERVER'] . ':' . $aRow['DBS_PORT'] . '] ' . $aRow['DBS_TYPE'] . ': ' . $aRow['DBS_DATABASE_NAME'] : 'PM Database',
'var_sql' => $aRow['VAR_SQL'],
'var_null' => (int)$aRow['VAR_NULL'],
'var_default' => $aRow['VAR_DEFAULT'],
@@ -690,4 +707,3 @@ class Variable
}
}
}

View File

@@ -1384,10 +1384,6 @@ class BpmnWorkflow extends Project\Bpmn
$activity = $bwp->getActivity($activityData["ACT_UID"]);
if ($activity["BOU_CONTAINER"] != $activityData["BOU_CONTAINER"]) {
$activity = null;
}
if ($forceInsert || is_null($activity)) {
if ($generateUid) {
//Generate and update UID

View File

@@ -71,223 +71,6 @@ class ReportingIndicators extends Api
}
}
// /**
// * Returns the aggregate Efficiency of a employee or set of employees
// *
// * @param string $employee_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @return array
// *
// * @url GET /employee-efficiency-index
// */
// public function doGetEmployeeEfficiencyIndex($employee_list, $init_date, $end_date)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($employee_list) > 1)
// ? $listArray = explode(',', $employee_list)
// : null;
// $response = $indicatorsObj->getEmployeeEfficiencyIndex($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date));
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Lists tasks of a employee and it's statistics (efficiency, average times, etc.)
// *
// * @param string $employee_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @param string $language {@from path}
// * @return array
// *
// * @url GET /employee-tasks
// */
// public function doGetEmployeeTasksInfo($employee_list, $init_date, $end_date, $language)
// {
// if ($employee_list == null || strlen($employee_list) <= 1)
// throw new InvalidArgumentException ('employee_list must have at least a value', 0);
//
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = $listArray = explode(',', $employee_list);
// $response = $indicatorsObj->getEmployeeTasksInfoList($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date),
// $language);
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the percent of Cases with Overdue time
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @return array
// *
// * @url GET /percent-overdue-cases
// */
// public function doGetPercentOverdueByProcess($process_list, $init_date, $end_date)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentOverdueCasesByProcess($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date));
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the percent of Cases with Overdue time with the selected periodicity
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @param string $periodicity {@from path}
// * @return array
// *
// * @url GET /percent-overdue-cases-history
// */
// public function doGetPercentOverdueByProcessHistory($process_list, $init_date, $end_date, $periodicity)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentOverdueCasesByProcessHistory($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date),
// $periodicity);
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the total of Cases with New time
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @return array
// *
// * @url GET /total-new-cases
// */
// public function doGetTotalNewByProcess($process_list, $init_date, $end_date)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentNewCasesByProcess($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date));
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the total of Cases with New time with the selected periodicity
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @param string $periodicity {@from path}
// * @return array
// *
// * @url GET /total-new-cases-history
// */
// public function doGetTotalNewByProcessHistory($process_list, $init_date, $end_date, $periodicity)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentNewCasesByProcessHistory($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date),
// $periodicity);
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the total of Cases with Completed time
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @return array
// *
// * @url GET /total-completed-cases
// */
// public function doGetTotalCompletedByProcess($process_list, $init_date, $end_date)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentCompletedCasesByProcess($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date));
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
// /**
// * Returns the total of Cases with Completed time with the selected periodicity
// *
// * @param string $$process_list {@from path}
// * @param string $init_date {@from path}
// * @param string $end_date {@from path}
// * @param string $periodicity {@from path}
// * @return array
// *
// * @url GET /total-completed-cases-history
// */
// public function doGetTotalCompletedByProcessHistory($process_list, $init_date, $end_date, $periodicity)
// {
// try {
// $indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
// $listArray = (strlen($process_list) > 1)
// ? $listArray = explode(',', $process_list)
// : null;
// $response = $indicatorsObj->getPercentCompletedCasesByProcessHistory($listArray,
// new \DateTime($init_date),
// new \DateTime($end_date),
// $periodicity);
// return $response;
// } catch (\Exception $e) {
// throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
// }
// }
//
/**
* Returns the total of Cases with Completed time with the selected periodicity
*
@@ -299,7 +82,7 @@ class ReportingIndicators extends Api
*
* @url GET /process-efficiency-data
*/
public function doGetProcessEficciencyData($indicator_uid, $measure_date, $compare_date, $language)
public function doGetProcessEficciencyData($indicator_uid, $compare_date, $measure_date, $language)
{
try {
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
@@ -324,7 +107,7 @@ class ReportingIndicators extends Api
*
* @url GET /employee-efficiency-data
*/
public function doGetEmployeeEficciencyData($indicator_uid, $measure_date, $compare_date, $language)
public function doGetEmployeeEficciencyData($indicator_uid, $compare_date, $measure_date, $language)
{
try {
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
@@ -390,6 +173,29 @@ class ReportingIndicators extends Api
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* Get list Status indicator
*
* @return array
*
* @author Marco Antonio Nina <marco.antonio.nina@colosa.com>
* @copyright Colosa - Bolivia
*
* @url GET /status-indicator
*/
public function doGetStatusIndicator() {
try {
$options['usrUid'] = $this->getUserId();
$indicatorsObj = new \ProcessMaker\BusinessModel\ReportingIndicators();
$response = $indicatorsObj->getStatusIndicator($options);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}

View File

@@ -175,9 +175,11 @@ class PmPdo implements \OAuth2\Storage\AuthorizationCodeInterface,
{
$access_token = new \OauthAccessTokens();
$access_token->load($token);
$stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE ACCESS_TOKEN = :token', $this->config['access_token_table']));
$stmt->execute(compact('token'));
$stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE EXPIRES>%s', $this->config['refresh_token_table'], "'".Date('Y-m-d H:i:s')."'"));
$stmt = $this->db->prepare(sprintf("DELETE FROM %s WHERE EXPIRES < %s", $this->config["refresh_token_table"], "'" . date("Y-m-d H:i:s") . "'"));
return $stmt->execute(compact('token'));
}

View File

@@ -68,7 +68,10 @@ class Server implements iAuthenticate
$this->server->addGrantType(new \ProcessMaker\Services\OAuth2\PmClientCredentials($this->storage));
// Add the "Refresh token" grant type
$this->server->addGrantType(new \OAuth2\GrantType\RefreshToken($this->storage));
$this->server->addGrantType(new \OAuth2\GrantType\RefreshToken(
$this->storage,
array("always_issue_new_refresh_token" => true)
));
// create some users in memory
//$users = array('bshaffer' => array('password' => 'brent123', 'first_name' => 'Brent', 'last_name' => 'Shaffer'));
@@ -261,7 +264,9 @@ class Server implements iAuthenticate
if ($returnResponse) {
return $response;
} else {
die($response->send());
$response->send();
exit(0);
}
}
@@ -279,9 +284,11 @@ class Server implements iAuthenticate
if ($request == null) {
$request = \OAuth2\Request::createFromGlobals();
}
$response = $this->server->handleTokenRequest($request);
$response = $this->server->handleTokenRequest($request); //Set/Get token //PmPdo->setAccessToken()
$token = $response->getParameters();
if (array_key_exists('access_token', $token)
&& array_key_exists('refresh_token', $token)
) {
@@ -309,17 +316,9 @@ class Server implements iAuthenticate
if ($returnResponse) {
return $response;
} else {
if ($response->getStatusCode() == 400) {
$msg = $response->getParameter("error_description", "");
$msg = ($msg != "")? $msg : $response->getParameter("error", "");
$response->send();
$rest = new \Maveriks\Extension\Restler();
$rest->setMessage(new \Luracast\Restler\RestException(\ProcessMaker\Services\Api::STAT_APP_EXCEPTION, $msg));
exit(0);
} else {
$response->send();
}
exit(0);
}
}