BUG 11510 Números de casos duplicados SOLVED
- Al parecer existe un problema de concurrencia al crear los casos en processmaker, de tal forma que si se intenta crear 2 casos al mismo tiempo el número del caso termina siendo el mismo para ambos casos. - Centralized incrementing of the sequence of the cases of the application.
This commit is contained in:
@@ -375,20 +375,11 @@ class Application extends BaseApplication
|
|||||||
$oSequences = new Sequences();
|
$oSequences = new Sequences();
|
||||||
$oSequences->lockSequenceTable();
|
$oSequences->lockSequenceTable();
|
||||||
|
|
||||||
if ($oSequences->nameExists("APP_NUMBER") ) {
|
$maxNumber = $oSequences->getSequeceNumber("APP_NUMBER");
|
||||||
$maxNumber = $oSequences->getSequeceNumber("APP_NUMBER");
|
|
||||||
} else {
|
|
||||||
$c->addSelectColumn('MAX(' . ApplicationPeer::APP_NUMBER . ')'); //the appnumber is based in all processes
|
|
||||||
//active, not only in the specified
|
|
||||||
//process guid
|
|
||||||
$result = ApplicationPeer::doSelectRS($c);
|
|
||||||
$result->next();
|
|
||||||
$row = $result->getRow();
|
|
||||||
$maxNumber = $row[0] + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->setAppNumber($maxNumber);
|
$this->setAppNumber($maxNumber);
|
||||||
$oSequences->changeSequence('APP_NUMBER', $maxNumber);
|
$oSequences->changeSequence('APP_NUMBER', $maxNumber);
|
||||||
|
$oSequences->unlockSequenceTable();
|
||||||
|
|
||||||
if ($this->validate()) {
|
if ($this->validate()) {
|
||||||
$con->begin();
|
$con->begin();
|
||||||
@@ -403,7 +394,6 @@ class Application extends BaseApplication
|
|||||||
|
|
||||||
$con->commit();
|
$con->commit();
|
||||||
|
|
||||||
$oSequences->unlockSequenceTable();
|
|
||||||
return $this->getAppUid();
|
return $this->getAppUid();
|
||||||
} else {
|
} else {
|
||||||
$msg = '';
|
$msg = '';
|
||||||
@@ -411,7 +401,6 @@ class Application extends BaseApplication
|
|||||||
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
foreach ($this->getValidationFailures() as $objValidationFailure) {
|
||||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||||
}
|
}
|
||||||
$oSequences->unlockSequenceTable();
|
|
||||||
|
|
||||||
throw (new PropelException('The APPLICATION row cannot be created!', new PropelException($msg)));
|
throw (new PropelException('The APPLICATION row cannot be created!', new PropelException($msg)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -215,9 +215,22 @@ class Sequences extends BaseSequences {
|
|||||||
*/
|
*/
|
||||||
public function getSequeceNumber($seqName)
|
public function getSequeceNumber($seqName)
|
||||||
{
|
{
|
||||||
|
$c = new Criteria();
|
||||||
|
$c->clearSelectColumns();
|
||||||
try {
|
try {
|
||||||
$aSequence = $this->load($seqName);
|
|
||||||
$nSeqValue = ($aSequence['SEQ_VALUE'] + 1);
|
if ($this->nameExists("APP_NUMBER") ) {
|
||||||
|
$aSequence = $this->load($seqName);
|
||||||
|
$nSeqValue = ($aSequence['SEQ_VALUE'] + 1);
|
||||||
|
} else {
|
||||||
|
$c->addSelectColumn('MAX(' . ApplicationPeer::APP_NUMBER . ')'); //the appnumber is based in all processes
|
||||||
|
//active, not only in the specified
|
||||||
|
//process guid
|
||||||
|
$result = ApplicationPeer::doSelectRS($c);
|
||||||
|
$result->next();
|
||||||
|
$row = $result->getRow();
|
||||||
|
$nSeqValue = $row[0] + 1;
|
||||||
|
}
|
||||||
|
|
||||||
return $nSeqValue;
|
return $nSeqValue;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user