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

b/3169 custom licensing #21

Merged
merged 1 commit into from
Apr 5, 2022
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
38 changes: 38 additions & 0 deletions src/dcat-us/dataset-formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,44 @@ describe('formatDcatDataset', () => {
expect(actual.license).toEqual(expectedLicense);
});

it('license should be overwritten if it is specified as "none"', () => {
const dataset = {
owner: 'fpgis.CALFIRE',
created: 1570747289000,
modified: 1570747379000,
tags: ['Uno', 'Dos', 'Tres'],
extent: {
coordinates: [
[-123.8832, 35.0024],
[-118.3281, 42.0122],
],
type: 'envelope',
},
name: 'DCAT_Test',
description: 'Some Description',
source: 'Test Source',
id: '00000000000000000000000000000000_0',
type: 'Feature Layer',
url: 'https://services1.arcgis.com/jUJYIo9tSA7EHvfZ/arcgis/rest/services/DCAT_Test/FeatureServer/0',
layer: {
geometryType: 'esriGeometryPolygon',
},
server: {
spatialReference: {
wkid: 3310,
},
},
license: 'none'
};

const expectedLicense = 'a-custom-license';

const actual = JSON.parse(formatDcatDataset(dataset, siteUrl, siteModel, buildDatasetTemplate({
license: '{{license || a-custom-license}}'
})));
expect(actual.license).toEqual(expectedLicense);
});

test('Hub Page gets default keyword when no tags', () => {
const datasetWithNoTags = {
owner: 'fpgis.CALFIRE',
Expand Down
5 changes: 5 additions & 0 deletions src/dcat-us/dataset-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export function formatDcatDataset (hubDataset: HubDatasetAttributes, siteUrl: st
licenseInfo = ''
} = hubDataset;

// Override hub.js default license value of 'none'
if (hubDataset.license === 'none') {
hubDataset.license = null;
}

const defaultDataset = {
'@type': 'dcat:Dataset',
identifier: landingPage,
Expand Down