Ejemplo n.º 1
0
 function loadByCategoryName($sCategoryName)
 {
     $c = new Criteria('workflow');
     $del = DBAdapter::getStringDelimiter();
     $c->clearSelectColumns();
     $c->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID);
     $c->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
     $c->add(ProcessCategoryPeer::CATEGORY_NAME, $sCategoryName);
     $dataset = ProcessCategoryPeer::doSelectRS($c);
     $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $dataset->next();
     $aRow = $dataset->getRow();
     return $aRow;
 }
Ejemplo n.º 2
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $categoryUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($categoryUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID);
             $criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_PARENT);
             $criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
             $criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_ICON);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = ProcessCategoryPeer::retrieveByPK($categoryUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table ProcessCategory ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
Ejemplo n.º 3
0
 function getCategoryArray()
 {
     global $oAppCache;
     require_once 'classes/model/ProcessCategory.php';
     $category[] = array("", G::LoadTranslation("ID_ALL_CATEGORIES"));
     $criteria = new Criteria('workflow');
     $criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_UID);
     $criteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
     $dataset = ProcessCategoryPeer::doSelectRS($criteria);
     $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $dataset->next();
     while ($row = $dataset->getRow()) {
         $category[] = array($row['CATEGORY_UID'], $row['CATEGORY_NAME']);
         $dataset->next();
     }
     return $category;
 }
Ejemplo n.º 4
0
 /**
  * creates an Application row
  *
  * @param array $aData
  * @return variant
  *
  */
 public function createRow($aData)
 {
     $con = Propel::getConnection(ProcessPeer::DATABASE_NAME);
     //$con->begin(); //does not allow dual BEGIN
     $this->setProUid($aData['PRO_UID']);
     $this->setProParent($aData['PRO_PARENT']);
     $this->setProTime($aData['PRO_TIME']);
     $this->setProTimeunit($aData['PRO_TIMEUNIT']);
     $this->setProStatus($aData['PRO_STATUS']);
     $this->setProTypeDay($aData['PRO_TYPE_DAY']);
     $this->setProType($aData['PRO_TYPE']);
     $this->setProAssignment($aData['PRO_ASSIGNMENT']);
     $this->setProShowMap($aData['PRO_SHOW_MAP']);
     $this->setProShowMessage($aData['PRO_SHOW_MESSAGE']);
     $this->setProSubprocess(isset($aData['PRO_SUBPROCESS']) ? $aData['PRO_SUBPROCESS'] : '');
     $this->setProTriDeleted(isset($aData['PRO_TRI_DELETED']) ? $aData['PRO_TRI_DELETED'] : '');
     $this->setProTriCanceled(isset($aData['PRO_TRI_CANCELED']) ? $aData['PRO_TRI_CANCELED'] : '');
     $this->setProTriPaused(isset($aData['PRO_TRI_PAUSED']) ? $aData['PRO_TRI_PAUSED'] : '');
     $this->setProTriReassigned(isset($aData['PRO_TRI_REASSIGNED']) ? $aData['PRO_TRI_REASSIGNED'] : '');
     $this->setProTriUnpaused(isset($aData['PRO_TRI_UNPAUSED']) ? $aData['PRO_TRI_UNPAUSED'] : '');
     $this->setProShowDelegate($aData['PRO_SHOW_DELEGATE']);
     $this->setProShowDynaform($aData['PRO_SHOW_DYNAFORM']);
     $this->setProDerivationScreenTpl(isset($aData['PRO_DERIVATION_SCREEN_TPL']) ? $aData['PRO_DERIVATION_SCREEN_TPL'] : '');
     // validate if the category exists
     $criteria = new Criteria('workflow');
     $criteria->add(ProcessCategoryPeer::CATEGORY_UID, $aData['PRO_CATEGORY']);
     $ds = ProcessCategoryPeer::doSelectRS($criteria, Propel::getDbConnection('workflow_ro'));
     $ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $ds->next();
     // if it is not set, set value as empty "No Category"
     if (!$ds->getRow()) {
         $aData['PRO_CATEGORY'] = '';
     }
     $this->setProCategory($aData['PRO_CATEGORY']);
     $this->setProSubCategory($aData['PRO_SUB_CATEGORY']);
     $this->setProIndustry($aData['PRO_INDUSTRY']);
     $this->setProCreateDate($aData['PRO_CREATE_DATE']);
     $this->setProCreateUser($aData['PRO_CREATE_USER']);
     $this->setProHeight($aData['PRO_HEIGHT']);
     $this->setProWidth($aData['PRO_WIDTH']);
     $this->setProTitleX($aData['PRO_TITLE_X']);
     $this->setProTitleY($aData['PRO_TITLE_Y']);
     $this->setProDynaforms(isset($aData['PRO_DYNAFORMS']) ? is_array($aData['PRO_DYNAFORMS']) ? serialize($aData['PRO_DYNAFORMS']) : $aData['PRO_DYNAFORMS'] : '');
     if ($this->validate()) {
         $con->begin();
         $res = $this->save();
         if (isset($aData['PRO_TITLE']) && trim($aData['PRO_TITLE']) != '') {
             $this->setProTitle($aData['PRO_TITLE']);
         } else {
             $this->setProTitle('Default Process Title');
         }
         if (isset($aData['PRO_DESCRIPTION'])) {
             $this->setProDescription($aData['PRO_DESCRIPTION']);
         } else {
             $this->setProDescription('Default Process Description');
         }
         $con->commit();
         $this->memcachedDelete();
         return $this->getProUid();
     } else {
         $msg = '';
         foreach ($this->getValidationFailures() as $objValidationFailure) {
             $msg .= $objValidationFailure->getMessage() . "<br/>";
         }
         throw new PropelException('The row cannot be created!', new PropelException($msg));
     }
 }
