Skip to content

Commit a267d26

Browse files
authored
Merge pull request #29 from meaningfy-ws/feature/RES25-42/domain-range
Fix property object value changes missed due to language filter
2 parents b5bba1e + 5f8f08e commit a267d26

8 files changed

+112
-54
lines changed

dqgen/resources/query_templates/count_property_value_updates.rq

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,15 @@ WHERE {
9999
?instance ?property ?newValue .
100100
}
101101
# the language tag shall be the same
102-
103-
FILTER( lang(?oldValue) = lang(?newValue) && ?oldValue != ?newValue )
104-
102+
FILTER (
103+
(
104+
# Case 1: Both values are language-tagged literals
105+
(isLiteral(?oldValue) && isLiteral(?newValue) && lang(?oldValue) != "" && lang(?newValue) != "" && lang(?oldValue) = lang(?newValue))
106+
||
107+
# Case 2: Both values are non-language-tagged literals or URIs
108+
((!isLiteral(?oldValue) || lang(?oldValue) = "") && (!isLiteral(?newValue) || lang(?newValue) = ""))
109+
)
110+
&& ?oldValue != ?newValue
111+
)
105112
}
106113
ORDER BY ?instance

dqgen/resources/query_templates/count_reified_property_value_updates.rq

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,15 @@ WHERE {
103103
?object ?objProperty ?newValue .
104104
}
105105
# the language tag shall be the same
106-
107-
FILTER( lang(?newValue) = lang(?oldValue) && ?newValue != ?oldValue )
106+
FILTER (
107+
(
108+
# Case 1: Both values are language-tagged literals
109+
(isLiteral(?oldValue) && isLiteral(?newValue) && lang(?oldValue) != "" && lang(?newValue) != "" && lang(?oldValue) = lang(?newValue))
110+
||
111+
# Case 2: Both values are non-language-tagged literals or URIs
112+
((!isLiteral(?oldValue) || lang(?oldValue) = "") && (!isLiteral(?newValue) || lang(?newValue) = ""))
113+
)
114+
&& ?oldValue != ?newValue
115+
)
108116
}
109117
ORDER BY ?instance

dqgen/resources/query_templates/property_value_updates.rq

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,15 @@ WHERE {
156156
?instance ?property ?newValue .
157157
}
158158
# the language tag shall be the same
159-
160-
FILTER( lang(?oldValue) = lang(?newValue) && ?oldValue != ?newValue )
161-
159+
FILTER (
160+
(
161+
# Case 1: Both values are language-tagged literals
162+
(isLiteral(?oldValue) && isLiteral(?newValue) && lang(?oldValue) != "" && lang(?newValue) != "" && lang(?oldValue) = lang(?newValue))
163+
||
164+
# Case 2: Both values are non-language-tagged literals or URIs
165+
((!isLiteral(?oldValue) || lang(?oldValue) = "") && (!isLiteral(?newValue) || lang(?newValue) = ""))
166+
)
167+
&& ?oldValue != ?newValue
168+
)
162169
}
163170
ORDER BY ?instance

dqgen/resources/query_templates/reified_property_value_updates.rq

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,15 @@ WHERE {
159159
?object ?objProperty ?newValue .
160160
}
161161
# the language tag shall be the same
162-
163-
FILTER( lang(?newValue) = lang(?oldValue) && ?newValue != ?oldValue )
162+
FILTER (
163+
(
164+
# Case 1: Both values are language-tagged literals
165+
(isLiteral(?oldValue) && isLiteral(?newValue) && lang(?oldValue) != "" && lang(?newValue) != "" && lang(?oldValue) = lang(?newValue))
166+
||
167+
# Case 2: Both values are non-language-tagged literals or URIs
168+
((!isLiteral(?oldValue) || lang(?oldValue) = "") && (!isLiteral(?newValue) || lang(?newValue) = ""))
169+
)
170+
&& ?oldValue != ?newValue
171+
)
164172
}
165173
ORDER BY ?instance

