More updates to handling PUT request for /project endpoint
This commit is contained in:
@@ -46,6 +46,28 @@ class System
|
||||
public $sRevision;
|
||||
public $sPath;
|
||||
public $newSystemClass;
|
||||
private static $config = null;
|
||||
private static $debug = null;
|
||||
private static $instance;
|
||||
private static $defaultConfig = array(
|
||||
'debug' => 0,
|
||||
'debug_sql' => 0,
|
||||
'debug_time' => 0,
|
||||
'debug_calendar' => 0,
|
||||
'wsdl_cache' => 1,
|
||||
'memory_limit' => "256M",
|
||||
'time_zone' => 'America/New_York',
|
||||
'memcached' => 0,
|
||||
'memcached_server' => '',
|
||||
'default_skin' => 'neoclassic',
|
||||
'default_lang' => 'en',
|
||||
'proxy_host' => '',
|
||||
'proxy_port' => '',
|
||||
'proxy_user' => '',
|
||||
'proxy_pass' => '',
|
||||
'size_log_file' => 5000000,
|
||||
'number_log_file' => 5
|
||||
);
|
||||
|
||||
/**
|
||||
* List currently installed plugins
|
||||
@@ -682,14 +704,14 @@ class System
|
||||
return System::getSchema( PATH_TRUNK . "workflow/engine/config/schema.xml" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the system schema rbac.
|
||||
*
|
||||
* @return schema content in an array
|
||||
*/
|
||||
public static function getSystemSchemaRbac ()
|
||||
{
|
||||
return System::getSchema( PATH_TRUNK . "rbac/engine/config/schema.xml" );
|
||||
/**
|
||||
* Retrieves the system schema rbac.
|
||||
*
|
||||
* @return schema content in an array
|
||||
*/
|
||||
public static function getSystemSchemaRbac ()
|
||||
{
|
||||
return System::getSchema( PATH_TRUNK . "rbac/engine/config/schema.xml" );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1041,80 +1063,52 @@ class System
|
||||
|
||||
public static function getSystemConfiguration ($globalIniFile = '', $wsIniFile = '', $wsName = '')
|
||||
{
|
||||
$readGlobalIniFile = false;
|
||||
$readWsIniFile = false;
|
||||
if (! is_null(self::$config)) {
|
||||
return self::$config;
|
||||
}
|
||||
|
||||
if (empty( $globalIniFile )) {
|
||||
if (empty($globalIniFile)) {
|
||||
$globalIniFile = PATH_CORE . 'config' . PATH_SEP . 'env.ini';
|
||||
}
|
||||
|
||||
if (empty( $wsIniFile )) {
|
||||
if (defined( 'PATH_DB' )) {
|
||||
if (empty($wsIniFile)) {
|
||||
if (defined('PATH_DB')) {
|
||||
// if we're on a valid workspace env.
|
||||
if (empty( $wsName )) {
|
||||
$uriParts = explode( '/', getenv( "REQUEST_URI" ) );
|
||||
if (isset( $uriParts[1] )) {
|
||||
if (substr( $uriParts[1], 0, 3 ) == 'sys') {
|
||||
$wsName = substr( $uriParts[1], 3 );
|
||||
if (empty($wsName)) {
|
||||
$uriParts = explode('/', getenv("REQUEST_URI"));
|
||||
|
||||
if (isset($uriParts[1])) {
|
||||
if (substr($uriParts[1], 0, 3) == 'sys') {
|
||||
$wsName = substr($uriParts[1], 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$wsIniFile = PATH_DB . $wsName . PATH_SEP . 'env.ini';
|
||||
}
|
||||
}
|
||||
|
||||
$readGlobalIniFile = file_exists( $globalIniFile ) ? true : false;
|
||||
$readWsIniFile = file_exists( $wsIniFile ) ? true : false;
|
||||
|
||||
if (isset( $_SESSION['PROCESSMAKER_ENV'] )) {
|
||||
$md5 = array ();
|
||||
|
||||
if ($readGlobalIniFile) {
|
||||
$md5[] = md5_file( $globalIniFile );
|
||||
}
|
||||
if ($readWsIniFile) {
|
||||
$md5[] = md5_file( $wsIniFile );
|
||||
}
|
||||
$hash = implode( '-', $md5 );
|
||||
|
||||
if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
|
||||
$_SESSION['PROCESSMAKER_ENV']['from_cache'] = 1;
|
||||
return $_SESSION['PROCESSMAKER_ENV'];
|
||||
}
|
||||
}
|
||||
|
||||
// default configuration
|
||||
$config = array('debug' => 0, 'debug_sql' => 0, 'debug_time' => 0, 'debug_calendar' => 0, 'wsdl_cache' => 1, 'memory_limit' => "256M", 'time_zone' => 'America/New_York', 'memcached' => 0, 'memcached_server' => '', 'default_skin' => 'neoclassic', 'default_lang' => 'en', 'proxy_host' => '', 'proxy_port' => '', 'proxy_user' => '', 'proxy_pass' => '', 'size_log_file' => 5000000, 'number_log_file' => 5);
|
||||
$config = self::$defaultConfig;
|
||||
|
||||
// read the global env.ini configuration file
|
||||
if ($readGlobalIniFile && ($globalConf = @parse_ini_file( $globalIniFile )) !== false) {
|
||||
$config = array_merge( $config, $globalConf );
|
||||
if (($globalConf = @parse_ini_file($globalIniFile)) !== false) {
|
||||
$config = array_merge($config, $globalConf);
|
||||
}
|
||||
|
||||
// Workspace environment configuration
|
||||
if ($readWsIniFile && ($wsConf = @parse_ini_file( $wsIniFile )) !== false) {
|
||||
$config = array_merge( $config, $wsConf );
|
||||
if (($wsConf = @parse_ini_file($wsIniFile)) !== false) {
|
||||
$config = array_merge($config, $wsConf);
|
||||
}
|
||||
|
||||
// validation debug config, only binary value is valid; debug = 1, to enable
|
||||
$config['debug'] = $config['debug'] == 1 ? 1 : 0;
|
||||
self::$debug = $config['debug'];
|
||||
|
||||
if ($config['proxy_pass'] != '') {
|
||||
$config['proxy_pass'] = G::decrypt( $config['proxy_pass'], 'proxy_pass' );
|
||||
$config['proxy_pass'] = G::decrypt($config['proxy_pass'], 'proxy_pass');
|
||||
}
|
||||
|
||||
$md5 = array ();
|
||||
if ($readGlobalIniFile) {
|
||||
$md5[] = @md5_file( $globalIniFile );
|
||||
}
|
||||
if ($readWsIniFile) {
|
||||
$md5[] = @md5_file( $wsIniFile );
|
||||
}
|
||||
$hash = implode( '-', $md5 );
|
||||
|
||||
$_SESSION['PROCESSMAKER_ENV'] = $config;
|
||||
$_SESSION['PROCESSMAKER_ENV_HASH'] = $hash;
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
@@ -1166,6 +1160,24 @@ class System
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getInstance()
|
||||
{
|
||||
if (is_null(self::$instance)) {
|
||||
self::$instance = new System();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public static function isDebugMode()
|
||||
{
|
||||
if (is_null(self::$debug)) {
|
||||
self::getSystemConfiguration();
|
||||
}
|
||||
|
||||
return self::$debug;
|
||||
}
|
||||
}
|
||||
// end System class
|
||||
|
||||
|
||||
@@ -89,11 +89,11 @@ class BpmnActivity extends BaseBpmnActivity
|
||||
parent::delete($con);
|
||||
}
|
||||
|
||||
public static function getAll($start = null, $limit = null, $filter = '', $returnType = null, $changeCaseTo=CASE_UPPER)
|
||||
public static function getAll($prjUid = null, $start = null, $limit = null, $filter = '', $returnType = null, $changeCaseTo=CASE_UPPER)
|
||||
{
|
||||
if (is_array($start)) {
|
||||
if (is_array($prjUid)) {
|
||||
// $start, is a array config
|
||||
extract($start, EXTR_OVERWRITE);
|
||||
extract($prjUid, EXTR_OVERWRITE);
|
||||
}
|
||||
|
||||
$activities = array();
|
||||
@@ -102,6 +102,10 @@ class BpmnActivity extends BaseBpmnActivity
|
||||
$c->addSelectColumn("BPMN_BOUND.*");
|
||||
$c->addJoin(BpmnActivityPeer::ACT_UID, BpmnBoundPeer::ELEMENT_UID, Criteria::LEFT_JOIN);
|
||||
|
||||
if (! is_null($prjUid)) {
|
||||
$c->add(BpmnActivityPeer::PRJ_UID, $prjUid, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$returnType = ($returnType != 'array' && $returnType != 'object') ? 'array' : $returnType;
|
||||
|
||||
switch ($returnType) {
|
||||
|
||||
@@ -27,7 +27,9 @@ use \BpmnArtifactPeer as ArtifactPeer;
|
||||
|
||||
use \ProcessMaker\Util\Hash;
|
||||
use \BasePeer;
|
||||
use Symfony\Component\Yaml\Exception\RuntimeException;
|
||||
|
||||
use \ProcessMaker\Util\Logger;
|
||||
use System;
|
||||
|
||||
|
||||
/**
|
||||
@@ -390,8 +392,8 @@ class Model
|
||||
$lanes = self::getBpmnCollectionBy('Lane', LanePeer::PRJ_UID, $prjUid, true);
|
||||
|
||||
//$activities = self::getBpmnCollectionBy('Activity', ActivityPeer::PRJ_UID, $prjUid, true);
|
||||
//$activities = Activity::getAll(null, null, null, 'object', CASE_LOWER);
|
||||
$activities = Activity::getAll(array('changeCaseTo' => CASE_LOWER));
|
||||
//$activities = Activity::getAll($prjUid, null, null, null, 'object', CASE_LOWER);
|
||||
$activities = Activity::getAll(array('prjUid' => $prjUid, 'changeCaseTo' => CASE_LOWER));
|
||||
//print_r($activities); die;
|
||||
|
||||
$events = self::getBpmnCollectionBy('Event', EventPeer::PRJ_UID, $prjUid, true);
|
||||
@@ -495,26 +497,25 @@ class Model
|
||||
$savedProject = self::loadProject($prjUid);
|
||||
$diff = self::getDiffFromProjects($savedProject, $projectUpdated);
|
||||
|
||||
self::updateDiagram($prjUid, $process->getProUid(), $diff);
|
||||
$result = self::updateDiagram($prjUid, $process->getProUid(), $diff);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function updateDiagram($prjUid, $proUid, $diff)
|
||||
{
|
||||
echo 'DIFF'. PHP_EOL;
|
||||
print_r($diff);
|
||||
self::log('executing: updateDiagram() with params -> ', $prjUid, $proUid, $diff);
|
||||
|
||||
//return false;
|
||||
$mapId = array();
|
||||
$uids = array();
|
||||
|
||||
// Updating objects
|
||||
foreach ($diff['updated'] as $element => $items) {
|
||||
foreach ($items as $data) {
|
||||
$data = array_change_key_case((array) $data, CASE_UPPER);
|
||||
//print_r($data); die;
|
||||
|
||||
// the calls in switch sentence are setting and saving the related BpmnBound objects too,
|
||||
// because methods: save(), fromArray(), toArray() are beautifully extended
|
||||
// of Activity, Event and Gateway classes ;) atte. @erik
|
||||
|
||||
switch ($element) {
|
||||
case 'laneset':
|
||||
@@ -614,6 +615,7 @@ class Model
|
||||
}
|
||||
}
|
||||
|
||||
return $uids;
|
||||
}
|
||||
|
||||
public function deleteProject($prjUid)
|
||||
@@ -905,5 +907,17 @@ class Model
|
||||
|
||||
return sha1($data);
|
||||
}
|
||||
|
||||
protected static function log()
|
||||
{
|
||||
if (System::isDebugMode()) {
|
||||
|
||||
$me = Logger::getInstance();
|
||||
$args = func_get_args();
|
||||
array_unshift($args, 'Class '.__CLASS__.': ');
|
||||
|
||||
call_user_func_array(array($me, 'setLog'), $args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Logger
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->logFile = sys_get_temp_dir() . '/processmaker.log';
|
||||
$this->logFile = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'processmaker.log';
|
||||
$this->fp = fopen($this->logFile, "a+");
|
||||
}
|
||||
|
||||
@@ -29,19 +29,25 @@ class Logger
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function setLog($data)
|
||||
public function setLog()
|
||||
{
|
||||
if (! is_string($data)) {
|
||||
$data = print_r($data, true);
|
||||
}
|
||||
$args = func_get_args();
|
||||
|
||||
fwrite($this->fp, "PM LOG: ".date('Y-m-d H:i:s') . " " . $data . PHP_EOL);
|
||||
foreach ($args as $arg) {
|
||||
if (! is_string($arg)) {
|
||||
$arg = print_r($arg, true);
|
||||
}
|
||||
|
||||
$stat = fwrite($this->fp, "- " . date('Y-m-d H:i:s') . " " . $arg . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
public static function log($data)
|
||||
public static function log()
|
||||
{
|
||||
$me = Logger::getInstance();
|
||||
$me->setLog($data);
|
||||
$args = func_get_args();
|
||||
|
||||
call_user_func_array(array($me, 'setLog'), $args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,17 @@ class Project extends Api
|
||||
}
|
||||
}
|
||||
|
||||
public function get($prjUid)
|
||||
{
|
||||
try {
|
||||
$project = BpmnModel::loadProject($prjUid);
|
||||
|
||||
return $project;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @status 201
|
||||
*/
|
||||
@@ -62,101 +73,13 @@ class Project extends Api
|
||||
}
|
||||
}
|
||||
|
||||
public function get($prjUid)
|
||||
{
|
||||
try {
|
||||
$project = BpmnModel::loadProject($prjUid);
|
||||
|
||||
return $project;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function put($prjUid, $request_data)
|
||||
{
|
||||
try {
|
||||
|
||||
$project = BpmnModel::updateProject($prjUid, $request_data);
|
||||
$result = BpmnModel::updateProject($prjUid, $request_data);
|
||||
|
||||
return $project;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function put22($prjUid, $request_data)
|
||||
{
|
||||
try {
|
||||
$project = BpmnModel::loadProject($prjUid);
|
||||
|
||||
|
||||
$projectUpdated = $project;
|
||||
$projectUpdated['diagrams'][0]['activities'][] = array(
|
||||
"act_uid" => "befd5b20508822592122970978652b05",
|
||||
"prj_uid" => "27289719452b05bef821d30070436486",
|
||||
"pro_uid" => "67771289152b05bef952892039062017",
|
||||
"act_name" => "Task # x",
|
||||
"act_type" => "TASK",
|
||||
"act_is_for_compensation" => 0,
|
||||
"act_start_quantity" => "1",
|
||||
"act_completion_quantity" => 0,
|
||||
"act_task_type" => "EMPTY",
|
||||
"act_implementation" => "",
|
||||
"act_instantiate" => 0,
|
||||
"act_script_type" => "",
|
||||
"act_script" => "",
|
||||
"act_loop_type" => "NONE",
|
||||
"act_test_before" => "",
|
||||
"act_loop_maximum" => 0,
|
||||
"act_loop_condition" => "",
|
||||
"act_loop_cardinality" => 0,
|
||||
"act_loop_behavior" => "",
|
||||
"act_is_adhoc" => 0,
|
||||
"act_is_collapsed" => 0,
|
||||
"act_completion_condition" => "",
|
||||
"act_ordering" => "",
|
||||
"act_cancel_remaining_instances" => 1,
|
||||
"act_protocol" => "",
|
||||
"act_method" =>"",
|
||||
"act_is_global" => 0,
|
||||
"act_referer" => "",
|
||||
"act_default_flow" => 0,
|
||||
"act_master_diagram" => "",
|
||||
"bou_uid" => "65717999352b05befddcaf6007443642",
|
||||
"dia_uid" => "12117099152b05bef8d4c66069408293",
|
||||
"element_uid" => "22970978652b05befd5b205088225921",
|
||||
"bou_element" => "pm_canvas",
|
||||
"bou_element_type" => "bpmnActivity",
|
||||
"bou_x" => 467,
|
||||
"bou_y" => 331,
|
||||
"bou_width" => 100,
|
||||
"bou_height" => 50,
|
||||
"bou_rel_position" => 0,
|
||||
"bou_size_identical" => 0,
|
||||
"bou_container" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
|
||||
|
||||
echo 'updated: ' . $projectUpdated['diagrams'][0]['activities'][0]['act_uid'] . PHP_EOL;
|
||||
echo 'deleted: ' . $projectUpdated['diagrams'][0]['activities'][1]['act_uid'] . PHP_EOL;
|
||||
echo 'deleted: ' . $projectUpdated['diagrams'][0]['events'][0]['evn_uid'] . PHP_EOL;
|
||||
echo 'deleted: ' . $projectUpdated['diagrams'][0]['events'][1]['evn_uid'] . PHP_EOL;
|
||||
|
||||
unset($projectUpdated['diagrams'][0]['activities'][1]);
|
||||
unset($projectUpdated['diagrams'][0]['events'][0]);
|
||||
unset($projectUpdated['diagrams'][0]['events'][1]);
|
||||
|
||||
$projectUpdated['diagrams'][0]['activities'][0]['act_name'] = 'changed name';
|
||||
|
||||
|
||||
$diff = \ProcessMaker\Adapter\Bpmn\Model::getDiffFromProjects($project, $projectUpdated);
|
||||
return $diff;
|
||||
|
||||
//$WorkflowProces = \ProcessMaker\Adapter\Workflow::loadFromBpmnProject($prjUid);
|
||||
//return $WorkflowProces;
|
||||
return $project;
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user