Ejemplo n.º 5
0
    /**

     * Create ProcessCategory record

     *

     * @param $ProcessCategory array.

     * @return void

     */

    public function createProcessCategoryRow ($row)

    {

        if ($row && is_array( $row ) && isset( $row['CATEGORY_UID'] )) {

            $record = ProcessCategoryPeer::retrieveByPK( $row['CATEGORY_UID'] );

            // create only if the category doesn't exists

            if (! $record) {

                $processCategory = new ProcessCategory();

                $processCategory->fromArray( $row, BasePeer::TYPE_FIELDNAME );

                $processCategory->save();

            }

        }

    }
Ejemplo n.º 6
0
 /**
  * Get process and task properties
  *
  * @param object $httpData{type, UID}
  */
 public function getProperties($httpData)
 {
     switch ($httpData->type) {
         case 'process':
             require_once 'classes/model/ProcessCategory.php';
             require_once 'classes/model/CalendarDefinition.php';
             G::LoadClass('processMap');
             $oProcessMap = new processMap(new DBConnection());
             $process = $oProcessMap->editProcessNew($httpData->UID);
             $category = ProcessCategoryPeer::retrieveByPk($process['PRO_CATEGORY']);
             $categoryName = is_object($category) ? $category->getCategoryName() : '';
             $calendar = CalendarDefinitionPeer::retrieveByPk($process['PRO_CALENDAR']);
             $calendarName = is_object($calendar) ? $calendar->getCalendarName() : '';
             $properties['Title'] = $process['PRO_TITLE'];
             $properties['Description'] = $process['PRO_DESCRIPTION'];
             $properties['Calendar'] = $calendarName;
             $properties['Category'] = $categoryName;
             $properties['Debug'] = $process['PRO_DEBUG'] == '1' ? true : false;
             $this->sucess = true;
             $this->prop = $properties;
             break;
         case 'task':
             require_once 'classes/model/Task.php';
             $task = new Task();
             $taskData = $task->load($httpData->UID);
             $properties['Title'] = $taskData['TAS_TITLE'];
             $properties['Description'] = $taskData['TAS_DESCRIPTION'];
             $properties['Variable for case priority'] = $taskData['TAS_PRIORITY_VARIABLE'];
             $properties['Starting Task'] = $taskData['TAS_START'] == 'TRUE' ? true : false;
             $this->sucess = true;
             $this->prop = $properties;
             break;
     }
 }
         $pcat->save();
         G::auditLog("CreateCategory", "Category Name: " . $catName);
         echo '{success: true}';
     } catch (Exception $ex) {
         echo '{success: false, error: ' . $ex->getMessage() . '}';
     }
     break;
 case 'checkEditCategoryName':
     require_once 'classes/model/ProcessCategory.php';
     $catUID = $_REQUEST['cat_uid'];
     $catName = $_REQUEST['cat_name'];
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(ProcessCategoryPeer::CATEGORY_NAME);
     $oCriteria->add(ProcessCategoryPeer::CATEGORY_NAME, $catName);
     $oCriteria->add(ProcessCategoryPeer::CATEGORY_UID, $catUID, Criteria::NOT_EQUAL);
     $oDataset = ProcessCategoryPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $row = $oDataset->getRow();
     $response = isset($row['CATEGORY_NAME']) ? 'false' : 'true';
     echo $response;
     break;
 case 'updateCategory':
     try {
         require_once 'classes/model/ProcessCategory.php';
         $catUID = $_REQUEST['cat_uid'];
         $catName = trim($_REQUEST['category']);
         $pcat = new ProcessCategory();
         $pcat->setNew(false);
         $pcat->setCategoryUid($catUID);
         $pcat->setCategoryName($catName);
Ejemplo n.º 8
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = ProcessCategoryPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setCategoryUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setCategoryParent($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCategoryName($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setCategoryIcon($arr[$keys[3]]);
     }
 }
Ejemplo n.º 9
0
 <?php 
try {
    $form = $_POST['form'];
    $CategoryUid = $form['CATEGORY_UID'];
    $CategoryParent = $form['CATEGORY_PARENT'];
    $CategoryName = $form['CATEGORY_NAME'];
    $CategoryIcon = $form['CATEGORY_ICON'];
    require_once "classes/model/ProcessCategory.php";
    //if exists the row in the database propel will update it, otherwise will insert.
    $tr = ProcessCategoryPeer::retrieveByPK($CategoryUid);
    $processCategory = new ProcessCategory();
    $aProcessCategory = $processCategory->loadByCategoryName($CategoryName);
    if (!is_array($aProcessCategory)) {
        if (!(is_object($tr) && get_class($tr) == 'ProcessCategory')) {
            $tr = new ProcessCategory();
        }
        $tr->setCategoryUid($CategoryUid);
        $tr->setCategoryParent($CategoryParent);
        $tr->setCategoryName($CategoryName);
        $tr->setCategoryIcon($CategoryIcon);
        if ($tr->validate()) {
            // we save it, since we get no validation errors, or do whatever else you like.
            $res = $tr->save();
        } else {
            // Something went wrong. We can now get the validationFailures and handle them.
            $msg = '';
            $validationFailuresArray = $tr->getValidationFailures();
            foreach ($validationFailuresArray as $objValidationFailure) {
                $msg .= $objValidationFailure->getMessage() . "<br/>";
            }
            //return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
Ejemplo n.º 10
0
 public function exists($catUid)
 {
     $oProCat = ProcessCategoryPeer::retrieveByPk($catUid);
     return is_object($oProCat) && get_class($oProCat) == 'ProcessCategory';
 }
Ejemplo n.º 11
0
    /**
     * GET return array category
     *
     * @return array
     */
    public function getCategoryList ()
    {
        $category = array ();
        $category[] = array ("", G::LoadTranslation( "ID_ALL_CATEGORIES" ));

        $criteria = new Criteria( 'workflow' );
        $criteria->addSelectColumn( \ProcessCategoryPeer::CATEGORY_UID );
        $criteria->addSelectColumn( \ProcessCategoryPeer::CATEGORY_NAME );
        $criteria->addAscendingOrderByColumn(\ProcessCategoryPeer::CATEGORY_NAME);

        $dataset = \ProcessCategoryPeer::doSelectRS( $criteria );
        $dataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC );
        $dataset->next();

        while ($row = $dataset->getRow()) {
            $category[] = array ($row['CATEGORY_UID'],$row['CATEGORY_NAME']);
            $dataset->next();
        }
        return $category;
    }
Ejemplo n.º 12
0
 /**
  * Get data of a Category
  *
  * @param string $categoryUid   Unique id of Category
  * @param bool   $flagGetRecord Value that set the getting
  *
  * return array Return an array with data of a Category
  */
 public function getCategory($categoryUid, $flagGetRecord = false)
 {
     try {
         //Verify data
         $this->throwExceptionIfNotExistsCategory($categoryUid, $this->arrayFieldNameForException["categoryUid"]);
         //Set variables
         if (!$flagGetRecord) {
             $process = new \Process();
             $arrayTotalProcessesByCategory = $process->getAllProcessesByCategory();
         }
         //Get data
         //SQL
         $criteria = $this->getCategoryCriteria();
         $criteria->add(\ProcessCategoryPeer::CATEGORY_UID, $categoryUid, \Criteria::EQUAL);
         $rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $rsCriteria->next();
         $row = $rsCriteria->getRow();
         if (!$flagGetRecord) {
             $row["CATEGORY_TOTAL_PROCESSES"] = isset($arrayTotalProcessesByCategory[$row["CATEGORY_UID"]]) ? (int) $arrayTotalProcessesByCategory[$row["CATEGORY_UID"]] : 0;
         }
         //Return
         return !$flagGetRecord ? $this->getCategoryDataFromRecord($row) : $row;
     } catch (\Exception $e) {
         throw $e;
     }
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(ProcessCategoryPeer::CATEGORY_UID, $pks, Criteria::IN);
         $objs = ProcessCategoryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Ejemplo n.º 14
0
    /**
     * Verify if doesn't exists the Process Category in table PROCESS_CATEGORY
     *
     * @param string $processCategoryUid    Unique id of Process Category
     * @param string $fieldNameForException Field name for the exception
     *
     * return void Throw exception if doesn't exists the Process Category in table PROCESS_CATEGORY
     */
    public function throwExceptionIfNotExistsProcessCategory($processCategoryUid, $fieldNameForException)
    {
        try {
            $obj = \ProcessCategoryPeer::retrieveByPK($processCategoryUid);

            if (!(is_object($obj) && get_class($obj) == "ProcessCategory")) {
                throw new \Exception(\G::LoadTranslation("ID_PROJECT_CATEGORY_DOES_NOT_EXIST", array($fieldNameForException, $processCategoryUid)));
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }