Skip to content

Commit

Permalink
Remove hard-coded SUPREMM references from the core.
Browse files Browse the repository at this point in the history
The realm settings were hardcoded in a couple of places in the code.
  • Loading branch information
jpwhite4 committed Oct 17, 2018
1 parent 1c60333 commit fa4c069
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 165 deletions.
43 changes: 33 additions & 10 deletions classes/Rest/Controllers/WarehouseControllerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1482,8 +1482,15 @@ private function getJobData(Application $app, XDUser $user, $realm, $jobId, $act
*/
private function getJobDataSet(XDUser $user, $realm, $jobId, $action)
{
$config = \Xdmod\Config::factory();

$rawstats = $config['rawstatistics'];
if (!isset($rawstats['realms'][$realm])) {
throw new \DataWarehouse\Query\Exceptions\AccessDeniedException;
}

$params = array(
new \DataWarehouse\Query\Model\Parameter('_id', '=', $jobId)
new \DataWarehouse\Query\Model\Parameter($rawstats['realms'][$realm]['primary_key'], '=', $jobId)
);

$QueryClass = "\\DataWarehouse\\Query\\$realm\\JobDataset";
Expand Down Expand Up @@ -1761,17 +1768,26 @@ private function processHistoryRequest(Application $app, XDUser $user, $realm, $
*/
private function processHistoryDefaultRealmRequest(Application $app, $action)
{
$config = \Xdmod\Config::factory();

$rawstats = $config['rawstatistics'];

$results = array();

if (isset($rawstats['realms'])) {
foreach($rawstats['realms'] as $realm => $realmconfig) {
$results[] = array('dtype' => 'realm',
'realm' => $realm,
'text' => $realmconfig['name']
);
}
}

return $app->json(
array(
'success' => true,
'action' => $action,
'results' => array(
array(
'dtype' => 'realm',
'realm' => 'SUPREMM',
'text' => 'SUPREMM'
)
)
'results' => $results
)
);
}
Expand Down Expand Up @@ -2062,14 +2078,21 @@ private function getJobTimeSeriesData(Application $app, Request $request, \XDUse
*/
private function getJobByPrimaryKey(Application $app, \XDUser $user, $realm, $searchparams)
{
$config = \Xdmod\Config::factory();

$rawstats = $config['rawstatistics'];
if (!isset($rawstats['realms'][$realm])) {
throw new \DataWarehouse\Query\Exceptions\AccessDeniedException;
}

if (isset($searchparams['jobref'])) {
$params = array(
new \DataWarehouse\Query\Model\Parameter('_id', '=', $searchparams['jobref'])
new \DataWarehouse\Query\Model\Parameter($rawstats['realms'][$realm]['primary_key'], '=', $searchparams['jobref'])
);
} else {
$params = array(
new \DataWarehouse\Query\Model\Parameter("resource_id", "=", $searchparams['resource_id']),
new \DataWarehouse\Query\Model\Parameter("local_job_id", "=", $searchparams['local_job_id'])
new \DataWarehouse\Query\Model\Parameter($rawstats['realms'][$realm]['ident_key'], "=", $searchparams['local_job_id'])
);
}

Expand Down
Empty file.
3 changes: 3 additions & 0 deletions configuration/rawstatistics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"realms": []
}
Loading

0 comments on commit fa4c069

Please sign in to comment.