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';
33 $server->wsdl->addComplexType(
34 'ArtifactQueryExtraField',
40 'extra_field_id' => array('name' => 'extra_field_id', 'type' => 'xsd:int'),
41 'values' => array('name' => 'values', 'type' => 'tns:ArrayOfint')
45 $server->wsdl->addComplexType(
46 'ArrayOfArtifactQueryExtraField',
53 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ArtifactQueryExtraField[]')
55 'tns:ArtifactQueryExtraField'
58 $server->wsdl->addComplexType(
59 'ArtifactQueryFields',
65 'sortcol' => array('name' => 'sortcol', 'type' => 'xsd:string'),
66 'sortord' => array('name' => 'sortord', 'type' => 'xsd:string'),
67 'moddaterange' => array('name' => 'changed', 'type' => 'xsd:string'),
68 'assignee' => array('name' => 'assignee', 'type' => 'tns:ArrayOfInteger'),
69 'status' => array('name' => 'status', 'type' => 'xsd:int'),
70 'extra_fields' => array('name' => 'extra_fields', 'type' => 'tns:ArrayOfArtifactQueryExtraField'),
71 'opendaterange' => array('name' => 'changed', 'type' => 'xsd:string'),
72 'closedaterange' => array('name' => 'changed', 'type' => 'xsd:string')
76 $server->wsdl->addComplexType(
83 'artifact_query_id' => array('name' => 'artifact_query_id', 'type' => 'xsd:int'),
84 'name' => array('name' => 'query_name', 'type' => 'xsd:string'),
85 'fields' => array('name' => 'fields', 'type' => 'tns:ArtifactQueryFields')
89 $server->wsdl->addComplexType(
90 'ArrayOfArtifactQuery',
97 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:ArtifactQuery[]')
105 'session_ser'=>'xsd:string',
106 'group_id'=>'xsd:int',
107 'group_artifact_id'=>'xsd:int'
109 array('getArtifactTypesResponse'=>'tns:ArrayOfArtifactQuery'),
111 $uri.'#artifactGetViews','rpc','encoded'
114 function artifactGetViews($session_ser, $group_id, $group_artifact_id) {
115 continue_session($session_ser);
116 $grp = group_get_object($group_id);
117 if (!$grp || !is_object($grp)) {
118 return new soap_fault ('','artifactGetViews','Could Not Get Project','Could Not Get Project');
119 } elseif ($grp->isError()) {
120 return new soap_fault ('','artifactGetViews',$grp->getErrorMessage(),$grp->getErrorMessage());
123 $at = new ArtifactType($grp,$group_artifact_id);
124 if (!$at || !is_object($at)) {
125 return new soap_fault ('','artifactGetViews','Could Not Get ArtifactType','Could Not Get ArtifactType');
126 } elseif ($at->isError()) {
127 return new soap_fault ('','artifactGetViews',$at->getErrorMessage(),$at->getErrorMessage());
130 $aqf = new ArtifactQueryFactory($at);
132 return queries_to_soap($aqf->getArtifactQueries());
135 function queries_to_soap($queries) {
137 // print_r($queries[1]->getExtraFields());
140 if (is_array($queries) && count($queries) > 0) {
141 for ($i=0; $i < count($queries); $i++) {
142 $artifactQuery =& $queries[$i];
144 // transform the extra fields data
145 $extra_fields = array();
146 $queryExtraFields = $artifactQuery->getExtraFields();
147 foreach ($queryExtraFields as $extra_field_id => $values) {
148 // $value may be a int. We wrap it in an array.
149 if (!is_array($values)) $values = array($values);
150 $extra_fields[] = array(
151 "extra_field_id" => $extra_field_id,
156 $assignee = $artifactQuery->getAssignee();
157 // this is a hack, ArtifactQuery::getAssignee sometimes returns an int and
158 // sometimes it returns an array
159 if (!is_array($assignee)) {
160 if (is_numeric($assignee)) { // a single ID
161 $assignee = array($assignee); // wrap in an array
168 "artifact_query_id" => $artifactQuery->getID(),
169 "name" => $artifactQuery->getName(),
171 "sortcol" => $artifactQuery->getSortCol(),
172 "sortord" => $artifactQuery->getSortOrd(),
173 "moddaterange" => $artifactQuery->getModDateRange(),
174 "assignee" => $assignee,
175 "status" => $artifactQuery->getStatus(),
176 "extra_fields" => $extra_fields,
177 "opendaterange" => $artifactQuery->getOpenDateRange(),
178 "closedaterange" => $artifactQuery->getCloseDateRange()
191 'artifactDeleteView',
193 'session_ser'=>'xsd:string',
194 'group_id'=>'xsd:int',
195 'group_artifact_id'=>'xsd:int',
196 'artifact_query_id' => 'xsd:int'
198 array('artifactDeleteViewResponse'=>'xsd:boolean'),
200 $uri.'#artifactDeleteView','rpc','encoded'
203 function artifactDeleteView($session_ser, $group_id, $group_artifact_id, $artifact_query_id) {
204 continue_session($session_ser);
205 $grp = group_get_object($group_id);
206 if (!$grp || !is_object($grp)) {
207 return new soap_fault ('','artifactDeleteView','Could Not Get Group','Could Not Get Group');
208 } elseif ($grp->isError()) {
209 return new soap_fault ('','artifactDeleteView',$grp->getErrorMessage(),$grp->getErrorMessage());
212 $at = new ArtifactType($grp,$group_artifact_id);
213 if (!$at || !is_object($at)) {
214 return new soap_fault ('','artifactDeleteView','Could Not Get ArtifactType','Could Not Get ArtifactType');
215 } elseif ($at->isError()) {
216 return new soap_fault ('','artifactDeleteView',$at->getErrorMessage(),$at->getErrorMessage());
219 $query = new ArtifactQuery($at, $artifact_query_id);
220 if (!$query || !is_object($query)) {
221 return new soap_fault ('','artifactDeleteView','Could Not Get Query','Could Not Get Query');
222 } elseif ($query->isError()) {
223 return new soap_fault ('','artifactDeleteView',$query->getErrorMessage(),$query->getErrorMessage());
236 'session_ser'=>'xsd:string',
237 'group_id'=>'xsd:int',
238 'group_artifact_id'=>'xsd:int',
239 'artifact_query_id' => 'xsd:int'
241 array('artifactSetView'=>'xsd:boolean'),
243 $uri.'#artifactSetView','rpc','encoded'
246 function artifactSetView($session_ser, $group_id, $group_artifact_id, $artifact_query_id) {
247 continue_session($session_ser);
248 $grp = group_get_object($group_id);
249 if (!$grp || !is_object($grp)) {
250 return new soap_fault ('','artifactSetView','Could Not Get Group','Could Not Get Group');
251 } elseif ($grp->isError()) {
252 return new soap_fault ('','artifactSetView',$grp->getErrorMessage(),$grp->getErrorMessage());
255 $at = new ArtifactType($grp,$group_artifact_id);
256 if (!$at || !is_object($at)) {
257 return new soap_fault ('','artifactSetView','Could Not Get ArtifactType','Could Not Get ArtifactType');
258 } elseif ($at->isError()) {
259 return new soap_fault ('','artifactSetView',$at->getErrorMessage(),$at->getErrorMessage());
262 $query = new ArtifactQuery($at, $artifact_query_id);
263 if (!$query || !is_object($query)) {
264 return new soap_fault ('','artifactDeleteView','Could Not Get Query','Could Not Get Query');
265 } elseif ($query->isError()) {
266 return new soap_fault ('','artifactDeleteView',$query->getErrorMessage(),$query->getErrorMessage());
269 $query->makeDefault();
276 $server->wsdl->addComplexType(
284 array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:int[]')
290 'artifactCreateView',
292 'session_ser'=>'xsd:string',
293 'group_id'=>'xsd:int',
294 'group_artifact_id'=>'xsd:int',
295 'name'=>'xsd:string',
297 'assignee'=>'tns:ArrayOfUserID',
298 'moddaterange'=>'xsd:string',
299 'sort_col'=>'xsd:string',
300 'sort_ord'=>'xsd:string',
301 'extra_fields'=>'tns:ArrayOfArtifactExtraFieldsData',
302 'opendaterange'=>'xsd:string',
303 'closedaterange'=>'xsd:string'
305 array('artifactCreateViewResponse'=>'xsd:int'),
307 $uri.'#artifactCreateView','rpc','encoded'
309 function artifactCreateView($session_ser, $group_id, $group_artifact_id, $name, $status, $assignee, $moddaterange,
310 $sort_col, $sort_ord, $extra_fields, $opendaterange, $closedaterange) {
312 continue_session($session_ser);
313 $grp = group_get_object($group_id);
314 if (!$grp || !is_object($grp)) {
315 return new soap_fault ('','artifactCreateView','Could Not Get Group','Could Not Get Group');
316 } elseif ($grp->isError()) {
317 return new soap_fault ('','artifactCreateView',$grp->getErrorMessage(),$grp->getErrorMessage());
320 $at = new ArtifactType($grp,$group_artifact_id);
321 if (!$at || !is_object($at)) {
322 return new soap_fault ('','artifactCreateView','Could Not Get ArtifactType','Could Not Get ArtifactType');
323 } elseif ($at->isError()) {
324 return new soap_fault ('','artifactCreateView',$at->getErrorMessage(),$at->getErrorMessage());
327 //rearrange the extra fields
328 $aef = $at->getExtraFields();
329 $extra_fields = arrangeExtraFields($extra_fields, $aef);
331 $query = new ArtifactQuery($at);
332 if (!$query->create($name, $status, $assignee, $moddaterange, $sort_col,
333 $sort_ord, $extra_fields, $opendaterange, $closedaterange)) {
334 return new soap_fault ('','artifactCreateView',$query->getErrorMessage(),$query->getErrorMessage());
337 return $query->getID();
345 'artifactUpdateView',
347 'session_ser'=>'xsd:string',
348 'group_id'=>'xsd:int',
349 'group_artifact_id'=>'xsd:int',
350 'query_id'=>'xsd:int',
351 'name'=>'xsd:string',
353 'assignee'=>'tns:ArrayOfUserID',
354 'moddaterange'=>'xsd:string',
355 'sort_col'=>'xsd:string',
356 'sort_ord'=>'xsd:string',
357 'extra_fields'=>'tns:ArrayOfArtifactExtraFieldsData',
358 'opendaterange'=>'xsd:string',
359 'closedaterange'=>'xsd:string'
361 array('artifactUpdateViewResponse'=>'xsd:int'),
363 $uri.'#artifactUpdateView','rpc','encoded'
366 function artifactUpdateView($session_ser, $group_id, $group_artifact_id, $query_id, $name, $status, $assignee, $moddaterange,
367 $sort_col, $sort_ord, $extra_fields, $opendaterange, $closedaterange) {
369 continue_session($session_ser);
370 $grp = group_get_object($group_id);
371 if (!$grp || !is_object($grp)) {
372 return new soap_fault ('','artifactUpdateView','Could Not Get Group','Could Not Get Group');
373 } elseif ($grp->isError()) {
374 return new soap_fault ('','artifactCreateView',$grp->getErrorMessage(),$grp->getErrorMessage());
377 $at = new ArtifactType($grp,$group_artifact_id);
378 if (!$at || !is_object($at)) {
379 return new soap_fault ('','artifactUpdateView','Could Not Get ArtifactType','Could Not Get ArtifactType');
380 } elseif ($at->isError()) {
381 return new soap_fault ('','artifactUpdateView',$at->getErrorMessage(),$at->getErrorMessage());
384 //rearrange the extra fields
385 $aef = $at->getExtraFields();
386 $extra_fields = arrangeExtraFields($extra_fields, $aef);
388 $query = new ArtifactQuery($at, $query_id);
389 if (!$query || !is_object($query)) {
390 return new soap_fault ('','artifactUpdateView','Could Not Get ArtifactType','Could Not Get ArtifactType');
391 } elseif ($query->isError()) {
392 return new soap_fault ('','artifactUpdateView',$query->getErrorMessage(),$query->getErrorMessage());
395 if (!$query->update($name, $status, $assignee, $moddaterange, $sort_col, $sort_ord,
396 $extra_fields, $opendaterange, $closedaterange)) {
397 return new soap_fault ('','artifactUpdateView',$query->getErrorMessage(),$query->getErrorMessage());
400 return $query->getID();