Adding merge support for the Process Definition, Variables, Dynaforms, Input and output documents.
This commit is contained in:
@@ -1180,14 +1180,6 @@ class Processes
|
||||
return $oProcess->createRow( $row );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $row
|
||||
*/
|
||||
public function updateProcessDefinitionRow ($row)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a Process register in DB, if the process doesn't exist with the same
|
||||
* uid of the $row['PRO_UID'] parameter the function creates a new one based
|
||||
@@ -1830,7 +1822,19 @@ class Processes
|
||||
*/
|
||||
public function updateProcessVariables($arrayData)
|
||||
{
|
||||
|
||||
try {
|
||||
foreach ($arrayData as $value) {
|
||||
$processVariables = new ProcessVariables();
|
||||
$record = $value;
|
||||
if ($processVariables->Exists($record["VAR_UID"])) {
|
||||
$processVariables->up($record);
|
||||
} else {
|
||||
$processVariables->create($record);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1885,7 +1889,15 @@ class Processes
|
||||
*/
|
||||
public function updateInputRows ($aInput)
|
||||
{
|
||||
|
||||
foreach ($aInput as $key => $row) {
|
||||
$oInput = new InputDocument();
|
||||
if ($oInput->InputExists( $row['INP_DOC_UID'] )) {
|
||||
$oInput->update( $row );
|
||||
} else {
|
||||
$oInput->create($row);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1993,7 +2005,16 @@ class Processes
|
||||
*/
|
||||
public function updateOutputRows ($aOutput)
|
||||
{
|
||||
|
||||
foreach ($aOutput as $key => $row) {
|
||||
$oOutput = new OutputDocument();
|
||||
//unset ($row['TAS_UID']);
|
||||
if (!$oOutput->OutputExists( $row['OUT_DOC_UID'] )) {
|
||||
$oOutput->update( $row );
|
||||
} else {
|
||||
$oOutput->create( $row );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2733,7 +2754,17 @@ class Processes
|
||||
*/
|
||||
public function updateDynaformRows ($aDynaform)
|
||||
{
|
||||
foreach ($aDynaform as $key => $row) {
|
||||
$oDynaform = new Dynaform();
|
||||
//unset ($row['TAS_UID']);
|
||||
if (!$oDynaform->exists( $row['DYN_UID'] )) {
|
||||
$res = $oDynaform->update( $row );
|
||||
} else {
|
||||
$res = $oDynaform->create( $row );
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,6 +20,7 @@ class ProcessVariables extends BaseProcessVariables {
|
||||
{
|
||||
$con = Propel::getConnection( ProcessVariablesPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$this->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
@@ -36,6 +37,28 @@ class ProcessVariables extends BaseProcessVariables {
|
||||
}
|
||||
}
|
||||
|
||||
public function update ($aData)
|
||||
{
|
||||
$con = Propel::getConnection( ProcessVariablesPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
$variable = ProcessVariablesPeer::retrieveByPK($aData['VAR_UID']);
|
||||
$variable->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
|
||||
if ($variable->validate()) {
|
||||
$result = $variable->save();
|
||||
} else {
|
||||
$e = new Exception( "Failed Validation in class " . get_class( $variable ) . "." );
|
||||
$e->aValidationFailures = $variable->getValidationFailures();
|
||||
throw ($e);
|
||||
}
|
||||
$con->commit();
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove($sVarUid)
|
||||
{
|
||||
$oConnection = Propel::getConnection(ProcessVariablesPeer::DATABASE_NAME);
|
||||
|
||||
@@ -5,6 +5,6 @@ namespace ProcessMaker\BusinessModel\Migrator;
|
||||
interface Importable
|
||||
{
|
||||
public function beforeImport($data);
|
||||
public function import($data);
|
||||
public function import($data, $replace);
|
||||
public function afterImport($data);
|
||||
}
|
||||
|
||||
@@ -30,10 +30,14 @@ class ProcessDefinitionMigrator implements Importable, Exportable
|
||||
// TODO: Implement beforeImport() method.
|
||||
}
|
||||
|
||||
public function import($data)
|
||||
public function import($data, $replace)
|
||||
{
|
||||
try {
|
||||
$this->bpmn->createFromStruct($data, false);
|
||||
if ($replace) {
|
||||
$this->bpmn->createFromStruct($data, false);
|
||||
} else {
|
||||
$this->bpmn->updateFromStruct($data['PRJ_UID'], $data, false);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -32,10 +32,14 @@ class VariablesMigrator implements Importable, Exportable
|
||||
* Imports the process variables
|
||||
* @param $data
|
||||
*/
|
||||
public function import($data)
|
||||
public function import($data, $replace)
|
||||
{
|
||||
try {
|
||||
$this->processes->createProcessVariables($data);
|
||||
if ($replace) {
|
||||
$this->processes->createProcessVariables($data);
|
||||
} else {
|
||||
$this->processes->updateProcessVariables($data);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
\Logger::log($e->getMessage());
|
||||
throw new ImportException($e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user