Skip to content

Commit

Permalink
Fix conceptual oversight: rule inputs must exist
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminaaron committed Apr 30, 2024
1 parent 360e9cb commit 4ef5410
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,22 @@ export async function validateOne(userProfile, requirementProfile, datafieldsStr
let askUserForDataPoints = []

// ----- for the ones we can't materialize we need user input -----
// this is one-dimensional so far, only predicates directly at mainPerson are possible TODO
// and we should tell the user that for instance either hasAge (rule output) or hasBirthday (rule input) is missing TOOD

// get all predicates directly attached to mainPerson
let query = `
PREFIX ff: <https://foerderfunke.org/default#>
SELECT DISTINCT ?predicate WHERE {
ff:mainPerson ?predicate ?object .
}`
let result = await runSparqlSelectQueryOnStore(query, store)
let existingMainPersonPredicates = result.map(n => n.predicate)

for (let missing of missingList) {
if (materializableDataPoints.find(n => n.output === missing.predicate)) continue
let matchingRule = materializableDataPoints.find(n => n.output === missing.predicate)
// we can only use a materialization rule that outputs our missing data point, if we have the input for this rule
if (matchingRule && existingMainPersonPredicates.includes(matchingRule.input)) continue
askUserForDataPoints.push(missing)
}

Expand Down

0 comments on commit 4ef5410

Please sign in to comment.