diff --git a/core/trunk/core/tests/class/DataAccessService_Database.php b/core/trunk/core/tests/class/DataAccessService_Database.php index a3e0fdb113cdcc9c14db2b31553f8f827d3b7acb..fb26c0f4303995ee340b57938318cdbf626c0ece 100644 --- a/core/trunk/core/tests/class/DataAccessService_Database.php +++ b/core/trunk/core/tests/class/DataAccessService_Database.php @@ -57,7 +57,7 @@ class DataAccessService_Database public function getData($dataObject) { - $parentObject = $dataObject->getParentObject(); + $parentObject = $dataObject->parentObject; $tableName = $dataObject->name; $table = $this->tables[$tableName]; @@ -101,7 +101,7 @@ class DataAccessService_Database public function saveData($dataObject) { - $parentObject = $dataObject->getParentObject(); + $parentObject = $dataObject->parentObject; $tableName = $dataObject->name; $table = $this->tables[$tableName]; diff --git a/core/trunk/core/tests/class/DataObject.php b/core/trunk/core/tests/class/DataObject.php index 978c9594aa6255cbe152a9ff1a181351bf1d4f37..a931b20efed668d599660bafa0c41425b8cca06c 100644 --- a/core/trunk/core/tests/class/DataObject.php +++ b/core/trunk/core/tests/class/DataObject.php @@ -5,28 +5,14 @@ class DataObject { private $name; - private $label; - private $comment; private $schemaPath; private $parentObject; private $storage; - public function DataObject($name, $schemaPath, $label=false, $comment=false) + public function DataObject($name, $schemaPath) { $this->name = $name; $this->schemaPath = $schemaPath; - $this->label = $label; - $this->comment = $comment; - } - - public function getSchemaPath() - { - return $this->schemaPath; - } - - public function getParentObject() - { - return $this->parentObject; } public function setParentObject($parentObject) @@ -69,15 +55,11 @@ class DataObject if($name === 'name') { return $this->name; } - if($name === 'label') { - if($this->label) { - return $this->label; - } else { - return $this->name; - } - } - if($name === 'comment') { - return $this->comment; + if($name === 'schemaPath') { + return $this->schemaPath; + } + if($name === 'parentObject') { + return $this->parentObject; } } diff --git a/core/trunk/core/tests/class/DataObjectArray.php b/core/trunk/core/tests/class/DataObjectArray.php index 8d172284ec7b5b678b33420807b73fbe898c0994..66307f08ef8876601dcd3d6a9401e3be2be56513 100644 --- a/core/trunk/core/tests/class/DataObjectArray.php +++ b/core/trunk/core/tests/class/DataObjectArray.php @@ -4,32 +4,19 @@ class DataObjectArray extends ArrayObject { private $name; - private $label; - private $comment; private $schemaPath; + private $arraySchemaPath; private $parentObject; - public function DataObjectArray($name, $schemaPath, $label=false, $comment=false) + public function DataObjectArray($name, $schemaPath, $arraySchemaPath) { $this->name = $name; $this->schemaPath = $schemaPath; - $this->label = $label; - $this->comment = $comment; - + $this->arraySchemaPath = $arraySchemaPath; $this->setFlags(ArrayObject::ARRAY_AS_PROPS); $this->setFlags(ArrayObject::STD_PROP_LIST); } - public function getSchemaPath() - { - return $this->schemaPath; - } - - public function getParentObject() - { - return $this->parentObject; - } - public function setParentObject($parentObject) { $this->parentObject = $parentObject; @@ -48,15 +35,14 @@ class DataObjectArray if($name === 'name') { return $this->name; } - if($name === 'label') { - if($this->label) { - return $this->label; - } else { - return $this->name; - } - } - if($name === 'comment') { - return $this->comment; + if($name === 'schemaPath') { + return $this->schemaPath; + } + if($name === 'arraySchemaPath') { + return $this->arraySchemaPath; + } + if($name === 'parentObject') { + return $this->parentObject; } } diff --git a/core/trunk/core/tests/class/DataObjectController.php b/core/trunk/core/tests/class/DataObjectController.php index bec8bc610f7c0bcf26bec8c891743b658357159c..b28c29842a74d2b7f00f047ed8201d6bdea8d91c 100644 --- a/core/trunk/core/tests/class/DataObjectController.php +++ b/core/trunk/core/tests/class/DataObjectController.php @@ -117,7 +117,7 @@ class dataObjectController extends DOMDocument $this->loadChildren($dataObject); } if($dataObject->isDataObjectArray) { - $schemaPath = $dataObject->getSchemaPath(); + $schemaPath = $dataObject->schemaPath; for($i=0; $i<count($objectDatas); $i++) { $objectData = $objectDatas[$i]; $itemDataObject = $this->instanciateDataObject($schemaPath); @@ -141,7 +141,7 @@ class dataObjectController extends DOMDocument public function saveDataObject($dataObject) { - $schemaPath = $dataObject->getSchemaPath(); + $schemaPath = $dataObject->schemaPath; $objectSchema = $this->schema->getSchemaElement($schemaPath); switch($objectSchema->{'das:source'}) { case 'database': @@ -170,13 +170,6 @@ class dataObjectController extends DOMDocument } } - public function getKey($objectName) - { - $objectSchema = $this->schema->getObjectSchema($objectName); - $keyColumnNames = $objectSchema->{'das:key-columns'}; - return $keyColumnNames; - } - public function setOrder($objectName, $orderElements, $orderMode='ASC') { $objectSchema = $this->schema->getObjectSchema($objectName); @@ -204,6 +197,31 @@ class dataObjectController extends DOMDocument } } + + public function getKey($objectName) + { + $objectSchema = $this->schema->getObjectSchema($objectName); + $keyColumnNames = $objectSchema->{'das:key-columns'}; + return $keyColumnNames; + } + + public function getLabels($dataObject) + { + $labels = array(); + $objectPath = $dataObject->schemaPath; + $objectSchema = $this->schema->getSchemaElement($objectPath); + $childElements = $objectSchema->getChildElements(); + for($i=0; $i<$childElements->length;$i++) { + $inlineChildElement = $childElements->item($i); + $childElement = $inlineChildElement->getRefElement(); + $childName = $childElement->name; + if($inlineChildElement->{'das:label'}) $label = $inlineChildElement->{'das:label'}; + elseif($childElement->{'das:label'}) $label = $childElement->{'das:label'}; + else $label = $childName; + $labels[$childName] = $label; + } + return $labels; + } //************************************************************************* // PRIVATE OBJECT HANDLING FUNCTIONS @@ -230,12 +248,8 @@ class dataObjectController extends DOMDocument if($inlineChildElement && $inlineChildElement->isDataObjectArray()) { $objectSchema = $this->schema->getSchemaElement($schemaPath); - $dataObject = new DataObjectArray( - $objectSchema->name, - $schemaPath, - $inlineChildElement->{'das:label'}, - $inlineChildElement->{'das:comment'} - ); + $arraySchemaPath = $inlineChildElement->getNodePath(); + $dataObject = new DataObjectArray($objectSchema->name, $schemaPath, $arraySchemaPath); } else { $dataObject = unserialize(serialize($this->prototypes[$schemaPath])); } @@ -245,18 +259,9 @@ class dataObjectController extends DOMDocument private function prototypeDataObject($schemaPath) { $objectSchema = $this->schema->getSchemaElement($schemaPath); - - /*if($objectSchema->ref) { - $objectSchema = $this->schema->getObjectSchema($objectSchema->ref); - if(!$objectSchema) die ("Referenced element named '" . $objectSchema->ref . "' not found in schema"); - }*/ + //echo "<br/>Create prototype object with $objectSchema->name"; - $prototypeDataObject = new DataObject( - $objectSchema->name, - $schemaPath, - $objectSchema->{'das:label'}, - $objectSchema->{'das:comment'} - ); + $prototypeDataObject = new DataObject($objectSchema->name, $schemaPath); // Set Das parameters $this->setDasSource($objectSchema); @@ -283,13 +288,7 @@ class dataObjectController extends DOMDocument $childValue = false; } //echo "<br/> Adding property '$childName'"; - $dataObjectProperty = new DataObjectProperty( - $childName, - $childPath, - $childValue, - $childElement->{'das:label'}, - $childElement->{'das:comment'} - ); + $dataObjectProperty = new DataObjectProperty($childName, $childPath, $childValue); $prototypeDataObject->$childName = $dataObjectProperty; $this->setDasProperty($objectSchema, $childElement); @@ -404,7 +403,7 @@ class dataObjectController extends DOMDocument private function getData($dataObject) { - $schemaPath = $dataObject->getSchemaPath(); + $schemaPath = $dataObject->schemaPath; $objectSchema = $this->schema->getSchemaElement($schemaPath); switch($objectSchema->{'das:source'}) { case 'database': diff --git a/core/trunk/core/tests/class/DataObjectProperty.php b/core/trunk/core/tests/class/DataObjectProperty.php index f3eee54647dd5a644c37b23fa9c2cad590b44d82..ed8145ffe55d0b1d7741e380ff3d0b24d103e5e6 100644 --- a/core/trunk/core/tests/class/DataObjectProperty.php +++ b/core/trunk/core/tests/class/DataObjectProperty.php @@ -2,38 +2,23 @@ class DataObjectProperty { - - private $name; - private $label; - private $comment; + private $name; private $schemaPath; private $parentObject; private $storage; - public function DataObjectProperty($name, $schemaPath, $value=false, $label=false, $comment=false) + public function DataObjectProperty($name, $schemaPath, $value=false) { - $this->schemaPath = $schemaPath; - $this->name = $name; + $this->name = $name; + $this->schemaPath = $schemaPath; $this->storage = $value; - $this->label = $label; - $this->comment = $comment; } - - public function getParentObject() - { - return $this->parentObject; - } public function setParentObject($parentObject) { $this->parentObject = $parentObject; } - public function getSchemaPath() - { - return $this->schemaPath; - } - public function __get($name) { if($name === 'isDataObjectProperty') { return true; @@ -41,18 +26,11 @@ class DataObjectProperty if($name === 'name') { return $this->name; } - if($name === 'value') { - return $this->storage; - } - if($name === 'label') { - if($this->label) { - return $this->label; - } else { - return $this->name; - } + if($name === 'schemaPath') { + return $this->schemaPath; } - if($name === 'comment') { - return $this->comment; + if($name === 'parentObject') { + return $this->parentObject; } } diff --git a/core/trunk/core/tests/class/DataObjectSchema.php b/core/trunk/core/tests/class/DataObjectSchema.php index a586bd6236badce8b0cded75241dd61bfac610f8..8f85a70bfa9cdc2c38aa61a800cc9835fe7941d4 100644 --- a/core/trunk/core/tests/class/DataObjectSchema.php +++ b/core/trunk/core/tests/class/DataObjectSchema.php @@ -148,8 +148,6 @@ class SchemaElement extends DOMElement { return $xpath->query($query, $contextElement); } - - function __get($name) { if($this->hasAttribute($name)) {