Esempio n. 1
0
 public function save(Default_Model_AppTag $value)
 {
     global $application;
     $data = array();
     if (!isnull($value->getId())) {
         $data['id'] = $value->getId();
     }
     if (!isnull($value->getAppID())) {
         $data['appid'] = $value->getAppID();
     }
     if (!isnull($value->getResearcherID())) {
         $data['researcherid'] = $value->getResearcherID();
     }
     if (!isnull($value->getTag())) {
         $data['tag'] = $value->getTag();
     }
     $q1 = 'id = ?';
     $q2 = $value->id;
     if (null === ($id = $value->id)) {
         unset($data['id']);
         $value->id = $this->getDbTable()->insert($data);
     } else {
         $s = $this->getDbTable()->getAdapter()->quoteInto($q1, $q2);
         $this->getDbTable()->update($data, $s);
     }
 }
Esempio n. 2
0
 public function parse($xml)
 {
     if (!is_null($this->_user)) {
         $tag = new Default_Model_AppTag();
         try {
             $xml = new SimpleXMLElement($xml);
         } catch (Exception $e) {
             $this->_error = RestErrorEnum::RE_INVALID_REPRESENTATION;
             return $tag;
         }
         // basic properties
         $xmli = $xml->xpath('//application:tag');
         if (count($xmli) === 0) {
             $this->_error = RestErrorEnum::RE_INVALID_REPRESENTATION;
             return $tag;
         }
         $xml = $xmli[0];
         $tagval = strval($xml);
         if ($tagval != '') {
             $tag->tag = $tagval;
             $tag->researcherid = $this->_parent->getUser()->id;
             $tag->appid = $this->_parent->getParam('id');
             try {
                 $tag->save();
             } catch (Exception $e) {
                 $this->_error = RestErrorEnum::RE_BACKEND_ERROR;
                 $this->_extError = 'Invalid tag name or tag already present';
                 return $tag;
             }
         } else {
             $this->_error = RestErrorEnum::RE_INVALID_REPRESENTATION;
             return $tag;
         }
     }
     $this->_error = RestErrorEnum::RE_OK;
     return $tag;
 }