Skip to content

Commit

Permalink
add validation
Browse files Browse the repository at this point in the history
  • Loading branch information
wbglaeser committed Jun 12, 2024
1 parent 5d16fd0 commit 9cf3a2b
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 138 deletions.
5 changes: 5 additions & 0 deletions config-overrides.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
webpack: function (config) {
return { ...config, ignoreWarnings: [/Failed to parse source map/] };
},
};
282 changes: 162 additions & 120 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
"private": true,
"homepage": "https://citizen-knowledge-graph.github.io/foerderfunke-react-app",
"dependencies": {
"@foerderfunke/matching-engine": "^0.4.5",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/plugin-transform-private-property-in-object": "^7.24.7",
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@foerderfunke/matching-engine": "^0.5.5",
"@mui/icons-material": "^5.15.19",
"@mui/material": "^5.15.19",
"@mui/x-charts": "^7.6.2",
Expand All @@ -22,9 +24,9 @@
"zustand": "^4.5.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
Expand All @@ -48,6 +50,7 @@
]
},
"devDependencies": {
"gh-pages": "^6.1.1"
"gh-pages": "^6.1.1",
"react-app-rewired": "^2.2.1"
}
}
1 change: 1 addition & 0 deletions public/assets/data/requirement-profiles.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"datafields": "https://raw.githubusercontent.com/Citizen-Knowledge-Graph/requirement-profiles/main/datafields.ttl",
"materialization": "https://raw.githubusercontent.com/Citizen-Knowledge-Graph/requirement-profiles/main/materialization.ttl",
"queries": [
{
"fileUrl": "https://raw.githubusercontent.com/Citizen-Knowledge-Graph/requirement-profiles/main/shacl/dev-kindergeld.ttl",
Expand Down
44 changes: 31 additions & 13 deletions src/services/validationService.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {UserModel} from "../models/UserModel";
import {
//validateAll,
validateAll,
validateUserProfile,
} from '@foerderfunke/matching-engine';
import {
convertUserProfileToTurtle,
convertUserProfileToTurtle, extractDatafieldsMetadata, extractRequirementProfilesMetadata,
} from '@foerderfunke/matching-engine/src/utils';
import readJson from "../utilities/readJson";
import {fetchTurtleResource} from "./githubService";
import { useMetadataStore, useValidationReportStore} from "../storage/zustand";

export const runValidation = async (activeUser) => {

Expand All @@ -24,18 +25,35 @@ export const runValidation = async (activeUser) => {
console.error('Invalid user profile');
}

// load materialization scripts
const materializationString = await fetchTurtleResource(validationConfig['materialization']);


// collect requirement profiles
//let requirementProfiles = {};
console.log('Fetching requirement profiles:', validationConfig['queries'][0]['fileUrl'])
const fileUrl = await fetchTurtleResource(validationConfig['queries'][0]['fileUrl']);
console.log(fileUrl);

// for (const requirementProfile in validationConfig['queries']) {
// const fileUrl = requirementProfile['fileUrl'];
// console.log('Fetching requirement profile:', fileUrl);
// //requirementProfiles[rpUri] = await fetchTurtleResource(fileUrl);
// }
// console.log('Running validations for:', Object.keys(requirementProfiles));
let requirementProfiles = {};
for (const requirementProfile of validationConfig['queries']) {
const {fileUrl, rpUri} = requirementProfile;
requirementProfiles[rpUri] = await fetchTurtleResource(fileUrl);
}
console.log('Running validations for:', Object.keys(requirementProfiles));

let validateAllReport = await validateAll(
userProfileString,
requirementProfiles,
datafieldsString,
materializationString,
false
);

useValidationReportStore.getState().updateValidationReport(validateAllReport);

// fetch metadata
let metadata = {
df: await extractDatafieldsMetadata(datafieldsString),
rp: await extractRequirementProfilesMetadata(Object.values(requirementProfiles)),
};

useMetadataStore.getState().updateMetadata(metadata);

return null;
}
16 changes: 16 additions & 0 deletions src/storage/zustand.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,19 @@ export const useProfileInputSectionStore = create((set) => ({
}));
},
}));

export const useMetadataStore = create((set) => ({
metadata: {},
updateMetadata: (newMetadata) => {
console.log('STATE UPDATE: We are updating the metadata');
set((state) => ({ metadata: newMetadata }));
},
}));

export const useValidationReportStore = create((set) => ({
validationReport: {},
updateValidationReport: (newValidationReport) => {
console.log('STATE UPDATE: We are updating the validation report');
set((state) => ({ validationReport: newValidationReport }));
},
}));

0 comments on commit 9cf3a2b

Please sign in to comment.