Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 54b5425

Browse files
committed
Finishing implementation of tracker submissions and fixing tests.
1 parent c2ca31d commit 54b5425

File tree

17 files changed

+695
-27
lines changed

17 files changed

+695
-27
lines changed

modules/tracker/configs/module.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ description = "Track scalar results over time"
66
category = "Visualization"
77
dependencies = api,scheduler
88
uuid = "3048a9fa-89ab-4e61-a55e-a49379fa6dc"
9-
version = "1.1.0"
9+
version = "1.2.0"
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
/*=========================================================================
3+
Midas Server
4+
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
5+
All rights reserved.
6+
For more information visit http://www.kitware.com/.
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
/**
22+
* API submission controller for the tracker module.
23+
*
24+
* @package Modules\Tracker\Controller
25+
*/
26+
class Apitracker_SubmissionController extends ApiController
27+
{
28+
/** @var string */
29+
public $moduleName = 'tracker';
30+
31+
/** Handle HTTP DELETE requests. Requires an id parameter. */
32+
public function deleteAction()
33+
{
34+
$this->_genericAction(
35+
$this->_request->getParams(),
36+
$this->_request->getControllerName(),
37+
$this->_request->getActionName(),
38+
array('default' => $this->_request->getActionName()),
39+
$this->moduleName,
40+
false
41+
);
42+
}
43+
44+
/** Handle HTTP GET requests. Requires an id parameter. */
45+
public function getAction()
46+
{
47+
$this->_genericAction(
48+
$this->_request->getParams(),
49+
$this->_request->getControllerName(),
50+
$this->_request->getActionName(),
51+
array('default' => $this->_request->getActionName()),
52+
$this->moduleName,
53+
false
54+
);
55+
}
56+
57+
/** Handle HTTP HEAD requests. */
58+
public function headAction()
59+
{
60+
$this->_response->setHttpResponseCode(200); // 200 OK
61+
}
62+
63+
/** Handle HTTP GET index or list requests. */
64+
public function indexAction()
65+
{
66+
$this->_genericAction(
67+
$this->_request->getParams(),
68+
$this->_request->getControllerName(),
69+
$this->_request->getActionName(),
70+
array('default' => $this->_request->getActionName()),
71+
$this->moduleName,
72+
false
73+
);
74+
}
75+
76+
/** Handle HTTP OPTIONS requests. */
77+
public function optionsAction()
78+
{
79+
$this->_response->setHeader('Allow', 'DELETE, GET, HEAD, OPTIONS, POST, PUT');
80+
}
81+
82+
/** Handle HTTP POST requests. */
83+
public function postAction()
84+
{
85+
$this->_genericAction(
86+
$this->_request->getParams(),
87+
$this->_request->getControllerName(),
88+
$this->_request->getActionName(),
89+
array('default' => $this->_request->getActionName()),
90+
$this->moduleName,
91+
false
92+
);
93+
}
94+
95+
/** Handle HTTP PUT requests. Requires an id parameter. */
96+
public function putAction()
97+
{
98+
$this->_genericAction(
99+
$this->_request->getParams(),
100+
$this->_request->getControllerName(),
101+
$this->_request->getActionName(),
102+
array('default' => $this->_request->getActionName()),
103+
$this->moduleName,
104+
false
105+
);
106+
}
107+
}

modules/tracker/controllers/components/ApiComponent.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public function itemAssociate($args)
116116
* @param producerRevision The repository revision of the producer that produced this value
117117
* @param submitTime The submit timestamp. Must be parseable with PHP strtotime().
118118
* @param value The value of the scalar
119+
* @param submissionId (Optional) the id of the submission
120+
* @param submissionUuid (Optional) the uuid of the submission
119121
* @param buildResultsUrl (Optional) The URL where build results can be viewed
120122
* @param extraUrls (Optional) JSON list of additional links
121123
* @param params (Optional) JSON object of arbitrary key/value pairs to display
@@ -261,11 +263,22 @@ public function scalarAdd($args)
261263

262264
$producerRevision = trim($args['producerRevision']);
263265

266+
$submissionId = -1;
267+
if (isset($args['submissionId'])) {
268+
$submissionId = $args['submissionId'];
269+
} else if (isset($args['submissionUuid'])) {
270+
$uuid = $args['submissionUuid'];
271+
$submissionModel = MidasLoader::loadModel('Submission', 'tracker');
272+
$submissionDao = $submissionModel->getOrCreateSubmission($producer, $uuid);
273+
$submissionId = $submissionDao->getKey();
274+
}
275+
264276
/** @var Tracker_ScalarModel $scalarModel */
265277
$scalarModel = MidasLoader::loadModel('Scalar', 'tracker');
266278
$scalar = $scalarModel->addToTrend(
267279
$trend,
268280
$submitTime,
281+
$submissionId,
269282
$producerRevision,
270283
$value,
271284
$user,
@@ -336,6 +349,9 @@ public function scalarAdd($args)
336349
*/
337350
public function resultsUploadJson($args)
338351
{
352+
/** Change this to add a submission Id or UUID */
353+
354+
$submissionId = -1;
339355
/** @var CommunityModel $communityModel */
340356
$communityModel = MidasLoader::loadModel('Community');
341357

@@ -509,6 +525,7 @@ public function resultsUploadJson($args)
509525
$scalar = $scalarModel->addToTrend(
510526
$trend,
511527
$submitTime,
528+
$submissionId,
512529
$producerRevision,
513530
$value,
514531
$user,
@@ -571,6 +588,7 @@ public function resultsUploadJson($args)
571588
$scalar = $scalarModel->addToTrend(
572589
$trend,
573590
$submitTime,
591+
$submissionId,
574592
$producerRevision,
575593
$value,
576594
$user,
@@ -626,4 +644,19 @@ private function _createOrFindByName($itemName, $community)
626644

627645
return $items[0];
628646
}
647+
648+
/**
649+
* Create a new submission
650+
*
651+
* @param uuid (Optional) A unique identifier for the submission
652+
* @param name (Optional) A name for the submission
653+
* @return The submission DAO that was created
654+
* @throws Exception
655+
*/
656+
public function submissionAdd($args)
657+
{
658+
$newApi = MidasLoader::loadComponent('Apisubmission',
659+
'tracker');
660+
return $newApi->post($args);
661+
}
629662
}

modules/tracker/controllers/components/ApiscalarComponent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public function index($args)
121121
* @path /tracker/scalar
122122
* @http POST
123123
* @param trend_id
124+
* @param submission_id (Optional)
124125
* @param user_id (Optional)
125126
* @param official (Optional)
126127
* @param build_results_url (Optional)
@@ -184,6 +185,7 @@ public function post($args)
184185
* @http PUT
185186
* @param id
186187
* @param trend_id
188+
* @param submission_id (Optional)
187189
* @param user_id (Optional)
188190
* @param official (Optional)
189191
* @param build_results_url (Optional)

0 commit comments

Comments
 (0)