This commit is contained in:
Roly Rudy Gutierrez Pinto
2017-08-09 14:49:21 -04:00
parent 254a9bf7b1
commit 810eeb0c2d
5 changed files with 409 additions and 103 deletions

View File

@@ -329,6 +329,22 @@ CLI::taskOpt("lang", "", "lLANG", "lang=LANG");
CLI::taskArg('workspace');
CLI::taskRun("cliListIds");
/**
*
*/
CLI::taskName('regenerate-pmtable-classes');
CLI::taskDescription(<<<EOT
Regenerate the class with incorrect reference
This method recursively finds all PHP files that reference the path PATH_DATA
incorrectly, which is caused by importing processes where the data directory
of ProcessMaker has different routes. Modified files are backed up with the
extension '.backup' in the same directory.
EOT
);
CLI::taskArg('workspace');
CLI::taskRun("regenerate_pmtable_classes");
/**
* Function run_info
* access public
@@ -1081,3 +1097,31 @@ function run_migrate_indexing_acv($args, $opts) {
$stop = microtime(true);
CLI::logging("<*> Migrating and populating indexing for avoiding the use of table APP_CACHE_VIEW process took " . ($stop - $start) . " seconds.\n");
}
/**
* This method recursively finds all PHP files that reference the path PATH_DATA
* incorrectly, which is caused by importing processes where the data directory
* of ProcessMaker has different routes. Modified files are backed up with the
* extension '.backup' in the same directory.
*
* @param array $args
* @param array $opts
* @throws Exception
* @return void
*/
function regenerate_pmtable_classes($args, $opts)
{
if (sizeof($args) > 0) {
$start = microtime(true);
CLI::logging("> Updating generated class files for PM Tables...\n");
Bootstrap::setConstantsRelatedWs($args[0]);
$workspaceTools = new workspaceTools($args[0]);
$workspaceTools->fixReferencePathFiles(PATH_DATA_SITE . "classes", PATH_DATA);
$stop = microtime(true);
CLI::logging("<*> Updating generated class files for PM Tables took " . ($stop - $start) . " seconds.\n");
} else {
throw new Exception("No workspace specified for updating generated class files.");
}
}

View File

