예제 #1
0
 public function testGroupsToArray()
 {
     $array = array('BMI' => array('groups' => array('group1', 'group2')));
     $attr = new Attribute();
     $attr->setName('BMI');
     $attr->addGroup('group1');
     $attr->addGroup('group2');
     $this->assertEquals($array, $attr->toArray());
 }
예제 #2
0
 protected function parseAttributes()
 {
     $attributes = array();
     foreach ($this->XPath->evaluate('//dd:DataDescription/Dictionary[@default="true"]/Field') as $f) {
         $attribute = new Attribute();
         foreach ($f->childNodes as $n) {
             if ($n->nodeName == "Name") {
                 $attribute->setName($n->nodeValue);
             }
             if ($n->nodeName == "Category") {
                 $attribute->addCategory($n->nodeValue);
             }
             if ($n->nodeName == "Interval") {
                 $closure = $n->getAttribute('closure');
                 $interval = substr($closure, 0, 4) === 'open' ? '(' : '<';
                 $interval .= $n->getAttribute('leftMargin') . ';' . $n->getAttribute('rightMargin');
                 $interval .= substr($closure, -4, 4) === 'Open' ? ')' : '>';
                 $attribute->addInterval($interval);
             }
         }
         array_push($attributes, $attribute);
     }
     return $attributes;
 }
예제 #3
0
 /**
  * Creates SK ITC Bundle DTD Attribute List
  *
  * @param string $source
  *        	SK ITC Bundle DTD Attribute List Source
  * @return \SK\ITCBundle\ORM\DTD\AttributeList
  */
 public static function create($source, Document $document)
 {
     $entity = null;
     $sourceAttributes = explode(" ", $source);
     $instance = new self($source);
     $entity = array_shift($sourceAttributes);
     $j = 0;
     for ($i = 0; $i < count($sourceAttributes); $i++) {
         $sourceAttribute = $sourceAttributes[$i];
         if (preg_match("/%/", $sourceAttribute) && $j == 0) {
             $j = $j + 2;
             $attribute = new Attribute("");
             $instance->setAttribute($attribute);
         } else {
             $column = $j % 3;
             switch ($column) {
                 case 0:
                     $attributeName = $sourceAttribute;
                     ++$j;
                     break;
                 case 1:
                     $attributeEntity = $sourceAttribute;
                     ++$j;
                     break;
                 case 2:
                     $attributeDefaultValue = $sourceAttribute;
                     $attribute = new Attribute("");
                     $attribute->setDocument($document);
                     $attribute->setName($attributeName);
                     $attribute->setEntity($document->getEntity($attributeEntity));
                     $attribute->setDefaultValue($attributeDefaultValue);
                     $instance->setAttribute($attribute);
                     $j = 0;
                     break;
             }
         }
     }
     return $instance;
 }