Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1172ab1
WIP: Migrate data from scalar to submission in tracker.
cpatrick Mar 6, 2016
32fe86a
Clean up SQL files.
cpatrick Mar 9, 2016
791b62b
Move more data up from scalar to submission.
cpatrick Mar 12, 2016
e3002e1
Upping version.
cpatrick Mar 16, 2016
eb26aff
Removing PGSQL and SQLite. Starting to fix the tests.
cpatrick Mar 17, 2016
041ab15
Applied fixes from StyleCI
cpatrick Mar 17, 2016
57eaaf3
Merge pull request #216 from midasplatform/analysis-qJ2OeD
cpatrick Mar 17, 2016
ec6b465
Fixing some more tests.
cpatrick Mar 17, 2016
210a8ea
Fix the tracker tests.
cpatrick Mar 18, 2016
3ca6379
Applied fixes from StyleCI
cpatrick Mar 18, 2016
8e733eb
Merge pull request #217 from midasplatform/analysis-XWNA6V
cpatrick Mar 18, 2016
42b6e61
Some api fixes for submission.
cpatrick Mar 19, 2016
9c14cc7
First pass at review response.
cpatrick Mar 22, 2016
d11e1e2
Applied fixes from StyleCI
cpatrick Mar 22, 2016
8df1dac
Merge pull request #220 from midasplatform/analysis-qx0YD9
cpatrick Mar 22, 2016
96996d3
Address review points.
cpatrick Mar 23, 2016
7a455a5
Applied fixes from StyleCI
cpatrick Mar 23, 2016
fc1442e
Merge pull request #222 from midasplatform/analysis-q1bOOA
cpatrick Mar 23, 2016
e8103e6
Remove default value of submission_id on tracker_scalar.
cpatrick Mar 23, 2016
df1b31a
Merge branch 'master' into tracker-2.0
Mar 23, 2016
3621b1b
Remove incorrect migration comments
Mar 23, 2016
cd62b62
Combine tracker_scalar drops into single alter statement
Mar 23, 2016
fc35df2
Add branch to scalar dao.
cpatrick Mar 24, 2016
7167c31
Remove result items from scalar details dialog.
cpatrick Mar 24, 2016
de21381
Add a first cut at trend groups.
cpatrick Apr 8, 2016
fddb28b
Applied fixes from StyleCI
cpatrick Apr 8, 2016
e82702c
Merge pull request #225 from midasplatform/analysis-qgOb5d
cpatrick Apr 8, 2016
a25b5c0
Merge remote-tracking branch 'origin/master' into tracker-2.0
cpatrick Apr 8, 2016
3ca3bb6
Remove pgsql relics from db upgrade.
cpatrick Apr 8, 2016
f7705ed
Add trendgroup to submission2item.
cpatrick Apr 8, 2016
aa2709c
Applied fixes from StyleCI
cpatrick Apr 9, 2016
0e030d0
Merge pull request #226 from midasplatform/analysis-zRvGk9
cpatrick Apr 9, 2016
e3e9eb6
Fix tracker tests due to trend group additions.
cpatrick Apr 9, 2016
6383414
Fix case of trend model filenames.
cpatrick Apr 9, 2016
6ef450c
Add indices for producer page performance.
cpatrick Apr 9, 2016
8782d15
Respond to review from @mgrauer.
cpatrick Apr 11, 2016
1ee80e8
Add support for limiting scalars from a submission by trendgroup.
cpatrick Apr 11, 2016
c7f5988
Applied fixes from StyleCI
Apr 12, 2016
eaeef52
Merge pull request #227 from midasplatform/analysis-zRv4JO
Apr 12, 2016
daf9083
Separate notification from aggregate metric spec model, upgrade Track…
Apr 13, 2016
ce16270
Split notification from specs in API
Apr 13, 2016
d265627
Split notification from spec in tracker Notification email
Apr 13, 2016
5d0bc1c
Split notification from spec in management UI
Apr 13, 2016
fac2630
Applied fixes from StyleCI
Apr 13, 2016
1ee6f0b
Merge pull request #229 from midasplatform/analysis-XWNK6j
Apr 13, 2016
9996340
Adjust notifications when creating metrics for a submission
Apr 13, 2016
e3435f2
Test alert job creation in aggregatemetric update API
Apr 13, 2016
020cf5f
Applied fixes from StyleCI
Apr 13, 2016
341402e
Merge pull request #230 from midasplatform/analysis-8KZjKD
Apr 13, 2016
31ed720
Add debug statements to tracker upgrade sql script
Apr 13, 2016
1a86288
Require READ for aggregatemetricnotification GET
Apr 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions modules/tracker/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
/**
* Notification manager for the tracker module.
*
* @property Tracker_AggregateMetricModel $Tracker_AggregateMetric
* @property Tracker_AggregateMetricSpecModel $Tracker_AggregateMetricSpec
* @property Tracker_ScalarModel $Tracker_Scalar
* @property Tracker_SubmissionModel $Tracker_Submission
* @property Tracker_TrendModel $Tracker_Trend
*/
class Tracker_Notification extends ApiEnabled_Notification
Expand All @@ -35,7 +38,7 @@ class Tracker_Notification extends ApiEnabled_Notification
public $_models = array('User');

