Skip to content

Commit

Permalink
Merge pull request #1047 from jpwhite4/show_in_catalog
Browse files Browse the repository at this point in the history
Add ability to hide realm from the metric catalog
  • Loading branch information
jpwhite4 authored Sep 19, 2019
2 parents cf85af6 + 078f3e1 commit 908511d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 13 additions & 2 deletions classes/DataWarehouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ public static function getAllocations($config = array())
* Get a mapping of categories to realms.
*
* If a realm does not explicitly declare a category, its name is used
* as the category.
* as the category. If a realm has the show_in_catalog property set to false
* then it does not appear in the list of categories.
*
* @return array An associative array mapping categories to the realms
* they contain.
Expand All @@ -369,6 +370,9 @@ public static function getCategories()

$categories = array();
foreach ($dwConfig['realms'] as $realmName => $realm) {
if (isset($realm['show_in_catalog']) && $realm['show_in_catalog'] === false) {
continue;
}
$category = (
isset($realm['category'])
? $realm['category']
Expand All @@ -387,12 +391,19 @@ public static function getCategories()
*
* @param string $realmName The name of the realm to get
* the category for.
* @return string The category the realm belongs to.
* @return string The category the realm belongs to or null if
* the realm has the show_in_catalog flag set to false.
*/
public static function getCategoryForRealm($realmName)
{
$dwConfig = \Configuration\XdmodConfiguration::assocArrayFactory('datawarehouse.json', CONFIG_DIR);

if (isset($dwConfig['realms'][$realmName]['show_in_catalog'])
&& $dwConfig['realms'][$realmName]['show_in_catalog'] === false
) {
return null;
}

if (isset($dwConfig['realms'][$realmName]['category'])) {
return $dwConfig['realms'][$realmName]['category'];
}
Expand Down
6 changes: 5 additions & 1 deletion html/controllers/metric_explorer/get_dw_descripter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@

foreach($query_descripter_realms as $query_descripter_realm => $query_descripter_groups)
{
$category = DataWarehouse::getCategoryForRealm($query_descripter_realm);
if ($category === null) {
continue;
}
$seenstats = array();

$realms[$query_descripter_realm] = array(
'text' => $query_descripter_realm,
'category' => DataWarehouse::getCategoryForRealm($query_descripter_realm),
'category' => $category,
'dimensions' => array(),
'metrics' => array(),
);
Expand Down

0 comments on commit 908511d

Please sign in to comment.