/**
  * @verbatim
  * Helper method that installs filter groups based on
  * the given XML node which represents a <filterGroups>
  * element.
  * @endverbatim
  * @param $filterGroupsNode XMLNode
  */
 function installFilterGroups($filterGroupsNode)
 {
     // Install filter groups.
     $filterGroupDao = DAORegistry::getDAO('FilterGroupDAO');
     /* @var $filterGroupDao FilterGroupDAO */
     import('lib.pkp.classes.filter.FilterGroup');
     foreach ($filterGroupsNode->getChildren() as $filterGroupNode) {
         /* @var $filterGroupNode XMLNode */
         $filterGroupSymbolic = $filterGroupNode->getAttribute('symbolic');
         // Make sure that the filter group has not been
         // installed before to guarantee idempotence.
         $existingFilterGroup =& $filterGroupDao->getObjectBySymbolic($filterGroupSymbolic);
         if (!is_null($existingFilterGroup)) {
             continue;
         }
         // Instantiate and configure the filter group.
         $filterGroup = new FilterGroup();
         $filterGroup->setSymbolic($filterGroupSymbolic);
         $filterGroup->setDisplayName($filterGroupNode->getAttribute('displayName'));
         $filterGroup->setDescription($filterGroupNode->getAttribute('description'));
         $filterGroup->setInputType($filterGroupNode->getAttribute('inputType'));
         $filterGroup->setOutputType($filterGroupNode->getAttribute('outputType'));
         // Install the filter group.
         $installedGroupId = $filterGroupDao->insertObject($filterGroup);
         assert(is_integer($installedGroupId));
         unset($filterGroup);
     }
 }
 /**
  * @covers FilterGroupDAO
  */
 public function testFilterGroupCrud()
 {
     $filterGroupDao = DAORegistry::getDAO('FilterGroupDAO');
     /* @var $filterGroupDao FilterGroupDAO */
     // Instantiate a test filter group object.
     $testFilterGroup = new FilterGroup();
     $testFilterGroup->setSymbolic('some-symbol');
     $testFilterGroup->setDisplayName('translation.key.displayName');
     $testFilterGroup->setDescription('translation.key.description');
     $testFilterGroup->setInputType('primitive::string');
     $testFilterGroup->setOutputType('primitive::integer');
     // Insert filter group instance.
     $filterGroupId = $filterGroupDao->insertObject($testFilterGroup, 9999);
     self::assertTrue(is_numeric($filterGroupId));
     self::assertTrue($filterGroupId > 0);
     // Retrieve filter group instance by id.
     $filterGroupById =& $filterGroupDao->getObjectById($filterGroupId);
     self::assertEquals($testFilterGroup, $filterGroupById);
     // Update filter group instance.
     $testFilterGroup->setSymbolic('some-other-symbol');
     $testFilterGroup->setDisplayName('translation.key.otherDisplayName');
     $testFilterGroup->setDescription('translation.key.otherDescription');
     $testFilterGroup->setInputType('primitive::integer');
     $testFilterGroup->setOutputType('primitive::string');
     $filterGroupDao->updateObject($testFilterGroup);
     $filterGroupAfterUpdate =& $filterGroupDao->getObject($testFilterGroup);
     self::assertEquals($testFilterGroup, $filterGroupAfterUpdate);
     // Retrieve filter group instance by symbolic name.
     $filterGroupBySymbolic =& $filterGroupDao->getObjectBySymbolic('some-other-symbol');
     self::assertEquals($testFilterGroup, $filterGroupAfterUpdate);
     // Delete filter group instance.
     $filterGroupDao->deleteObjectById($filterGroupId);
     self::assertNull($filterGroupDao->getObjectById($filterGroupId));
 }
Exemplo n.º 3
0
 protected function setUp()
 {
     parent::setUp();
     // Create a test filter group.
     $someGroup = new FilterGroup();
     $someGroup->setSymbolic('test-filter-group');
     $someGroup->setDisplayName('some.test.filter.group.display');
     $someGroup->setDescription('some.test.filter.group.description');
     $someGroup->setInputType('primitive::string');
     $someGroup->setOutputType('primitive::string');
     $filterGroupDao = DAORegistry::getDAO('FilterGroupDAO');
     /* @var $filterGroupDao FilterGroupDAO */
     self::assertTrue(is_integer($filterGroupId = $filterGroupDao->insertObject($someGroup)));
 }
Exemplo n.º 4
0
 protected function setUp()
 {
     // Clean up from earlier tests.
     $filterDao = DAORegistry::getDAO('FilterDAO');
     /* @var $filterDao FilterDAO */
     $filterGroupDao = DAORegistry::getDAO('FilterGroupDAO');
     /* @var $filterGroupDao FilterGroupDAO */
     foreach ($filterDao->getObjectsByGroup('test-filter-group', 9999) as $filter) {
         $filterDao->deleteObject($filter);
     }
     $filterGroupDao->deleteObjectBySymbolic('test-filter-group');
     // Create a test filter group.
     $someGroup = new FilterGroup();
     $someGroup->setSymbolic('test-filter-group');
     $someGroup->setDisplayName('some.test.filter.group.display');
     $someGroup->setDescription('some.test.filter.group.description');
     $someGroup->setInputType('primitive::string');
     $someGroup->setOutputType('primitive::string');
     self::assertTrue(is_integer($filterGroupId = $filterGroupDao->insertObject($someGroup)));
 }
Exemplo n.º 5
0
 /**
  * Internal function to return a filter group
  * object from a row.
  *
  * @param $row array
  * @return FilterGroup
  */
 function &_fromRow(&$row)
 {
     // Instantiate the filter group.
     $filterGroup = new FilterGroup();
     // Configure the filter group.
     $filterGroup->setId((int) $row['filter_group_id']);
     $filterGroup->setSymbolic($row['symbolic']);
     $filterGroup->setDisplayName($row['display_name']);
     $filterGroup->setDescription($row['description']);
     $filterGroup->setInputType($row['input_type']);
     $filterGroup->setOutputType($row['output_type']);
     return $filterGroup;
 }