3 * SOAP Tracker Include - this file contains wrapper functions for the tracker query interface
5 * Copyright 2004 (c) GForge, LLC
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once $gfcommon.'include/Error.class.php';
25 require_once $gfcommon.'tracker/ArtifactQuery.class.php';
26 require_once $gfcommon.'tracker/ArtifactQueryFactory.class.php';
27 // imports ArrayOfArtifactExtraFieldsData type
28 require_once $gfwww.'soap/tracker/tracker.php';
34 $server->wsdl->addComplexType(
35 'ArtifactQueryExtraField',
41 'extra_field_id' => array('name' => 'extra_field_id', 'type' => 'xsd:int'),
42 'values' => array('name' => 'values', 'type' => 'tns:ArrayOfint')
46 $server->wsdl->addComplexType(
47 'ArrayOfArtifactQueryExtraField',
54 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ArtifactQueryExtraField[]')
56 'tns:ArtifactQueryExtraField'
60 $server->wsdl->addComplexType(
61 'ArtifactQueryFields',
67 'sortcol' => array('name' => 'sortcol', 'type' => 'xsd:string'),
68 'sortord' => array('name' => 'sortord', 'type' => 'xsd:string'),
69 'moddaterange' => array('name' => 'changed', 'type' => 'xsd:string'),
70 'assignee' => array('name' => 'assignee', 'type' => 'tns:ArrayOfInteger'),
71 'status' => array('name' => 'status', 'type' => 'xsd:int'),
72 'extra_fields' => array('name' => 'extra_fields', 'type' => 'tns:ArrayOfArtifactQueryExtraField'),
73 'opendaterange' => array('name' => 'changed', 'type' => 'xsd:string'),
74 'closedaterange' => array('name' => 'changed', 'type' => 'xsd:string')
79 $server->wsdl->addComplexType(
86 'artifact_query_id' => array('name' => 'artifact_query_id', 'type' => 'xsd:int'),
87 'name' => array('name' => 'query_name', 'type' => 'xsd:string'),
88 'fields' => array('name' => 'fields', 'type' => 'tns:ArtifactQueryFields')
92 $server->wsdl->addComplexType(
93 'ArrayOfArtifactQuery',
100 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ArtifactQuery[]')
108 'session_ser'=>'xsd:string',
109 'group_id'=>'xsd:int',
110 'group_artifact_id'=>'xsd:int'
112 array('getArtifactTypesResponse'=>'tns:ArrayOfArtifactQuery'),
114 $uri.'#artifactGetViews','rpc','encoded'
117 function artifactGetViews($session_ser, $group_id, $group_artifact_id) {
118 continue_session($session_ser);
119 $grp = group_get_object($group_id);
120 if (!$grp || !is_object($grp)) {
121 return new soap_fault ('','artifactGetViews','Could Not Get Project','Could Not Get Project');
122 } elseif ($grp->isError()) {
123 return new soap_fault ('','artifactGetViews',$grp->getErrorMessage(),$grp->getErrorMessage());
126 $at = new ArtifactType($grp,$group_artifact_id);
127 if (!$at || !is_object($at)) {
128 return new soap_fault ('','artifactGetViews','Could Not Get ArtifactType','Could Not Get ArtifactType');
129 } elseif ($at->isError()) {
130 return new soap_fault ('','artifactGetViews',$at->getErrorMessage(),$at->getErrorMessage());
133 $aqf = new ArtifactQueryFactory($at);
135 return queries_to_soap($aqf->getArtifactQueries());
138 function queries_to_soap($queries) {
140 // print_r($queries[1]->getExtraFields());
143 if (is_array($queries) && count($queries) > 0) {
144 for ($i=0; $i < count($queries); $i++) {
145 $artifactQuery =& $queries[$i];
147 // transform the extra fields data
148 $extra_fields = array();
149 $queryExtraFields = $artifactQuery->getExtraFields();
150 foreach ($queryExtraFields as $extra_field_id => $values) {
151 // $value may be a int. We wrap it in an array.
152 if (!is_array($values)) $values = array($values);
153 $extra_fields[] = array(
154 "extra_field_id" => $extra_field_id,
159 $assignee = $artifactQuery->getAssignee();
160 // this is a hack, ArtifactQuery::getAssignee sometimes returns an int and
161 // sometimes it returns an array
162 if (!is_array($assignee)) {
163 if (is_numeric($assignee)) { // a single ID
164 $assignee = array($assignee); // wrap in an array
171 "artifact_query_id" => $artifactQuery->getID(),
172 "name" => $artifactQuery->getName(),
174 "sortcol" => $artifactQuery->getSortCol(),
175 "sortord" => $artifactQuery->getSortOrd(),
176 "moddaterange" => $artifactQuery->getModDateRange(),
177 "assignee" => $assignee,
178 "status" => $artifactQuery->getStatus(),
179 "extra_fields" => $extra_fields,
180 "opendaterange" => $artifactQuery->getOpenDateRange(),
181 "closedaterange" => $artifactQuery->getCloseDateRange()
195 'artifactDeleteView',
197 'session_ser'=>'xsd:string',
198 'group_id'=>'xsd:int',
199 'group_artifact_id'=>'xsd:int',
200 'artifact_query_id' => 'xsd:int'
202 array('artifactDeleteViewResponse'=>'xsd:boolean'),
204 $uri.'#artifactDeleteView','rpc','encoded'
207 function artifactDeleteView($session_ser, $group_id, $group_artifact_id, $artifact_query_id) {
208 continue_session($session_ser);
209 $grp = group_get_object($group_id);
210 if (!$grp || !is_object($grp)) {
211 return new soap_fault ('','artifactDeleteView','Could Not Get Group','Could Not Get Group');
212 } elseif ($grp->isError()) {
213 return new soap_fault ('','artifactDeleteView',$grp->getErrorMessage(),$grp->getErrorMessage());
216 $at = new ArtifactType($grp,$group_artifact_id);
217 if (!$at || !is_object($at)) {
218 return new soap_fault ('','artifactDeleteView','Could Not Get ArtifactType','Could Not Get ArtifactType');
219 } elseif ($at->isError()) {
220 return new soap_fault ('','artifactDeleteView',$at->getErrorMessage(),$at->getErrorMessage());
223 $query = new ArtifactQuery($at, $artifact_query_id);
224 if (!$query || !is_object($query)) {
225 return new soap_fault ('','artifactDeleteView','Could Not Get Query','Could Not Get Query');
226 } elseif ($query->isError()) {
227 return new soap_fault ('','artifactDeleteView',$query->getErrorMessage(),$query->getErrorMessage());
240 'session_ser'=>'xsd:string',
241 'group_id'=>'xsd:int',
242 'group_artifact_id'=>'xsd:int',
243 'artifact_query_id' => 'xsd:int'
245 array('artifactSetView'=>'xsd:boolean'),
247 $uri.'#artifactSetView','rpc','encoded'
250 function artifactSetView($session_ser, $group_id, $group_artifact_id, $artifact_query_id) {
251 continue_session($session_ser);
252 $grp = group_get_object($group_id);
253 if (!$grp || !is_object($grp)) {
254 return new soap_fault ('','artifactSetView','Could Not Get Group','Could Not Get Group');
255 } elseif ($grp->isError()) {
256 return new soap_fault ('','artifactSetView',$grp->getErrorMessage(),$grp->getErrorMessage());
259 $at = new ArtifactType($grp,$group_artifact_id);
260 if (!$at || !is_object($at)) {
261 return new soap_fault ('','artifactSetView','Could Not Get ArtifactType','Could Not Get ArtifactType');
262 } elseif ($at->isError()) {
263 return new soap_fault ('','artifactSetView',$at->getErrorMessage(),$at->getErrorMessage());
266 $query = new ArtifactQuery($at, $artifact_query_id);
267 if (!$query || !is_object($query)) {
268 return new soap_fault ('','artifactDeleteView','Could Not Get Query','Could Not Get Query');
269 } elseif ($query->isError()) {
270 return new soap_fault ('','artifactDeleteView',$query->getErrorMessage(),$query->getErrorMessage());
273 $query->makeDefault();
280 $server->wsdl->addComplexType(
288 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ArrayOfint')
294 'artifactCreateView',
296 'session_ser'=>'xsd:string',
297 'group_id'=>'xsd:int',
298 'group_artifact_id'=>'xsd:int',
299 'name'=>'xsd:string',
301 'assignee'=>'tns:ArrayOfUserID',
302 'moddaterange'=>'xsd:string',
303 'sort_col'=>'xsd:string',
304 'sort_ord'=>'xsd:string',
305 'extra_fields'=>'tns:ArrayOfArtifactExtraFieldsData',
306 'opendaterange'=>'xsd:string',
307 'closedaterange'=>'xsd:string'
309 array('artifactCreateViewResponse'=>'xsd:int'),
311 $uri.'#artifactCreateView','rpc','encoded'
313 function artifactCreateView($session_ser, $group_id, $group_artifact_id, $name, $status, $assignee, $moddaterange,
314 $sort_col, $sort_ord, $extra_fields, $opendaterange, $closedaterange) {
316 continue_session($session_ser);
317 $grp = group_get_object($group_id);
318 if (!$grp || !is_object($grp)) {
319 return new soap_fault ('','artifactCreateView','Could Not Get Group','Could Not Get Group');
320 } elseif ($grp->isError()) {
321 return new soap_fault ('','artifactCreateView',$grp->getErrorMessage(),$grp->getErrorMessage());
324 $at = new ArtifactType($grp,$group_artifact_id);
325 if (!$at || !is_object($at)) {
326 return new soap_fault ('','artifactCreateView','Could Not Get ArtifactType','Could Not Get ArtifactType');
327 } elseif ($at->isError()) {
328 return new soap_fault ('','artifactCreateView',$at->getErrorMessage(),$at->getErrorMessage());
331 //rearrange the extra fields
332 $aef = $at->getExtraFields();
333 $extra_fields = arrangeExtraFields($extra_fields, $aef);
335 $query = new ArtifactQuery($at);
336 if (!$query->create($name, $status, $assignee, $moddaterange, $sort_col,
337 $sort_ord, $extra_fields, $opendaterange, $closedaterange)) {
338 return new soap_fault ('','artifactCreateView',$query->getErrorMessage(),$query->getErrorMessage());
341 return $query->getID();
349 'artifactUpdateView',
351 'session_ser'=>'xsd:string',
352 'group_id'=>'xsd:int',
353 'group_artifact_id'=>'xsd:int',
354 'query_id'=>'xsd:int',
355 'name'=>'xsd:string',
357 'assignee'=>'tns:ArrayOfUserID',
358 'moddaterange'=>'xsd:string',
359 'sort_col'=>'xsd:string',
360 'sort_ord'=>'xsd:string',
361 'extra_fields'=>'tns:ArrayOfArtifactExtraFieldsData',
362 'opendaterange'=>'xsd:string',
363 'closedaterange'=>'xsd:string'
365 array('artifactUpdateViewResponse'=>'xsd:int'),
367 $uri.'#artifactUpdateView','rpc','encoded'
370 function artifactUpdateView($session_ser, $group_id, $group_artifact_id, $query_id, $name, $status, $assignee, $moddaterange,
371 $sort_col, $sort_ord, $extra_fields, $opendaterange, $closedaterange) {
373 continue_session($session_ser);
374 $grp = group_get_object($group_id);
375 if (!$grp || !is_object($grp)) {
376 return new soap_fault ('','artifactUpdateView','Could Not Get Group','Could Not Get Group');
377 } elseif ($grp->isError()) {
378 return new soap_fault ('','artifactCreateView',$grp->getErrorMessage(),$grp->getErrorMessage());
381 $at = new ArtifactType($grp,$group_artifact_id);
382 if (!$at || !is_object($at)) {
383 return new soap_fault ('','artifactUpdateView','Could Not Get ArtifactType','Could Not Get ArtifactType');
384 } elseif ($at->isError()) {
385 return new soap_fault ('','artifactUpdateView',$at->getErrorMessage(),$at->getErrorMessage());
388 //rearrange the extra fields
389 $aef = $at->getExtraFields();
390 $extra_fields = arrangeExtraFields($extra_fields, $aef);
393 $query = new ArtifactQuery($at, $query_id);
394 if (!$query || !is_object($query)) {
395 return new soap_fault ('','artifactUpdateView','Could Not Get ArtifactType','Could Not Get ArtifactType');
396 } elseif ($query->isError()) {
397 return new soap_fault ('','artifactUpdateView',$query->getErrorMessage(),$query->getErrorMessage());
400 if (!$query->update($name, $status, $assignee, $moddaterange, $sort_col, $sort_ord,
401 $extra_fields, $opendaterange, $closedaterange)) {
402 return new soap_fault ('','artifactUpdateView',$query->getErrorMessage(),$query->getErrorMessage());
405 return $query->getID();