00001 <?php
00002
00011 class SDRResourceObj extends SXMLModel {
00012 private static $ATTRIBUTES = array(
00013 'cserdId' => array(),
00014 'resourceIdentifier' => array('type' => 'string'),
00015 'averageReviewRating' => array(),
00016 'title' => array('type' => 'string'),
00017 'description' => array('type' => 'string'),
00018 'collContext' => array('type' => 'SDRContextObj'),
00019 'projectContext' => array('type' => 'SDRContextObj'),
00020 'metadata' => array('type' => 'SDRMetadataObj'),
00021 'alignments' => array('type' => 'SDRAlignmentList'),
00022 'relationships' => array('type' => 'SDRRelationshipList')
00023 );
00024
00033 public function __construct($xml = null) {
00034 parent::__construct();
00035
00036 $this->registerAttributes(self::$ATTRIBUTES);
00037 $this->registerNodeName('SDRResource');
00038
00039 if($xml)
00040 $this->setXML($xml);
00041 }
00042
00051 protected function setXMLImpl($xml) {
00052 $this->set('cserdId', (int)$xml->header->cserdId);
00053 $this->set('resourceIdentifier', (string)$xml->header->resourceIdentifier);
00054 $this->set('averageReviewRating', $xml->header->averageReviewRating);
00055 $this->set('title', (string)$xml->fields->title);
00056 $this->set('description', (string)$xml->fields->description);
00057 $this->set('collContext', new SDRContextObj($xml->fields->collContext));
00058 $this->set('projectContext', new SDRContextObj($xml->fields->projectContext));
00059 if($xml->metadata)
00060 $this->set('metadata', new SDRMetadataObj($xml->metadata));
00061 if($xml->alignments)
00062 $this->set('alignments', new SDRAlignmentList($xml->alignments));
00063 if($xml->relationships)
00064 $this->set('relationships', new SDRRelationshipList($xml->relationships));
00065 return true;
00066 }
00067
00077 protected function getXMLImpl($root, $forceRegen) {
00078 $xml = "<$root>";
00079 $xml .= '<header><cserdId>' . $this->get('cserdId')
00080 . '</cserdId><resourceIdentifier>' . $this->get('resourceIdentifier')
00081 . '</resourceIdentifier><averageReviewRating>' . $this->get('averageReviewRating')
00082 . '</averageReviewRating></header>'
00083 . '<fields><title>' . $this->get('title')
00084 . '</title><description>' . $this->get('description')
00085 . '</description>';
00086 $xml .= $this->get('collContext')->getXML(array('forceRegen' => $forceRegen));
00087 $xml .= $this->get('projectContext')->getXML(array('forceRegen' => $forceRegen));
00088 $xml .= '</fields>';
00089 if($md = $this->get('metadata'))
00090 $xml .= $md->getXML(array('forceRegen' => $forceRegen));
00091 if($al = $this->get('alignments'))
00092 $xml .= $al->getXML(array('forceRegen' => $forceRegen));
00093 if($re = $this->get('relationships'))
00094 $xml .= $re->getXML(array('forceRegen' => $forceRegen));
00095 $xml .= "</$root>";
00096 return $xml;
00097 }
00098 }
00099
00100 ?>