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

feat: Summarise created and updated datetimes #109

Merged
merged 7 commits into from
Oct 11, 2021
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
15 changes: 13 additions & 2 deletions extensions/linz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ See [ISO/IEC 13249-3:2016(en)](https://www.iso.org/obp/ui/#!iso:std:60343:en) fo
| Field Name | Type | Description |
| ---------------------------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| title | string | **REQUIRED**. Collection title. |
| linz:created | string | **REQUIRED**. Creation date and time of the collection in UTC. |
| summaries/created/minimum | date-time | **REQUIRED**. Earliest [asset created value](#asset-fields), in UTC. |
| summaries/created/maximum | date-time | **REQUIRED**. Latest [asset created value](#asset-fields), in UTC. |
| summaries/updated/minimum | date-time | **REQUIRED**. Earliest [asset updated value](#asset-fields), in UTC. |
| summaries/updated/maximum | date-time | **REQUIRED**. Latest [asset updated value](#asset-fields), in UTC. |
| linz:lifecycle | string | **REQUIRED**. Lifecycle Status of Collection. Must be one of `under development`, `preview`, `ongoing`, `completed`, `deprecated`. |
| linz:providers | [Providers Object](#providers-object) | **REQUIRED**. A list of providers, which may include all organizations capturing or processing the data or the hosting provider. Providers should be listed in chronological order with the most recent provider being the last element of the list. |
| linz:security_classification | string | **REQUIRED**. New Zealand Government [Security Classification](https://www.digital.govt.nz/standards-and-guidance/governance/managing-online-channels/security-and-privacy-for-websites/foundations/classify-information/). Must be one of `unclassified`, `in-confidence`, `sensitive`, `restricted`, `confidential`, `secret` or `top-secret`. |
| linz:updated | string | **REQUIRED**. Date and time the collection was updated last, in UTC. |

### Providers Object

Expand All @@ -85,6 +87,15 @@ This is the introduction for the purpose and the content of the Providers Object

Note: for the `manager` role at Toitū Te Whenua LINZ, the name should be either a the role name of a person who manages this dataset (to preserve their privacy) or the name of a team that manages this dataset. The `url` should be an internal URL that links to more information about that person or team.

## Asset Fields

These fields apply to assets within both items and collections.

| Field Name | Type | Description |
| ----------------- | ------ | --------------------------------------------------------------- |
| assets/\*/created | string | **REQUIRED**. Creation date and time of the asset, in UTC. |
| assets/\*/updated | string | **REQUIRED**. Date and time the asset was last updated, in UTC. |

## Extensions

This extension includes these other extensions:
Expand Down
12 changes: 10 additions & 2 deletions extensions/linz/examples/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"title": "A title",
"description": "A description",
"license": "Apache-2.0",
"linz:created": "2015-06-23T00:00:00Z",
"linz:lifecycle": "under development",
"linz:providers": [
{
Expand All @@ -28,7 +27,6 @@
}
],
"linz:security_classification": "unclassified",
"linz:updated": "2015-06-23T00:00:00Z",
"extent": {
"spatial": {
"bbox": [[172.9, 1.3, 173, 1.4]]
Expand All @@ -38,6 +36,14 @@
}
},
"summaries": {
"created": {
"minimum": "1999-01-01T00:00:00Z",
"maximum": "2010-01-01T00:00:00Z"
},
"updated": {
"minimum": "1999-01-02T00:00:00Z",
"maximum": "2010-01-02T00:00:00Z"
},
"datetime": {
"minimum": "2015-06-23T00:00:00Z",
"maximum": "2019-07-10T13:44:56Z"
Expand Down Expand Up @@ -66,6 +72,8 @@
"assets": {
"example": {
"href": "https://example.com/examples/file.xyz",
"created": "2000-01-01T00:00:00Z",
"updated": "2020-01-01T00:00:00Z",
"proj:epsg": 32659
}
}
Expand Down
6 changes: 4 additions & 2 deletions extensions/linz/examples/item.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
}
],
"assets": {
"data": {
"href": "https://example.com/examples/file.xyz"
"example": {
"href": "https://example.com/examples/file.xyz",
"created": "2000-01-01T00:00:00Z",
"updated": "2020-01-01T00:00:00Z"
}
},
"linz:geospatial_type": "polygon"
Expand Down
83 changes: 63 additions & 20 deletions extensions/linz/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,7 @@
"allOf": [
{
"type": "object",
"required": [
"linz:created",
"linz:lifecycle",
"linz:providers",
"linz:security_classification",
"linz:updated",
"providers",
"title"
]
"required": ["linz:lifecycle", "linz:providers", "linz:security_classification", "providers", "title"]
},
{
"$ref": "https://schemas.stacspec.org/v1.0.0/collection-spec/json-schema/collection.json#"
Expand Down Expand Up @@ -73,11 +65,26 @@
"fields": {
"type": "object",
"properties": {
"linz:created": {
"title": "Creation Time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
"assets": {
"type": "object",
"additionalProperties": {
"type": "object",
"required": ["created", "updated"],
"properties": {
"created": {
"title": "Creation time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
},
"updated": {
"title": "Last update time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
}
}
}
},
"linz:geospatial_type": {
"type": "string",
Expand Down Expand Up @@ -171,12 +178,6 @@
"type": "string",
"enum": ["unclassified", "in-confidence", "sensitive", "restricted", "confidential", "secret", "top-secret"]
},
"linz:updated": {
"title": "Last Update Time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
},
"providers": {
"allOf": [
{
Expand All @@ -203,6 +204,48 @@
}
]
},
"summaries": {
"type": "object",
"required": ["created", "updated"],
"properties": {
"created": {
"type": "object",
"required": ["minimum", "maximum"],
"properties": {
"minimum": {
"title": "Earliest asset creation time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
},
"maximum": {
"title": "Latest asset creation time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
}
}
},
"updated": {
"type": "object",
"required": ["minimum", "maximum"],
"properties": {
"minimum": {
"title": "Earliest asset updated time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
},
"maximum": {
"title": "Latest asset updated time",
"type": "string",
"format": "date-time",
"pattern": "(\\+00:00|Z)$"
}
}
}
}
},
"title": {
"type": "string",
"minLength": 1
Expand Down
63 changes: 43 additions & 20 deletions extensions/linz/tests/linz_collection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,57 @@ o.spec('LINZ collection', () => {
).equals(true)(JSON.stringify(validate.errors));
});

o("Example without 'linz:created' property should fail validation", async () => {
o("Summaries with no 'created' property should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['linz:created'];
delete example['summaries']['created'];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(validate.errors.some((error) => error.message === "should have required property '['linz:created']'")).equals(
true,
)(JSON.stringify(validate.errors));
o(
validate.errors.some(
(error) => error.dataPath === '.summaries' && error.message === "should have required property 'created'",
),
).equals(true)(JSON.stringify(validate.errors));
});

o("Asset with no 'created' property should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['assets']['example']['created'];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) =>
error.dataPath === ".assets['example']" && error.message === "should have required property 'created'",
),
).equals(true)(JSON.stringify(validate.errors));
});

o("Asset with no 'updated' property should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['assets']['example']['updated'];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) =>
error.dataPath === ".assets['example']" && error.message === "should have required property 'updated'",
),
).equals(true)(JSON.stringify(validate.errors));
});

o("Example without 'linz:lifecycle' property should fail validation", async () => {
Expand Down Expand Up @@ -149,21 +187,6 @@ o.spec('LINZ collection', () => {
).equals(true)(JSON.stringify(validate.errors));
});

o("Example without 'linz:updated' property should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['linz:updated'];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(validate.errors.some((error) => error.message === "should have required property '['linz:updated']'")).equals(
true,
)(JSON.stringify(validate.errors));
});

o("Example without 'linz:providers' 'name' property should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
Expand Down
36 changes: 36 additions & 0 deletions extensions/linz/tests/linz_item.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,40 @@ o.spec('LINZ item', () => {
o(valid).equals(false);
o(validate.errors[0].message).equals('should be equal to one of the allowed values');
});

o("Asset with no 'created' property should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['assets']['example']['created'];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) =>
error.dataPath === ".assets['example']" && error.message === "should have required property 'created'",
),
).equals(true)(JSON.stringify(validate.errors));
});

o("Asset with no 'updated' property should fail validation", async () => {
// given
const example = JSON.parse(await fs.readFile(examplePath));
delete example['assets']['example']['updated'];

// when
let valid = validate(example);

// then
o(valid).equals(false);
o(
validate.errors.some(
(error) =>
error.dataPath === ".assets['example']" && error.message === "should have required property 'updated'",
),
).equals(true)(JSON.stringify(validate.errors));
});
});