This commit is contained in:
Paula Quispe
2018-08-09 15:33:42 -04:00
parent 4f619588e8
commit 922c13a4d1
2 changed files with 63 additions and 46 deletions

View File

@@ -3083,32 +3083,37 @@ class Processes
/** /**
* Get Groupwf Rows for a Process form an array * Get Groupwf Rows for a Process form an array
* *
* @param array $aGroups * @param array $groups
* @return array $aGroupwf *
* @return array $groupList
* @throws Exception
*/ */
public function getGroupwfRows($aGroups) public function getGroupwfRows($groups)
{ {
try { try {
$aInGroups = array(); $inGroups = [];
foreach ($aGroups as $key => $val) { foreach ($groups as $key => $val) {
$aInGroups[] = $val['USR_UID']; $inGroups[] = $val['USR_UID'];
} }
$aGroupwf = array(); $groupList = [];
$oCriteria = new Criteria('workflow'); $criteria = new Criteria('workflow');
$oCriteria->add(GroupwfPeer::GRP_UID, $aInGroups, Criteria::IN); $criteria->add(GroupwfPeer::GRP_UID, $inGroups, Criteria::IN);
$oDataset = GroupwfPeer::doSelectRS($oCriteria); $dataset = GroupwfPeer::doSelectRS($criteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next(); $dataset->next();
while ($aRow = $oDataset->getRow()) { while ($row = $dataset->getRow()) {
$oGroupwf = new Groupwf(); $groupWf = new Groupwf();
$aGroupwf[] = $oGroupwf->Load($aRow['GRP_UID']); $infoGroup = $groupWf->Load($row['GRP_UID']);
$oDataset->next(); unset($infoGroup['GRP_ID']);
$groupList[] = $infoGroup;
$dataset->next();
} }
return $aGroupwf; return $groupList;
} catch (Exception $oError) { } catch (Exception $error) {
throw ($oError); throw ($error);
} }
} }
@@ -3783,19 +3788,24 @@ class Processes
} }
/** /**
* Get Task User Rows from an array of data * Get Task User rows from an array of data
* *
* @param array $aTaskUser * @param array $group
* @return array $aStepTrigger * @return array $aStepTrigger
*/ */
public function createGroupRow($aGroupwf) public function createGroupRow($group)
{ {
foreach ($aGroupwf as $key => $row) { foreach ($group as $key => $row) {
$oGroupwf = new Groupwf(); $groupWf = new Groupwf();
if ($oGroupwf->GroupwfExists($row['GRP_UID'])) { if ($groupWf->GroupwfExists($row['GRP_UID'])) {
$oGroupwf->remove($row['GRP_UID']); $groupInfo = $groupWf->Load($row['GRP_UID']);
$groupWf->remove($row['GRP_UID']);
} }
$res = $oGroupwf->create($row); //We will to keep the GRP_ID
if (!empty($groupInfo['GRP_ID'])) {
$row['GRP_ID'] = $groupInfo['GRP_ID'];
}
$res = $groupWf->create($row);
} }
} }

View File

@@ -72,47 +72,54 @@ class Groupwf extends BaseGroupwf
/** /**
* Creates the Group * Creates the Group
* *
* @param array $aData $oData is not necessary * @param array $data is not necessary
*
* @return void * @return void
*
* @throws Exception
*/ */
public function create ($aData) public function create($data)
{ {
//$oData is not necessary //$oData is not necessary
$con = Propel::getConnection( GroupwfPeer::DATABASE_NAME ); $con = Propel::getConnection(GroupwfPeer::DATABASE_NAME);
try { try {
if (isset( $aData['GRP_UID'] )) { if (!empty($data['GRP_UID'])) {
$this->setGrpUid( $aData['GRP_UID'] ); $this->setGrpUid($data['GRP_UID']);
} else { } else {
$this->setGrpUid( G::generateUniqueID() ); $this->setGrpUid(G::generateUniqueID());
}
if(!empty($data['GRP_ID'])){
$this->setGrpId($data['GRP_ID']);
} }
if (isset( $aData['GRP_TITLE'] )) { if (!empty($data['GRP_TITLE'])) {
$this->setGrpTitle( $aData['GRP_TITLE'] ); $this->setGrpTitle($data['GRP_TITLE']);
} else { } else {
$this->setGrpTitle( 'Default Group Title' ); $this->setGrpTitle('Default Group Title');
} }
if (isset( $aData['GRP_STATUS'] )) { if (!empty($aData['GRP_STATUS'])) {
$this->setGrpStatus( $aData['GRP_STATUS'] ); $this->setGrpStatus($data['GRP_STATUS']);
} else { } else {
$this->setGrpStatus( 'ACTIVE' ); $this->setGrpStatus('ACTIVE');
} }
if (isset( $aData['GRP_LDAP_DN'] )) { if (!empty($aData['GRP_LDAP_DN'])) {
$this->setGrpLdapDn( $aData['GRP_LDAP_DN'] ); $this->setGrpLdapDn($data['GRP_LDAP_DN']);
} else { } else {
$this->setGrpLdapDn( '' ); $this->setGrpLdapDn('');
} }
if ($this->validate()) { if ($this->validate()) {
$con->begin(); $con->begin();
if (isset( $aData['GRP_TITLE'] )) { if (!empty($data['GRP_TITLE'])) {
$this->setGrpTitleContent( $aData['GRP_TITLE'] ); $this->setGrpTitleContent($data['GRP_TITLE']);
} else { } else {
$this->setGrpTitleContent( 'Default Group Title' ); $this->setGrpTitleContent('Default Group Title');
} }
$res = $this->save(); $res = $this->save();
$con->commit(); $con->commit();
return $this->getGrpUid(); return $this->getGrpUid();
} else { } else {
$msg = ''; $msg = '';
@@ -120,7 +127,7 @@ class Groupwf extends BaseGroupwf
$msg .= $objValidationFailure->getMessage() . "<br/>"; $msg .= $objValidationFailure->getMessage() . "<br/>";
} }
throw (new PropelException( 'The row cannot be created!', new PropelException( $msg ) )); throw (new PropelException('The row cannot be created!', new PropelException($msg)));
} }
} catch (Exception $e) { } catch (Exception $e) {