13 require_once
'tpps.submission.api.inc';
14 require_once
'tpps.queries.api.inc';
38 $items[
'tpps/api/refresh_views'] = array(
39 'title' =>
'TPPS Refresh Views',
40 'page callback' =>
'tpps_api_refresh_views',
41 'page arguments' => array(),
42 'access arguments' => array(
'access content'),
43 'delivery callback' =>
'drupal_json_output',
44 'type' => MENU_CALLBACK,
50 $items[
'tpps/api/check_accession/%'] = array(
51 'title' =>
'TPPS Check Accession',
52 'page callback' =>
'tpps_api_check_accession',
53 'page arguments' => array(3),
54 'access callback' =>
'tpps_access',
55 'access arguments' => array(
'access content'),
56 'delivery callback' =>
'drupal_json_output',
57 'type' => MENU_CALLBACK,
63 $items[
'tpps/api/submission/%'] = array(
64 'title' =>
'TPPS Raw Submissions',
65 'page callback' =>
'tpps_load_submission',
66 'page arguments' => array(3),
67 'access callback' =>
'tpps_access',
68 'access arguments' => array(
'access content'),
69 'delivery callback' =>
'drupal_json_output',
70 'type' => MENU_CALLBACK,
78 $items[
'tpps/api/submissions'] = array(
79 'title' =>
'TPPS Submissions Query',
80 'page callback' =>
'tpps_api_submission_query',
81 'page arguments' => array(),
82 'access callback' =>
'tpps_access',
83 'access arguments' => array(
'access content'),
84 'delivery callback' =>
'drupal_json_output',
85 'type' => MENU_CALLBACK,
93 $items[
'tpps/api/submission_info'] = array(
94 'title' =>
'TPPS Submission Data',
95 'page callback' =>
'tpps_api_submission_info',
96 'page arguments' => array(),
97 'access callback' =>
'tpps_access',
98 'access arguments' => array(
'access content'),
99 'delivery callback' =>
'drupal_json_output',
100 'type' => MENU_CALLBACK,
103 $items[
'tpps/api/files/%'] = array(
104 'title' =>
'TPPS Submission Files Download',
105 'page callback' =>
'tpps_api_compress_files',
106 'page arguments' => array(3),
107 'access callback' =>
'tpps_access',
108 'access arguments' => array(
'access tpps details'),
109 'type' => MENU_NORMAL_ITEM,
133 $path = $base_url .
"/tpps/api/$type";
137 if (!empty($query)) {
139 foreach ($query as $key => $val) {
140 $args[] =
"$key=$val";
142 $path .=
"?" . implode(
"&", $args);
144 $response = file_get_contents($path);
145 return json_decode($response);
161 if (empty($accession)) {
177 throw new Exception(
'Invalid state accession number');
180 $zip_name =
"{$accession}_files.zip";
186 $files = $state[
'files'];
187 foreach ($files as $fid) {
188 $file_str[] = str_replace(
' ',
'\\ ', drupal_realpath(file_load($fid)->uri));
191 if (file_exists(drupal_realpath($zip_loc))) {
195 $file_str = implode(
" ", $file_str);
196 $cmd =
"zip -j $zip_loc $file_str";
198 drupal_add_http_header(
'Content-Type',
'application/zip');
199 drupal_add_http_header(
'Content-Disposition',
'attachment; filename="' . $zip_name .
'"');
200 drupal_add_http_header(
'Content-length', filesize($zip_loc));
201 drupal_add_http_header(
'Pragma',
"no-cache");
202 drupal_add_http_header(
'Expires',
'0');
204 readfile(
"$zip_loc");
210 db_query(
'refresh materialized view chado.tpps_search_genotype_name;');
211 db_query(
'refresh materialized view chado.tpps_search_genotype_marker;');
tpps_api_compress_files($accession=NULL)
tpps_api_call($type, $id=NULL, array $query=array())
tpps_load_submission($accession, $state=TRUE)
tpps_api_check_accession($accession=NULL)