@prefix this: . @prefix sub: . @prefix np: . @prefix grlc: . @prefix dct: . @prefix nt: . @prefix npx: . @prefix xsd: . @prefix rdfs: . @prefix orcid: . @prefix prov: . @prefix foaf: . sub:Head { this: a np:Nanopublication; np:hasAssertion sub:assertion; np:hasProvenance sub:provenance; np:hasPublicationInfo sub:pubinfo . } sub:assertion { sub:list-preset-assignments a grlc:grlc-query; dct:description "Lists the presets assigned in a given space ref (space IRI + root definition). Pass the ref's root nanopub (root_np); the query resolves the ref via npa:rootNanopub and reads the server-materialised npa:PresetAssignment rows scoped by npa:forSpaceRef from the trust-validated current space-state graph (only admin-authored assignments are materialised, so this is authorisation-scoped). An assignment is identified by the assigned preset's stable KIND (dct:isVersionOf) and the resource, mirroring view displays, which the client dedups by view kind (nanodash issue #607): among the assignments of one preset kind for one resource only the latest by dct:created counts, so assigning another version of the same preset replaces the earlier assignment instead of adding a second, competing row; a version declaring no kind keys on itself, and the preset listed is the version that assignment pinned. The preset is listed only when that latest row is still activated (npa:isActivated true) -- a deactivation is a newer admin-authored row with npa:isActivated false. The update columns surface a newer version of the assigned preset (update_noheader is the notice, update_label its tooltip, updatePreset the version the update action pre-fills): the newest non-invalidated version of the same kind, restricted to versions published by the same agent as the assigned version, so an unrelated agent cannot advertise a version of someone else's preset here. Presets never auto-update -- adopting the newer version stays an explicit, admin-signed act. Columns match the IRI-keyed list-preset-assignments (preset, preset_label, deactivatePreset, added_by, date_added, update_noheader, update_label, updatePreset, np, np_label) so it drives the existing Preset assignments view unchanged. Ref-scoped variant: shows only that one ref's assignments rather than merging all refs claiming the IRI."; dct:license ; rdfs:label "List preset assignments (ref-scoped)"; grlc:endpoint ; grlc:sparql """prefix rdfs: prefix dct: prefix np: prefix npa: prefix npx: prefix gen: select ?preset (sample(?lbl) as ?preset_label) (str(?preset) as ?deactivatePreset) (sample(?user) as ?added_by) (?date as ?date_added) (sample(?update) as ?update_noheader) (sample(?updateNote) as ?update_label) (sample(?updateTarget) as ?updatePreset) ?np (\"^\" as ?np_label) where { values ?_root_np_multi_iri {} graph npa:spacesGraph { ?ref npa:rootNanopub ?_root_np_multi_iri . } graph npa:graph { npa:thisRepo npa:hasCurrentSpaceState ?g . } graph ?g { ?paRef a npa:PresetAssignment ; npa:forSpaceRef ?ref ; npa:ofPreset ?preset ; npa:forResource ?resource ; npa:isActivated ?activated ; npa:viaNanopub ?np ; dct:created ?date . } # The assigned preset version: its label, its stable kind, its author and its date. optional { ?pnp npx:embeds ?preset ; np:hasAssertion ?pa . optional { graph npa:graph { ?pnp npx:signedBy ?presetSigner } } optional { graph npa:graph { ?pnp dct:created ?presetDate } } graph ?pa { optional { ?preset rdfs:label ?lbl } optional { ?preset dct:isVersionOf ?presetKindOptional } } } # Assignment identity is (preset KIND, resource) -- as for view displays, where the # client dedups by view kind -- so assigning another version of the same preset # replaces the earlier assignment instead of adding a second, competing one. A # version that declares no kind keys on itself. bind(coalesce(?presetKindOptional, ?preset) as ?presetKey) filter(?activated = true) filter not exists { graph ?g { ?pa2 a npa:PresetAssignment ; npa:forSpaceRef ?ref ; npa:ofPreset ?preset2 ; npa:forResource ?resource ; npa:viaNanopub ?np2 ; dct:created ?date2 . } optional { ?pnp2 npx:embeds ?preset2 ; np:hasAssertion ?pa2Assertion . graph ?pa2Assertion { ?preset2 dct:isVersionOf ?presetKind2 } } filter(coalesce(?presetKind2, ?preset2) = ?presetKey) filter(?date2 > ?date || (?date2 = ?date && str(?np2) > str(?np))) } # Newest version of the assigned preset's kind, restricted to versions published by # the same agent as the assigned version, so an unrelated agent cannot advertise a # version of someone else's preset here (issue #607). Presets never auto-update: # this only surfaces the newer version and pre-fills the update action with it. optional { { select (?versionKind as ?presetKey) (?versionSigner as ?presetSigner) (iri(strafter(max(concat(str(?vDate), \">\", str(?vPreset))), \">\")) as ?latestVersion) (max(?vDate) as ?latestDate) where { graph npa:graph { ?vNp npx:hasNanopubType gen:Preset ; npa:hasValidSignatureForPublicKeyHash ?vPubkey ; dct:created ?vDate ; npx:signedBy ?versionSigner ; npx:embeds ?vPreset ; np:hasAssertion ?vA . filter not exists { ?vInv npx:invalidates ?vNp ; npa:hasValidSignatureForPublicKeyHash ?vPubkey . } } graph ?vA { ?vPreset a gen:Preset ; dct:isVersionOf ?versionKind . } } group by ?versionKind ?versionSigner } } bind(bound(?latestVersion) && ?latestVersion != ?preset && ?latestDate > ?presetDate as ?hasUpdate) bind(if(?hasUpdate, \"⬆️ newer version available\", \"\") as ?update) bind(if(?hasUpdate, concat(\"Version of \", substr(str(?latestDate), 1, 10), \" is newer than the assigned one\"), \"\") as ?updateNote) bind(if(?hasUpdate, str(?latestVersion), \"\") as ?updateTarget) optional { graph npa:graph { ?np npx:signedBy ?user } } } group by ?preset ?date ?np order by desc(?date) """ . } sub:provenance { sub:assertion prov:wasAttributedTo orcid:0000-0002-1267-0234 . } sub:pubinfo { orcid:0000-0002-1267-0234 foaf:name "Tobias Kuhn" . this: dct:created "2026-09-09T06:25:41Z"^^xsd:dateTime; dct:creator orcid:0000-0002-1267-0234; dct:license ; npx:embeds sub:list-preset-assignments; npx:supersedes ; nt:wasCreatedFromProvenanceTemplate ; nt:wasCreatedFromPubinfoTemplate ; nt:wasCreatedFromTemplate . sub:sig npx:hasAlgorithm "RSA"; npx:hasPublicKey "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwUtewGCpT5vIfXYE1bmf/Uqu1ojqnWdYxv+ySO80ul8Gu7m8KoyPAwuvaPj0lvPtHrg000qMmkxzKhYknEjq8v7EerxZNYp5B3/3+5ZpuWOYAs78UnQVjbHSmDdmryr4D4VvvNIiUmd0yxci47dTFUj4DvfHnGd6hVe5+goqdcwIDAQAB"; npx:hasSignature "F1c2jsp8NU6hK25v/e0THoCsmT4+znz+MNDTVPSoCitrqwPaYlNP76fuKVbk7cCklq1TDnFbMGeLq+urDfF5ucXgPzJ2eMlkhF8rH0e9vaKEmYWPFBbWU8potat7Fdj/zJmHHTm8NesfJ0XfY2T5IciDx+BVfzyUPcn5HBFh0Io="; npx:hasSignatureTarget this:; npx:signedBy orcid:0000-0002-1267-0234 . }