Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2103 - Add Dataset Filtering #97

Merged
merged 5 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
7.x-1.14
-------
- #95 Add UI for odsm cache admin.
- #2103 Added Dataset Federated Data Filtering

7.x-1.13.4
----------
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ When you return to the tags section of the form after saving, you will now see a

![screen shot 2014-07-16 at 12 22 00 am](https://cloud.githubusercontent.com/assets/512243/5281826/ad5e3eac-7ac6-11e4-8c7d-91076527c84d.png)

### Data Federation Filtering

To exclude specific groups from the API, navigate to `/admin/config/services/odsm/settings` and choose the groups you wish to include.

You must then edit your API and check the **Apply Data Federation Filters** checkbox for the filters to apply to your endpoint.

## Customizing

### Adding new schemas
Expand Down
1 change: 1 addition & 0 deletions dkan-module-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ else
fi

ahoy drush en $DKAN_MODULE -y
ahoy drush updb -y

#Fix for behat bug not recognizing symlinked feature files or files outside it's root. See https://jira.govdelivery.com/browse/CIVIC-1005
#cp dkan_workflow/test/features/dkan_workflow.feature dkan/test/features/.
49 changes: 49 additions & 0 deletions open_data_schema_map.admin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* @file
* ODSM Admin form functions.
*/

/**
* ODSM Admin Settings Form.
*
* @param array $form_state
* Form state array
*
* @return array
* Form array
*/
function open_data_schema_map_admin_settings_form($form_state) {
$available_filters = _open_data_schema_map_get_available_filters('name');
$form['data_json'] = array(
'#type' => 'fieldset',
'#title' => t('Data Federation Filters'),
'#description' => t('Use this form to exclude specific groups from federated data. Currently, these filters are available to schemas:') . ' ' . implode(', ', $available_filters),
);
$group_options = array();
$result = db_query("SELECT node.title AS node_title, node.nid AS nid
FROM {node} node
WHERE ((node.status = '1') AND (node.type IN ('group')) )
ORDER BY node_title ASC"
);
if ($result) {
foreach ($result as $record) {
$group_options[$record->nid] = $record->node_title;
}
}
$form['data_json']['odsm_settings_groups'] = array(
'#type' => 'checkboxes',
'#title' => t('Groups to include'),
'#default_value' => variable_get('odsm_settings_groups', array()),
'#options' => $group_options,
'#description' => t('If none of the groups are selected, all groups will be included in the data.json. If any of the groups are checked, only datasets belonging to those groups will be included.'),
);
$form['data_json']['odsm_settings_no_publishers'] = array(
'#type' => 'checkbox',
'#title' => t('Include datasets with no listed publisher in the data.json.'),
'#description' => t('If this option is selected, datasets with no listed publisher will be given the default publisher name.'),
'#default_value' => variable_get('odsm_settings_no_publishers', 1),
);

return system_settings_form($form);
}
33 changes: 28 additions & 5 deletions open_data_schema_map.install
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function open_data_schema_map_schema() {
'description' => 'Output Format.',
'type' => 'varchar',
'length' => 20,
'not null' => True,
'not null' => TRUE,
'default' => 'json',
),
'endpoint' => array(
Expand All @@ -87,6 +87,13 @@ function open_data_schema_map_schema() {
'size' => 'big',
'serialize' => TRUE,
),
'filter_enabled' => array(
'description' => 'Whether Data Federation Filter is enabled.',
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'default' => 0,
),
),
'primary key' => array('id'),
);
Expand All @@ -95,19 +102,17 @@ function open_data_schema_map_schema() {


/**
* Ensures that the output format field is in the table.
*
* Ensures that the output format field is in the table
* Also sets outputformat to 'json' for all existing entries
*
*/

function open_data_schema_map_update_7001() {

$column = array(
'type' => 'varchar',
'description' => "Output Format",
'length' => 20,
'not null' => True,
'not null' => TRUE,
'default' => 'json',
);

Expand All @@ -116,3 +121,21 @@ function open_data_schema_map_update_7001() {
db_add_field($data_table_name, 'outputformat', $column);
}
}

/**
* Ensures that the filter_enabled field is in the table.
*/
function open_data_schema_map_update_7002() {
$column = array(
'description' => 'Whether Data Federation Filter is enabled.',
'type' => 'int',
'not null' => TRUE,
'size' => 'tiny',
'default' => 0,
);

$data_table_name = 'open_data_schema_map';
if (!db_field_exists('open_data_schema_map', 'filter_enabled')) {
db_add_field($data_table_name, 'filter_enabled', $column);
}
}
Loading