@@ -17,7 +17,7 @@ class ConsolidatedCases
$RepTabUid = $data['rep_uid'];
$TableName = $data['table_name'];
$Title = $data['title'];
if($this->isUpdateFields($data) && $Status) {
if ($this->isUpdateFields($data) && $Status) {
return true;
}
if ($this->existTable && $Status) {
@@ -26,14 +26,14 @@ class ConsolidatedCases
if ($RepTabUid != '') {
$this->deleteRepTab($RepTabUid, $Status, $TasUid, $TableName);
if(!$Status){
if (!$Status) {
return true;
}
$RepTabUid = '';
}
$_POST['form']['PRO_UID'] = $ProUid;
$_POST['form']['REP_TAB_UID'] = $RepTabUid;
$_POST['form']['REP_TAB_UID'] = $RepTabUid;
$_POST['form']['REP_TAB_NAME'] = $TableName;
$_POST['form']['REP_TAB_TYPE'] = "NORMAL";
$_POST['form']['REP_TAB_GRID'] = '';
@@ -43,7 +43,7 @@ class ConsolidatedCases
$_POST['form']['REP_TAB_TITLE'] = $Title;
$_POST['form']['FIELDS'] = array();
$sOldTableName = $_POST['form']['REP_TAB_NAME'];
$sOldTableName = $_POST['form']['REP_TAB_NAME'];
$sOldConnection = $_POST['form']['REP_TAB_CONNECTION'];
$_POST['form']['REP_TAB_UID'] = $this->createReportTable($_POST['form']);
@@ -174,7 +174,7 @@ class ConsolidatedCases
if ($this->existTableName) {
$diff = array_diff($data, $this->rowRepTab);
}
if ($this->existCaseConsolidate){
if ($this->existCaseConsolidate) {
$diff = array_diff($diff, $this->rowCaseConsCore);
}
return count($diff) <= 0;
@@ -213,9 +213,23 @@ class ConsolidatedCases
return $oReportTable->getRepTabUid();
}
public function createReportVariables($RepTabUid, $ProUid, $formFields)
public function createReportVariables($repTabUid, $proUid, $formFields)
{
list($fieldsClass, $fields) = $this->buildReportVariables($formFields, function ($repVarName, $repVarType) use ($repTabUid, $proUid) {
$reportVar = new ReportVar();
$reportVar->create(array(
'REP_TAB_UID' => $repTabUid,
'PRO_UID' => $proUid,
'REP_VAR_NAME' => $repVarName,
'REP_VAR_TYPE' => $repVarType)
);
});
return array($fieldsClass, $fields);
}
public function buildReportVariables($formFields, $callbackFunction = null)
{
$oReportVar = new ReportVar();
$fieldsClass = array();
$fields = array();
$i = 1;
@@ -224,7 +238,7 @@ class ConsolidatedCases
$fieldsClass[$i]['FLD_KEY'] = 'on';
$fieldsClass[$i]['FLD_AUTO_INCREMENT'] = 'off';
$fieldsClass[$i]['FLD_DESCRIPTION'] = '';
$fieldsClass[$i]['FLD_TYPE'] = 'VARCHAR' ;
$fieldsClass[$i]['FLD_TYPE'] = 'VARCHAR';
$fieldsClass[$i]['FLD_SIZE'] = 32;
$i++;
$fieldsClass[$i]['FLD_NAME'] = 'APP_NUMBER';
@@ -232,26 +246,26 @@ class ConsolidatedCases
$fieldsClass[$i]['FLD_KEY'] = 'on';
$fieldsClass[$i]['FLD_AUTO_INCREMENT'] = 'off';
$fieldsClass[$i]['FLD_DESCRIPTION'] = '';
$fieldsClass[$i]['FLD_TYPE'] = 'VARCHAR' ;
$fieldsClass[$i]['FLD_TYPE'] = 'VARCHAR';
$fieldsClass[$i]['FLD_SIZE'] = 255;
foreach ($formFields as $sField) {
$aField = explode('-', $sField);
if ($aField[1] == 'title' || $aField[1] == 'submit') {
foreach ($formFields as $field) {
$fieldProperty = explode('-', $field);
if ($fieldProperty[1] == 'title' || $fieldProperty[1] == 'submit') {
continue;
}
$i++;
$fieldsClass[$i]['FLD_NAME'] = $aField[0];
$fieldsClass[$i]['FLD_NAME'] = $fieldProperty[0];
$fieldsClass[$i]['FLD_NULL'] = 'off';
$fieldsClass[$i]['FLD_KEY'] = 'off';
$fieldsClass[$i]['FLD_AUTO_INCREMENT'] = 'off';
$fieldsClass[$i]['FLD_DESCRIPTION'] = '';
switch ($aField[1]) {
switch ($fieldProperty[1]) {
case 'currency':
case 'percentage':
$sType = 'number';
$fieldsClass[$i]['FLD_TYPE'] = 'FLOAT' ;
$type = 'number';
$fieldsClass[$i]['FLD_TYPE'] = 'FLOAT';
$fieldsClass[$i]['FLD_SIZE'] = 255;
break;
case 'text':
@@ -262,34 +276,32 @@ class ConsolidatedCases
case 'radiogroup':
case 'hidden':
case "link":
$sType = 'char';
$fieldsClass[$i]['FLD_TYPE'] = 'VARCHAR' ;
$type = 'char';
$fieldsClass[$i]['FLD_TYPE'] = 'VARCHAR';
$fieldsClass[$i]['FLD_SIZE'] = 255;
break;
case 'textarea':
$sType = 'text';
$fieldsClass[$i]['FLD_TYPE'] = 'TEXT' ;
$type = 'text';
$fieldsClass[$i]['FLD_TYPE'] = 'TEXT';
$fieldsClass[$i]['FLD_SIZE'] = '';
break;
case 'date':
$sType = 'date';
$fieldsClass[$i]['FLD_TYPE'] = 'DATE' ;
$type = 'date';
$fieldsClass[$i]['FLD_TYPE'] = 'DATE';
$fieldsClass[$i]['FLD_SIZE'] = '';
break;
default:
$sType = 'char';
$fieldsClass[$i]['FLD_TYPE'] = 'VARCHAR' ;
$type = 'char';
$fieldsClass[$i]['FLD_TYPE'] = 'VARCHAR';
$fieldsClass[$i]['FLD_SIZE'] = 255;
break;
}
$oReportVar->create(array(
'REP_TAB_UID' => $RepTabUid,
'PRO_UID' => $ProUid,
'REP_VAR_NAME' => $aField[0],
'REP_VAR_TYPE' => $sType)
);
$fields[] = array('sFieldName' => $aField[0], 'sType' => $sType);
if (!empty($callbackFunction) && is_callable($callbackFunction)) {
$callbackFunction($fieldProperty[0], $type);
}
$fields[] = array('sFieldName' => $fieldProperty[0], 'sType' => $type);
}
return array($fieldsClass, $fields);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,172 @@
<?php
namespace ProcessMaker\Util;
/**
* This class regenerates the 'Propel' classes that are necessary for the
* administration of a 'Report Table', this is caused by the import of processes
* where the data directory of ProcessMaker has different routes.
*/
class FixReferencePath
{
private $modeDebug = false;
private $resumeDebug = "";
/**
* Get property modeDebug.
*
* @return boolean
*/
public function getModeDebug()
{
return $this->modeDebug;
}
/**
* Set property modeDebug.
*
* @param boolean $modeDebug
*/
public function setModeDebug($modeDebug)
{
$this->modeDebug = $modeDebug;
}
/**
* Get property resumeDebug.
*
* @return string
*/
public function getResumeDebug()
{
return $this->resumeDebug;
}
/**
* Set property resumeDebug.
*
* @param string $resumeDebug
*/
public function setResumeDebug($resumeDebug)
{
$this->resumeDebug = $resumeDebug;
}
/**
* Find all PHP type files recursively.
* The '$pathData' argument is the path to be replaced with the path found
* as incorrect.
*
* @param string $directory
* @param string $pathData
* @return void
*/
public function runProcess($directory, $pathData)
{
try {
//This variable is not defined and does not involve its value in this
//task, it is removed at the end of the method.
$_SERVER["REQUEST_URI"] = "";
if (!defined("SYS_SKIN")) {
$conf = new \Configurations();
define("SYS_SKIN", $conf->getConfiguration('SKIN_CRON', ''));
}
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\ReportTablePeer::REP_TAB_UID);
$criteria->addSelectColumn(\CaseConsolidatedCorePeer::TAS_UID);
$criteria->addSelectColumn(\ReportTablePeer::REP_TAB_NAME);
$criteria->addJoin(\ReportTablePeer::REP_TAB_UID, \CaseConsolidatedCorePeer::REP_TAB_UID, \Criteria::JOIN);
$criteria->add(\CaseConsolidatedCorePeer::CON_STATUS, "ACTIVE", \Criteria::EQUAL);
$doSelect = \ReportTablePeer::doSelectRS($criteria);
$doSelect->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($doSelect->next()) {
$row = $doSelect->getRow();
$fields = $this->getReportTableFields($row["REP_TAB_UID"]);
$this->regeneratePropelClasses($row["REP_TAB_NAME"], $fields, $row["TAS_UID"]);
$this->outVerboseln("* Regenerate classes for table: " . $row["REP_TAB_NAME"]);
}
unset($_SERVER["REQUEST_URI"]);
} catch (Exception $e) {
CLI::logging(CLI::error("Error:" . "Error in updating consolidated files, proceed to regenerate manually: " . $e));
}
}
/**
* Gets the fields of the 'Report Table'.
*
* @param string $repTabUid
* @return array
*/
public function getReportTableFields($repTabUid)
{
$fields = array();
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\ReportVarPeer::REP_VAR_NAME);
$criteria->addSelectColumn(\ReportVarPeer::REP_VAR_TYPE);
$criteria->add(\ReportVarPeer::REP_TAB_UID, $repTabUid, \Criteria::EQUAL);
$doSelect = \ReportVarPeer::doSelectRS($criteria);
$doSelect->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
while ($doSelect->next()) {
$row = $doSelect->getRow();
$fields[] = $row['REP_VAR_NAME'] . '-' . $row['REP_VAR_TYPE'];
}
return $fields;
}
/**
* Regenerate 'Propel' classes for 'Report Tables'. The name of the 'Report Table',
* the fields and the related task are required.
*
* @param string $repTabName
* @param array $fields
* @param string $guid
* @return void
*/
public function regeneratePropelClasses($repTabName, $fields, $guid)
{
$consolidatedCases = new \ConsolidatedCases();
list($outFieldsClass, $outFields) = $consolidatedCases->buildReportVariables($fields);
$className = $repTabName;
$sourcePath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
@unlink($sourcePath . $className . '.php');
@unlink($sourcePath . $className . 'Peer.php');
@unlink($sourcePath . PATH_SEP . 'map' . PATH_SEP . $className . 'MapBuilder.php');
@unlink($sourcePath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $className . '.php');
@unlink($sourcePath . PATH_SEP . 'om' . PATH_SEP . 'Base' . $className . 'Peer.php');
$additionalTables = new \AdditionalTables();
$additionalTables->createPropelClasses($repTabName, $className, $outFieldsClass, $guid);
}
/**
* Display the output found, the message is not displayed if the value of the
* 'modeVerbose' property is false.
*
* @param string $message
* @return void
*/
private function outVerbose($message)
{
$this->resumeDebug = $this->resumeDebug . $message;
if ($this->modeDebug === true) {
echo $message;
}
}
/**
* Shows on the screen the output found with line break.
*
* @param string $message
* @return void
*/
private function outVerboseln($message)
{
$this->outVerbose($message . "\n");
}
}

View File

@@ -2130,3 +2130,47 @@ Ext.onReady(function() {
}
});
var te = new Ext.tree.TreeEditor(
treepanelmain,
new Ext.form.TextField({
allowBlank: false,
blankText: 'A text is required'//,
// validator: function (value) {
// console.log('validator');
// },
// listeners: {
// change: function (f, neval, olval) {
// console.log('change');
// //f.setValue(Ext.util.Format.htmlEncode(neval));
// },
// valid: function (f, neval, olval) {
// console.log('valid');
// }
// },
// renderer:myrender
}), {
// editDelay: 100,
// revertInvalid: false,
listeners:{
complete:function(){
console.log("okokoko111");
},
destroy:function(){
console.log("my removido124314234");
}
},
renderer:myrender
});
var myrender = function(value){
return "<div>"+value+"5345345345</div>";
};
Ext.override(Ext.form.field.Base, {
setValue: function(val) {
console.log("holal");
val = Ext.util.Format.htmlDecode(val);
return this.callParent([val]);
}
});