/** @var array */
public $_moduleModels = array('Scalar', 'Trend', 'AggregateMetricSpec', 'AggregateMetric');
public $_moduleModels = array('AggregateMetric', 'AggregateMetricNotification', 'AggregateMetricSpec', 'Scalar', 'Submission', 'Trend');

/** @var array */
public $_moduleComponents = array('Api');
Expand Down Expand Up @@ -94,7 +97,7 @@ public function communityDeleted($args)
}

/**
* When an item is deleted, we must delete associated item2scalar records.
* When an item is deleted, we must delete associated item2submission records.
*
* @todo
* @param array $args associative array of parameters including the key "item"
Expand Down Expand Up @@ -221,27 +224,37 @@ public function sendAggregateEmail($params)
$userDao = $this->User->load($params['recipient_id']);
if ($userDao === false) {
$this->getLogger()->warn(
'Attempting to send aggregate metric threshold notification to user id '.$params['recipientId'].': No such user.'
'Attempting to send aggregate metric threshold notification to user id '.$params['recipient_id'].': No such user.'
);

return;
}

/** @var Tracker_AggregateMetricDao $aggregateMetricDao */
$aggregateMetricDao = $this->Tracker_AggregateMetric->load($params['aggregate_metric_id']);
if ($aggregateMetricDao === false) {
$this->getLogger()->warn(
'Attempting to send aggregate metric threshold notification with aggregate metric '.$params['aggregate_metric_id'].': No such metric.'
);

return;
}

/** @var Tracker_AggregateMetricSpecDao $aggregateMetricSpecDao */
$aggregateMetricSpecDao = $this->Tracker_AggregateMetricSpec->load($params['aggregate_metric_spec_id']);
$aggregateMetricSpecDao = $aggregateMetricDao->getAggregateMetricSpec();
if ($aggregateMetricSpecDao === false) {
$this->getLogger()->warn(
'Attempting to send aggregate metric threshold notification with aggregate metric spec '.$params['aggregateMetricSpecId'].': No such spec.'
'Attempting to send aggregate metric threshold notification with aggregate metric spec that does not exist.'
);

return;
}

/** @var Tracker_AggregateMetricDao $aggregateMetricDao */
$aggregateMetricDao = $this->Tracker_AggregateMetric->load($params['aggregate_metric_id']);
/** @var Tracker_AggregateMetricNotificationDao $aggregateMetricNotificationDao */
$aggregateMetricNotificationDao = $this->Tracker_AggregateMetricNotification->load($params['aggregate_metric_notification_id']);
if ($aggregateMetricDao === false) {
$this->getLogger()->warn(
'Attempting to send aggregate metric threshold notification with aggregate metric '.$params['aggregateMetricId'].': No such metric.'
'Attempting to send aggregate metric threshold notification with aggregate metric notification id '.$params['aggregate_metric_notification_id'].': No such notification.'
);

return;
Expand All @@ -254,9 +267,9 @@ public function sendAggregateEmail($params)

$producerName = $producerDao->getDisplayName();
$metricName = $aggregateMetricSpecDao->getName();
$branch = $aggregateMetricSpecDao->getBranch();
$thresholdValue = $aggregateMetricSpecDao->getValue();
$thresholdComparison = $aggregateMetricSpecDao->getComparison();
$thresholdValue = $aggregateMetricNotificationDao->getValue();
$thresholdComparison = $aggregateMetricNotificationDao->getComparison();
$branch = $aggregateMetricNotificationDao->getBranch();
$metricValue = $aggregateMetricDao->getValue();
$subject = 'Threshold Alert: '.$producerName.': '.$metricName;

Expand Down
2 changes: 1 addition & 1 deletion modules/tracker/configs/module.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ description = "Track scalar results over time"
category = "Visualization"
dependencies = api,scheduler
uuid = "3048a9fa-89ab-4e61-a55e-a49379fa6dc"
version = "1.2.4"
version = "2.0.1"
2 changes: 1 addition & 1 deletion modules/tracker/controllers/ProducerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function viewAction()
}

