/** * Method to save record in database * @param $projectData * @return bool */ public function saveProjectData($projectData) { $source_definition = json_decode($projectData['rst_source_definition']); if (isset($projectData[$this->suffix . 'name']) && !empty($projectData[$this->suffix . 'name'])) { $name = $this->getNameWithSuffix($projectData[$this->suffix . 'name']); } else { $name = $this->getNameWithSuffix($projectData[$this->name]); } $projectData['rst_uid'] = PMSEEngineUtils::generateUniqueID(); $source_definition->name = $name; $source_definition->id = $projectData['rst_uid']; $projectData['rst_source_definition'] = json_encode($source_definition); unset($projectData[$this->id]); unset($projectData['rst_uid']); $new_uid = parent::saveProjectData($projectData); if ($new_uid) { // Update new id into 'rst_source_definition' field $br_bean = BeanFactory::getBean('pmse_Business_Rules', $new_uid); $def = json_decode($br_bean->rst_source_definition); $def->id = $new_uid; $br_bean->rst_source_definition = json_encode($def); $br_bean->save(); return $new_uid; } else { return false; } }
protected function updateBean(SugarBean $bean, ServiceBase $api, $args) { $id = parent::updateBean($bean, $api, $args); //retrieve a Bean created if (isset($args['record']) && !empty($args['record'])) { $projectBean = BeanFactory::retrieveBean($args['module'], $args['record']); } else { $projectBean = $bean; } //Create a Diagram row $diagramBean = BeanFactory::getBean('pmse_BpmnDiagram')->retrieve_by_string_fields(array('prj_id' => $id)); if (empty($diagramBean)) { $diagramBean = BeanFactory::newBean('pmse_BpmnDiagram'); $diagramBean->dia_uid = PMSEEngineUtils::generateUniqueID(); } $diagramBean->name = $projectBean->name; $diagramBean->description = $projectBean->description; $diagramBean->assigned_user_id = $projectBean->assigned_user_id; $diagramBean->prj_id = $id; $dia_id = $diagramBean->save(); //Create a Process row $processBean = BeanFactory::getBean('pmse_BpmnProcess')->retrieve_by_string_fields(array('prj_id' => $id)); if (empty($processBean)) { $processBean = BeanFactory::newBean('pmse_BpmnProcess'); $processBean->pro_uid = PMSEEngineUtils::generateUniqueID(); } $processBean->name = $projectBean->name; $processBean->description = $projectBean->description; $processBean->assigned_user_id = $projectBean->assigned_user_id; $processBean->prj_id = $id; $processBean->dia_id = $dia_id; $pro_id = $processBean->save(); //Create a ProcessDefinition row $processDefinitionBean = BeanFactory::getBean('pmse_BpmProcessDefinition')->retrieve_by_string_fields(array('prj_id' => $id)); if (empty($processDefinitionBean)) { $processDefinitionBean = BeanFactory::newBean('pmse_BpmProcessDefinition'); $processDefinitionBean->id = $pro_id; $processDefinitionBean->new_with_id = true; } $processDefinitionBean->prj_id = $id; $processDefinitionBean->pro_module = $projectBean->prj_module; $processDefinitionBean->pro_status = $projectBean->prj_status; $processDefinitionBean->assigned_user_id = $projectBean->assigned_user_id; $processDefinitionBean->save(); $relDepStatus = $projectBean->prj_status == 'ACTIVE' ? 'INACTIVE' : 'ACTIVE'; while ($relatedDepBean = BeanFactory::getBean('pmse_BpmRelatedDependency')->retrieve_by_string_fields(array('prj_id' => $id, 'pro_status' => $relDepStatus))) { $relatedDepBean->pro_status = $projectBean->prj_status; $relatedDepBean->save(); } $keysArray = array('prj_id' => $id, 'pro_id' => $pro_id); $dynaF = BeanFactory::getBean('pmse_BpmDynaForm')->retrieve_by_string_fields(array('prj_id' => $id, 'pro_id' => $pro_id, 'name' => 'Default')); if (empty($dynaF)) { $editDyna = false; } else { $editDyna = true; } $dynaForm = new PMSEDynaForm(); $dynaForm->generateDefaultDynaform($processDefinitionBean->pro_module, $keysArray, $editDyna); return $id; }
/** * Process the content of a license string. * @param string $lic * @return \stdClass */ public function processLicense($lic) { $result = new stdClass(); $result->success = false; $key = blowfishGetKey('ProcessMaker'); // $lic = preg_replace('/\n|\r\n/', '', $lic); // print_r($lic); try { $license = json_decode($this->crypt->openLicense($key, $lic)); } catch (Exception $e) { $result->message = $e->getMessage(); return $result; } if (empty($license)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_NOTVALID', $this->moduleName); return $result; } else { if (!isset($license->lic_activation_code)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_ACTIVATIONCODEMISSING' . $this->moduleName); return $result; } } //Verify if activationCode exist in DB $rs = $this->amBean->retrieve_by_string_fields(array('acm_key' => $license->lic_activation_code)); if (empty($rs)) { $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_ALREADYINSTALLED', $this->moduleName); return $result; } $sql = "UPDATE pmse_ bpm_access_management SET acm_status = 'INACTIVE'"; $GLOBALS["db"]->query($sql); //Insert into DataBase $this->amBean->new_with_id = true; $this->amBean->acm_key = $license->lic_activation_code; $this->amBean->acm_type = $license->lic_type; $this->amBean->acm_status = 'ACTIVE'; //$license->lic_status; $this->amBean->acm_expiration_date = date("Y-m-d H:i:s", strtotime($license->lic_product_expiration_date)); $this->amBean->acm_data = $lic; $this->amBean->acm_uid = PMSEEngineUtils::generateUniqueID(); $this->amBean->save(); if (!$this->amBean->in_save) { $result->success = true; $result->message = translate('LBL_PMSE_ADAM_LICENSEMANAGER_MESSAGE_INSTALLSUCCESSFULLY', $this->moduleName); } return $result; }
/** * Save the project elements data. * @param $elementsData * @param $keysArray * @param $beanType * @param bool $generateBound * @param bool $generateWithId * @param string $field_uid */ public function saveProjectElementsData($elementsData, $keysArray, $beanType, $generateBound = false, $generateWithId = false, $field_uid = '') { foreach ($elementsData as $element) { $boundBean = BeanFactory::getBean('pmse_BpmnBound'); $elementBean = BeanFactory::getBean($beanType); $element['prj_id'] = $keysArray['prj_id']; $element['pro_id'] = $keysArray['pro_id']; $element['dia_id'] = $keysArray['dia_id']; foreach ($element as $key => $value) { if (strpos($key, '_name') !== false) { $elementBean->name = $value; } else { $elementBean->{$key} = $value; } if ($generateBound) { $boundBean->{$key} = $value; } if (strpos($key, '_uid') !== false) { $uid = $key; } } $savedId = $elementBean->save(); if (!empty($savedId)) { $this->savedElements[$beanType][$elementBean->{$uid}] = $savedId; } if (!empty($field_uid)) { $elementBean->{$field_uid} = PMSEEngineUtils::generateUniqueID(); } if ($generateBound) { switch ($beanType) { case 'pmse_BpmnArtifact': $element_type = 'bpmnArtifact'; break; default: $element_type = ''; } $boundBean->bou_uid = PMSEEngineUtils::generateUniqueID(); $boundBean->dia_id = $keysArray['dia_id']; $boundBean->element_id = $keysArray['dia_id']; $boundBean->bou_element_type = $element_type; $boundBean->bou_element = $savedId; $boundBean->save(); } } }
/** * Generates a default dynaform based in the base module name. * @param string $baseModule * @param array $keys * @param boolean $update * @return boolean */ public function generateDefaultDynaform($baseModule, $keys, $update = false) { $this->baseModule = $baseModule; $params = array(); if ($update) { $this->dynaform->retrieve_by_string_fields(array('prj_id' => $keys['prj_id'], 'pro_id' => $keys['pro_id'], 'name' => 'Default')); } else { $params['dyn_uid'] = PMSEEngineUtils::generateUniqueID(); } $params['name'] = 'Default'; $params['description'] = 'Default'; $params['prj_id'] = isset($keys['prj_id']) ? $keys['prj_id'] : null; $params['pro_id'] = isset($keys['pro_id']) ? $keys['prj_id'] : null; $params['dyn_module'] = $this->baseModule; $params['dyn_name'] = "Default"; $params['dyn_description'] = "Default"; $moduleViewDefs = get_custom_file_if_exists('modules/' . $baseModule . '/metadata/editviewdefs.php'); $viewdefs = array(); if (!@(include_once $moduleViewDefs)) { return false; } else { $params['dyn_view_defs'] = array('BpmView' => $viewdefs[$baseModule]['EditView']); return $this->saveDynaform($baseModule, $params); } }