public function get() { if (parent::get() !== false) { db()->setFetchMode(Zend_Db::FETCH_OBJ); $res = db()->query("SELECT sci_class.toxmlext(" . $this->getParam("id") . ") as x")->fetchAll(); $x = array(); foreach ($res as $r) { $x[] = $r->x; } if ($this->getParam("format") === "json") { return new JSONRestResponse(new XMLFragmentRestResponse($x, $this), $this); } else { return new XMLFragmentRestResponse($x, $this); } } else { return false; } }
public function get() { if (parent::get() !== false) { db()->setFetchMode(Zend_Db::FETCH_NUM); $res = db()->query("SELECT privgroup_to_xml(" . pg_escape_string($this->getParam("id")) . ")")->fetchAll(); if (count($res) > 0) { $ret = array(); foreach ($res as $r) { $ret[] = $r[0]; } return new XMLFragmentRestResponse($ret, $this); } else { $this->setError(RestErrorEnum::RE_ITEM_NOT_FOUND); return false; } } else { return false; } }
/** * @overrides get() from RestResource */ public function get($extraFilter = null) { if (parent::get() !== false) { global $application; $isAdmin = $this->userIsAdmin(); $mapper = new Default_Model_VOsMapper(); $db = $application->getBootstrap()->getResource('db'); $flt = $this->getParam("flt"); $select = $mapper->getDbTable()->getAdapter()->select()->distinct()->from('vos'); $from = ''; $where = ''; $orderby = ''; $limit = ''; $filter = FilterParser::getVOs($flt); if (is_array($filter->expr())) { $ex = implode(" ", $filter->expr()); } else { $ex = $filter->expr(); } $fltexp = $filter->expr(); if (!is_array($fltexp)) { $fltexp = array($fltexp); } foreach ($fltexp as $x) { getZendSelectParts($select, $from, $where, $orderby, $limit); if (!$isAdmin) { if (strpos($from, ' applications ') !== false && (strpos($ex, 'applications.moderated) IS FALSE') === false || strpos($ex, 'applications.deleted) IS FALSE') === false)) { $f = new Default_Model_ApplicationsFilter(); $f->moderated->equals(false)->and($f->deleted->equals(false)); $filter->chain($f, "AND"); } if (strpos($from, ' researchers ') !== false && strpos($ex, 'researchers.deleted) IS FALSE') === false) { $f = new Default_Model_ResearchersFilter(); $f->deleted->equals(false); $filter->chain($f, "AND"); } } if (strpos($ex, 'vos.deleted) IS FALSE') === false) { $f = new Default_Model_VOsFilter(); $f->deleted->equals(false); $filter->chain($f, "AND"); } } if (!is_null($extraFilter)) { $filter->chain($extraFilter, "AND"); } $mapper->joins($select, $filter); if (is_array($filter->expr())) { $from = array(); $where = array(); foreach ($filter->expr() as $x) { $s = clone $select; $s->where($x); getZendSelectParts($s, $f, $w, $orderby, $limit); $from[] = $f; $where[] = $w; } $flt = str_replace("''", "\\'", php_to_pg_array($filter->fltstr, false)); $from = str_replace("''", "\\'", php_to_pg_array($from, false)); $where = str_replace("''", "\\'", php_to_pg_array($where, false)); } else { $select->where($filter->expr()); getZendSelectParts($select, $from, $where, $orderby, $limit); } $db->setFetchMode(Zend_Db::FETCH_BOTH); $rs = $db->query('SELECT * FROM vo_logistics(?,?,?)', array($flt, $from, $where))->fetchAll(); if (count($rs) > 0) { $rs = $rs[0]; $x = $rs['vo_logistics']; } else { $x = ''; } return new XMLFragmentRestResponse($x, $this); } else { return false; } }
public function get() { if (parent::get() !== false) { $rel = $this->getParam("data"); if (!$rel) { $rel = $this->getRawData(); } if ($rel !== null) { $releases = $rel->getReleases(); if ($releases) { $s2 = ''; foreach ($releases as $release) { $s3 = $release->toXML(true); $s4 = ''; $s5 = ''; $targets = $release->getSupportedTargets(); if ($targets) { for ($i = 0; $i < count($targets); $i += 1) { $target = $targets[$i]; $s4 .= $target->toXML(true); } $s3 = str_replace("</MetaProductRelease>", $s4 . "</MetaProductRelease>", $s3); } //begin: this should be replaced with a db view. Unique poas of releases under repository area. $poas = $release->getPOAs(); if ($poas) { $s5 = ''; foreach ($poas as $poa) { $s6 = ''; $s7 = $poa->toXML(true); $pcks = $poa->getPackages(); if ($pcks) { foreach ($pcks as $pck) { $s6 = $pck->toXML(); $s7 = str_replace("</MetaPoaRelease>", $s6 . "</MetaPoaRelease>", $s7); } } if ($release->currentStateId != 1) { $repourls = $poa->getRepositoryUrls(); if ($repourls) { $s7 = str_replace("</MetaPoaRelease>", $repourls . "</MetaPoaRelease>", $s7); } } $s5 .= $s7; } $s3 = str_replace("</MetaProductRelease>", $s5 . "</MetaProductRelease>", $s3); $s3 = str_replace("</MetaProductRelease>", "<utclastproductiondate>" . $release->getUTCLastProductionBuild() . "</utclastproductiondate></MetaProductRelease>", $s3); $s3 = str_replace("</MetaProductRelease>", "<utcservertime>" . gmdate("Y-m-d H:i:s", (int) gmdate('U')) . "</utcservertime></MetaProductRelease>", $s3); } //end: this should be replaced with a db view. Unique poas of releases under repository area. $s2 .= $s3; } } $contacts = $rel->getContacts(); if ($contacts) { $s4 = ''; foreach ($contacts as $contact) { $s4 .= $contact->toXML(true); } } $s = $rel->toXML(true); $s = str_replace("</MetaProductRepoArea>", $s4 . "</MetaProductRepoArea>", $s); $s = str_replace("</MetaProductRepoArea>", $s2 . "</MetaProductRepoArea>", $s); $s = str_replace("</MetaProductRepoArea>", "<utclastproductiondate>" . $rel->getUTCLastProductionBuild() . "</utclastproductiondate></MetaProductRepoArea>", $s); $s = str_replace("</MetaProductRepoArea>", "<utcservertime>" . gmdate("Y-m-d H:i:s", (int) gmdate('U')) . "</utcservertime></MetaProductRepoArea>", $s); $s = '<repository datatype="item" content="repositoryarea" ' . (isset($_SESSION["default"]) && isset($_SESSION["default"]["userid"]) ? 'userid="' . $_SESSION["default"]["userid"] . '"' : '') . ' host="' . $_SERVER['HTTP_HOST'] . '" >' . $s . '</repository>'; //return $s; return RepositoryXSLT::transform($s, "repoarea"); } else { $this->setError(RestErrorEnum::RE_ITEM_NOT_FOUND); return false; } } }
/** * @overrides delete() from RestResource */ public function delete() { if (parent::delete() !== false) { $ret = $this->get(); $locs = new Default_Model_DatasetLocations(); $lid = $this->getParam("lid"); $locs->filter->id->numequals($lid); if (count($locs->items) == 1) { $loc = $locs->items[0]; db()->exec("DELETE FROM dataset_location_organizations WHERE dataset_location_id = " . $lid); db()->exec("DELETE FROM dataset_location_sites WHERE dataset_location_id = " . $lid); $locs->remove($loc); } return $ret; } else { return false; } }