$this->view->producer = $producerDao;
$this->view->trendGroups = $this->Tracker_Trend->getTrendsGroupByDatasets($producerDao);
$this->view->trendGroups = $this->Tracker_Trend->getTrendsByGroup($producerDao);
$this->view->isAdmin = $this->Tracker_Producer->policyCheck($producerDao, $this->userSession->Dao, MIDAS_POLICY_ADMIN);
$this->view->json['tracker']['producer'] = $producerDao;

Expand Down
23 changes: 14 additions & 9 deletions modules/tracker/controllers/ScalarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
* Scalar controller for the tracker module.
*
* @property Tracker_ScalarModel $Tracker_Scalar
* @property Tracker_SubmissionModel $Tracker_Submission
*/
class Tracker_ScalarController extends Tracker_AppController
{
/** @var array */
public $_moduleModels = array('Scalar');
public $_moduleModels = array('Scalar', 'Submission');

/**
* Display the dialog of scalar details, including associated result items with thumbnails.
Expand All @@ -50,18 +51,23 @@ public function detailsAction()
/** @var Tracker_ScalarDao $scalarDao */
$scalarDao = $this->Tracker_Scalar->load($scalarId);

/** @var Tracker_SubmissionDao $submissionDao */
$submissionDao = $this->Tracker_Submission->load($scalarDao->getSubmissionId());

if ($this->Tracker_Scalar->policyCheck($scalarDao, $this->userSession->Dao, MIDAS_POLICY_READ) === false
) {
throw new Zend_Exception('The scalar does not exist or you do not have the necessary permission', 403);
}

$this->view->isAdmin = $this->Tracker_Scalar->policyCheck($scalarDao, $this->userSession->Dao, MIDAS_POLICY_ADMIN);

$this->view->scalar = $scalarDao;
$this->view->extraParams = $scalarDao->getParams();
$this->view->extraUrls = json_decode($scalarDao->getExtraUrls(), true);
$this->view->submission = $submissionDao;
$this->view->extraParams = $submissionDao->getParams();
$this->view->extraUrls = json_decode($submissionDao->getExtraUrls(), true);

$revisionUrl = $scalarDao->getTrend()->getProducer()->getRevisionUrl();
$producerRevision = $scalarDao->getProducerRevision();
$revisionUrl = $submissionDao->getProducer()->getRevisionUrl();
$producerRevision = $submissionDao->getProducerRevision();

if (!is_null($revisionUrl)) {
$producerRevisionUrl = preg_replace('/%revision/', $producerRevision, $revisionUrl);
Expand All @@ -70,11 +76,10 @@ public function detailsAction()
$this->view->revisionHtml = $producerRevision;
}

$this->view->resultItems = $this->Tracker_Scalar->getAssociatedItems($scalarDao);
$this->view->otherValues = $this->Tracker_Scalar->getOtherValuesFromSubmission($scalarDao);
$this->view->otherValues = $this->Tracker_Submission->getValuesFromSubmission($submissionDao);

if ($scalarDao->getUserId() !== -1) {
$this->view->submittedBy = $scalarDao->getUser();
if ($submissionDao->getUserId() !== -1) {
$this->view->submittedBy = $submissionDao->getUser();
} else {
$this->view->submittedBy = null;
}
Expand Down
17 changes: 11 additions & 6 deletions modules/tracker/controllers/TrendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
* @property Tracker_ScalarModel $Tracker_Scalar
* @property Tracker_ThresholdNotificationModel $Tracker_ThresholdNotification
* @property Tracker_TrendModel $Tracker_Trend
* @property Tracker_SubmissionModel $Tracker_Submission
* @property Tracker_ProducerModel $Tracker_Producer
*/
class Tracker_TrendController extends Tracker_AppController
{
/** @var array */
public $_components = array('Breadcrumb');

/** @var array */
public $_moduleModels = array('Producer', 'Scalar', 'ThresholdNotification', 'Trend');
public $_moduleModels = array('Producer', 'Scalar', 'ThresholdNotification', 'Trend', 'Submission');

/**
* View a given trend.
Expand Down Expand Up @@ -81,7 +83,7 @@ public function viewAction()

$userId = $this->userSession->Dao ? $this->userSession->Dao->getKey() : null;

$this->view->allBranches = $this->Tracker_Scalar->getDistinctBranches();
$this->view->allBranches = $this->Tracker_Submission->getDistinctBranches();

$trendIds = explode(' ', trim(str_replace(',', ' ', $trendId)));
$trendDaos = array();
Expand All @@ -104,15 +106,15 @@ public function viewAction()
);

if (!isset($this->view->json['tracker']['producerId'])) {
$this->view->json['tracker']['producerId'] = $trendDao->getProducerId();
$this->view->json['tracker']['producerId'] = $trendDao->getTrendgroup()->getProducerId();
}

$trendDaos[] = $trendDao;
}

/** @var Tracker_TrendDao $trendDao */
$trendDao = $trendDaos[0];
$producerDao = $trendDao->getProducer();
$producerDao = $trendDao->getTrendgroup()->getProducer();
$communityDao = $producerDao->getCommunity();

if (count($trendDaos) === 1) {
Expand All @@ -131,7 +133,7 @@ public function viewAction()
/** @var Tracker_TrendDao $rightTrendDao */
$rightTrendDao = $this->Tracker_Trend->load($rightTrendId);

if ($communityDao !== false && $communityDao->getKey() !== $rightTrendDao->getProducer()->getCommunityId()
if ($communityDao !== false && $communityDao->getKey() !== $rightTrendDao->getTrendgroup()->getProducer()->getCommunityId()
) {
throw new Zend_Exception('The right trend must belong to the same community as the other trends', 403);
}
Expand Down Expand Up @@ -555,8 +557,11 @@ public function setkeymetricAction()
/** @var Tracker_TrendDao $trendDao */
$trendDao = $this->Tracker_Trend->load($trendId);

/** @var Tracker_TrendgroupDao $trendGroup */
$trendGroup = $trendDao->getTrendgroup();

/** @var Tracker_ProducerDao $producerDao */
$producerDao = $trendDao->getProducer();
$producerDao = $trendGroup->getProducer();

if ($this->Tracker_Producer->policyCheck($producerDao, $this->userSession->Dao, MIDAS_POLICY_ADMIN) === false
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/*=========================================================================
Midas Server
Copyright Kitware SAS, 26 rue Louis Guérin, 69100 Villeurbanne, France.
All rights reserved.
For more information visit http://www.kitware.com/.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0.txt

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

/** API aggregateMetricNotification controller for the tracker module. */
class Apitracker_AggregatemetricnotificationController extends ApiController
{
/** @var string */
public $moduleName = 'tracker';

/** Handle HTTP DELETE requests. Requires an id parameter. */
public function deleteAction()
{
$this->_genericAction(
$this->_request->getParams(),
$this->_request->getControllerName(),
$this->_request->getActionName(),
array('default' => $this->_request->getActionName()),
$this->moduleName,
false
);
}

/** Handle HTTP GET requests. Requires an id parameter. */
public function getAction()
{
$this->_genericAction(
$this->_request->getParams(),
$this->_request->getControllerName(),
$this->_request->getActionName(),
array('default' => $this->_request->getActionName()),
$this->moduleName,
false
);
}

/** Handle HTTP HEAD requests. */
public function headAction()
{
$this->_response->setHttpResponseCode(200); // 200 OK
}

/** Handle HTTP GET index or list requests. */
public function indexAction()
{
$this->_genericAction(
$this->_request->getParams(),
$this->_request->getControllerName(),
$this->_request->getActionName(),
array('default' => $this->_request->getActionName()),
$this->moduleName,
false
);
}

/** Handle HTTP OPTIONS requests. */
public function optionsAction()
{
$this->_response->setHeader('Allow', 'DELETE, GET, HEAD, OPTIONS, POST, PUT');
}

/** Handle HTTP POST requests. */
public function postAction()
{
$this->_genericAction(
$this->_request->getParams(),
$this->_request->getControllerName(),
$this->_request->getActionName(),
array('default' => $this->_request->getActionName()),
$this->moduleName,
false
);
}

/** Handle HTTP PUT requests. Requires an id parameter. */
public function putAction()
{
$this->_genericAction(
$this->_request->getParams(),
$this->_request->getControllerName(),
$this->_request->getActionName(),
array('default' => $this->_request->getActionName()),
$this->moduleName,
false
);
}
}
Loading