Skip to content

Commit

Permalink
Add support for HVD
Browse files Browse the repository at this point in the history
  • Loading branch information
skodapetr committed May 19, 2024
1 parent 453e64c commit 738ec96
Show file tree
Hide file tree
Showing 11 changed files with 361 additions and 78 deletions.
15 changes: 13 additions & 2 deletions server/data-source/couchdb-dataset.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getId, getTypes, getEntityByIri, getString, getStrings, getResource, getResources, getPlainStrings, getPlainString, getEntityByType, getValue } from "./shared/jsonld.mjs";
import { selectForLanguages } from "./shared/couchdb-response.mjs";
import { DCTERMS, DCAT, VCARD, SKOS, SGOV, EUA, ADMS, FOAF, OWL, NKOD, PU, SPDX } from "./shared/vocabulary.mjs";
import { DCTERMS, DCAT, VCARD, SKOS, SGOV, EUA, ADMS, FOAF, OWL, NKOD, PU, SPDX , EUROPE} from "./shared/vocabulary.mjs";

export function createCouchDbDataset(couchDbConnector) {
return {
Expand Down Expand Up @@ -72,6 +72,7 @@ function jsonldToDataset(jsonld, iri) {
loadDatasetTemporal(jsonld, entity, result);
loadDatasetOptional(entity, result);
loadDatasetNationalCatalog(jsonld, entity, result);
loadDatasetHighValueDatasets(entity, result);
return result;
}

Expand Down Expand Up @@ -121,6 +122,8 @@ function createEmptyDataset(iri) {
"isFromVdf": false,
"isCodelist": false,
"vdfOriginator": null,
"applicableLegislation": [],
"hvdCategory": [],
}
}

Expand Down Expand Up @@ -230,11 +233,16 @@ function loadDatasetNationalCatalog(jsonld, entity, dataset) {
const types = getTypes(entity);
dataset.isFromForm = types.includes(NKOD.SourceForm);
dataset.isFromCatalog = types.includes(NKOD.SourceLkod);
dataset.isFromVDF = types.includes(NKOD.Vdf);
dataset.isFromVdf = types.includes(NKOD.Vdf);
dataset.isCodelist = types.includes(NKOD.CodeList);
dataset.vdfOriginator = getResource(entity, NKOD.originator);
}

function loadDatasetHighValueDatasets(entity, dataset) {
dataset.applicableLegislation = getResources(entity, EUROPE.applicableLegislation);
dataset.hvdCategory = getResources(entity, EUROPE.hvdCategory);
}

function jsonldToDistribution(jsonld, iri) {
const entity = getEntityByIri(jsonld, iri);
if (entity === null) {
Expand Down Expand Up @@ -263,6 +271,7 @@ function jsonldToDistribution(jsonld, iri) {
"compressFormat": getResource(entity, DCAT.compressFormat),
"type": "Distribution",
"legal": loadDistributionLegal(jsonld, entity),
"applicableLegislation": getResources(entity, EUROPE.applicableLegislation),
};

const accessServiceIri = getResource(entity, DCAT.accessService);
Expand Down Expand Up @@ -304,6 +313,7 @@ function loadDistributionDataService(jsonld, iri) {
"endpointDescription": getResource(entity, DCAT.endpointDescription),
"endpointURL": getResource(entity, DCAT.endpointURL),
"conformsTo": getResources(entity, DCTERMS.conformsTo),
"applicableLegislation": getResources(entity, EUROPE.applicableLegislation),
}
}

Expand All @@ -314,6 +324,7 @@ function createEmptyDataService() {
"endpointDescription": null,
"endpointURL": null,
"conformsTo": [],
"applicableLegislation": [],
};
}

Expand Down
7 changes: 7 additions & 0 deletions server/data-source/shared/vocabulary.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,10 @@ export const LP = {
export const SGOV = {
"ObjectType": "https://slovník.gov.cz/základní/pojem/typ-objektu",
};

const EUROPE_PREFIX = "http://data.europa.eu/r5r/";

export const EUROPE = {
"applicableLegislation": EUROPE_PREFIX + "applicableLegislation",
"hvdCategory": EUROPE_PREFIX + "hvdCategory",
};
10 changes: 9 additions & 1 deletion server/data-source/solr-dataset.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function buildDatasetsQuery(language, query) {
sort,
sortDirection,
offset,
limit
limit,
hvdCategory,
applicableLegislation,
} = query;
const fq = [
...prepareFieldQuery("publisher", publisher),
Expand All @@ -66,6 +68,8 @@ function buildDatasetsQuery(language, query) {
...prepareFieldQuery("file_type", format),
...prepareFieldQuery("data_service_type", dataServiceType),
...prepareFieldQuery("is_part_of", isPartOf),
...prepareFieldQuery("hvd_category", hvdCategory),
...prepareFieldQuery("applicable_legislation", applicableLegislation),
];
if (temporalStart !== null) {
fq.push(`temporal_start:[* TO ${temporalStart}T00:00:00Z]`);
Expand All @@ -86,6 +90,7 @@ function buildDatasetsQuery(language, query) {
"data_service_type",
"publisher",
"theme",
"hvd_category",
],
"fl": [
"iri",
Expand All @@ -94,6 +99,7 @@ function buildDatasetsQuery(language, query) {
"description_cs",
"description_en",
"file_type",
"applicable_legislation",
],
"fq": fq,
"sort": prepareSort(language, sort, sortDirection),
Expand All @@ -116,6 +122,7 @@ function parseDatasetsResponse(languages, response) {
"title": selectLanguage(document, "title_", languages),
"description": selectLanguage(document, "description_", languages),
"file_type": document["file_type"] ?? [],
"applicable_legislation": document["applicable_legislation"] ?? [],
}));

const facet_fields = response["facet_counts"]["facet_fields"];
Expand All @@ -125,6 +132,7 @@ function parseDatasetsResponse(languages, response) {
"dataServiceType": parseFacet(facet_fields["data_service_type"]),
"publisher": parseFacet(facet_fields["publisher"]),
"theme": parseFacet(facet_fields["theme"]),
"hvdCategory": parseFacet(facet_fields["hvd_category"]),
};

return {
Expand Down
Loading

0 comments on commit 738ec96

Please sign in to comment.