コード例 #1
0
 public function testConstructSelectClauseForDisplayField()
 {
     $displayField = new DisplayField();
     $fieldName = 'Acme';
     $displayField->setName($fieldName);
     $options = array(array('is_value_list' => true, 'is_encrypted' => true, 'field_alias' => 'Abcd'), array('is_value_list' => true, 'is_encrypted' => true, 'field_alias' => null), array('is_value_list' => true, 'is_encrypted' => false, 'field_alias' => 'Abcd'), array('is_value_list' => true, 'is_encrypted' => false, 'field_alias' => null), array('is_value_list' => false, 'is_encrypted' => false, 'field_alias' => 'Abcd'), array('is_value_list' => false, 'is_encrypted' => false, 'field_alias' => null), array('is_value_list' => false, 'is_encrypted' => true, 'field_alias' => 'Abcd'), array('is_value_list' => false, 'is_encrypted' => true, 'field_alias' => null));
     $encrypt = KeyHandler::keyExists();
     if ($encrypt) {
         $key = KeyHandler::readKey();
     }
     foreach ($options as $option) {
         $displayField = new DisplayField();
         $displayField->setName($fieldName);
         $displayField->setIsValueList($option['is_value_list']);
         $displayField->setIsEncrypted($option['is_encrypted']);
         $displayField->setFieldAlias($option['field_alias']);
         $expected = $fieldName;
         if ($encrypt && $option['is_encrypted']) {
             $expected = 'AES_DECRYPT(UNHEX(' . $fieldName . '),"' . $key . '")';
         }
         if ($option['is_value_list']) {
             $expected = 'GROUP_CONCAT(DISTINCT ' . $expected . " SEPARATOR '|" . '\\n' . "|' ) ";
         }
         if ($option['field_alias']) {
             $expected = $expected . ' AS ' . $option['field_alias'];
         }
         $selectStatement = null;
         $selectStatement = $this->reportGeneratorService->constructSelectClauseForDisplayField($selectStatement, $displayField);
         $this->assertEquals($expected, $selectStatement);
         $selectStatement = "x";
         $expected = 'x,' . $expected;
         $selectStatement = $this->reportGeneratorService->constructSelectClauseForDisplayField($selectStatement, $displayField);
         $this->assertEquals($expected, $selectStatement);
     }
 }
コード例 #2
0
 /**
  *
  * @param <type> $columns
  * @return DisplayField 
  */
 public function saveCustomDisplayField($columns)
 {
     try {
         if (array_key_exists('displayFieldId', $columns)) {
             $displayField = Doctrine::getTable("DisplayField")->find($columns['displayFieldId']);
             $displayField->setLabel($columns['label']);
         } else {
             $displayField = new DisplayField();
             $displayField->setReportGroupId($columns['reportGroupId']);
             $displayField->setName($columns['name']);
             $displayField->setLabel($columns['label']);
             $displayField->setFieldAlias($columns['fieldAlias']);
             $displayField->setIsSortable($columns['isSortable']);
             $displayField->setSortOrder($columns['sortOrder']);
             $displayField->setSortField($columns['sortField']);
             $displayField->setElementType($columns['elementType']);
             $displayField->setElementProperty($columns['elementProperty']);
             $displayField->setWidth($columns['width']);
             $displayField->setIsExportable($columns['isExportable']);
             $displayField->setTextAlignmentStyle($columns['textAlignmentStyle']);
             $displayField->setIsValueList($columns['isValueList']);
             $displayField->setDisplayFieldGroupId($columns['displayFieldGroupId']);
             $displayField->setDefaultValue($columns['defaultValue']);
             $displayField->setIsEncrypted($columns['isEncrypted']);
         }
         $displayField->save();
         return $displayField;
     } catch (Exception $ex) {
         throw new DaoException($ex->getMessage());
     }
 }