@lblod/ember-rdfa-editor-lblod-plugins 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-it.json +14 -0
- package/.woodpecker/.release.yml +15 -0
- package/.woodpecker/.test.yml +23 -0
- package/CHANGELOG.md +84 -0
- package/README.md +311 -14
- package/RELEASE.md +60 -0
- package/addon/commands/generate-template-command.js +35 -0
- package/addon/commands/insert-and-collapse.js +32 -0
- package/addon/commands/modify-date-command.js +42 -0
- package/addon/components/besluit-type-plugin/besluit-type-select.hbs +28 -0
- package/addon/components/besluit-type-plugin/besluit-type-select.js +21 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.hbs +83 -0
- package/addon/components/besluit-type-plugin/toolbar-dropdown.js +188 -0
- package/addon/components/citaten-plugin/citaat-card.hbs +76 -0
- package/addon/components/citaten-plugin/citaat-card.js +286 -0
- package/addon/components/citaten-plugin/citaat-insert.hbs +20 -0
- package/addon/components/citaten-plugin/citaat-insert.js +68 -0
- package/addon/components/citaten-plugin/citations/article-list.hbs +13 -0
- package/addon/components/citaten-plugin/citations/article-preview.hbs +16 -0
- package/addon/components/citaten-plugin/citations/decision-detail.hbs +110 -0
- package/addon/components/citaten-plugin/citations/decision-detail.js +94 -0
- package/addon/components/citaten-plugin/citations/decision-list.hbs +15 -0
- package/addon/components/citaten-plugin/citations/decision-preview.hbs +53 -0
- package/addon/components/citaten-plugin/citations/search-modal.hbs +175 -0
- package/addon/components/citaten-plugin/citations/search-modal.js +244 -0
- package/addon/components/citaten-plugin/helpers/alert-load-error.hbs +21 -0
- package/addon/components/citaten-plugin/helpers/alert-no-items.hbs +10 -0
- package/addon/components/import-snippet-plugin/card.hbs +17 -0
- package/addon/components/import-snippet-plugin/card.js +95 -0
- package/addon/components/insert-variable-plugin/insert-variable-card.hbs +33 -0
- package/addon/components/insert-variable-plugin/insert-variable-card.js +125 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-card.hbs +22 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-card.js +64 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-insert.hbs +18 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +24 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-time-picker.hbs +21 -0
- package/addon/components/rdfa-date-plugin/rdfa-date-time-picker.js +73 -0
- package/addon/components/roadsign-regulation-plugin/expanded-measure.hbs +44 -0
- package/addon/components/roadsign-regulation-plugin/expanded-measure.js +38 -0
- package/addon/components/roadsign-regulation-plugin/measure-template.hbs +5 -0
- package/addon/components/roadsign-regulation-plugin/measure-template.js +30 -0
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.hbs +12 -0
- package/addon/components/roadsign-regulation-plugin/roadsign-regulation-card.js +101 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.hbs +92 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-modal.js +268 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.hbs +25 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-pagination.js +55 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.hbs +73 -0
- package/addon/components/roadsign-regulation-plugin/roadsigns-table.js +24 -0
- package/addon/components/standard-template-plugin/template-card.hbs +16 -0
- package/addon/components/standard-template-plugin/template-card.js +7 -0
- package/addon/components/standard-template-plugin/template-provider.hbs +6 -0
- package/addon/components/standard-template-plugin/template-provider.js +75 -0
- package/addon/components/table-of-contents-plugin/card.hbs +5 -0
- package/addon/components/table-of-contents-plugin/card.js +53 -0
- package/addon/components/table-of-contents-plugin/inline-components/outline.hbs +21 -0
- package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.hbs +9 -0
- package/addon/components/table-of-contents-plugin/inline-components/table-of-contents.js +100 -0
- package/addon/components/template-variable-plugin/template-variable-card.hbs +34 -0
- package/addon/components/template-variable-plugin/template-variable-card.js +230 -0
- package/addon/constants.js +24 -0
- package/{dist → addon}/helpers/limit-text.js +1 -4
- package/addon/initializers/plugin-initializer.js +75 -0
- package/addon/inline-components/table-of-contents.js +43 -0
- package/addon/marks/citaten-mark.js +32 -0
- package/addon/models/instruction.js +19 -0
- package/addon/models/measure.js +46 -0
- package/{dist → addon}/models/sign.js +12 -13
- package/addon/models/template.js +9 -0
- package/addon/plugins/besluit-type-plugin.js +16 -0
- package/addon/plugins/citaten-plugin.js +22 -0
- package/addon/plugins/generate-template-plugin.js +16 -0
- package/addon/plugins/import-snippet-plugin.js +16 -0
- package/addon/plugins/insert-variable-plugin.js +19 -0
- package/addon/plugins/rdfa-date-plugin.js +26 -0
- package/addon/plugins/roadsign-regulation-plugin.js +24 -0
- package/addon/plugins/standard-template-plugin.js +33 -0
- package/addon/plugins/table-of-contents-plugin.js +27 -0
- package/addon/plugins/template-variable-plugin.js +21 -0
- package/addon/serializers/application.js +8 -0
- package/{dist → addon}/services/import-rdfa-snippet.js +28 -18
- package/{dist → addon}/services/roadsign-registry.js +67 -121
- package/addon/services/standard-template-plugin.js +45 -0
- package/addon/utils/fetchBesluitTypes.js +90 -0
- package/addon/utils/generate-template-plugin/default-resources.js +9 -0
- package/addon/utils/instantiate-uuids.js +34 -0
- package/addon/utils/legislation-types.js +32 -0
- package/addon/utils/memoize.js +8 -0
- package/addon/utils/processMatch.js +80 -0
- package/addon/utils/roadsign-regulation-plugin/fetchData.js +78 -0
- package/addon/utils/roadsign-regulation-plugin/includeInstructions.js +10 -0
- package/addon/utils/variable-plugins/default-variable-types.js +56 -0
- package/{dist/fetch-data-284bf106.js → addon/utils/variable-plugins/fetch-data.js} +36 -18
- package/{dist/vlaamse-codex-187fe526.js → addon/utils/vlaamse-codex.js} +159 -63
- package/app/components/besluit-type-plugin/besluit-type-select.js +1 -0
- package/app/components/besluit-type-plugin/toolbar-dropdown.js +1 -0
- package/app/components/citaten-plugin/citaat-card.js +1 -0
- package/app/components/citaten-plugin/citaat-insert.js +1 -0
- package/app/components/citaten-plugin/citations/article-list.js +1 -0
- package/app/components/citaten-plugin/citations/article-preview.js +1 -0
- package/app/components/citaten-plugin/citations/decision-detail.js +1 -0
- package/app/components/citaten-plugin/citations/decision-list.js +1 -0
- package/app/components/citaten-plugin/citations/decision-preview.js +1 -0
- package/app/components/citaten-plugin/citations/modal.js +1 -0
- package/app/components/citaten-plugin/citations/search-modal.js +1 -0
- package/app/components/citaten-plugin/helpers/alert-load-error.js +1 -0
- package/app/components/citaten-plugin/helpers/alert-no-items.js +1 -0
- package/app/components/import-snippet-plugin/card.js +1 -0
- package/app/components/insert-variable-plugin/insert-variable-card.js +1 -0
- package/app/components/rdfa-date-plugin/rdfa-date-plugin-card.js +1 -0
- package/app/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +1 -0
- package/app/components/rdfa-date-plugin/rdfa-date-time-picker.js +1 -0
- package/app/components/roadsign-regulation-plugin/expanded-measure.js +1 -0
- package/app/components/roadsign-regulation-plugin/measure-template.js +1 -0
- package/app/components/roadsign-regulation-plugin/roadsign-regulation-card.js +1 -0
- package/app/components/roadsign-regulation-plugin/roadsigns-modal.js +1 -0
- package/app/components/roadsign-regulation-plugin/roadsigns-pagination.js +1 -0
- package/app/components/roadsign-regulation-plugin/roadsigns-table.js +1 -0
- package/app/components/standard-template-plugin/template-card.js +1 -0
- package/app/components/standard-template-plugin/template-provider.js +1 -0
- package/app/components/table-of-contents-plugin/card.js +1 -0
- package/app/components/table-of-contents-plugin/inline-components/outline.js +1 -0
- package/app/components/table-of-contents-plugin/inline-components/table-of-contents.js +1 -0
- package/app/components/template-variable-plugin/template-variable-card.js +1 -0
- package/app/helpers/limit-text.js +4 -0
- package/app/initializers/plugin-initializer.js +4 -0
- package/app/models/instruction.js +1 -0
- package/app/models/measure.js +1 -0
- package/app/models/sign.js +1 -0
- package/app/models/template.js +1 -0
- package/app/serializers/application.js +1 -0
- package/app/services/import-rdfa-snippet.js +1 -0
- package/app/services/rdfa-editor-roadsign-regulation-plugin.js +1 -0
- package/app/services/roadsign-registry.js +1 -0
- package/app/services/standard-template-plugin.js +1 -0
- package/{dist → app}/styles/citaten-plugin.scss +0 -0
- package/config/environment.js +0 -1
- package/index.js +8 -0
- package/package.json +112 -107
- package/tsconfig.json +42 -0
- package/types/dummy/index.d.ts +1 -0
- package/types/ember-data/types/registries/model.d.ts +6 -0
- package/types/global.d.ts +7 -0
- package/addon-main.js +0 -4
- package/dist/_app_/components/besluit-type-plugin/besluit-type-select.js +0 -1
- package/dist/_app_/components/besluit-type-plugin/toolbar-dropdown.js +0 -1
- package/dist/_app_/components/citaten-plugin/citaat-card.js +0 -1
- package/dist/_app_/components/citaten-plugin/citaat-insert.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/article-list.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/article-preview.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/decision-detail.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/decision-list.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/decision-preview.js +0 -1
- package/dist/_app_/components/citaten-plugin/citations/search-modal.js +0 -1
- package/dist/_app_/components/citaten-plugin/helpers/alert-load-error.js +0 -1
- package/dist/_app_/components/citaten-plugin/helpers/alert-no-items.js +0 -1
- package/dist/_app_/components/import-snippet-plugin/card.js +0 -1
- package/dist/_app_/components/insert-variable-plugin/insert-variable-card.js +0 -1
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -1
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -1
- package/dist/_app_/components/rdfa-date-plugin/rdfa-date-time-picker.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/expanded-measure.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/measure-template.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/roadsign-regulation-card.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/roadsigns-modal.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/roadsigns-pagination.js +0 -1
- package/dist/_app_/components/roadsign-regulation-plugin/roadsigns-table.js +0 -1
- package/dist/_app_/components/standard-template-plugin/template-card.js +0 -1
- package/dist/_app_/components/standard-template-plugin/template-provider.js +0 -1
- package/dist/_app_/components/table-of-contents-plugin/card.js +0 -1
- package/dist/_app_/components/table-of-contents-plugin/inline-components/outline.js +0 -1
- package/dist/_app_/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -1
- package/dist/_app_/components/template-variable-plugin/template-variable-card.js +0 -1
- package/dist/_app_/helpers/limit-text.js +0 -1
- package/dist/_app_/initializers/plugin-initializer.js +0 -1
- package/dist/_app_/models/instruction.js +0 -1
- package/dist/_app_/models/measure.js +0 -1
- package/dist/_app_/models/sign.js +0 -1
- package/dist/_app_/models/template.js +0 -1
- package/dist/_app_/serializers/application.js +0 -1
- package/dist/_app_/services/import-rdfa-snippet.js +0 -1
- package/dist/_app_/services/roadsign-registry.js +0 -1
- package/dist/_app_/services/standard-template-plugin.js +0 -1
- package/dist/_rollupPluginBabelHelpers-537ad14b.js +0 -48
- package/dist/_rollupPluginBabelHelpers-537ad14b.js.map +0 -1
- package/dist/components/besluit-type-plugin/besluit-type-select.js +0 -30
- package/dist/components/besluit-type-plugin/besluit-type-select.js.map +0 -1
- package/dist/components/besluit-type-plugin/toolbar-dropdown.js +0 -292
- package/dist/components/besluit-type-plugin/toolbar-dropdown.js.map +0 -1
- package/dist/components/citaten-plugin/citaat-card.js +0 -367
- package/dist/components/citaten-plugin/citaat-card.js.map +0 -1
- package/dist/components/citaten-plugin/citaat-insert.js +0 -84
- package/dist/components/citaten-plugin/citaat-insert.js.map +0 -1
- package/dist/components/citaten-plugin/citations/article-list.js +0 -10
- package/dist/components/citaten-plugin/citations/article-list.js.map +0 -1
- package/dist/components/citaten-plugin/citations/article-preview.js +0 -10
- package/dist/components/citaten-plugin/citations/article-preview.js.map +0 -1
- package/dist/components/citaten-plugin/citations/decision-detail.js +0 -123
- package/dist/components/citaten-plugin/citations/decision-detail.js.map +0 -1
- package/dist/components/citaten-plugin/citations/decision-list.js +0 -10
- package/dist/components/citaten-plugin/citations/decision-list.js.map +0 -1
- package/dist/components/citaten-plugin/citations/decision-preview.js +0 -10
- package/dist/components/citaten-plugin/citations/decision-preview.js.map +0 -1
- package/dist/components/citaten-plugin/citations/search-modal.js +0 -282
- package/dist/components/citaten-plugin/citations/search-modal.js.map +0 -1
- package/dist/components/citaten-plugin/helpers/alert-load-error.js +0 -10
- package/dist/components/citaten-plugin/helpers/alert-load-error.js.map +0 -1
- package/dist/components/citaten-plugin/helpers/alert-no-items.js +0 -10
- package/dist/components/citaten-plugin/helpers/alert-no-items.js.map +0 -1
- package/dist/components/import-snippet-plugin/card.js +0 -99
- package/dist/components/import-snippet-plugin/card.js.map +0 -1
- package/dist/components/insert-variable-plugin/insert-variable-card.js +0 -190
- package/dist/components/insert-variable-plugin/insert-variable-card.js.map +0 -1
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-card.js +0 -85
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-card.js.map +0 -1
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-insert.js +0 -23
- package/dist/components/rdfa-date-plugin/rdfa-date-plugin-insert.js.map +0 -1
- package/dist/components/rdfa-date-plugin/rdfa-date-time-picker.js +0 -91
- package/dist/components/rdfa-date-plugin/rdfa-date-time-picker.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/expanded-measure.js +0 -52
- package/dist/components/roadsign-regulation-plugin/expanded-measure.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/measure-template.js +0 -42
- package/dist/components/roadsign-regulation-plugin/measure-template.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/roadsign-regulation-card.js +0 -82
- package/dist/components/roadsign-regulation-plugin/roadsign-regulation-card.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/roadsigns-modal.js +0 -251
- package/dist/components/roadsign-regulation-plugin/roadsigns-modal.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/roadsigns-pagination.js +0 -71
- package/dist/components/roadsign-regulation-plugin/roadsigns-pagination.js.map +0 -1
- package/dist/components/roadsign-regulation-plugin/roadsigns-table.js +0 -36
- package/dist/components/roadsign-regulation-plugin/roadsigns-table.js.map +0 -1
- package/dist/components/standard-template-plugin/template-card.js +0 -15
- package/dist/components/standard-template-plugin/template-card.js.map +0 -1
- package/dist/components/standard-template-plugin/template-provider.js +0 -109
- package/dist/components/standard-template-plugin/template-provider.js.map +0 -1
- package/dist/components/table-of-contents-plugin/card.js +0 -52
- package/dist/components/table-of-contents-plugin/card.js.map +0 -1
- package/dist/components/table-of-contents-plugin/inline-components/outline.js +0 -10
- package/dist/components/table-of-contents-plugin/inline-components/outline.js.map +0 -1
- package/dist/components/table-of-contents-plugin/inline-components/table-of-contents.js +0 -92
- package/dist/components/table-of-contents-plugin/inline-components/table-of-contents.js.map +0 -1
- package/dist/components/template-variable-plugin/template-variable-card.js +0 -178
- package/dist/components/template-variable-plugin/template-variable-card.js.map +0 -1
- package/dist/constants-c77fd478.js +0 -16
- package/dist/constants-c77fd478.js.map +0 -1
- package/dist/fetch-data-284bf106.js.map +0 -1
- package/dist/helpers/limit-text.js.map +0 -1
- package/dist/includeInstructions-a32c24e6.js +0 -10
- package/dist/includeInstructions-a32c24e6.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/initializers/plugin-initializer.js +0 -401
- package/dist/initializers/plugin-initializer.js.map +0 -1
- package/dist/legislation-types-4d487cb9.js +0 -26
- package/dist/legislation-types-4d487cb9.js.map +0 -1
- package/dist/models/instruction.js +0 -18
- package/dist/models/instruction.js.map +0 -1
- package/dist/models/measure.js +0 -41
- package/dist/models/measure.js.map +0 -1
- package/dist/models/sign.js.map +0 -1
- package/dist/models/template.js +0 -48
- package/dist/models/template.js.map +0 -1
- package/dist/serializers/application.js +0 -10
- package/dist/serializers/application.js.map +0 -1
- package/dist/services/import-rdfa-snippet.js.map +0 -1
- package/dist/services/roadsign-registry.js.map +0 -1
- package/dist/services/standard-template-plugin.js +0 -53
- package/dist/services/standard-template-plugin.js.map +0 -1
- package/dist/styles/test.css +0 -0
- package/dist/vlaamse-codex-187fe526.js.map +0 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { inject as service } from '@ember/service';
|
|
2
|
+
|
|
3
|
+
export default class StandardTemplatePlugin {
|
|
4
|
+
@service standardTemplatePlugin;
|
|
5
|
+
matches = new Set();
|
|
6
|
+
controller;
|
|
7
|
+
|
|
8
|
+
get name() {
|
|
9
|
+
return 'standard-template-plugin';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async initialize(controller) {
|
|
13
|
+
let templates;
|
|
14
|
+
try {
|
|
15
|
+
templates = await this.standardTemplatePlugin.fetchTemplates.perform();
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.warn(
|
|
18
|
+
`Plugin ${this.name} had trouble initializing: Templates failed to load`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (templates) {
|
|
22
|
+
templates.forEach((template) => {
|
|
23
|
+
template.matches.forEach((match) => this.matches.add(match));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
this.controller = controller;
|
|
27
|
+
controller.registerWidget({
|
|
28
|
+
desiredLocation: 'insertSidebar',
|
|
29
|
+
componentName: 'standard-template-plugin/template-card',
|
|
30
|
+
identifier: 'standard-template-plugin/template-card',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import TableOfContentsSpec from '../inline-components/table-of-contents';
|
|
2
|
+
|
|
3
|
+
export default class TableOfContentsPlugin {
|
|
4
|
+
controller;
|
|
5
|
+
|
|
6
|
+
get name() {
|
|
7
|
+
return 'table-of-contents-plugin';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
initialize(controller, options) {
|
|
11
|
+
this.controller = controller;
|
|
12
|
+
controller.registerInlineComponent(
|
|
13
|
+
new TableOfContentsSpec(this.controller)
|
|
14
|
+
);
|
|
15
|
+
const widgetArgs = options?.config
|
|
16
|
+
? {
|
|
17
|
+
config: options.config,
|
|
18
|
+
}
|
|
19
|
+
: {};
|
|
20
|
+
controller.registerWidget({
|
|
21
|
+
componentName: 'table-of-contents-plugin/card',
|
|
22
|
+
identifier: 'table-of-contents-plugin/card',
|
|
23
|
+
desiredLocation: 'sidebar',
|
|
24
|
+
widgetArgs,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import InsertAndCollapseCommand from '../commands/insert-and-collapse';
|
|
2
|
+
|
|
3
|
+
export default class TemplateVariablePlugin {
|
|
4
|
+
controller;
|
|
5
|
+
|
|
6
|
+
get name() {
|
|
7
|
+
return 'template-variable-plugin';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
initialize(controller) {
|
|
11
|
+
this.controller = controller;
|
|
12
|
+
controller.registerWidget({
|
|
13
|
+
componentName: 'template-variable-plugin/template-variable-card',
|
|
14
|
+
identifier: 'template-variable-plugin/card',
|
|
15
|
+
desiredLocation: 'sidebar',
|
|
16
|
+
});
|
|
17
|
+
controller.registerCommand(
|
|
18
|
+
new InsertAndCollapseCommand(controller._rawEditor._model)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import JSONAPISerializer from '@ember-data/serializer/json-api';
|
|
2
|
+
|
|
3
|
+
export default class ApplicationSerializer extends JSONAPISerializer {
|
|
4
|
+
serializeAttribute(snapshot, json, key, attributes) {
|
|
5
|
+
if (key !== 'uri')
|
|
6
|
+
super.serializeAttribute(snapshot, json, key, attributes);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { b as _defineProperty } from '../_rollupPluginBabelHelpers-537ad14b.js';
|
|
2
1
|
import Service from '@ember/service';
|
|
3
2
|
import { A } from '@ember/array';
|
|
4
3
|
import ContextScanner from '@lblod/marawa/rdfa-context-scanner';
|
|
@@ -15,6 +14,7 @@ class RdfaSnippet {
|
|
|
15
14
|
this.blocks = blocks;
|
|
16
15
|
this.type = type;
|
|
17
16
|
}
|
|
17
|
+
|
|
18
18
|
get resourceTypeString() {
|
|
19
19
|
return (this.resourceTypes || []).join(', ');
|
|
20
20
|
}
|
|
@@ -32,11 +32,13 @@ class RdfaSnippet {
|
|
|
32
32
|
* @constructor
|
|
33
33
|
* @extends EmberService
|
|
34
34
|
*/
|
|
35
|
-
class ImportRdfaSnippet extends Service {
|
|
35
|
+
export default class ImportRdfaSnippet extends Service {
|
|
36
|
+
errors;
|
|
37
|
+
|
|
38
|
+
snippets;
|
|
39
|
+
|
|
36
40
|
constructor() {
|
|
37
41
|
super(...arguments);
|
|
38
|
-
_defineProperty(this, "errors", void 0);
|
|
39
|
-
_defineProperty(this, "snippets", void 0);
|
|
40
42
|
this.snippets = A();
|
|
41
43
|
this.errors = A();
|
|
42
44
|
this.contextScanner = new ContextScanner();
|
|
@@ -75,7 +77,7 @@ class ImportRdfaSnippet extends Service {
|
|
|
75
77
|
* @return {Array} array of RdfaSnippets
|
|
76
78
|
*/
|
|
77
79
|
snippetsForType(type) {
|
|
78
|
-
return this.snippets.filter(snippet => snippet.type === type);
|
|
80
|
+
return this.snippets.filter((snippet) => snippet.type === type);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
/**
|
|
@@ -92,20 +94,19 @@ class ImportRdfaSnippet extends Service {
|
|
|
92
94
|
const credentials = params.omitCredentials ? 'omit' : 'include';
|
|
93
95
|
data = await fetch(params.source, {
|
|
94
96
|
credentials,
|
|
95
|
-
headers: {
|
|
96
|
-
Accept: 'text/html'
|
|
97
|
-
}
|
|
97
|
+
headers: { Accept: 'text/html' },
|
|
98
98
|
});
|
|
99
|
+
|
|
99
100
|
if (!data) {
|
|
100
101
|
this.errors.pushObject({
|
|
101
102
|
source: params.source,
|
|
102
|
-
details: `No data found for ${params.uri}
|
|
103
|
+
details: `No data found for ${params.uri}`,
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
} catch (err) {
|
|
106
107
|
this.errors.pushObject({
|
|
107
108
|
source: params.source,
|
|
108
|
-
details: `Error fetching data ${params.uri}: ${err}
|
|
109
|
+
details: `Error fetching data ${params.uri}: ${err}`,
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
112
|
return data;
|
|
@@ -117,9 +118,19 @@ class ImportRdfaSnippet extends Service {
|
|
|
117
118
|
* @method determineType
|
|
118
119
|
*/
|
|
119
120
|
determineType(params, snippet, rdfaBlocks) {
|
|
120
|
-
const triples = rdfaBlocks
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
const triples = rdfaBlocks
|
|
122
|
+
.map((block) => block.context)
|
|
123
|
+
.reduce((prevValue, next) => [...prevValue, ...next])
|
|
124
|
+
.filter((v, i, a) => a.indexOf(v) === i); //This filters only unique values
|
|
125
|
+
const types = triples
|
|
126
|
+
.filter((triple) => triple.predicate === 'a')
|
|
127
|
+
.map((triple) => triple.object)
|
|
128
|
+
.filter((v, i, a) => a.indexOf(v) === i); //This filters only unique values
|
|
129
|
+
if (
|
|
130
|
+
types.includes(
|
|
131
|
+
'https://data.vlaanderen.be/ns/mobiliteit#Verkeersbord-Verkeersteken'
|
|
132
|
+
)
|
|
133
|
+
) {
|
|
123
134
|
return 'roadsign';
|
|
124
135
|
} else {
|
|
125
136
|
return 'generic';
|
|
@@ -137,13 +148,15 @@ class ImportRdfaSnippet extends Service {
|
|
|
137
148
|
try {
|
|
138
149
|
const snippet = await data.text();
|
|
139
150
|
const snippetElements = this.htmlToElements(snippet);
|
|
140
|
-
const rdfaBlocks = snippetElements
|
|
151
|
+
const rdfaBlocks = snippetElements
|
|
152
|
+
.map((e) => this.contextScanner.analyse(e))
|
|
153
|
+
.reduce((acc, blocks) => [...acc, ...blocks], []);
|
|
141
154
|
const type = this.determineType(params, snippet, rdfaBlocks);
|
|
142
155
|
this.storeSnippet(params.source, type, snippet, rdfaBlocks);
|
|
143
156
|
} catch (err) {
|
|
144
157
|
this.errors.pushObject({
|
|
145
158
|
source: params.source,
|
|
146
|
-
details: `Error fetching data ${params.uri}: ${err}
|
|
159
|
+
details: `Error fetching data ${params.uri}: ${err}`,
|
|
147
160
|
});
|
|
148
161
|
}
|
|
149
162
|
}
|
|
@@ -173,6 +186,3 @@ class ImportRdfaSnippet extends Service {
|
|
|
173
186
|
this.snippets.pushObject(new RdfaSnippet(source, type, content, blocks));
|
|
174
187
|
}
|
|
175
188
|
}
|
|
176
|
-
|
|
177
|
-
export { ImportRdfaSnippet as default };
|
|
178
|
-
//# sourceMappingURL=import-rdfa-snippet.js.map
|
|
@@ -1,86 +1,12 @@
|
|
|
1
|
-
import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty, b as _defineProperty } from '../_rollupPluginBabelHelpers-537ad14b.js';
|
|
2
1
|
import Service from '@ember/service';
|
|
3
2
|
import { task, restartableTask, timeout } from 'ember-concurrency';
|
|
4
3
|
import { tracked } from '@glimmer/tracking';
|
|
5
4
|
import { getOwner } from '@ember/application';
|
|
6
|
-
import {
|
|
7
|
-
import Instruction from '../models/instruction
|
|
8
|
-
import Measure from '../models/measure
|
|
9
|
-
import Sign from '../models/sign
|
|
5
|
+
import { generateMeasuresQuery } from '../utils/roadsign-regulation-plugin/fetchData';
|
|
6
|
+
import Instruction from '../models/instruction';
|
|
7
|
+
import Measure from '../models/measure';
|
|
8
|
+
import Sign from '../models/sign';
|
|
10
9
|
|
|
11
|
-
function buildFilters({
|
|
12
|
-
zonality,
|
|
13
|
-
type,
|
|
14
|
-
codes,
|
|
15
|
-
category
|
|
16
|
-
}) {
|
|
17
|
-
const filters = [];
|
|
18
|
-
if (zonality) {
|
|
19
|
-
filters.push(`FILTER(?zonality IN (<${zonality}>, <${POTENTIALLY_ZONAL_URI}>))`);
|
|
20
|
-
}
|
|
21
|
-
if (type) {
|
|
22
|
-
filters.push(`FILTER(?signType = <${type}>)`);
|
|
23
|
-
}
|
|
24
|
-
if (codes) {
|
|
25
|
-
filters.push(`
|
|
26
|
-
${codes.map(uri => `
|
|
27
|
-
?uri ext:relation/ext:concept <${uri}>.
|
|
28
|
-
`).join(' ')}
|
|
29
|
-
`);
|
|
30
|
-
}
|
|
31
|
-
if (category) {
|
|
32
|
-
filters.push(`FILTER(?signClassification = <${category}>)`);
|
|
33
|
-
}
|
|
34
|
-
return filters;
|
|
35
|
-
}
|
|
36
|
-
function generateMeasuresQuery({
|
|
37
|
-
zonality,
|
|
38
|
-
type,
|
|
39
|
-
codes,
|
|
40
|
-
category,
|
|
41
|
-
pageStart = 0,
|
|
42
|
-
count
|
|
43
|
-
}) {
|
|
44
|
-
const filters = buildFilters({
|
|
45
|
-
zonality,
|
|
46
|
-
type,
|
|
47
|
-
codes,
|
|
48
|
-
category
|
|
49
|
-
});
|
|
50
|
-
let pagination = '';
|
|
51
|
-
if (!count) {
|
|
52
|
-
pagination = `LIMIT 10 OFFSET ${pageStart}`;
|
|
53
|
-
}
|
|
54
|
-
const query = `
|
|
55
|
-
SELECT ${count ? '(COUNT(DISTINCT(?template)) AS ?count)' : '?uri ?label ?basicTemplate ?annotatedTemplate ?zonality ?temporal'}
|
|
56
|
-
WHERE {
|
|
57
|
-
?uri a lblodMobiliteit:TrafficMeasureConcept;
|
|
58
|
-
skos:prefLabel ?label;
|
|
59
|
-
ext:zonality ?zonality;
|
|
60
|
-
ext:relation ?relationUri;
|
|
61
|
-
ext:template ?template.
|
|
62
|
-
?template ext:annotated ?annotatedTemplate;
|
|
63
|
-
ext:value ?basicTemplate.
|
|
64
|
-
?relationUri a ext:MustUseRelation ;
|
|
65
|
-
ext:concept ?signUri.
|
|
66
|
-
?signUri a ?signType;
|
|
67
|
-
skos:prefLabel ?signCode.
|
|
68
|
-
|
|
69
|
-
${filters.join('\n')}
|
|
70
|
-
OPTIONAL {
|
|
71
|
-
?uri ext:temporal ?temporal.
|
|
72
|
-
}
|
|
73
|
-
OPTIONAL {
|
|
74
|
-
?signUri org:classification ?signClassification.
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
${count ? '' : `GROUP BY ?uri ?label ?template ?zonality\n ORDER BY ASC(strlen(str(?label))) ASC(?label)`}
|
|
78
|
-
${pagination}
|
|
79
|
-
`;
|
|
80
|
-
return query;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
var _class, _descriptor;
|
|
84
10
|
const PREFIXES = `
|
|
85
11
|
PREFIX ex: <http://example.org#>
|
|
86
12
|
PREFIX lblodMobiliteit: <http://data.lblod.info/vocabularies/mobiliteit/>
|
|
@@ -91,17 +17,22 @@ PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
|
91
17
|
PREFIX org: <http://www.w3.org/ns/org#>
|
|
92
18
|
PREFIX mobiliteit: <https://data.vlaanderen.be/ns/mobiliteit#>
|
|
93
19
|
`;
|
|
20
|
+
|
|
94
21
|
const DEBOUNCE_MS = 100;
|
|
95
|
-
|
|
22
|
+
|
|
23
|
+
export default class RoadsignRegistryService extends Service {
|
|
24
|
+
@tracked classifications = [];
|
|
25
|
+
instructions = new Map();
|
|
26
|
+
|
|
96
27
|
constructor() {
|
|
97
28
|
super(...arguments);
|
|
98
|
-
_initializerDefineProperty(this, "classifications", _descriptor, this);
|
|
99
|
-
_defineProperty(this, "instructions", new Map());
|
|
100
29
|
const config = getOwner(this).resolveRegistration('config:environment');
|
|
101
30
|
this.imageBaseUrl = config.roadsignRegulationPlugin.imageBaseUrl;
|
|
102
31
|
this.endpoint = config.roadsignRegulationPlugin.endpoint;
|
|
103
32
|
this.loadClassifications.perform();
|
|
104
33
|
}
|
|
34
|
+
|
|
35
|
+
@task
|
|
105
36
|
*loadClassifications() {
|
|
106
37
|
const result = yield this.executeQuery.perform(`
|
|
107
38
|
SELECT DISTINCT ?classificationUri ?classificationLabel WHERE {
|
|
@@ -112,11 +43,13 @@ let RoadsignRegistryService = (_class = class RoadsignRegistryService extends Se
|
|
|
112
43
|
}
|
|
113
44
|
`);
|
|
114
45
|
const bindings = result.results.bindings;
|
|
115
|
-
this.classifications = bindings.map(binding => ({
|
|
46
|
+
this.classifications = bindings.map((binding) => ({
|
|
116
47
|
value: binding.classificationUri.value,
|
|
117
|
-
label: binding.classificationLabel.value
|
|
48
|
+
label: binding.classificationLabel.value,
|
|
118
49
|
}));
|
|
119
50
|
}
|
|
51
|
+
|
|
52
|
+
@task
|
|
120
53
|
*getInstructionsForMeasure(uri) {
|
|
121
54
|
if (this.instructions.has(uri)) {
|
|
122
55
|
return this.instructions.get(uri);
|
|
@@ -126,18 +59,26 @@ let RoadsignRegistryService = (_class = class RoadsignRegistryService extends Se
|
|
|
126
59
|
return instructions;
|
|
127
60
|
}
|
|
128
61
|
}
|
|
62
|
+
|
|
63
|
+
@restartableTask
|
|
129
64
|
*searchCode(codeString, category, type, combinedSigns) {
|
|
130
65
|
yield timeout(DEBOUNCE_MS);
|
|
131
66
|
if (!Array.isArray(combinedSigns)) {
|
|
132
|
-
if (combinedSigns) combinedSigns = [combinedSigns];
|
|
67
|
+
if (combinedSigns) combinedSigns = [combinedSigns];
|
|
68
|
+
else combinedSigns = [];
|
|
133
69
|
}
|
|
134
70
|
let signFilter = '';
|
|
135
71
|
if (combinedSigns.length > 0) {
|
|
136
|
-
signFilter = combinedSigns
|
|
72
|
+
signFilter = combinedSigns
|
|
73
|
+
.map((sign) => `?measure ext:relation/ext:concept <${sign}>.`)
|
|
74
|
+
.join('\n');
|
|
137
75
|
signFilter += '\n';
|
|
138
|
-
const commaSeperatedSigns = combinedSigns
|
|
76
|
+
const commaSeperatedSigns = combinedSigns
|
|
77
|
+
.map((sign) => `<${sign}>`)
|
|
78
|
+
.join(',');
|
|
139
79
|
signFilter += `FILTER (?signUri NOT IN (${commaSeperatedSigns}))`;
|
|
140
80
|
}
|
|
81
|
+
|
|
141
82
|
const query = `
|
|
142
83
|
SELECT DISTINCT ?signUri ?signCode WHERE {
|
|
143
84
|
?measure ext:relation/ext:concept ?signUri.
|
|
@@ -145,25 +86,35 @@ let RoadsignRegistryService = (_class = class RoadsignRegistryService extends Se
|
|
|
145
86
|
skos:prefLabel ?signCode;
|
|
146
87
|
ext:valid "true"^^<http://mu.semte.ch/vocabularies/typed-literals/boolean>.
|
|
147
88
|
${category ? `?signUri org:classification <${category}>` : ''}
|
|
148
|
-
${
|
|
89
|
+
${
|
|
90
|
+
type
|
|
91
|
+
? ''
|
|
92
|
+
: `
|
|
149
93
|
VALUES ?signType {
|
|
150
94
|
<https://data.vlaanderen.be/ns/mobiliteit#Verkeersbordconcept>
|
|
151
95
|
<https://data.vlaanderen.be/ns/mobiliteit#Wegmarkeringconcept>
|
|
152
96
|
<https://data.vlaanderen.be/ns/mobiliteit#Verkeerslichtconcept>
|
|
153
97
|
}
|
|
154
|
-
`
|
|
98
|
+
`
|
|
99
|
+
}
|
|
155
100
|
${signFilter}
|
|
156
|
-
${
|
|
101
|
+
${
|
|
102
|
+
codeString
|
|
103
|
+
? `FILTER(CONTAINS(LCASE(?signCode), "${codeString.toLowerCase()}"))`
|
|
104
|
+
: ''
|
|
105
|
+
}
|
|
157
106
|
}
|
|
158
107
|
ORDER BY ASC(?signCode)
|
|
159
108
|
`;
|
|
160
109
|
const result = yield this.executeQuery.perform(query);
|
|
161
|
-
const codes = result.results.bindings.map(binding => ({
|
|
110
|
+
const codes = result.results.bindings.map((binding) => ({
|
|
162
111
|
value: binding.signUri.value,
|
|
163
|
-
label: binding.signCode.value
|
|
112
|
+
label: binding.signCode.value,
|
|
164
113
|
}));
|
|
165
114
|
return codes;
|
|
166
115
|
}
|
|
116
|
+
|
|
117
|
+
@task
|
|
167
118
|
*executeQuery(query) {
|
|
168
119
|
const encodedQuery = encodeURIComponent(`${PREFIXES}\n${query.trim()}`);
|
|
169
120
|
const response = yield fetch(this.endpoint, {
|
|
@@ -171,16 +122,20 @@ let RoadsignRegistryService = (_class = class RoadsignRegistryService extends Se
|
|
|
171
122
|
mode: 'cors',
|
|
172
123
|
headers: {
|
|
173
124
|
Accept: 'application/sparql-results+json',
|
|
174
|
-
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
|
125
|
+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
175
126
|
},
|
|
176
|
-
body: `query=${encodedQuery}
|
|
127
|
+
body: `query=${encodedQuery}`,
|
|
177
128
|
});
|
|
178
129
|
if (response.ok) {
|
|
179
130
|
return response.json();
|
|
180
131
|
} else {
|
|
181
|
-
throw new Error(
|
|
132
|
+
throw new Error(
|
|
133
|
+
`Request to MOW backend was unsuccessful: [${response.status}] ${response.statusText}`
|
|
134
|
+
);
|
|
182
135
|
}
|
|
183
136
|
}
|
|
137
|
+
|
|
138
|
+
@task
|
|
184
139
|
*fetchInstructionsForMeasure(uri) {
|
|
185
140
|
const query = `SELECT ?name ?template ?annotatedTemplate
|
|
186
141
|
WHERE {
|
|
@@ -193,32 +148,32 @@ let RoadsignRegistryService = (_class = class RoadsignRegistryService extends Se
|
|
|
193
148
|
}
|
|
194
149
|
`;
|
|
195
150
|
const result = yield this.executeQuery.perform(query);
|
|
196
|
-
const instructions = result.results.bindings.map(binding =>
|
|
151
|
+
const instructions = result.results.bindings.map((binding) =>
|
|
152
|
+
Instruction.fromBinding(binding)
|
|
153
|
+
);
|
|
197
154
|
return instructions;
|
|
198
155
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
type,
|
|
202
|
-
codes,
|
|
203
|
-
category,
|
|
204
|
-
pageStart
|
|
205
|
-
} = {}) {
|
|
156
|
+
@restartableTask
|
|
157
|
+
*fetchMeasures({ zonality, type, codes, category, pageStart } = {}) {
|
|
206
158
|
const selectQuery = generateMeasuresQuery({
|
|
207
159
|
zonality,
|
|
208
160
|
type,
|
|
209
161
|
codes,
|
|
210
162
|
category,
|
|
211
|
-
pageStart
|
|
163
|
+
pageStart,
|
|
212
164
|
});
|
|
213
165
|
const countQuery = generateMeasuresQuery({
|
|
214
166
|
zonality,
|
|
215
167
|
type,
|
|
216
168
|
codes,
|
|
217
169
|
category,
|
|
218
|
-
count: true
|
|
170
|
+
count: true,
|
|
219
171
|
});
|
|
220
172
|
const countResult = yield this.executeQuery.perform(countQuery);
|
|
221
|
-
const count =
|
|
173
|
+
const count =
|
|
174
|
+
countResult.results.bindings.length == 1
|
|
175
|
+
? Number(countResult.results.bindings[0].count.value)
|
|
176
|
+
: 0;
|
|
222
177
|
const measures = [];
|
|
223
178
|
const result = yield this.executeQuery.perform(selectQuery);
|
|
224
179
|
for (const binding of result.results.bindings) {
|
|
@@ -227,11 +182,10 @@ let RoadsignRegistryService = (_class = class RoadsignRegistryService extends Se
|
|
|
227
182
|
measure.classifications = makeClassificationSet(measure.signs);
|
|
228
183
|
measures.push(measure);
|
|
229
184
|
}
|
|
230
|
-
return {
|
|
231
|
-
measures,
|
|
232
|
-
count
|
|
233
|
-
};
|
|
185
|
+
return { measures, count };
|
|
234
186
|
}
|
|
187
|
+
|
|
188
|
+
@task
|
|
235
189
|
*fetchSignsForMeasure(uri) {
|
|
236
190
|
const query = `
|
|
237
191
|
SELECT ?uri ?code ?image ?zonality ?order (GROUP_CONCAT(?classification; SEPARATOR="|") AS ?classifications)
|
|
@@ -254,20 +208,14 @@ WHERE {
|
|
|
254
208
|
for (const binding of result.results.bindings) {
|
|
255
209
|
const sign = Sign.fromBinding({
|
|
256
210
|
...binding,
|
|
257
|
-
imageBaseUrl: this.imageBaseUrl
|
|
211
|
+
imageBaseUrl: this.imageBaseUrl,
|
|
258
212
|
});
|
|
259
213
|
signs.push(sign);
|
|
260
214
|
}
|
|
261
215
|
return signs;
|
|
262
216
|
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
enumerable: true,
|
|
266
|
-
writable: true,
|
|
267
|
-
initializer: function () {
|
|
268
|
-
return [];
|
|
269
|
-
}
|
|
270
|
-
}), _applyDecoratedDescriptor(_class.prototype, "loadClassifications", [task], Object.getOwnPropertyDescriptor(_class.prototype, "loadClassifications"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getInstructionsForMeasure", [task], Object.getOwnPropertyDescriptor(_class.prototype, "getInstructionsForMeasure"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "searchCode", [restartableTask], Object.getOwnPropertyDescriptor(_class.prototype, "searchCode"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "executeQuery", [task], Object.getOwnPropertyDescriptor(_class.prototype, "executeQuery"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "fetchInstructionsForMeasure", [task], Object.getOwnPropertyDescriptor(_class.prototype, "fetchInstructionsForMeasure"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "fetchMeasures", [restartableTask], Object.getOwnPropertyDescriptor(_class.prototype, "fetchMeasures"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "fetchSignsForMeasure", [task], Object.getOwnPropertyDescriptor(_class.prototype, "fetchSignsForMeasure"), _class.prototype)), _class);
|
|
217
|
+
}
|
|
218
|
+
|
|
271
219
|
function makeClassificationSet(signs) {
|
|
272
220
|
const classifications = new Set();
|
|
273
221
|
for (const sign of signs) {
|
|
@@ -278,6 +226,7 @@ function makeClassificationSet(signs) {
|
|
|
278
226
|
sortSet(classifications);
|
|
279
227
|
return classifications;
|
|
280
228
|
}
|
|
229
|
+
|
|
281
230
|
function sortSet(set) {
|
|
282
231
|
const entries = [];
|
|
283
232
|
for (const member of set) {
|
|
@@ -289,6 +238,3 @@ function sortSet(set) {
|
|
|
289
238
|
}
|
|
290
239
|
return set;
|
|
291
240
|
}
|
|
292
|
-
|
|
293
|
-
export { RoadsignRegistryService as default };
|
|
294
|
-
//# sourceMappingURL=roadsign-registry.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Service, { inject as service } from '@ember/service';
|
|
2
|
+
import { task, waitForProperty } from 'ember-concurrency';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
|
|
5
|
+
export default class RdfaEditorStandardTemplatePluginService extends Service {
|
|
6
|
+
@service store;
|
|
7
|
+
@tracked templates;
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.loadTemplates();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@task
|
|
15
|
+
*fetchTemplates() {
|
|
16
|
+
yield waitForProperty(this, 'templates');
|
|
17
|
+
return this.templates;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async loadTemplates() {
|
|
21
|
+
this.templates = await this.store.query('template', {
|
|
22
|
+
fields: { templates: 'title,contexts,matches,disabled-in-contexts' },
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
Filter the valid templates for a context.
|
|
28
|
+
@method templatesForContext
|
|
29
|
+
@param {Array} Array of templates
|
|
30
|
+
@param {Array} The path of rdfaContext objects from the root till the current context
|
|
31
|
+
@return {Array} Array of templates (filtered)
|
|
32
|
+
@private
|
|
33
|
+
*/
|
|
34
|
+
templatesForContext(templates, rdfaTypes) {
|
|
35
|
+
let isMatchingForContext = (template) => {
|
|
36
|
+
return (
|
|
37
|
+
rdfaTypes.filter((e) => template.get('contexts').includes(e)).length >
|
|
38
|
+
0 &&
|
|
39
|
+
rdfaTypes.filter((e) => template.get('disabledInContexts').includes(e))
|
|
40
|
+
.length === 0
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
return templates.filter(isMatchingForContext);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { SparqlEndpointFetcher } from 'fetch-sparql-endpoint';
|
|
2
|
+
|
|
3
|
+
export default async function fetchBesluitTypes(classificationUri, ENV) {
|
|
4
|
+
const query = `
|
|
5
|
+
PREFIX conceptscheme: <https://data.vlaanderen.be/id/conceptscheme/>
|
|
6
|
+
PREFIX BesluitType: <https://data.vlaanderen.be/id/concept/BesluitType/>
|
|
7
|
+
PREFIX BesluitDocumentType: <https://data.vlaanderen.be/id/concept/BesluitDocumentType/>
|
|
8
|
+
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
|
|
9
|
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
10
|
+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
11
|
+
PREFIX core: <http://mu.semte.ch/vocabularies/core/>
|
|
12
|
+
PREFIX besluit: <http://lblod.data.gift/vocabularies/besluit/>
|
|
13
|
+
PREFIX BestuurseenheidClassificatieCode: <http://data.vlaanderen.be/id/concept/BestuurseenheidClassificatieCode/>
|
|
14
|
+
PREFIX sch: <http://schema.org/>
|
|
15
|
+
PREFIX rule: <http://lblod.data.gift/vocabularies/notification/>
|
|
16
|
+
PREFIX lblodRule: <http://data.lblod.info/id/notification-rule/>
|
|
17
|
+
|
|
18
|
+
SELECT ?s ?p ?o WHERE {
|
|
19
|
+
?s skos:inScheme conceptscheme:BesluitType ;
|
|
20
|
+
besluit:notificationRule ?rule .
|
|
21
|
+
?rule besluit:decidableBy <${classificationUri}> .
|
|
22
|
+
OPTIONAL { ?rule sch:validFrom ?validFrom . }
|
|
23
|
+
OPTIONAL { ?rule sch:validThrough ?validThrough . }
|
|
24
|
+
BIND(now() AS ?currentTime) .
|
|
25
|
+
BIND(STRLEN(STR(?validFrom)) > 0 AS ?validFromExists) .
|
|
26
|
+
BIND(STRLEN(STR(?validThrough)) > 0 AS ?validThroughExists) .
|
|
27
|
+
FILTER(
|
|
28
|
+
((?validFromExists && ?validThroughExists) && (?currentTime < ?validThrough && ?currentTime >= ?validFrom)) ||
|
|
29
|
+
((!?validFromExists && ?validThroughExists) && (?currentTime < ?validThrough)) ||
|
|
30
|
+
((?validFromExists && !?validThroughExists) && (?currentTime >= ?validFrom))
|
|
31
|
+
) .
|
|
32
|
+
?s ?p ?o .
|
|
33
|
+
VALUES ?p {
|
|
34
|
+
skos:prefLabel
|
|
35
|
+
skos:definition
|
|
36
|
+
skos:broader
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
const typeFetcher = new SparqlEndpointFetcher({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
});
|
|
43
|
+
const endpoint = ENV.besluitTypePlugin.endpoint;
|
|
44
|
+
const bindingStream = await typeFetcher.fetchBindings(endpoint, query);
|
|
45
|
+
const validBesluitTriples = [];
|
|
46
|
+
bindingStream.on('data', (triple) => {
|
|
47
|
+
validBesluitTriples.push(triple);
|
|
48
|
+
});
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
bindingStream.on('error', reject);
|
|
51
|
+
bindingStream.on('end', () => {
|
|
52
|
+
resolve(validBesluitTriples);
|
|
53
|
+
});
|
|
54
|
+
}).then(quadsToBesluitTypeObjects);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function quadsToBesluitTypeObjects(triples) {
|
|
58
|
+
const besluitTypes = new Map();
|
|
59
|
+
triples.forEach((triple) => {
|
|
60
|
+
const existing = besluitTypes.get(triple.s.value) || {
|
|
61
|
+
uri: triple.s.value,
|
|
62
|
+
};
|
|
63
|
+
switch (triple.p.value) {
|
|
64
|
+
case 'http://www.w3.org/2004/02/skos/core#definition':
|
|
65
|
+
existing.definition = triple.o.value;
|
|
66
|
+
break;
|
|
67
|
+
case 'http://www.w3.org/2004/02/skos/core#prefLabel':
|
|
68
|
+
existing.label = triple.o.value;
|
|
69
|
+
break;
|
|
70
|
+
case 'http://www.w3.org/2004/02/skos/core#broader':
|
|
71
|
+
existing.broader = triple.o.value;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
besluitTypes.set(triple.s.value, existing);
|
|
75
|
+
});
|
|
76
|
+
return createBesluitTypeObjectsHierarchy([...besluitTypes.values()]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function createBesluitTypeObjectsHierarchy(allBesluitTypes) {
|
|
80
|
+
const besluitTypes = allBesluitTypes.filter((bst) => !bst.broader);
|
|
81
|
+
const subTypes = allBesluitTypes.filter((bst) => !!bst.broader);
|
|
82
|
+
subTypes.forEach((subtype) => {
|
|
83
|
+
//Use allBesluitTypes to find the parent. This means no tree recursive search process, but we can still create trees of multiple levels deep.
|
|
84
|
+
const parent = allBesluitTypes.find((type) => type.uri === subtype.broader);
|
|
85
|
+
if (parent)
|
|
86
|
+
if (parent.subTypes) parent.subTypes.push(subtype);
|
|
87
|
+
else parent.subTypes = [subtype];
|
|
88
|
+
});
|
|
89
|
+
return besluitTypes;
|
|
90
|
+
}
|