Skip to content

Commit

Permalink
dev: simplify filter
Browse files Browse the repository at this point in the history
  • Loading branch information
blake-regalia committed Dec 6, 2024
1 parent 04c995f commit ce0dfa9
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/main/kotlin/org/openmbee/flexo/mms/GuardedPatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,6 @@ import org.openmbee.flexo.mms.server.LdpMutateResponse
import org.openmbee.flexo.mms.server.SparqlUpdateRequest


fun quadDataFilter(subjectIri: String): (Quad)->Boolean {
return {
if(it.subject.isURI && it.subject.uri == subjectIri && it.predicate.uri.contains(FORBIDDEN_PREDICATES_REGEX)) {
throw Http400Exception("User not allowed to use IRIs in the namespace <${it.predicate.uri}>")
}

true
}
}

fun quadPatternFilter(subjectIri: String): (Quad)->Boolean {
return {
if(it.subject.isVariable) {
Expand Down Expand Up @@ -65,14 +55,13 @@ suspend fun <TResponseContext: LdpMutateResponse> LdpDcLayer1Context<TResponseCo
var whereString = ""

// prepare quad filters
val dataFilter = quadDataFilter(baseIri)
val patternFilter = quadPatternFilter(baseIri)

// each operation
for(update in sparqlUpdateAst.operations) {
when(update) {
is UpdateDataDelete -> deleteBgpString = asSparqlGroup(update.quads, dataFilter)
is UpdateDataInsert -> insertBgpString = asSparqlGroup(update.quads, dataFilter)
is UpdateDataDelete -> deleteBgpString = asSparqlGroup(update.quads, patternFilter)
is UpdateDataInsert -> insertBgpString = asSparqlGroup(update.quads, patternFilter)
is UpdateDeleteWhere -> {
deleteBgpString = asSparqlGroup(update.quads, patternFilter)
whereString = deleteBgpString
Expand Down

0 comments on commit ce0dfa9

Please sign in to comment.