|
|
@@ -0,0 +1,67 @@
|
|
|
+import {Injectable} from '@angular/core';
|
|
|
+
|
|
|
+import ontology from '../data/rural_attractiveness.owl.json';
|
|
|
+
|
|
|
+@Injectable({providedIn: 'root'})
|
|
|
+export class AdjusterPresetsService {
|
|
|
+ activeProblem;
|
|
|
+ activeRole;
|
|
|
+ activeSchema;
|
|
|
+
|
|
|
+ roles = [];
|
|
|
+ schemas = [];
|
|
|
+
|
|
|
+ constructor() {
|
|
|
+ this.loadRoles();
|
|
|
+ this.loadSchemas();
|
|
|
+ }
|
|
|
+
|
|
|
+ getActiveRoleProblems() {
|
|
|
+ return this.activeRole.problems ?? [];
|
|
|
+ }
|
|
|
+
|
|
|
+ loadRoles() {
|
|
|
+ this.roles = ontology
|
|
|
+ .filter((subject) => subject['@type']?.includes("http://www.semanticweb.org/attractiveness/Role"))
|
|
|
+ .map((subject) => {
|
|
|
+ return {
|
|
|
+ id: subject['@id'],
|
|
|
+ labels: subject["http://www.w3.org/2000/01/rdf-schema#label"],
|
|
|
+ problems: subject["http://www.semanticweb.org/attractiveness/solvesProblem"].map(
|
|
|
+ (problem) => {
|
|
|
+ const problemEntity = ontology.find((subject) => subject['@id'] == problem['@id']);
|
|
|
+ return {
|
|
|
+ id: problem['@id'],
|
|
|
+ labels: problemEntity?.["http://www.w3.org/2000/01/rdf-schema#label"],
|
|
|
+ requiredDatasets: problemEntity?.["http://www.semanticweb.org/attractiveness/requiresDataset"].map((dataset) => dataset['@id'])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.activeRole = this.roles[0];
|
|
|
+ this.activeProblem = this.roles[0].problems[0];
|
|
|
+ console.log("Roles", this.roles);
|
|
|
+ }
|
|
|
+
|
|
|
+ loadSchemas() {
|
|
|
+ this.schemas = ontology
|
|
|
+ .filter((subject) => subject['@type']?.includes("http://www.semanticweb.org/attractiveness/ClassificationSchema"))
|
|
|
+ .map((subject) => {
|
|
|
+ return {
|
|
|
+ id: subject['@id'],
|
|
|
+ labels: subject["http://www.w3.org/2000/01/rdf-schema#label"],
|
|
|
+ groups: subject["http://www.semanticweb.org/attractiveness/consistsOf"].map(
|
|
|
+ (group) => {
|
|
|
+ return {
|
|
|
+ id: group['@id'],
|
|
|
+ labels: ontology.find((subject) => subject['@id'] == group['@id'])?.["http://www.w3.org/2000/01/rdf-schema#label"]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.activeSchema = this.schemas[0];
|
|
|
+ console.log("Schemas", this.schemas);
|
|
|
+ }
|
|
|
+}
|