예제 #1
0
 public function testToArray()
 {
     $array = array('Support' => array('localizedName' => 'Support', 'explanation' => 'Relative support of the rule', 'field' => array('name' => 'prahovaHodnota', 'localizedName' => 'treshold value', 'minValue' => 0, 'minValueInclusive' => false, 'maxValue' => 1, 'maxValueInclusive' => false, 'dataType' => 'double')));
     $IM = new FLInterestMeasure('Support', 'Support', 'Relative support of the rule');
     $IM->setField('prahovaHodnota', 'treshold value', 0, false, 1, false, 'double');
     $this->assertEquals($array, $IM->toArray());
 }
예제 #2
0
 protected function parseIMTypes()
 {
     $array['types'] = array();
     foreach ($this->XPath->evaluate('BuildingBlocks/InterestMeasures/Types/Type') as $t) {
         $name = $this->XPath->evaluate('Name', $t)->item(0)->nodeValue;
         $defaultValue = $this->XPath->evaluate('DefaultValue', $t)->item(0)->nodeValue;
         $localizedName = '';
         if ($LN = $this->XPath->evaluate('LocalizedName[@lang="' . $this->lang . '"]', $t)->item(0)) {
             $localizedName = $LN->nodeValue;
         }
         $thresholdType = $this->XPath->evaluate('ThresholdType', $t)->item(0)->nodeValue;
         $compareType = $this->XPath->evaluate('CompareType', $t)->item(0)->nodeValue;
         $explanation = '';
         if ($EX = $this->XPath->evaluate('Explanation[@lang="' . $this->lang . '"]', $t)->item(0)) {
             $explanation = $EX->nodeValue;
         }
         $IM = new FLInterestMeasure($name, $defaultValue, $localizedName, $thresholdType, $compareType, $explanation);
         foreach ($this->XPath->evaluate('Field', $t) as $f) {
             $name = $this->XPath->evaluate('Name', $f)->item(0)->nodeValue;
             $localizedName = $this->XPath->evaluate('LocalizedName[@lang="' . $this->lang . '"]', $f)->item(0)->nodeValue;
             $dataType = $this->XPath->evaluate('Validation/Datatype', $f)->item(0)->nodeValue;
             if ($dataType === 'enum') {
                 // enumeration
                 $vals = array();
                 foreach ($this->XPath->evaluate('Validation/Value', $f) as $fv) {
                     array_push($vals, $fv->nodeValue);
                 }
                 sort($vals);
                 $IM->addEnumerationField($name, $localizedName, $vals, $dataType);
             } else {
                 // interval
                 if ($mv = $this->XPath->evaluate('Validation/MinValue', $f)->item(0)) {
                     $minValue = intval($mv->nodeValue);
                     $minValueInclusive = $mv->getAttribute('inclusive') === 'yes';
                 } else {
                     $minValue = self::$IM_MIN;
                     $minValueInclusive = self::$IM_INCLUSIVE_MIN;
                 }
                 if ($mv = $this->XPath->evaluate('Validation/MaxValue', $f)->item(0)) {
                     $maxValue = intval($mv->nodeValue);
                     $maxValueInclusive = $mv->getAttribute('inclusive') === 'yes';
                 } else {
                     $maxValue = self::$IM_MAX;
                     $maxValueInclusive = self::$IM_INCLUSIVE_MAX;
                 }
                 $IM->addIntervalField($name, $localizedName, $minValue, $minValueInclusive, $maxValue, $maxValueInclusive, $dataType);
             }
         }
         $array['types'] = array_merge_recursive($array['types'], $IM->toArray());
     }
     return $array;
 }