tests/test_data/rdfs/dsA/test_queries/value_update_property_concept_alt_label.rq

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PREFIX xhv: <http://www.w3.org/1999/xhtml/vocab#>
3737
#
3838
# Show all properties value updates
3939
#
40-
SELECT DISTINCT ?instance (?prefLabel as ?instanceLabel) ?property (?old_value AS ?initialValue) (?value AS ?updatedValue)
40+
SELECT DISTINCT ?instance (?prefLabel as ?instanceLabel) ?property (?oldValue AS ?initialValue) (?newValue AS ?updatedValue)
4141
WHERE {
4242
GRAPH ?versionHistoryGraph {
4343
# parameters
@@ -72,7 +72,7 @@ WHERE {
7272
# get all property and values
7373
GRAPH ?newVersionGraph {
7474
?instance a ?class .
75-
?instance ?property ?value .
75+
?instance ?property ?newValue .
7676
optional {
7777
?instance skos:prefLabel ?prefLabel .
7878
#restrict prefLabel to a certain language
@@ -81,19 +81,26 @@ WHERE {
8181
}
8282
# ... which were attached to some (other) instance before and had another value
8383
GRAPH ?oldVersionGraph {
84-
?instance ?property ?old_value .
84+
?instance ?property ?oldValue .
8585
}
8686
# the old value shall be deleted
8787
GRAPH ?deletionsGraph {
88-
?instance ?property ?old_value .
88+
?instance ?property ?oldValue .
8989
}
9090
# the new value shall be inserted
9191
GRAPH ?insertionsGraph {
92-
?instance ?property ?value .
92+
?instance ?property ?newValue .
9393
}
94-
# the language tag shall be the same
95-
96-
FILTER( lang(?old_value) = lang(?value) && ?old_value != ?value )
97-
94+
# handle both language-tagged literals and non-language-tagged values
95+
FILTER(
96+
(
97+
# Case 1: Both values are language-tagged literals
98+
(isLiteral(?oldValue) && isLiteral(?newValue) && lang(?oldValue) != "" && lang(?newValue) != "" && lang(?oldValue) = lang(?newValue))
99+
||
100+
# Case 2: Both values are non-language-tagged literals or URIs
101+
((!isLiteral(?oldValue) || lang(?oldValue) = "") && (!isLiteral(?newValue) || lang(?newValue) = ""))
102+
)
103+
&& ?oldValue != ?newValue
104+
)
98105
}
99-
ORDER BY ?instance ?value
106+
ORDER BY ?instance ?newValue

tests/test_data/rdfs/dsA/test_queries/value_update_property_concept_notation.rq

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PREFIX xhv: <http://www.w3.org/1999/xhtml/vocab#>
3737
#
3838
# Show all properties value updates
3939
#
40-
SELECT DISTINCT ?instance (?prefLabel as ?instanceLabel) ?property (?old_value AS ?initialValue) (?value AS ?updatedValue)
40+
SELECT DISTINCT ?instance (?prefLabel as ?instanceLabel) ?property (?oldValue AS ?initialValue) (?newValue AS ?updatedValue)
4141
WHERE {
4242
GRAPH ?versionHistoryGraph {
4343
# parameters
@@ -72,7 +72,7 @@ WHERE {
7272
# get all property and values
7373
GRAPH ?newVersionGraph {
7474
?instance a ?class .
75-
?instance ?property ?value .
75+
?instance ?property ?newValue .
7676
optional {
7777
?instance skos:prefLabel ?prefLabel .
7878
#restrict prefLabel to a certain language
@@ -81,19 +81,26 @@ WHERE {
8181
}
8282
# ... which were attached to some (other) instance before and had another value
8383
GRAPH ?oldVersionGraph {
84-
?instance ?property ?old_value .
84+
?instance ?property ?oldValue .
8585
}
8686
# the old value shall be deleted
8787
GRAPH ?deletionsGraph {
88-
?instance ?property ?old_value .
88+
?instance ?property ?oldValue .
8989
}
9090
# the new value shall be inserted
9191
GRAPH ?insertionsGraph {
92-
?instance ?property ?value .
92+
?instance ?property ?newValue .
9393
}
94-
# the language tag shall be the same
95-
96-
FILTER( lang(?old_value) = lang(?value) && ?old_value != ?value )
97-
94+
# handle both language-tagged literals and non-language-tagged values
95+
FILTER(
96+
(
97+
# Case 1: Both values are language-tagged literals
98+
(isLiteral(?oldValue) && isLiteral(?newValue) && lang(?oldValue) != "" && lang(?newValue) != "" && lang(?oldValue) = lang(?newValue))
99+
||
100+
# Case 2: Both values are non-language-tagged literals or URIs
101+
((!isLiteral(?oldValue) || lang(?oldValue) = "") && (!isLiteral(?newValue) || lang(?newValue) = ""))
102+
)
103+
&& ?oldValue != ?newValue
104+
)
98105
}
99-
ORDER BY ?instance ?value
106+
ORDER BY ?instance ?newValue

tests/test_data/rdfs/dsB/test_queries/value_update_reified_concept_alt_label_literal_form.rq

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PREFIX xhv: <http://www.w3.org/1999/xhtml/vocab#>
3737
#
3838
# Show reified structures updated values
3939
#
40-
SELECT DISTINCT ?instance (?prefLabel as ?instanceLabel) ?property ?objProperty (?value AS ?oldValue) ?newValue
40+
SELECT DISTINCT ?instance (?prefLabel as ?instanceLabel) ?property ?objProperty (?oldValue AS ?initialValue) (?newValue AS ?updatedValue)
4141
WHERE {
4242
GRAPH ?versionHistoryGraph {
4343
# parameters
@@ -70,7 +70,7 @@ WHERE {
7070
?insertions a sh:SchemeDeltaInsertions ;
7171
sh:usingNamedGraph/sd:name ?insertionsGraph .
7272
}
73-
# get all reified structures values
73+
# get all reified structures values
7474
GRAPH ?newVersionGraph {
7575
?instance a ?class .
7676
?instance ?property ?object .
@@ -83,20 +83,27 @@ WHERE {
8383
}
8484
# ... which were attached to some (other) instance before and had another value
8585
GRAPH ?oldVersionGraph {
86-
?instance ?property ?object .
87-
?object ?objProperty ?value .
86+
?instance ?property ?object .
87+
?object ?objProperty ?oldValue .
8888
}
8989
# the old value shall be deleted
9090
GRAPH ?deletionsGraph {
91-
?object ?objProperty ?value .
92-
}
91+
?object ?objProperty ?oldValue .
92+
}
9393
# the new value shall be inserted
9494
GRAPH ?insertionsGraph {
95-
96-
?object ?objProperty ?newValue .
97-
}
98-
# the language tag shall be the same
99-
100-
FILTER( lang(?newValue) = lang(?value) && ?newValue != ?value )
95+
?object ?objProperty ?newValue .
96+
}
97+
# handle both language-tagged literals and non-language-tagged values
98+
FILTER(
99+
(
100+
# Case 1: Both values are language-tagged literals
101+
(isLiteral(?oldValue) && isLiteral(?newValue) && lang(?oldValue) != "" && lang(?newValue) != "" && lang(?oldValue) = lang(?newValue))
102+
||
103+
# Case 2: Both values are non-language-tagged literals or URIs
104+
((!isLiteral(?oldValue) || lang(?oldValue) = "") && (!isLiteral(?newValue) || lang(?newValue) = ""))
105+
)
106+
&& ?oldValue != ?newValue
107+
)
101108
}
102109
ORDER BY ?instance ?newValue

tests/test_data/rdfs/dsB/test_queries/value_update_reified_concept_pref_label_literal_form.rq

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ PREFIX xhv: <http://www.w3.org/1999/xhtml/vocab#>
3737
#
3838
# Show reified structures updated values
3939
#
40-
SELECT DISTINCT ?instance (?prefLabel as ?instanceLabel) ?property ?objProperty (?value AS ?oldValue) ?newValue
40+
SELECT DISTINCT ?instance (?prefLabel as ?instanceLabel) ?property ?objProperty (?oldValue AS ?initialValue) (?newValue AS ?updatedValue)
4141
WHERE {
4242
GRAPH ?versionHistoryGraph {
4343
# parameters
@@ -70,7 +70,7 @@ WHERE {
7070
?insertions a sh:SchemeDeltaInsertions ;
7171
sh:usingNamedGraph/sd:name ?insertionsGraph .
7272
}
73-
# get all reified structures values
73+
# get all reified structures values
7474
GRAPH ?newVersionGraph {
7575
?instance a ?class .
7676
?instance ?property ?object .
@@ -83,20 +83,27 @@ WHERE {
8383
}
8484
# ... which were attached to some (other) instance before and had another value
8585
GRAPH ?oldVersionGraph {
86-
?instance ?property ?object .
87-
?object ?objProperty ?value .
86+
?instance ?property ?object .
87+
?object ?objProperty ?oldValue .
8888
}
8989
# the old value shall be deleted
9090
GRAPH ?deletionsGraph {
91-
?object ?objProperty ?value .
92-
}
91+
?object ?objProperty ?oldValue .
92+
}
9393
# the new value shall be inserted
9494
GRAPH ?insertionsGraph {
95-
96-
?object ?objProperty ?newValue .
97-
}
98-
# the language tag shall be the same
99-
100-
FILTER( lang(?newValue) = lang(?value) && ?newValue != ?value )
95+
?object ?objProperty ?newValue .
96+
}
97+
# handle both language-tagged literals and non-language-tagged values
98+
FILTER(
99+
(
100+
# Case 1: Both values are language-tagged literals
101+
(isLiteral(?oldValue) && isLiteral(?newValue) && lang(?oldValue) != "" && lang(?newValue) != "" && lang(?oldValue) = lang(?newValue))
102+
||
103+
# Case 2: Both values are non-language-tagged literals or URIs
104+
((!isLiteral(?oldValue) || lang(?oldValue) = "") && (!isLiteral(?newValue) || lang(?newValue) = ""))
105+
)
106+
&& ?oldValue != ?newValue
107+
)
101108
}
102109
ORDER BY ?instance ?newValue

0 commit comments

Comments
 (0)