From bf17bcad5fd87313b797cdb6187ef7e42d6e2911 Mon Sep 17 00:00:00 2001 From: Marcin Procyk Date: Wed, 13 Apr 2022 15:21:55 +0200 Subject: [PATCH] refactor(triplestore): remove graphDB support (#2037) * remove graphDB related scripts + clean docs * remove consistency checking * remove graphDB config * refactor twirl templates related to graphDB * remove embedded-jena-graphdb config * refactor twirl templates related to graphDB in admin routes * refactor twirl templates related to graphDB in v1 routes * remove GraphDBAPI * remove more graphDB inference related stuff * update docs * remove more graphDB stuff * PR changes * more PR changes * chore: release 20.1.0 (#2036) * commit to trigger bad gh actions Co-authored-by: DaSCH Bot <50987250+daschbot@users.noreply.github.com> --- README.md | 2 +- docs/02-knora-ontologies/knora-base.md | 3 - .../04-publishing-deployment/configuration.md | 4 - .../getting-started.md | 3 - docs/04-publishing-deployment/updates.md | 51 +- docs/05-internals/design/api-v2/gravsearch.md | 4 +- .../design/principles/consistency-checking.md | 3 + .../design/principles/design-overview.md | 2 +- .../design/principles/store-module.md | 10 +- .../design/principles/triplestore-updates.md | 15 +- .../development/docker-compose.md | 18 +- docs/05-internals/development/overview.md | 3 +- docs/05-internals/development/testing.md | 6 - docs/07-lucene/index.md | 2 +- docs/faq/index.md | 5 +- .../incunabula-data.ttl | 174 -- webapi/scripts/.gitignore | 5 - webapi/scripts/KnoraRules.pie | 448 ---- webapi/scripts/Readme.md | 33 - .../graphdb-drop-knora-prod-repository.ttl | 2 - .../graphdb-drop-knora-test-repository.ttl | 2 - ...raphdb-drop-knora-test-unit-repository.ttl | 2 - webapi/scripts/graphdb-dump-repository.sh | 56 - webapi/scripts/graphdb-empty-repository.sh | 54 - ...hdb-free-docker-init-knora-test-minimal.sh | 44 - ...raphdb-free-docker-init-knora-test-unit.sh | 34 - .../graphdb-free-docker-init-knora-test.sh | 44 - ...free-knora-test-repository-config.ttl.tmpl | 22 - ...knora-test-unit-repository-config.ttl.tmpl | 22 - ...graphdb-free-local-init-knora-test-unit.sh | 34 - .../graphdb-free-local-init-knora-test.sh | 44 - webapi/scripts/graphdb-knora-index-create.rq | 10 - webapi/scripts/graphdb-knora-index-update.rq | 2 - webapi/scripts/graphdb-knora-prod-data.expect | 58 - .../graphdb-knora-test-data-minimal.expect | 28 - webapi/scripts/graphdb-knora-test-data.expect | 62 - ...raphdb-knora-test-unit-data-minimal.expect | 28 - ...graphdb-se-docker-init-knora-prod-empty.sh | 42 - .../graphdb-se-docker-init-knora-prod.sh | 44 - ...aphdb-se-docker-init-knora-test-minimal.sh | 44 - ...-se-docker-init-knora-test-unit-minimal.sh | 44 - .../graphdb-se-docker-init-knora-test-unit.sh | 34 - .../graphdb-se-docker-init-knora-test.sh | 44 - .../graphdb-se-drop-knora-prod-repository.ttl | 2 - ...b-se-knora-prod-repository-config.ttl.tmpl | 22 - ...b-se-knora-test-repository-config.ttl.tmpl | 22 - ...knora-test-unit-repository-config.ttl.tmpl | 22 - .../graphdb-se-local-init-knora-prod-empty.sh | 42 - .../graphdb-se-local-init-knora-prod.sh | 44 - .../graphdb-se-local-init-knora-test-unit.sh | 34 - .../graphdb-se-local-init-knora-test.sh | 44 - webapi/scripts/graphdb-upload-repository.sh | 56 - .../win-graphdb-free-init-knora-test.sh | 38 - .../scripts/win-graphdb-knora-test-data.ttl | 25 - webapi/src/main/resources/application.conf | 19 - .../webapi/messages/OntologyConstants.scala | 2 - .../triplestoremessages/GraphDBAPI.scala | 45 - .../util/search/SparqlTransformer.scala | 123 - .../responders/v2/SearchResponderV2.scala | 60 +- .../knora/webapi/settings/KnoraSettings.scala | 8 - .../settings/KnoraSettingsConstants.scala | 4 - .../org/knora/webapi/settings/package.scala | 1 - .../triplestore/TriplestoreManager.scala | 2 +- .../http/HttpTriplestoreConnector.scala | 202 +- .../sparql/admin/changeParentNode.scala.txt | 8 +- ...reateNewAdministrativePermission.scala.txt | 13 - ...NewDefaultObjectAccessPermission.scala.txt | 13 - .../sparql/admin/createNewGroup.scala.txt | 13 - .../sparql/admin/createNewListNode.scala.txt | 13 - .../sparql/admin/createNewProject.scala.txt | 13 - .../sparql/admin/createNewUser.scala.txt | 13 - .../queries/sparql/admin/deleteNode.scala.txt | 4 - .../sparql/admin/deletePermission.scala.txt | 16 - .../sparql/admin/getFileValue.scala.txt | 42 +- .../admin/getFileValueGraphDB.scala.txt | 42 - .../admin/getFileValueStandard.scala.txt | 45 - .../queries/sparql/admin/getGroups.scala.txt | 5 +- .../sparql/admin/getListNode.scala.txt | 5 +- .../admin/getListNodeWithChildren.scala.txt | 5 +- .../queries/sparql/admin/getLists.scala.txt | 5 +- .../sparql/admin/getNodePath.scala.txt | 5 +- .../sparql/admin/getParentNode.scala.txt | 5 +- .../sparql/admin/getPermissionByIRI.scala.txt | 5 +- .../admin/getProjectAdminData.scala.txt | 5 +- .../admin/getProjectAdminMembers.scala.txt | 5 +- .../sparql/admin/getProjectMembers.scala.txt | 5 +- .../sparql/admin/getProjectOfEntity.scala.txt | 16 - .../admin/getProjectPermissions.scala.txt | 5 +- .../sparql/admin/getProjects.scala.txt | 5 +- .../queries/sparql/admin/getUsers.scala.txt | 5 +- .../sparql/admin/isEntityUsed.scala.txt | 5 +- .../queries/sparql/admin/isNodeUsed.scala.txt | 5 +- .../sparql/admin/updateGroup.scala.txt | 16 - .../sparql/admin/updateListInfo.scala.txt | 16 - .../sparql/admin/updateNodePosition.scala.txt | 16 - .../sparql/admin/updatePermission.scala.txt | 16 - .../sparql/admin/updateProject.scala.txt | 16 - .../queries/sparql/admin/updateUser.scala.txt | 16 - .../sparql/admin/updateUserPassword.scala.txt | 16 - .../sparql/v1/addValueVersion.scala.txt | 5 +- .../queries/sparql/v1/changeComment.scala.txt | 5 +- .../queries/sparql/v1/changeLink.scala.txt | 5 +- .../sparql/v1/changeResourceLabel.scala.txt | 5 +- .../sparql/v1/checkResourceDeletion.scala.txt | 5 +- .../v1/checkResourceLabelChange.scala.txt | 5 +- .../sparql/v1/checkValueDeletion.scala.txt | 5 +- .../queries/sparql/v1/ckanDokubib.scala.txt | 5 +- .../sparql/v1/ckanIncunabula.scala.txt | 5 +- .../queries/sparql/v1/createLink.scala.txt | 5 +- .../queries/sparql/v1/createValue.scala.txt | 8 +- .../queries/sparql/v1/deleteLink.scala.txt | 5 +- .../sparql/v1/deleteResource.scala.txt | 5 +- .../queries/sparql/v1/deleteValue.scala.txt | 5 +- .../sparql/v1/findLinkValueByIri.scala.txt | 5 +- .../sparql/v1/findLinkValueByObject.scala.txt | 5 +- .../sparql/v1/findResourceWithValue.scala.txt | 5 +- .../sparql/v1/findValueInVersions.scala.txt | 5 +- ...rateWhereStatementsForGetMapping.scala.txt | 43 - ...getAdministrativePermissionByIri.scala.txt | 5 +- ...tivePermissionForProjectAndGroup.scala.txt | 5 +- ...inistrativePermissionsForProject.scala.txt | 5 +- .../queries/sparql/v1/getContext.scala.txt | 99 +- .../sparql/v1/getContextGraphDB.scala.txt | 94 - .../sparql/v1/getContextStandard.scala.txt | 108 - .../sparql/v1/getCreatedResource.scala.txt | 5 +- ...getDefaultObjectAccessPermission.scala.txt | 5 +- ...faultObjectAccessPermissionByIri.scala.txt | 5 +- ...bjectAccessPermissionsForProject.scala.txt | 5 +- .../v1/getFileValuesForResource.scala.txt | 5 +- .../queries/sparql/v1/getGraphData.scala.txt | 79 +- .../sparql/v1/getGraphDataGraphDB.scala.txt | 98 - .../sparql/v1/getGraphDataStandard.scala.txt | 85 - .../queries/sparql/v1/getGroupByIri.scala.txt | 5 +- .../sparql/v1/getGroupByName.scala.txt | 5 +- .../sparql/v1/getGroupMembersByIri.scala.txt | 5 +- .../sparql/v1/getGroupMembersByName.scala.txt | 5 +- .../queries/sparql/v1/getGroups.scala.txt | 5 +- .../sparql/v1/getIncomingReferences.scala.txt | 83 +- .../v1/getIncomingReferencesGraphDB.scala.txt | 86 - .../getIncomingReferencesStandard.scala.txt | 92 - .../v1/getLastModificationDate.scala.txt | 5 +- ...etLinkSourceAndTargetPermissions.scala.txt | 5 +- .../twirl/queries/sparql/v1/getList.scala.txt | 5 +- .../queries/sparql/v1/getNodePath.scala.txt | 5 +- .../v1/getObjectAccessPermission.scala.txt | 5 +- .../v1/getProjectAdminMembersByIri.scala.txt | 5 +- ...etProjectAdminMembersByShortname.scala.txt | 5 +- .../sparql/v1/getProjectByIri.scala.txt | 5 +- .../sparql/v1/getProjectByShortcode.scala.txt | 5 +- .../sparql/v1/getProjectByShortname.scala.txt | 5 +- .../v1/getProjectMembersByIri.scala.txt | 5 +- .../v1/getProjectMembersByShortname.scala.txt | 5 +- .../queries/sparql/v1/getProjects.scala.txt | 5 +- .../queries/sparql/v1/getRegions.scala.txt | 35 +- .../sparql/v1/getRegionsGraphDB.scala.txt | 41 - .../sparql/v1/getRegionsStandard.scala.txt | 44 - .../sparql/v1/getResourceClass.scala.txt | 5 +- .../sparql/v1/getResourceInfo.scala.txt | 45 +- .../v1/getResourceInfoGraphDB.scala.txt | 63 - .../v1/getResourceInfoStandard.scala.txt | 53 - .../getResourcePropertiesAndValues.scala.txt | 100 +- ...sourcePropertiesAndValuesGraphDB.scala.txt | 102 - ...ourcePropertiesAndValuesStandard.scala.txt | 109 - .../v1/getResourceSearchResult.scala.txt | 93 +- .../getResourceSearchResultGraphDB.scala.txt | 97 - .../getResourceSearchResultStandard.scala.txt | 106 - .../getResourceTypesForNamedGraph.scala.txt | 5 +- .../v1/getResourcesByProjectAndType.scala.txt | 5 +- .../sparql/v1/getUserByEmail.scala.txt | 5 +- .../queries/sparql/v1/getUserByIri.scala.txt | 5 +- .../queries/sparql/v1/getUsers.scala.txt | 5 +- .../queries/sparql/v1/getValue.scala.txt | 59 +- .../sparql/v1/getValueGraphDB.scala.txt | 60 - .../sparql/v1/getValueStandard.scala.txt | 68 - .../sparql/v1/getVersionHistory.scala.txt | 55 +- .../v1/getVersionHistoryGraphDB.scala.txt | 63 - .../v1/getVersionHistoryStandard.scala.txt | 66 - .../queries/sparql/v1/isPartOf.scala.txt | 43 +- .../sparql/v1/isPartOfGraphDB.scala.txt | 52 - .../sparql/v1/isPartOfStandard.scala.txt | 52 - .../sparql/v1/searchExtended.scala.txt | 624 ++++- .../sparql/v1/searchExtendedGraphDB.scala.txt | 644 ----- .../v1/searchExtendedStandard.scala.txt | 638 ----- .../sparql/v1/searchFulltext.scala.txt | 141 +- .../sparql/v1/searchFulltextGraphDB.scala.txt | 138 - .../v1/searchFulltextStandard.scala.txt | 153 -- .../v2/addCardinalitiesToClass.scala.txt | 5 +- .../sparql/v2/addValueVersion.scala.txt | 5 +- .../v2/changeClassLabelsOrComments.scala.txt | 5 +- .../sparql/v2/changeLinkMetadata.scala.txt | 5 +- .../sparql/v2/changeLinkTarget.scala.txt | 5 +- .../v2/changeOntologyMetadata.scala.txt | 5 +- .../v2/changePropertyGuiElement.scala.txt | 15 +- .../changePropertyLabelsOrComments.scala.txt | 5 +- .../v2/changeResourceMetadata.scala.txt | 5 +- .../v2/changeValuePermissions.scala.txt | 5 +- .../sparql/v2/checkResourceDeletion.scala.txt | 5 +- .../sparql/v2/checkValueDeletion.scala.txt | 5 +- .../queries/sparql/v2/createClass.scala.txt | 5 +- .../queries/sparql/v2/createLink.scala.txt | 5 +- .../sparql/v2/createNewMapping.scala.txt | 5 +- .../sparql/v2/createOntology.scala.txt | 5 +- .../sparql/v2/createProperty.scala.txt | 5 +- .../queries/sparql/v2/createValue.scala.txt | 8 +- .../queries/sparql/v2/deleteClass.scala.txt | 5 +- .../queries/sparql/v2/deleteLink.scala.txt | 5 +- .../sparql/v2/deleteOntology.scala.txt | 5 +- .../sparql/v2/deleteProperty.scala.txt | 5 +- .../sparql/v2/deleteResource.scala.txt | 5 +- .../queries/sparql/v2/deleteValue.scala.txt | 5 +- .../queries/sparql/v2/eraseResource.scala.txt | 64 +- .../sparql/v2/eraseResourceGraphDB.scala.txt | 79 - .../sparql/v2/eraseResourceStandard.scala.txt | 71 - .../v2/getAllOntologyMetadata.scala.txt | 5 +- ...getAllResourcesInProjectPrequery.scala.txt | 25 +- ...esourcesInProjectPrequeryGraphDB.scala.txt | 30 - ...sourcesInProjectPrequeryStandard.scala.txt | 28 - .../sparql/v2/getClassDefinition.scala.txt | 5 +- .../queries/sparql/v2/getDeleteDate.scala.txt | 5 +- .../queries/sparql/v2/getGraphData.scala.txt | 106 +- .../sparql/v2/getGraphDataGraphDB.scala.txt | 119 - .../sparql/v2/getGraphDataStandard.scala.txt | 113 - .../queries/sparql/v2/getMapping.scala.txt | 46 +- .../sparql/v2/getOntologyGraph.scala.txt | 5 +- .../sparql/v2/getOntologyInfo.scala.txt | 5 +- .../sparql/v2/getPropertyDefinition.scala.txt | 5 +- .../getResourcePropertiesAndValues.scala.txt | 280 +- ...sourcePropertiesAndValuesGraphDB.scala.txt | 314 --- ...ourcePropertiesAndValuesStandard.scala.txt | 295 -- .../getResourceValueVersionHistory.scala.txt | 60 +- ...sourceValueVersionHistoryGraphDB.scala.txt | 62 - ...ourceValueVersionHistoryStandard.scala.txt | 64 - ...esourcesByClassInProjectPrequery.scala.txt | 55 +- ...sByClassInProjectPrequeryGraphDB.scala.txt | 61 - ...ByClassInProjectPrequeryStandard.scala.txt | 65 - .../sparql/v2/getStandoffTagByUUID.scala.txt | 5 +- .../queries/sparql/v2/isEntityUsed.scala.txt | 5 +- .../sparql/v2/isOntologyUsed.scala.txt | 5 +- .../v2/replaceClassCardinalities.scala.txt | 15 +- .../sparql/v2/searchFulltext.scala.txt | 161 +- .../sparql/v2/searchFulltextGraphDB.scala.txt | 138 - .../v2/searchFulltextStandard.scala.txt | 172 -- .../sparql/v2/searchResourceByLabel.scala.txt | 101 +- .../v2/searchResourceByLabelGraphDB.scala.txt | 106 - .../searchResourceByLabelStandard.scala.txt | 118 - ...> searchResourceByLabelSubQuery.scala.txt} | 0 ...urceByLabelSubQuerySelectGraphDB.scala.txt | 55 - .../sparql/v2/isPropertyUsed.scala.txt | 5 +- .../v2/OntologyResponderV2Spec.scala | 22 - .../triplestore/AllTriplestoreSpec.scala | 47 +- .../GraphDBConsistencyCheckingSpec.scala | 2377 ----------------- 251 files changed, 2232 insertions(+), 10910 deletions(-) delete mode 100644 test_data/store.triplestore.GraphDBConsistencyCheckingSpec/incunabula-data.ttl delete mode 100644 webapi/scripts/.gitignore delete mode 100644 webapi/scripts/KnoraRules.pie delete mode 100644 webapi/scripts/graphdb-drop-knora-prod-repository.ttl delete mode 100644 webapi/scripts/graphdb-drop-knora-test-repository.ttl delete mode 100644 webapi/scripts/graphdb-drop-knora-test-unit-repository.ttl delete mode 100755 webapi/scripts/graphdb-dump-repository.sh delete mode 100755 webapi/scripts/graphdb-empty-repository.sh delete mode 100755 webapi/scripts/graphdb-free-docker-init-knora-test-minimal.sh delete mode 100755 webapi/scripts/graphdb-free-docker-init-knora-test-unit.sh delete mode 100755 webapi/scripts/graphdb-free-docker-init-knora-test.sh delete mode 100644 webapi/scripts/graphdb-free-knora-test-repository-config.ttl.tmpl delete mode 100644 webapi/scripts/graphdb-free-knora-test-unit-repository-config.ttl.tmpl delete mode 100755 webapi/scripts/graphdb-free-local-init-knora-test-unit.sh delete mode 100755 webapi/scripts/graphdb-free-local-init-knora-test.sh delete mode 100644 webapi/scripts/graphdb-knora-index-create.rq delete mode 100644 webapi/scripts/graphdb-knora-index-update.rq delete mode 100755 webapi/scripts/graphdb-knora-prod-data.expect delete mode 100755 webapi/scripts/graphdb-knora-test-data-minimal.expect delete mode 100755 webapi/scripts/graphdb-knora-test-data.expect delete mode 100755 webapi/scripts/graphdb-knora-test-unit-data-minimal.expect delete mode 100755 webapi/scripts/graphdb-se-docker-init-knora-prod-empty.sh delete mode 100755 webapi/scripts/graphdb-se-docker-init-knora-prod.sh delete mode 100755 webapi/scripts/graphdb-se-docker-init-knora-test-minimal.sh delete mode 100755 webapi/scripts/graphdb-se-docker-init-knora-test-unit-minimal.sh delete mode 100755 webapi/scripts/graphdb-se-docker-init-knora-test-unit.sh delete mode 100755 webapi/scripts/graphdb-se-docker-init-knora-test.sh delete mode 100644 webapi/scripts/graphdb-se-drop-knora-prod-repository.ttl delete mode 100644 webapi/scripts/graphdb-se-knora-prod-repository-config.ttl.tmpl delete mode 100644 webapi/scripts/graphdb-se-knora-test-repository-config.ttl.tmpl delete mode 100644 webapi/scripts/graphdb-se-knora-test-unit-repository-config.ttl.tmpl delete mode 100755 webapi/scripts/graphdb-se-local-init-knora-prod-empty.sh delete mode 100755 webapi/scripts/graphdb-se-local-init-knora-prod.sh delete mode 100755 webapi/scripts/graphdb-se-local-init-knora-test-unit.sh delete mode 100755 webapi/scripts/graphdb-se-local-init-knora-test.sh delete mode 100755 webapi/scripts/graphdb-upload-repository.sh delete mode 100644 webapi/scripts/win-graphdb-free-init-knora-test.sh delete mode 100644 webapi/scripts/win-graphdb-knora-test-data.ttl delete mode 100644 webapi/src/main/scala/org/knora/webapi/messages/store/triplestoremessages/GraphDBAPI.scala delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValueGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValueStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/generateWhereStatementsForGetMapping.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContextGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContextStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphDataGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphDataStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferencesGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferencesStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegionsGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegionsStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfoGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfoStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValuesGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValuesStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResultGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResultStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValueGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValueStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistoryGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistoryStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOfGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOfStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtendedGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtendedStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltextGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltextStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResourceGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResourceStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequeryGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequeryStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphDataGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphDataStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValuesGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValuesStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistoryGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistoryStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequeryGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequeryStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltextGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltextStandard.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelGraphDB.scala.txt delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelStandard.scala.txt rename webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/{searchResourceByLabelSubQuerySelectStandard.scala.txt => searchResourceByLabelSubQuery.scala.txt} (100%) delete mode 100644 webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelSubQuerySelectGraphDB.scala.txt delete mode 100644 webapi/src/test/scala/org/knora/webapi/store/triplestore/GraphDBConsistencyCheckingSpec.scala diff --git a/README.md b/README.md index 607b61aba4..06c7f5ae66 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ We write automated tests using [ScalaTest](https://www.scalatest.org). You can r There are three sets of automated tests: -* Unit tests, route-to-route tests, and end-to-end tests are under `webapi/src/test`. To run these, type `graphdb:test` or `graphdb-free:test` (depending on which triplestore you're using) at the SBT console in the `webapi` project. To run a single test, use `graphdb:test-only *NameOfTestSpec`. +* Unit tests, route-to-route tests, and end-to-end tests are under `webapi/src/test`. To run these, type `test` at the SBT console in the `webapi` project. To run a single test, use `testOnly *NameOfTestSpec`. * Integration tests, which can involve [Sipi](https://github.com/daschswiss/sipi), are under `src/it`. To run these, first start Sipi, then type `it:test` at the SBT console in the `webapi` project. Whenever you add a new feature or fix a bug, you should add one or more tests diff --git a/docs/02-knora-ontologies/knora-base.md b/docs/02-knora-ontologies/knora-base.md index 21b0b6a7d4..0b9e67fa1a 100644 --- a/docs/02-knora-ontologies/knora-base.md +++ b/docs/02-knora-ontologies/knora-base.md @@ -953,9 +953,6 @@ in user-created ontologies. Three types of consistency rules are enforced: - Constraints on the types of the subjects and objects of OWL object properties must be satisfied. - A datatype property may not have an empty string as an object. -The implementation of consistency checking is partly triplestore-dependent; Knora may be able to provide stricter checks -with some triplestores than with others. - ### OWL Cardinalities As noted in [Resources](#resources), each subclass of diff --git a/docs/04-publishing-deployment/configuration.md b/docs/04-publishing-deployment/configuration.md index 8cde61ed1f..db03da8f41 100644 --- a/docs/04-publishing-deployment/configuration.md +++ b/docs/04-publishing-deployment/configuration.md @@ -53,10 +53,6 @@ A number of core settings is additionally configurable through system environmen | app.triplestore.use-https | KNORA_WEBAPI_TRIPLESTORE_USE_HTTPS | false | | app.triplestore.host | KNORA_WEBAPI_TRIPLESTORE_HOST | localhost | | app.triplestore.auto-init | KNORA_WEBAPI_TRIPLESTORE_AUTOINIT | false | -| app.triplestore.graphdb.port | KNORA_WEBAPI_TRIPLESTORE_GRAPHDB_PORT | 7200 | -| app.triplestore.graphdb.repository-name | KNORA_WEBAPI_TRIPLESTORE_GRAPHDB_REPOSITORY_NAME | knora-test | -| app.triplestore.graphdb.username | KNORA_WEBAPI_TRIPLESTORE_GRAPHDB_USERNAME | admin | -| app.triplestore.graphdb.password | KNORA_WEBAPI_TRIPLESTORE_GRAPHDB_PASSWORD | root | | app.triplestore.fuseki.port | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PORT | 3030 | | app.triplestore.fuseki.repository-name | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_REPOSITORY_NAME | knora-test | | app.triplestore.fuseki.username | KNORA_WEBAPI_TRIPLESTORE_FUSEKI_USERNAME | admin | diff --git a/docs/04-publishing-deployment/getting-started.md b/docs/04-publishing-deployment/getting-started.md index 4cfd03a024..0ef498ce80 100644 --- a/docs/04-publishing-deployment/getting-started.md +++ b/docs/04-publishing-deployment/getting-started.md @@ -50,9 +50,6 @@ DSP-API is designed to work with any standards-compliant triplestore. It is primarily tested with [Apache Jena Fuseki](https://jena.apache.org), an open source triplestore. -Built-in support and configuration for a high-performance, proprietary -triplestore [Ontotext GraphDB](http://ontotext.com/products/graphdb/) is -provided but unmaintained (GraphDB must be licensed separately by the user). Other triplestores are planned. ## Running the DSP-Stack diff --git a/docs/04-publishing-deployment/updates.md b/docs/04-publishing-deployment/updates.md index b2cfd97fad..0c48801383 100644 --- a/docs/04-publishing-deployment/updates.md +++ b/docs/04-publishing-deployment/updates.md @@ -15,54 +15,7 @@ manual changes are needed, these will be described in the release notes, and mus done first. Before starting a new version of Knora, back up your repository, so you can restore it -in case the automatic repository update fails. You can use one of these scripts -in `webapi/scripts`: - -- `fuseki-dump-repository.sh` for Fuseki -- `graphdb-dump-repository.sh` for GraphDB - +in case the automatic repository update fails. For Fuseki use `fuseki-dump-repository.sh` +script located in `webapi/scripts`. For information on command-line options, run the script with no arguments. - -## Upgrading from a Knora Version Before 7.0.0 - -**WARNING**: If you do not follow this procedure, your data may be -corrupted, and Knora may not work. - -You must first upgrade to Knora 7.0.0, then upgrade again to the current -version. - -The overall procedure is: - -1. Back up your repository as described above. - -2. Install Knora release 7.0.0, and read the general instructions in - `upgrade/graphdb-se/old/README.md` in that release. - -3. Follow the instructions in one of the subsections below for the version you are - upgrading from. - -4. Back up your repository again. - -5. Install the current release of Knore, and follow any manual update instructions - in its release notes. - -6. Start Knora to continue the automatic upgrade. - -### Upgrading from Knora 6.0.0 or 6.0.1 - -1. Follow the instructions in `upgrade/graphdb-se/old/1263-knora-admin/README.md`. - -2. Follow the instructions in - [Upgrading from Knora 7.0.0 or Later](#upgrading-from-knora-7-0-0-or-later). - -### Upgrading from Knora 5.0.0 - -1. Follow the instructions in `upgrade/graphdb-se/old/1211-datetime/README.md`. - -2. Follow the instructions in `upgrade/graphdb-se/old/1230-delete-previews/README.md`. - -3. Follow the instructions in `upgrade/graphdb-se/old/1263-knora-admin/README.md`. - -4. Follow the instructions in - [Upgrading from Knora 7.0.0 or Later](#upgrading-from-knora-7-0-0-or-later). diff --git a/docs/05-internals/design/api-v2/gravsearch.md b/docs/05-internals/design/api-v2/gravsearch.md index 49797f79d4..0dade5ef11 100644 --- a/docs/05-internals/design/api-v2/gravsearch.md +++ b/docs/05-internals/design/api-v2/gravsearch.md @@ -309,9 +309,7 @@ When the triplestore-specific version of the query is generated: Gravsearch also provides some virtual properties, which take advantage of forward-chaining inference as an optimisation if the triplestore provides it. For example, the virtual property -`knora-api:standoffTagHasStartAncestor` is equivalent to `knora-base:standoffTagHasStartParent*`, but -with GraphDB it is implemented using a custom inference rule (in `KnoraRules.pie`) and is therefore more -efficient. If Knora is not using the triplestore's inference, `SparqlTransformer.transformStatementInWhereForNoInference` +`knora-api:standoffTagHasStartAncestor` is equivalent to `knora-base:standoffTagHasStartParent*`. If Knora is not using the triplestore's inference, `SparqlTransformer.transformStatementInWhereForNoInference` replaces `knora-api:standoffTagHasStartAncestor` with `knora-base:standoffTagHasStartParent*`. # Optimisation of generated SPARQL diff --git a/docs/05-internals/design/principles/consistency-checking.md b/docs/05-internals/design/principles/consistency-checking.md index 949fea9104..5d488839db 100644 --- a/docs/05-internals/design/principles/consistency-checking.md +++ b/docs/05-internals/design/principles/consistency-checking.md @@ -5,6 +5,9 @@ # Consistency Checking +**Attention!** GraphDB is not supported anymore, therefore parts related +to it in this document are redundant. + ## Requirements Knora is designed to prevent inconsistencies in RDF data, diff --git a/docs/05-internals/design/principles/design-overview.md b/docs/05-internals/design/principles/design-overview.md index fc01e1b194..2e1d03592a 100644 --- a/docs/05-internals/design/principles/design-overview.md +++ b/docs/05-internals/design/principles/design-overview.md @@ -26,7 +26,7 @@ Knora is written in [Scala](http://www.scala-lang.org/), using the [Akka](http://akka.io/) framework for message-based concurrency. It is designed to work with any standards-compliant triplestore via the [SPARQL 1.1 Protocol](http://www.w3.org/TR/sparql11-protocol/), but is currently -tested only with [Ontotext GraphDB](http://graphdb.ontotext.com/) (with support +tested only with [Apache Jena Fuseki](https://jena.apache.org) (with support for other triplestores coming soon). ## Knora APIs diff --git a/docs/05-internals/design/principles/store-module.md b/docs/05-internals/design/principles/store-module.md index 40ed928e40..b4a25f8466 100644 --- a/docs/05-internals/design/principles/store-module.md +++ b/docs/05-internals/design/principles/store-module.md @@ -26,14 +26,10 @@ HTTP-based triplestore support is implemented in the `org.knora.webapi.triplestore.http` package. An HTTP-based triplestore is one that is accessed remotely over the HTTP -protocol. `HttpTriplestoreConnector` supports the following triplestores: +protocol. `HttpTriplestoreConnector` supports the open source triplestore +- [Apache Jena Fuseki](https://jena.apache.org). - - Ontotext GraphDB - - Fuseki 2 - -### GraphDB - -### Fuseki 2 +### Apache Jena Fuseki ## Embedded Triplestores diff --git a/docs/05-internals/design/principles/triplestore-updates.md b/docs/05-internals/design/principles/triplestore-updates.md index 62c7037689..7c2f1996a4 100644 --- a/docs/05-internals/design/principles/triplestore-updates.md +++ b/docs/05-internals/design/principles/triplestore-updates.md @@ -36,16 +36,11 @@ the same data, and may eventually provide functionality to facilitate this coordination.) We can assume that each SPARQL update operation will run in its own -database transaction with an isolation level of 'read committed'. This -is what GraphDB does when it receives a SPARQL update over HTTP (see -[GraphDB SE -Transactions](http://graphdb.ontotext.com/documentation/standard/storage.html#transaction-control)). +database transaction with an isolation level of 'read committed'. We cannot assume that it is possible to run more than one SPARQL update -in a single database transaction. (The [SPARQL 1.1 -Protocol](http://www.w3.org/TR/sparql11-protocol/) does not provide a -way to do this, and currently it can be done only by embedding the -triplestore in the application and using a vendor-specific API, but we -cannot require this in Knora.) +in a single database transaction. The [SPARQL 1.1 Protocol](http://www.w3.org/TR/sparql11-protocol/) does not provide a way to do this, and currently it +can be done only by embedding the triplestore in the application and +using a vendor-specific API, but we cannot require this in Knora.) ### Permissions @@ -253,7 +248,7 @@ Knora enforces consistency constraints using three redundant mechanisms: 1. By doing pre-update checks using SPARQL SELECT queries and cached ontology data. 2. By doing checks in the `WHERE` clauses of SPARQL updates. -3. By using GraphDB's built-in consistency checker (see +3. **Deprecated**: By using GraphDB's built-in consistency checker (see [Consistency Checking](consistency-checking.md)). We take the view that redundant consistency checks are a good thing. diff --git a/docs/05-internals/development/docker-compose.md b/docs/05-internals/development/docker-compose.md index 635a755e51..56b465edb0 100644 --- a/docs/05-internals/development/docker-compose.md +++ b/docs/05-internals/development/docker-compose.md @@ -5,27 +5,13 @@ # Starting the Knora Stack inside Docker Container -To run Knora locally, we provide `docker-compose.yml` which can be used to start GraphDB, Sipi, +To run Knora locally, we provide `docker-compose.yml` which can be used to start Fuseki, Sipi, Webapi running each in its own Docker container. -For GraphDB it is additionally necessary to define two environment variables: - -``` -$ export KNORA_GDB_LICENSE # full path to the GraphDB-SE license file, e.g., /Users/name/GDB/GDB.license -$ export KNORA_GDB_HOME # full path to a local folder where GraphDB should store it's data, e.g., /users/name/GDB/home -``` - -Per default, GraphDB-SE is started. If GraphDB-Free is needed, because there is no awailable license, -then a third environment variable can be set to something like: - -``` -$ export KNORA_GDB_IMAGE=daschswiss/graphdb-free:8.3.1 -``` - To run the whole stack: ``` -$ docker-compose up +$ make stack-up ``` For additional information please see the [Docker Compose documentation](https://docs.docker.com/compose/) diff --git a/docs/05-internals/development/overview.md b/docs/05-internals/development/overview.md index 3d75ee521a..4deab1b22a 100644 --- a/docs/05-internals/development/overview.md +++ b/docs/05-internals/development/overview.md @@ -10,8 +10,7 @@ installation of Knora. The different parts are: 1. The cloned [DSP-API](https://github.com/dasch-swiss/dsp-api) Github repository -1. One of the supplied triplestores in the DSP-API Github repository - (GraphDB-SE 8 or Fuseki 3). +1. Fuseki - supplied triplestore in the DSP-API Github repository. 1. Sipi by building from [source](https://github.com/dasch-swiss/sipi) or using the docker [image](https://hub.docker.com/r/daschswiss/sipi/) diff --git a/docs/05-internals/development/testing.md b/docs/05-internals/development/testing.md index 3edaad24db..f06cfb9c0d 100644 --- a/docs/05-internals/development/testing.md +++ b/docs/05-internals/development/testing.md @@ -5,12 +5,6 @@ # Testing -Prerequisite: Before running any tests, a supported triplestore needs to -be started and initialized through a script inside the "scripts" folder. -For example, when using "GraphDB Free", the nedded script is -"graphdb-free-init-knora-test-unit.sh". Please note the occurrence of -"test-unit" in the name of the script. - ## How to Write Unit Tests 1) Inside a test, at the beginning, add the following (change the paths diff --git a/docs/07-lucene/index.md b/docs/07-lucene/index.md index 28c523f141..6142c037f8 100644 --- a/docs/07-lucene/index.md +++ b/docs/07-lucene/index.md @@ -6,6 +6,6 @@ # Lucene The Lucene full-text index provided by the triplestore is used to perform full-text searches in Knora. -The exact behavior can be different depending on the triplestore, e.g., GraphDB or Fuseki. +The exact behavior can be different depending on the triplestore. * [Lucene Query Parser Syntax](lucene-query-parser-syntax.md) diff --git a/docs/faq/index.md b/docs/faq/index.md index e21cd3f3b1..da18c24129 100644 --- a/docs/faq/index.md +++ b/docs/faq/index.md @@ -29,10 +29,7 @@ we recommend converting it to Knora resources, which are stored as RDF. ### Which triplestores can be used with Knora? -Knora is tested with [Ontotext GraphDB SE](http://graphdb.ontotext.com/). -Our goal is to support several triplestores, including open-source options. -Integration with [Apache Jena Fuseki](https://jena.apache.org/documentation/fuseki2/) -has been partly implemented, but is not currently supported. +Knora is tested with [Apache Jena Fuseki](https://jena.apache.org/). ## Knora Ontologies diff --git a/test_data/store.triplestore.GraphDBConsistencyCheckingSpec/incunabula-data.ttl b/test_data/store.triplestore.GraphDBConsistencyCheckingSpec/incunabula-data.ttl deleted file mode 100644 index 2156aeb393..0000000000 --- a/test_data/store.triplestore.GraphDBConsistencyCheckingSpec/incunabula-data.ttl +++ /dev/null @@ -1,174 +0,0 @@ -@prefix xml: . -@prefix xsd: . -@prefix rdf: . -@prefix rdfs: . -@prefix owl: . -@prefix foaf: . -@prefix knora-base: . -@prefix salsah-gui: . -@prefix incunabula: . - - a incunabula:Sideband; - incunabula:description ; - incunabula:sbTitle ; - knora-base:attachedToProject ; - knora-base:attachedToUser ; - knora-base:creationDate "2016-03-02T15:05:55Z"^^xsd:dateTime; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:hasStillImageFileValue ; - knora-base:isDeleted false; - rdfs:label "l_1a" . - - a knora-base:TextValue; - knora-base:valueHasUUID "25279d8dcd8e01"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-03-02T15:05:55Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "l_1a" . - - a knora-base:TextValue; - knora-base:valueHasUUID "a4167701aa4d03"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-03-02T15:05:55Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "213610" . - - a knora-base:StillImageFileValue; - knora-base:valueHasUUID "aca600df2b2a"^^xsd:string; - knora-base:attachedToUser ; - knora-base:dimX 328; - knora-base:dimY 4240; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:internalFilename "incunabula_0000060840.jp2"; - knora-base:internalMimeType "image/jp2"; - knora-base:isDeleted false; - knora-base:originalFilename "l1a.tiff"; - knora-base:originalMimeType "image/tiff"; - knora-base:valueCreationDate "2015-05-19T22:39:12Z"^^xsd:dateTime; - knora-base:valueHasString "l1a.tiff" . - - a incunabula:book; - incunabula:citation , , - ; - incunabula:hasAuthor ; - incunabula:location ; - incunabula:physical_desc ; - incunabula:pubdate ; - incunabula:publisher ; - incunabula:publoc ; - incunabula:title ; - incunabula:url ; - knora-base:attachedToProject ; - knora-base:attachedToUser ; - knora-base:creationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser|RV knora-admin:UnknownUser"; - knora-base:isDeleted false; - rdfs:label "Zeitglöcklein des Lebens und Leidens Christi" . - - a knora-base:TextValue; - knora-base:valueHasUUID "0ca74ce5"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|V knora-admin:ProjectMember,knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "Basel" . - - a knora-base:TextValue; - knora-base:valueHasUUID "10e00c7acc2704"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|D knora-admin:ProjectMember|V knora-admin:UnknownUser,knora-admin:KnownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "http://www.ub.uni-koeln.de/cdm/compoundobject/collection/inkunabeln/id/1878/rec/1" . - - a knora-base:TextValue; - knora-base:valueHasUUID "184e99ca01"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "Schramm Bd. XXI, S. 27" . - - a knora-base:TextValue; - knora-base:valueHasUUID "497df9ab"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "Johann Amerbach" . - - a knora-base:TextValue; - knora-base:valueHasUUID "5524469101"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:UnknownUser,knora-admin:KnownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "Dimension: 8°" . - - a knora-base:TextValue; - knora-base:valueHasUUID "8653a672"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:UnknownUser,knora-admin:KnownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "Berthold, der Bruder" . - - a knora-base:TextValue; - knora-base:valueHasUUID "92faf25701"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|D knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "Universitäts- und Stadtbibliothek Köln, Sign: AD+S167" . - - a knora-base:TextValue; - knora-base:valueHasUUID "9ea13f3d02"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 2; - knora-base:valueHasString "ISTC ib00512000" . - - a knora-base:TextValue; - knora-base:valueHasUUID "c3295339"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 0; - knora-base:valueHasString "Zeitglöcklein des Lebens und Leidens Christi" . - - a knora-base:DateValue; - knora-base:valueHasUUID "cfd09f1e01"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasCalendar "JULIAN"; - knora-base:valueHasEndJDN 2266376; - knora-base:valueHasEndPrecision "YEAR"; - knora-base:valueHasOrder 0; - knora-base:valueHasStartJDN 2266011; - knora-base:valueHasStartPrecision "YEAR"; - knora-base:valueHasString "1492-01-01 - 1492-12-31" . - - a knora-base:TextValue; - knora-base:valueHasUUID "db77ec0302"^^xsd:string; - knora-base:attachedToUser ; - knora-base:hasPermissions "CR knora-admin:Creator|M knora-admin:ProjectMember|V knora-admin:KnownUser,knora-admin:UnknownUser"; - knora-base:isDeleted false; - knora-base:valueCreationDate "2016-01-22T11:31:24Z"^^xsd:dateTime; - knora-base:valueHasOrder 1; - knora-base:valueHasString "GW 4168" . diff --git a/webapi/scripts/.gitignore b/webapi/scripts/.gitignore deleted file mode 100644 index 620768f687..0000000000 --- a/webapi/scripts/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -graphdb-se-knora-prod-repository-config.ttl -graphdb-se-knora-test-repository-config.ttl -graphdb-se-knora-test-unit-repository-config.ttl -graphdb-free-knora-test-repository-config.ttl -graphdb-free-knora-test-unit-repository-config.ttl diff --git a/webapi/scripts/KnoraRules.pie b/webapi/scripts/KnoraRules.pie deleted file mode 100644 index 157b707020..0000000000 --- a/webapi/scripts/KnoraRules.pie +++ /dev/null @@ -1,448 +0,0 @@ -/* - * A GraphDB inference rules file based on GraphDB's built-in rules file - * builtin_RdfsRules.pie, adding rules for Knora-specific consistency checks. - */ - -/* OWLIM rules and axioms for the TRREE engine - * - * From Thu 03-03-2006 - * - * Every rule consists of one or more premises and one or more corollaries - * in the following format: - * - * Rules - * { - * Id: Rule_Id - * < Premise #1 > - * < Premise #2 > - * . . . - * < Premise #n > - * --------------------- - * < Corollary #1 > - * < Corollary #2 > - * . . . - * < Corollary #m > - * } - * - * Every premise may contain constraints stating that the value of one or - * more variables in the statement must not be equal to a full URI, a short name - * or the value of another variable from the same rule. - * This is written in the following format: - * - * . . . . . . . . . . . - * a b [Constraint a != b] - * a c [Constraint a != , c != a, c != b] - * ----------------------------------- - * c a b - * b [Constraint b != ] - * - * Every left value in the not-equal constraint must denote a variable - * and every right value can be a variable, a short name or a full URI. - * Not-equal constraints may be used to force the engine not to apply - * the rule when the constraints are not satisfied. This will improve - * engine's performance. - * Constraints are valid anywhere within the rule-body. - * If a variable is not bound yet then the constraint is considered satisfied - * (and therefore does not apply). - * In the rule head, a constraint only affects the production of the rule conclusion it neighbours. - * - * In addition one or more axioms may be added in the following format: - * - * Axioms - * { - * < Axiom #1 > - * < Axiom #2 > - * . . . - * < Axiom #n > - * } - * - * The premises, the corollaries and the axioms must be written in N-Triple format. - * The subject, the predicate and the object must denote a full URI or - * a short name in format : where is defined in - * the prefix section written in the following format: - * - * Prefices - * { - * < Prefix #1 > : < Full URI for prefix #1 > - * < Prefix #2 > : < Full URI for prefix #2 > - * . . . . . . . . . . . . . . - * < Prefix #n > : < Full URI for prefix #n > - * } - * - * The sections must be arranged in the following order: - * - * Prefices // If any - * { - * . . . - * } - * Axioms // If any - * { - * . . . - * } - * Rules // Must necessarily be present - * { - * . . . - * } - * - * Variables in the rules must be literals consisting of one symbol only. - * They must NOT be surrounded by angle braces. - * ONLY rule statements may contain variables. - * - * The contents of this file is translated into java code and is output - * to com.ontotext.trree.RdfsHashInferencer and com.ontotext.trree.OwlHashInferencer. - * Use program RuleCompiler.java in order to compile this file. - * Please do not make changes in file generated files because - * next time the translator is started the changes will disappear. - * - */ - -Prefices -{ - rdf : http://www.w3.org/1999/02/22-rdf-syntax-ns# - rdfs : http://www.w3.org/2000/01/rdf-schema# - owl : http://www.w3.org/2002/07/owl# - xsd : http://www.w3.org/2001/XMLSchema# - knora-base : http://www.knora.org/ontology/knora-base# - onto : http://www.ontotext.com/ -} - -Axioms -{ -// RDF axiomatic triples (from RDF Semantics, section 3.1): - - - - - - - - - - -// RDFS axiomatic triples (from RDF Semantics, section 4.1): - -/*[partialRDFS]*/ - - - - - - -/*[partialRDFS]*/ - - - - - -/*[partialRDFS]*/ - - - - - - - - - -// - - - - - - - - - - - - - - - - - - -/*[partialRDFS]*/ - - - - - - - - - - - - - - - - - - - - } - -Rules -{ -/*[partialRDFS]*/ -Id: rdf1_rdfs4a_4b - x a y - ------------------------------- - x - a - y -/*[partialRDFS]*/ - - -Id: rdfs2 - x a y [Constraint a != ] - a z [Constraint z != ] - ------------------------------- - x z - -Id: rdfs3 - x a u - a z [Constraint z != ] - ------------------------------- - u z - -Id: rdfs5 - a b [Constraint a != b, a != c, b != c] - b c - ------------------------------- - a c - - -Id: rdfs6 - a - ------------------------------- - a a - - -Id: rdfs7 - x a y [Constraint a != b] - a b - ------------------------------- - x b y - - -Id: rdfs8_10 - x - ------------------------------- - x - x x - -Id: rdfs9 - a x [Constraint x != y] - x y - ------------------------------- - a y - - -Id: rdfs11 - x y [Constraint x != y, x != z, y != z] - y z - ------------------------------- - x z - - -Id: rdfs12 - x - ------------------------------- - x - - -Id: rdfs13 - x - ------------------------------- - x - -// , implemented here to optimise standoff searches. -Id: prp_trp - p - x p y - y p z - ------------------------------- - x p z - -/******************************************************************************** - * Knora-specific consistency checks * - ********************************************************************************/ - - -/* - * Inference rules that construct tables (i.e. named graphs) used to optimize the consistency rules below. - */ - -// Constructs a table of subjects belonging to classes that have owl:cardinality 1 on some property p. -Id: cardinality_1_table - i r - r "1"^^xsd:nonNegativeInteger - r p - ------------------------------------ - i p r [Context ] - -// Constructs a table of subjects belonging to classes that have owl:minCardinality 1 on some property p. -Id: minCardinality_1_table - i r - r "1"^^xsd:nonNegativeInteger - r p - ------------------------------------ - i p r [Context ] - -// Constructs a table of subjects belonging to classes that have owl:maxCardinality 1 on some property p. -Id: maxCardinality_1_table - i r - r "1"^^xsd:nonNegativeInteger - r p - ------------------------------------ - i p r [Context ] - - -/* - * A consistency rule that disallows empty strings. - */ - Consistency: empty_string - i p "" - ------------------------------------ - - -/* - * Consistency rules for subject and object class constraints. - */ - -// Every subproperty of knora-base:resourceProperty must have a knora-base:objectClassConstraint. -Consistency: object_class_constraint_required - p [Constraint p != ] - ------------------------------------ - p c - - -// The subject of a property must belong to the class specified in the property's knora-base:subjectClassConstraint. -Consistency: subject_class_constraint - p t - i p j - ------------------------------------ - i t - -// The object of an object property must belong to the class specified in the property's knora-base:objectClassConstraint. -Consistency: object_class_constraint - p t - i p j - ------------------------------------ - j t - - -/* - * Consistency rules for cardinalities on any properties. - */ - -// With owl:minCardinality 1, the property must have an object. It's OK if the object is marked as deleted. -Consistency: min_cardinality_1_any_object - i p r [Context ] - ------------------------------------ - i p j - -// With owl:cardinality 1, the property must have an object. It's OK if the object is marked as deleted. -Consistency: cardinality_1_not_less_any_object - i p r [Context ] - ------------------------------------ - i p j - - -/* - * Consistency rule for owl:cardinality 1 with rdfs:label. - */ -Consistency: cardinality_1_not_greater_rdfs_label - i r [Context ] - i j [Constraint j != k] - i k - ------------------------------------ - - -/* - * Consistency rules for cardinalities on properties whose objects cannot be marked as deleted - * using the boolean flag knora-base:isDeleted. - */ - -// With owl:maxCardinality 1, if the object of the property cannot be marked as deleted, just check that there -// is not more than one object. -Consistency: max_cardinality_1_without_deletion_flag - i p r [Context ] - p - i p j [Constraint j != k] - i p k [Cut] - ------------------------------------ - -// With owl:cardinality 1, if the object of the property cannot be marked as deleted, just check that there -// is not more than one object. -Consistency: cardinality_1_not_greater_without_deletion_flag - i p r [Context ] - p - i p j [Constraint j != k] - i p k [Cut] - ------------------------------------ - - -/* - * Consistency rules for cardinalities on properties whose objects can be marked as deleted - * using the boolean flag knora-base:isDeleted. Here we take advantage of the fact that every class - * that *allows* knora-base:isDeleted also *requires* knora-base:isDeleted. So an object that can be - * marked as deleted, but has not been marked as deleted, will have knora-base:isDeleted false. - */ - -// With owl:maxCardinality 1, if the object of the property can be marked as deleted, there must not be -// more than one non-deleted object. (In other words, it's OK if there is more than one object, -// as long only one object has knora-base:isDeleted false.) -Consistency: max_cardinality_1_with_deletion_flag - i p r [Context ] - i p j [Constraint j != k] - i p k [Cut] - j "false"^^xsd:boolean - k "false"^^xsd:boolean - ------------------------------------ - -// With owl:cardinality 1, if the object of the property can be marked as deleted, there must not be -// more than one non-deleted object. (In other words, it's OK if there is more than one object, -// as long only one object has knora-base:isDeleted false.) -Consistency: cardinality_1_not_greater_with_deletion_flag - i p r [Context ] - i p j [Constraint j != k] - i p k [Cut] - j "false"^^xsd:boolean - k "false"^^xsd:boolean - ------------------------------------ - -// If a resource has a property pointing to a resource or value, the resource class must have -// some cardinality for that property. -Consistency: resource_prop_cardinality_any - i j - ------------------------------------ - i p j - i r - r p - - -// If a value has a subproperty of knora-base:valueHas, the value class must have -// some cardinality for that property. -Consistency: value_prop_cardinality_any - i j - ------------------------------------ - i p j - i r - r p - - -/* -Consistency: standoff_parent - i j - i t - ------------------------------------ - t c - j c -*/ - -} diff --git a/webapi/scripts/Readme.md b/webapi/scripts/Readme.md index 1b07795652..c6aae41e9e 100644 --- a/webapi/scripts/Readme.md +++ b/webapi/scripts/Readme.md @@ -13,36 +13,3 @@ $ make fuseki-init-knora-test-unit-minimal $ make fuseki-init-knora-test $ make fuseki-init-knora-test-minimal ``` - -## GraphDB - -### Initialize for CI (continuous integration) and unit testing (running tests inside sbt) - -This script will create the ``knora-test-unit`` repository and not load any data. Data will be loaded during testing. - - - with GraphDB running inside a docker container: - ```$ graphdb-se-docker-init-knora-test-unit.sh``` - - - with GraphDB running locally, e.g., graphdb distribution: - ```$ graphdb-se-local-init-knora-test-unit.sh ``` - - -### Initialize for using in the test / staging environment - -This script will create the ``knora-test`` repository and load test data specified in ``graphdb-knora-test-data.expect``. - - - with GraphDB running inside a docker container: - ```$ graphdb-se-docker-init-knora-test.sh``` - - - with GraphDB running locally, e.g., graphdb distribution: - ```$ graphdb-se-local-init-knora-test.sh ``` - -### Initialize for using in the production environment - -This script will create the ``knora-prod`` repository and load data specified in ``graphdb-knora-prod-data.expect``. - - - with GraphDB running inside a docker container: - ```$ graphdb-se-docker-init-knora-prod.sh``` - - - with GraphDB running locally, e.g., graphdb distribution: - ```$ graphdb-se-local-init-knora-prod.sh ``` diff --git a/webapi/scripts/graphdb-drop-knora-prod-repository.ttl b/webapi/scripts/graphdb-drop-knora-prod-repository.ttl deleted file mode 100644 index 9098a184d6..0000000000 --- a/webapi/scripts/graphdb-drop-knora-prod-repository.ttl +++ /dev/null @@ -1,2 +0,0 @@ -drop knora-prod . -exit . diff --git a/webapi/scripts/graphdb-drop-knora-test-repository.ttl b/webapi/scripts/graphdb-drop-knora-test-repository.ttl deleted file mode 100644 index e79708ddeb..0000000000 --- a/webapi/scripts/graphdb-drop-knora-test-repository.ttl +++ /dev/null @@ -1,2 +0,0 @@ -drop knora-test . -exit . diff --git a/webapi/scripts/graphdb-drop-knora-test-unit-repository.ttl b/webapi/scripts/graphdb-drop-knora-test-unit-repository.ttl deleted file mode 100644 index 9901a0fa6b..0000000000 --- a/webapi/scripts/graphdb-drop-knora-test-unit-repository.ttl +++ /dev/null @@ -1,2 +0,0 @@ -drop knora-test-unit . -exit . diff --git a/webapi/scripts/graphdb-dump-repository.sh b/webapi/scripts/graphdb-dump-repository.sh deleted file mode 100755 index db930d6d78..0000000000 --- a/webapi/scripts/graphdb-dump-repository.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -#set -x - -POSITIONAL=() -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -r|--repository) - REPOSITORY="$2" - shift # past argument - shift # past value - ;; - -u|--username) - USER_NAME="$2" - shift # past argument - shift # past value - ;; - -p|--password) - PASSWORD="$2" - shift # past argument - shift # past value - ;; - -h|--host) - HOST="$2" - shift # past argument - shift # past value - ;; - *) # unknown option - POSITIONAL+=("$1") # save it in an array for later - shift # past argument - ;; -esac -done -set -- "${POSITIONAL[@]}" # restore positional parameters - -FILE="$1" - -if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" || -z "${FILE}" ]]; then - echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST] FILE" - exit 1 -fi - -if [[ -z "${PASSWORD}" ]]; then - echo -n "Password: " - IFS="" read -rs PASSWORD - echo -fi - -if [[ -z "${HOST}" ]]; then - HOST="localhost:7200" -fi - -curl -sS -X GET -H "Accept: application/trig" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements?infer=false" > "${FILE}" diff --git a/webapi/scripts/graphdb-empty-repository.sh b/webapi/scripts/graphdb-empty-repository.sh deleted file mode 100755 index 2c4f60af08..0000000000 --- a/webapi/scripts/graphdb-empty-repository.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash - -#set -x - -POSITIONAL=() -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -r|--repository) - REPOSITORY="$2" - shift # past argument - shift # past value - ;; - -u|--username) - USER_NAME="$2" - shift # past argument - shift # past value - ;; - -p|--password) - PASSWORD="$2" - shift # past argument - shift # past value - ;; - -h|--host) - HOST="$2" - shift # past argument - shift # past value - ;; - *) # unknown option - POSITIONAL+=("$1") # save it in an array for later - shift # past argument - ;; -esac -done -set -- "${POSITIONAL[@]}" # restore positional parameters - -if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" ]]; then - echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST]" - exit 1 -fi - -if [[ -z "${PASSWORD}" ]]; then - echo -n "Password: " - IFS="" read -rs PASSWORD - echo -fi - -if [[ -z "${HOST}" ]]; then - HOST="localhost:7200" -fi - -curl -sS -X POST -H "Content-Type: application/sparql-update" -d "DROP ALL" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements" diff --git a/webapi/scripts/graphdb-free-docker-init-knora-test-minimal.sh b/webapi/scripts/graphdb-free-docker-init-knora-test-minimal.sh deleted file mode 100755 index 208e1cdafc..0000000000 --- a/webapi/scripts/graphdb-free-docker-init-knora-test-minimal.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-free-knora-test-repository-config.ttl.tmpl > graphdb-free-knora-test-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-free-knora-test-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-test-data-minimal.expect $GRAPHDB - -printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}" diff --git a/webapi/scripts/graphdb-free-docker-init-knora-test-unit.sh b/webapi/scripts/graphdb-free-docker-init-knora-test-unit.sh deleted file mode 100755 index a54330d6d5..0000000000 --- a/webapi/scripts/graphdb-free-docker-init-knora-test-unit.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-unit-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-free-knora-test-unit-repository-config.ttl.tmpl > graphdb-free-knora-test-unit-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-free-knora-test-unit-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test-unit" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test-unit/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi diff --git a/webapi/scripts/graphdb-free-docker-init-knora-test.sh b/webapi/scripts/graphdb-free-docker-init-knora-test.sh deleted file mode 100755 index 49e70ed33f..0000000000 --- a/webapi/scripts/graphdb-free-docker-init-knora-test.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-free-knora-test-repository-config.ttl.tmpl > graphdb-free-knora-test-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-free-knora-test-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-test-data.expect $GRAPHDB - -printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}" diff --git a/webapi/scripts/graphdb-free-knora-test-repository-config.ttl.tmpl b/webapi/scripts/graphdb-free-knora-test-repository-config.ttl.tmpl deleted file mode 100644 index c06d08d81f..0000000000 --- a/webapi/scripts/graphdb-free-knora-test-repository-config.ttl.tmpl +++ /dev/null @@ -1,22 +0,0 @@ -@prefix rdfs: . -@prefix rep: . -@prefix sr: . -@prefix sail: . -@prefix owlim: . - -[] a rep:Repository ; - rep:repositoryID "knora-test" ; - rdfs:label "Knora test repository" ; - rep:repositoryImpl [ - rep:repositoryType "graphdb:FreeSailRepository" ; - sr:sailImpl [ - sail:sailType "graphdb:FreeSail" ; - owlim:ruleset "PIE_FILE" ; - owlim:check-for-inconsistencies "true"; - owlim:base-URL "http://rdfh.ch/" ; - owlim:repository-type "file-repository" ; - owlim:query-timeout "5" ; - owlim:throw-QueryEvaluationException-on-timeout "true"; - owlim:query-limit-results "50000"; - ] - ]. diff --git a/webapi/scripts/graphdb-free-knora-test-unit-repository-config.ttl.tmpl b/webapi/scripts/graphdb-free-knora-test-unit-repository-config.ttl.tmpl deleted file mode 100644 index c5e3e2a989..0000000000 --- a/webapi/scripts/graphdb-free-knora-test-unit-repository-config.ttl.tmpl +++ /dev/null @@ -1,22 +0,0 @@ -@prefix rdfs: . -@prefix rep: . -@prefix sr: . -@prefix sail: . -@prefix owlim: . - -[] a rep:Repository ; - rep:repositoryID "knora-test-unit" ; - rdfs:label "Knora unit test repository" ; - rep:repositoryImpl [ - rep:repositoryType "graphdb:FreeSailRepository" ; - sr:sailImpl [ - sail:sailType "graphdb:FreeSail" ; - owlim:ruleset "PIE_FILE" ; - owlim:check-for-inconsistencies "true"; - owlim:base-URL "http://rdfh.ch/" ; - owlim:repository-type "file-repository" ; - owlim:query-timeout "5" ; - owlim:throw-QueryEvaluationException-on-timeout "true"; - owlim:query-limit-results "50000"; - ] - ]. diff --git a/webapi/scripts/graphdb-free-local-init-knora-test-unit.sh b/webapi/scripts/graphdb-free-local-init-knora-test-unit.sh deleted file mode 100755 index bc703aebe9..0000000000 --- a/webapi/scripts/graphdb-free-local-init-knora-test-unit.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-unit-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"$PWD/KnoraRules.pie"'@' graphdb-free-knora-test-unit-repository-config.ttl.tmpl > graphdb-free-knora-test-unit-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-free-knora-test-unit-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test-unit" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test-unit/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi diff --git a/webapi/scripts/graphdb-free-local-init-knora-test.sh b/webapi/scripts/graphdb-free-local-init-knora-test.sh deleted file mode 100755 index 074f9ced3d..0000000000 --- a/webapi/scripts/graphdb-free-local-init-knora-test.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"$PWD/KnoraRules.pie"'@' graphdb-free-knora-test-repository-config.ttl.tmpl > graphdb-free-knora-test-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-free-knora-test-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-test-data.expect $GRAPHDB - -printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}" \ No newline at end of file diff --git a/webapi/scripts/graphdb-knora-index-create.rq b/webapi/scripts/graphdb-knora-index-create.rq deleted file mode 100644 index 578135b74a..0000000000 --- a/webapi/scripts/graphdb-knora-index-create.rq +++ /dev/null @@ -1,10 +0,0 @@ -prefix luc: - -INSERT DATA { - luc:include luc:setParam "literal" . - luc:index luc:setParam "literal" . - luc:languages luc:setParam "" . - luc:moleculeSize luc:setParam "0" . - luc:useRDFRank luc:setParam "no" . - luc:fullTextSearchIndex luc:createIndex "true" . -} \ No newline at end of file diff --git a/webapi/scripts/graphdb-knora-index-update.rq b/webapi/scripts/graphdb-knora-index-update.rq deleted file mode 100644 index 4ac5da0da9..0000000000 --- a/webapi/scripts/graphdb-knora-index-update.rq +++ /dev/null @@ -1,2 +0,0 @@ -PREFIX luc: -INSERT DATA { luc:fullTextSearchIndex luc:updateIndex _:b1 . } \ No newline at end of file diff --git a/webapi/scripts/graphdb-knora-prod-data.expect b/webapi/scripts/graphdb-knora-prod-data.expect deleted file mode 100755 index f85ae493d6..0000000000 --- a/webapi/scripts/graphdb-knora-prod-data.expect +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/expect - -set timeout 120 -spawn openrdf-console/bin/console.sh --force --echo --serverURL [lindex $argv 0] -set prompt "> " -expect $prompt -send "open knora-prod .\r" -expect $prompt -send "load ../../knora-ontologies/knora-admin.ttl into http://www.knora.org/ontology/knora-admin .\r" -expect $prompt -send "load ../../knora-ontologies/knora-base.ttl into http://www.knora.org/ontology/knora-base .\r" -expect $prompt -send "load ../../knora-ontologies/standoff-onto.ttl into http://www.knora.org/ontology/standoff .\r" -expect $prompt -send "load ../../knora-ontologies/standoff-data.ttl into http://www.knora.org/data/standoff .\r" -expect $prompt -send "load ../../knora-ontologies/salsah-gui.ttl into http://www.knora.org/ontology/salsah-gui .\r" -expect $prompt -send "load ../../test_data/all_data/admin-data.ttl into http://www.knora.org/data/admin .\r" -expect $prompt -send "load ../../test_data/all_data/permissions-data.ttl into http://www.knora.org/data/permissions .\r" -expect $prompt -send "load ../../test_data/all_data/system-data.ttl into http://www.knora.org/data/0000/SystemProject .\r" -expect $prompt -send "load ../../test_data/ontologies/incunabula-onto.ttl into http://www.knora.org/ontology/0803/incunabula .\r" -expect $prompt -send "load ../../test_data/all_data/incunabula-data.ttl into http://www.knora.org/data/0803/incunabula .\r" -expect $prompt -send "load ../../test_data/ontologies/dokubib-onto.ttl into http://www.knora.org/ontology/0804/dokubib .\r" -expect $prompt -send "load ../../test_data/ontologies/images-onto.ttl into http://www.knora.org/ontology/00FF/images .\r" -expect $prompt -send "load ../../test_data/demo_data/images-demo-data.ttl into http://www.knora.org/data/00FF/images .\r" -expect $prompt -send "load ../../test_data/ontologies/anything-onto.ttl into http://www.knora.org/ontology/0001/anything .\r" -expect $prompt -send "load ../../test_data/all_data/anything-data.ttl into http://www.knora.org/data/0001/anything .\r" -expect $prompt -send "load ../../test_data/ontologies/beol-onto.ttl into http://www.knora.org/ontology/0801/beol .\r" -expect $prompt -send "load ../../test_data/ontologies/biblio-onto.ttl into http://www.knora.org/ontology/0801/biblio .\r" -expect $prompt -send "load ../../test_data/ontologies/newton-onto.ttl into http://www.knora.org/ontology/0801/newton .\r" -expect $prompt -send "load ../../test_data/ontologies/leibniz-onto.ttl into http://www.knora.org/ontology/0801/leibniz .\r" -expect $prompt -send "load ../../test_data/all_data/biblio-data.ttl into http://www.knora.org/data/0801/biblio .\r" -expect $prompt -send "load ../../test_data/all_data/beol-data.ttl into http://www.knora.org/data/0801/beol .\r" -expect $prompt -send "load ../../test_data/ontologies/webern-onto.ttl into http://www.knora.org/ontology/0806/webern .\r" -expect $prompt -send "load ../../test_data/all_data/webern-data.ttl into http://www.knora.org/data/0806/webern .\r" -expect $prompt - -send "close .\r" -expect $prompt -send "exit .\r" diff --git a/webapi/scripts/graphdb-knora-test-data-minimal.expect b/webapi/scripts/graphdb-knora-test-data-minimal.expect deleted file mode 100755 index edb32ae5bf..0000000000 --- a/webapi/scripts/graphdb-knora-test-data-minimal.expect +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/expect - -set timeout 120 -spawn openrdf-console/bin/console.sh --force --echo --serverURL [lindex $argv 0] -set prompt "> " -expect $prompt -send "open knora-test .\r" -expect $prompt -send "load ../../knora-ontologies/knora-admin.ttl into http://www.knora.org/ontology/knora-admin .\r" -expect $prompt -send "load ../../knora-ontologies/knora-base.ttl into http://www.knora.org/ontology/knora-base .\r" -expect $prompt -send "load ../../knora-ontologies/standoff-onto.ttl into http://www.knora.org/ontology/standoff .\r" -expect $prompt -send "load ../../knora-ontologies/standoff-data.ttl into http://www.knora.org/data/standoff .\r" -expect $prompt -send "load ../../knora-ontologies/salsah-gui.ttl into http://www.knora.org/ontology/salsah-gui .\r" -expect $prompt -send "load ../../test_data/all_data/admin-data.ttl into http://www.knora.org/data/admin .\r" -expect $prompt -send "load ../../test_data/all_data/permissions-data.ttl into http://www.knora.org/data/permissions .\r" -expect $prompt -send "load ../../test_data/all_data/system-data.ttl into http://www.knora.org/data/0000/SystemProject .\r" -expect $prompt - -send "close .\r" -expect $prompt -send "exit .\r" diff --git a/webapi/scripts/graphdb-knora-test-data.expect b/webapi/scripts/graphdb-knora-test-data.expect deleted file mode 100755 index 87d7d6f13e..0000000000 --- a/webapi/scripts/graphdb-knora-test-data.expect +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/expect - -set timeout 120 -spawn openrdf-console/bin/console.sh --force --echo --serverURL [lindex $argv 0] -set prompt "> " -expect $prompt -send "open knora-test .\r" -expect $prompt -send "load ../../knora-ontologies/knora-admin.ttl into http://www.knora.org/ontology/knora-admin .\r" -expect $prompt -send "load ../../knora-ontologies/knora-base.ttl into http://www.knora.org/ontology/knora-base .\r" -expect $prompt -send "load ../../knora-ontologies/standoff-onto.ttl into http://www.knora.org/ontology/standoff .\r" -expect $prompt -send "load ../../knora-ontologies/standoff-data.ttl into http://www.knora.org/data/standoff .\r" -expect $prompt -send "load ../../knora-ontologies/salsah-gui.ttl into http://www.knora.org/ontology/salsah-gui .\r" -expect $prompt -send "load ../../test_data/all_data/admin-data.ttl into http://www.knora.org/data/admin .\r" -expect $prompt -send "load ../../test_data/all_data/permissions-data.ttl into http://www.knora.org/data/permissions .\r" -expect $prompt -send "load ../../test_data/all_data/system-data.ttl into http://www.knora.org/data/0000/SystemProject .\r" -expect $prompt -send "load ../../test_data/ontologies/incunabula-onto.ttl into http://www.knora.org/ontology/0803/incunabula .\r" -expect $prompt -send "load ../../test_data/all_data/incunabula-data.ttl into http://www.knora.org/data/0803/incunabula .\r" -expect $prompt -send "load ../../test_data/ontologies/dokubib-onto.ttl into http://www.knora.org/ontology/0804/dokubib .\r" -expect $prompt -send "load ../../test_data/ontologies/images-onto.ttl into http://www.knora.org/ontology/00FF/images .\r" -expect $prompt -send "load ../../test_data/demo_data/images-demo-data.ttl into http://www.knora.org/data/00FF/images .\r" -expect $prompt -send "load ../../test_data/ontologies/anything-onto.ttl into http://www.knora.org/ontology/0001/anything .\r" -expect $prompt -send "load ../../test_data/all_data/anything-data.ttl into http://www.knora.org/data/0001/anything .\r" -expect $prompt -send "load ../../test_data/ontologies/minimal-onto.ttl into http://www.knora.org/ontology/0001/minimal .\r" -expect $prompt -send "load ../../test_data/ontologies/something-onto.ttl into http://www.knora.org/ontology/0001/something .\r" -expect $prompt -send "load ../../test_data/ontologies/beol-onto.ttl into http://www.knora.org/ontology/0801/beol .\r" -expect $prompt -send "load ../../test_data/ontologies/biblio-onto.ttl into http://www.knora.org/ontology/0801/biblio .\r" -expect $prompt -send "load ../../test_data/ontologies/newton-onto.ttl into http://www.knora.org/ontology/0801/newton .\r" -expect $prompt -send "load ../../test_data/ontologies/leibniz-onto.ttl into http://www.knora.org/ontology/0801/leibniz .\r" -expect $prompt -send "load ../../test_data/all_data/biblio-data.ttl into http://www.knora.org/data/0801/biblio .\r" -expect $prompt -send "load ../../test_data/all_data/beol-data.ttl into http://www.knora.org/data/0801/beol .\r" -expect $prompt -send "load ../../test_data/ontologies/webern-onto.ttl into http://www.knora.org/ontology/0806/webern .\r" -expect $prompt -send "load ../../test_data/all_data/webern-data.ttl into http://www.knora.org/data/0806/webern .\r" -expect $prompt - -send "close .\r" -expect $prompt -send "exit .\r" diff --git a/webapi/scripts/graphdb-knora-test-unit-data-minimal.expect b/webapi/scripts/graphdb-knora-test-unit-data-minimal.expect deleted file mode 100755 index 00ef6f474a..0000000000 --- a/webapi/scripts/graphdb-knora-test-unit-data-minimal.expect +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/expect - -set timeout 120 -spawn openrdf-console/bin/console.sh --force --echo --serverURL [lindex $argv 0] -set prompt "> " -expect $prompt -send "open knora-test-unit .\r" -expect $prompt -send "load ../../knora-ontologies/knora-admin.ttl into http://www.knora.org/ontology/knora-admin .\r" -expect $prompt -send "load ../../knora-ontologies/knora-base.ttl into http://www.knora.org/ontology/knora-base .\r" -expect $prompt -send "load ../../knora-ontologies/standoff-onto.ttl into http://www.knora.org/ontology/standoff .\r" -expect $prompt -send "load ../../knora-ontologies/standoff-data.ttl into http://www.knora.org/data/standoff .\r" -expect $prompt -send "load ../../knora-ontologies/salsah-gui.ttl into http://www.knora.org/ontology/salsah-gui .\r" -expect $prompt -send "load ../_test_data/all_data/admin-data.ttl into http://www.knora.org/data/admin .\r" -expect $prompt -send "load ../_test_data/all_data/permissions-data.ttl into http://www.knora.org/data/permissions .\r" -expect $prompt -send "load ../_test_data/all_data/system-data.ttl into http://www.knora.org/data/0000/SystemProject .\r" -expect $prompt - -send "close .\r" -expect $prompt -send "exit .\r" diff --git a/webapi/scripts/graphdb-se-docker-init-knora-prod-empty.sh b/webapi/scripts/graphdb-se-docker-init-knora-prod-empty.sh deleted file mode 100755 index ab39c4bb52..0000000000 --- a/webapi/scripts/graphdb-se-docker-init-knora-prod-empty.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-prod-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-se-knora-prod-repository-config.ttl.tmpl > graphdb-se-knora-prod-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-prod-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-prod" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-prod/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}Loading Data${NO_COLOUR}\n\n" - -printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-prod/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}" \ No newline at end of file diff --git a/webapi/scripts/graphdb-se-docker-init-knora-prod.sh b/webapi/scripts/graphdb-se-docker-init-knora-prod.sh deleted file mode 100755 index fd18dd8394..0000000000 --- a/webapi/scripts/graphdb-se-docker-init-knora-prod.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-prod-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-se-knora-prod-repository-config.ttl.tmpl > graphdb-se-knora-prod-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-prod-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-prod" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-prod/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-prod-data.expect $GRAPHDB - -printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-prod/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}" \ No newline at end of file diff --git a/webapi/scripts/graphdb-se-docker-init-knora-test-minimal.sh b/webapi/scripts/graphdb-se-docker-init-knora-test-minimal.sh deleted file mode 100755 index acf5149d25..0000000000 --- a/webapi/scripts/graphdb-se-docker-init-knora-test-minimal.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-se-knora-test-repository-config.ttl.tmpl > graphdb-se-knora-test-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-test-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-test-data-minimal.expect $GRAPHDB - -printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}\n\n" diff --git a/webapi/scripts/graphdb-se-docker-init-knora-test-unit-minimal.sh b/webapi/scripts/graphdb-se-docker-init-knora-test-unit-minimal.sh deleted file mode 100755 index 22a536d593..0000000000 --- a/webapi/scripts/graphdb-se-docker-init-knora-test-unit-minimal.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-unit-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-se-knora-test-unit-repository-config.ttl.tmpl > graphdb-se-knora-test-unit-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-test-unit-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test-unit" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test-unit/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-test-unit-data-minimal.expect $GRAPHDB - -printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test-unit/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}\n\n" diff --git a/webapi/scripts/graphdb-se-docker-init-knora-test-unit.sh b/webapi/scripts/graphdb-se-docker-init-knora-test-unit.sh deleted file mode 100755 index d0033efd58..0000000000 --- a/webapi/scripts/graphdb-se-docker-init-knora-test-unit.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-unit-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-se-knora-test-unit-repository-config.ttl.tmpl > graphdb-se-knora-test-unit-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-test-unit-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test-unit" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test-unit/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi diff --git a/webapi/scripts/graphdb-se-docker-init-knora-test.sh b/webapi/scripts/graphdb-se-docker-init-knora-test.sh deleted file mode 100755 index d4ab671753..0000000000 --- a/webapi/scripts/graphdb-se-docker-init-knora-test.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"/graphdb/KnoraRules.pie"'@' graphdb-se-knora-test-repository-config.ttl.tmpl > graphdb-se-knora-test-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-test-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-test-data.expect $GRAPHDB - -printf "${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}\n\n" diff --git a/webapi/scripts/graphdb-se-drop-knora-prod-repository.ttl b/webapi/scripts/graphdb-se-drop-knora-prod-repository.ttl deleted file mode 100644 index 9098a184d6..0000000000 --- a/webapi/scripts/graphdb-se-drop-knora-prod-repository.ttl +++ /dev/null @@ -1,2 +0,0 @@ -drop knora-prod . -exit . diff --git a/webapi/scripts/graphdb-se-knora-prod-repository-config.ttl.tmpl b/webapi/scripts/graphdb-se-knora-prod-repository-config.ttl.tmpl deleted file mode 100644 index 39e20f026a..0000000000 --- a/webapi/scripts/graphdb-se-knora-prod-repository-config.ttl.tmpl +++ /dev/null @@ -1,22 +0,0 @@ -@prefix rdfs: . -@prefix rep: . -@prefix sr: . -@prefix sail: . -@prefix owlim: . - -[] a rep:Repository ; - rep:repositoryID "knora-prod" ; - rdfs:label "Knora production repository" ; - rep:repositoryImpl [ - rep:repositoryType "owlim:MonitorRepository" ; - sr:sailImpl [ - sail:sailType "owlim:Sail" ; - owlim:ruleset "PIE_FILE" ; - owlim:check-for-inconsistencies "true"; - owlim:base-URL "http://rdfh.ch/" ; - owlim:repository-type "file-repository" ; - owlim:query-timeout "30" ; - owlim:throw-QueryEvaluationException-on-timeout "true"; - owlim:query-limit-results "50000"; - ] - ]. diff --git a/webapi/scripts/graphdb-se-knora-test-repository-config.ttl.tmpl b/webapi/scripts/graphdb-se-knora-test-repository-config.ttl.tmpl deleted file mode 100644 index ee5ee85f18..0000000000 --- a/webapi/scripts/graphdb-se-knora-test-repository-config.ttl.tmpl +++ /dev/null @@ -1,22 +0,0 @@ -@prefix rdfs: . -@prefix rep: . -@prefix sr: . -@prefix sail: . -@prefix owlim: . - -[] a rep:Repository ; - rep:repositoryID "knora-test" ; - rdfs:label "Knora test repository" ; - rep:repositoryImpl [ - rep:repositoryType "owlim:MonitorRepository" ; - sr:sailImpl [ - sail:sailType "owlim:Sail" ; - owlim:ruleset "PIE_FILE" ; - owlim:check-for-inconsistencies "true"; - owlim:base-URL "http://rdfh.ch/" ; - owlim:repository-type "file-repository" ; - owlim:query-timeout "30" ; - owlim:throw-QueryEvaluationException-on-timeout "true"; - owlim:query-limit-results "50000"; - ] - ]. diff --git a/webapi/scripts/graphdb-se-knora-test-unit-repository-config.ttl.tmpl b/webapi/scripts/graphdb-se-knora-test-unit-repository-config.ttl.tmpl deleted file mode 100644 index eef97561f4..0000000000 --- a/webapi/scripts/graphdb-se-knora-test-unit-repository-config.ttl.tmpl +++ /dev/null @@ -1,22 +0,0 @@ -@prefix rdfs: . -@prefix rep: . -@prefix sr: . -@prefix sail: . -@prefix owlim: . - -[] a rep:Repository ; - rep:repositoryID "knora-test-unit" ; - rdfs:label "Knora unit test repository" ; - rep:repositoryImpl [ - rep:repositoryType "owlim:MonitorRepository" ; - sr:sailImpl [ - sail:sailType "owlim:Sail" ; - owlim:ruleset "PIE_FILE" ; - owlim:check-for-inconsistencies "true"; - owlim:base-URL "http://rdfh.ch/" ; - owlim:repository-type "file-repository" ; - owlim:query-timeout "30" ; - owlim:throw-QueryEvaluationException-on-timeout "true"; - owlim:query-limit-results "50000"; - ] - ]. diff --git a/webapi/scripts/graphdb-se-local-init-knora-prod-empty.sh b/webapi/scripts/graphdb-se-local-init-knora-prod-empty.sh deleted file mode 100755 index a2f5da5756..0000000000 --- a/webapi/scripts/graphdb-se-local-init-knora-prod-empty.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-prod-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"$PWD/KnoraRules.pie"'@' graphdb-se-knora-prod-repository-config.ttl.tmpl > graphdb-se-knora-prod-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-prod-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-prod" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-prod/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}${DELIMITER}Loading Data${NO_COLOUR}\n\n" - -printf "\n${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-prod/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}\n" diff --git a/webapi/scripts/graphdb-se-local-init-knora-prod.sh b/webapi/scripts/graphdb-se-local-init-knora-prod.sh deleted file mode 100755 index 8ea63b9acd..0000000000 --- a/webapi/scripts/graphdb-se-local-init-knora-prod.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-prod-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"$PWD/KnoraRules.pie"'@' graphdb-se-knora-prod-repository-config.ttl.tmpl > graphdb-se-knora-prod-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-prod-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-prod" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-prod/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}${DELIMITER}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-prod-data.expect $GRAPHDB - -printf "\n${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-prod/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}\n" diff --git a/webapi/scripts/graphdb-se-local-init-knora-test-unit.sh b/webapi/scripts/graphdb-se-local-init-knora-test-unit.sh deleted file mode 100755 index ae596baeaf..0000000000 --- a/webapi/scripts/graphdb-se-local-init-knora-test-unit.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-unit-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"$PWD/KnoraRules.pie"'@' graphdb-se-knora-test-unit-repository-config.ttl.tmpl > graphdb-se-knora-test-unit-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-test-unit-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test-unit" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test-unit/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi diff --git a/webapi/scripts/graphdb-se-local-init-knora-test.sh b/webapi/scripts/graphdb-se-local-init-knora-test.sh deleted file mode 100755 index 3b2e5605b0..0000000000 --- a/webapi/scripts/graphdb-se-local-init-knora-test.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -e - -GRAPHDB="http://localhost:7200" -CONSOLE="openrdf-console/bin/console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -sed -e 's@PIE_FILE@'"$PWD/KnoraRules.pie"'@' graphdb-se-knora-test-repository-config.ttl.tmpl > graphdb-se-knora-test-repository-config.ttl - -curl -X POST -H "Content-Type:text/turtle" -T graphdb-se-knora-test-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config-test" - -curl -X POST -H "Content-Type:text/turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Creating Lucene Index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST --data-urlencode 'update@./graphdb-knora-index-create.rq' $GRAPHDB/repositories/knora-test/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi - -printf "${GREEN}${DELIMITER}Loading Data${NO_COLOUR}\n\n" - -./graphdb-knora-test-data.expect $GRAPHDB - -printf "\n${GREEN}Data Loaded.\n\n${DELIMITER}Updating Lucene Index${NO_COLOUR}\n\n" - -curl -X POST --data-urlencode 'update@./graphdb-knora-index-update.rq' $GRAPHDB/repositories/knora-test/statements - -printf "${GREEN}Lucene Index Updated.${NO_COLOUR}\n" diff --git a/webapi/scripts/graphdb-upload-repository.sh b/webapi/scripts/graphdb-upload-repository.sh deleted file mode 100755 index f837a66cfb..0000000000 --- a/webapi/scripts/graphdb-upload-repository.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash - -#set -x - -POSITIONAL=() -while [[ $# -gt 0 ]] -do -key="$1" - -case $key in - -r|--repository) - REPOSITORY="$2" - shift # past argument - shift # past value - ;; - -u|--username) - USER_NAME="$2" - shift # past argument - shift # past value - ;; - -p|--password) - PASSWORD="$2" - shift # past argument - shift # past value - ;; - -h|--host) - HOST="$2" - shift # past argument - shift # past value - ;; - *) # unknown option - POSITIONAL+=("$1") # save it in an array for later - shift # past argument - ;; -esac -done -set -- "${POSITIONAL[@]}" # restore positional parameters - -FILE="$1" - -if [[ -z "${REPOSITORY}" || -z "${USER_NAME}" || -z "${FILE}" ]]; then - echo "Usage: $(basename "$0") -r|--repository REPOSITORY -u|--username USERNAME [-p|--password PASSWORD] [-h|--host HOST] FILE" - exit 1 -fi - -if [[ -z "${PASSWORD}" ]]; then - echo -n "Password: " - IFS="" read -rs PASSWORD - echo -fi - -if [[ -z "${HOST}" ]]; then - HOST="localhost:7200" -fi - -curl -sS -X POST -H "Content-Type: application/trig" --data-binary "@${FILE}" -u "${USER_NAME}:${PASSWORD}" "http://${HOST}/repositories/${REPOSITORY}/statements" | tee /dev/null diff --git a/webapi/scripts/win-graphdb-free-init-knora-test.sh b/webapi/scripts/win-graphdb-free-init-knora-test.sh deleted file mode 100644 index 38193c9f5f..0000000000 --- a/webapi/scripts/win-graphdb-free-init-knora-test.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash - -set -e - -HOST="http://localhost" -PORT="7200" -GRAPHDB="${HOST}:${PORT}" -CONSOLE="openrdf-console/bin/win-console.sh --force --echo --serverURL $GRAPHDB" - -GREEN='\033[0;32m' -RED='\033[0;31m' -NO_COLOUR='\033[0m' -DELIMITER="****************************************************************************************************\n* " - -printf "${GREEN}${DELIMITER}Deleting repository${NO_COLOUR}\n\n" - -cat graphdb-drop-knora-test-repository.ttl | $CONSOLE - -printf "\n${GREEN}${DELIMITER}Creating repository${NO_COLOUR}\n\n" - -curl -X POST -H "Content-Type:application/x-turtle" -T graphdb-free-knora-test-repository-config.ttl "$GRAPHDB/repositories/SYSTEM/rdf-graphs/service?graph=http://www.knora.org/config" - -curl -X POST -H "Content-Type:application/x-turtle" -d " a ." $GRAPHDB/repositories/SYSTEM/statements - -printf "${GREEN}Repository created.\n\n${DELIMITER}Loading test data${NO_COLOUR}\n\n" - -cat win-graphdb-knora-test-data.ttl | $CONSOLE - -printf "\n\n${GREEN}${DELIMITER}Creating Lucene index${NO_COLOUR}\n\n" - -STATUS=$(curl -s -w '%{http_code}' -S -X POST -H "Content-Type:text/turtle" --data-binary @./graphdb-free-knora-test-index-config.ttl $GRAPHDB/repositories/knora-test/statements) - -if [ "$STATUS" == "204" ] -then - printf "${GREEN}Lucene index built.${NO_COLOUR}\n\n" -else - printf "${RED}Building of Lucene index failed: ${STATUS}${NO_COLOUR}\n\n" -fi diff --git a/webapi/scripts/win-graphdb-knora-test-data.ttl b/webapi/scripts/win-graphdb-knora-test-data.ttl deleted file mode 100644 index e3ad193d4b..0000000000 --- a/webapi/scripts/win-graphdb-knora-test-data.ttl +++ /dev/null @@ -1,25 +0,0 @@ -open knora-test . -load ../../knora-ontologies/knora-base.ttl into http://www.knora.org/ontology/knora-base . -load ../../knora-ontologies/knora-admin.ttl into http://www.knora.org/ontology/knora-base . -load ../../knora-ontologies/standoff-onto.ttl into http://www.knora.org/ontology/standoff . -load ../../knora-ontologies/standoff-data.ttl into http://www.knora.org/data/standoff . -load ../../knora-ontologies/salsah-gui.ttl into http://www.knora.org/ontology/salsah-gui . -load ../../test-data/all_data/admin-data.ttl into http://www.knora.org/data/admin . -load ../../test-data/all_data/permissions-data.ttl into http://www.knora.org/data/permissions . -load ../../test-data/all_data/system-data.ttl into http://www.knora.org/data/FFFF/SystemProject . -load ../../test-data/ontologies/incunabula-onto.ttl into http://www.knora.org/ontology/0803/incunabula . -load ../../test-data/all_data/incunabula-data.ttl into http://www.knora.org/data/incunabula . -load ../../test-data/ontologies/dokubib-onto.ttl into http://www.knora.org/ontology/00FE/dokubib . -load ../../test-data/ontologies/images-onto.ttl into http://www.knora.org/ontology/00FF/images . -load ../../test-data/demo_data/images-demo-data.ttl into http://www.knora.org/data/00FF/images . -load ../../test-data/ontologies/anything-onto.ttl into http://www.knora.org/ontology/0001/anything . -load ../../test-data/all_data/anything-data.ttl into http://www.knora.org/data/anything . -load ../../test-data/ontologies/something-onto.ttl into http://www.knora.org/ontology/something . -load ../../test-data/ontologies/beol-onto.ttl into http://www.knora.org/ontology/0801/beol . -load ../../test-data/all_data/beol-data.ttl into http://www.knora.org/data/0801/beol . -load ../../test-data/ontologies/biblio-onto.ttl into http://www.knora.org/ontology/0801/biblio . -load ../../test-data/all_data/biblio-data.ttl into http://www.knora.org/data/biblio . -load ../../test-data/ontologies/webern-onto.ttl into http://www.knora.org/ontology/0806/webern . -load ../../test-data/all_data/webern-data.ttl into http://www.knora.org/data/0806/webern . -close . -exit . diff --git a/webapi/src/main/resources/application.conf b/webapi/src/main/resources/application.conf index 3ed032868c..d435e5a515 100644 --- a/webapi/src/main/resources/application.conf +++ b/webapi/src/main/resources/application.conf @@ -510,10 +510,7 @@ app { triplestore { dbtype = "fuseki" dbtype = ${?KNORA_WEBAPI_TRIPLESTORE_DBTYPE} - // dbtype = "graphdb-se" - // dbtype = "graphdb-free" // dbtype = "embedded-jena-tdb" - // dbtype = "embedded-jena-graphdb" // dbtype = "fake-triplestore" use-https = false @@ -532,17 +529,6 @@ app { auto-init = false auto-init = ${?KNORA_WEBAPI_TRIPLESTORE_AUTOINIT} - graphdb { - port = 7200 - port = ${?KNORA_WEBAPI_TRIPLESTORE_GRAPHDB_PORT} - repository-name = "knora-test" - repository-name = ${?KNORA_WEBAPI_TRIPLESTORE_GRAPHDB_REPOSITORY_NAME} - username = "admin" - username = ${?KNORA_WEBAPI_TRIPLESTORE_GRAPHDB_USERNAME} - password = "root" - password = ${?KNORA_WEBAPI_TRIPLESTORE_GRAPHDB_PASSWORD} - } - fuseki { port = 3030 port = ${?KNORA_WEBAPI_TRIPLESTORE_FUSEKI_PORT} @@ -560,11 +546,6 @@ app { storage-path = "_TMP" // ignored if "memory" } - embedded-jena-graphdb { - graphdb-persisted-storage = true - graphdb-storage-path = "_TMP_GRAPHDB" - } - fake-jena-tdb { fake-persisted-storage = true fake-triplestore-data-dir = "src/main/resources/query-log" diff --git a/webapi/src/main/scala/org/knora/webapi/messages/OntologyConstants.scala b/webapi/src/main/scala/org/knora/webapi/messages/OntologyConstants.scala index 759f18641c..d79d24a89e 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/OntologyConstants.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/OntologyConstants.scala @@ -1187,7 +1187,5 @@ object OntologyConstants { val PermissionNamedGraph: IRI = "http://www.knora.org/data/permissions" val PersistentMapNamedGraph: IRI = "http://www.knora.org/data/maps" val KnoraExplicitNamedGraph: IRI = "http://www.knora.org/explicit" - val GraphDBExplicitNamedGraph: IRI = "http://www.ontotext.com/explicit" } - } diff --git a/webapi/src/main/scala/org/knora/webapi/messages/store/triplestoremessages/GraphDBAPI.scala b/webapi/src/main/scala/org/knora/webapi/messages/store/triplestoremessages/GraphDBAPI.scala deleted file mode 100644 index 41fe9ec128..0000000000 --- a/webapi/src/main/scala/org/knora/webapi/messages/store/triplestoremessages/GraphDBAPI.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.knora.webapi.messages.store.triplestoremessages - -import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport -import spray.json.{DefaultJsonProtocol, RootJsonFormat} - -// Used to communicate with the GraphDB API - -sealed trait GraphDBAPI - -case class GraphDBRepository( - externalUrl: String, - id: String, - local: Boolean, - location: String, - readable: Boolean, - sesameType: String, - title: String, - typeOf: String, - unsupported: Boolean, - uri: String, - writable: Boolean -) extends GraphDBAPI - -object GraphDBJsonProtocol extends SprayJsonSupport with DefaultJsonProtocol { - // 'typeOf' in the case class is 'type' in json - implicit val graphDBRepositoryFormat: RootJsonFormat[GraphDBRepository] = jsonFormat( - GraphDBRepository, - "externalUrl", - "id", - "local", - "location", - "readable", - "sesameType", - "title", - "type", - "unsupported", - "uri", - "writable" - ) -} diff --git a/webapi/src/main/scala/org/knora/webapi/messages/util/search/SparqlTransformer.scala b/webapi/src/main/scala/org/knora/webapi/messages/util/search/SparqlTransformer.scala index 9c5a848c68..cc15b5dd54 100644 --- a/webapi/src/main/scala/org/knora/webapi/messages/util/search/SparqlTransformer.scala +++ b/webapi/src/main/scala/org/knora/webapi/messages/util/search/SparqlTransformer.scala @@ -15,44 +15,6 @@ import org.knora.webapi.messages.{OntologyConstants, SmartIri, StringFormatter} */ object SparqlTransformer { - /** - * Transforms a non-triplestore-specific SELECT query for GraphDB. - * - * @param useInference `true` if the triplestore's inference should be used. - */ - class GraphDBSelectToSelectTransformer(useInference: Boolean) extends SelectToSelectTransformer { - private implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance - - override def transformStatementInSelect(statementPattern: StatementPattern): Seq[StatementPattern] = - Seq(statementPattern) - - override def transformStatementInWhere( - statementPattern: StatementPattern, - inputOrderBy: Seq[OrderCriterion] - ): Seq[StatementPattern] = - transformKnoraExplicitToGraphDBExplicit(statement = statementPattern, useInference = useInference) - - override def transformFilter(filterPattern: FilterPattern): Seq[QueryPattern] = Seq(filterPattern) - - override def optimiseQueryPatterns(patterns: Seq[QueryPattern]): Seq[QueryPattern] = - moveBindToBeginning(moveLuceneToBeginning(patterns)) - - override def transformLuceneQueryPattern(luceneQueryPattern: LuceneQueryPattern): Seq[QueryPattern] = - transformLuceneQueryPatternForGraphDB(luceneQueryPattern) - - override def getFromClause: Option[FromClause] = - if (useInference) { - None - } else { - // To turn off inference, add FROM . - Some(FromClause(IriRef(OntologyConstants.NamedGraphs.GraphDBExplicitNamedGraph.toSmartIri))) - } - - override def enteringUnionBlock(): Unit = {} - - override def leavingUnionBlock(): Unit = {} - } - /** * Transforms a non-triplestore-specific SELECT for a triplestore that does not have inference enabled (e.g., Fuseki). * @@ -88,34 +50,6 @@ object SparqlTransformer { override def leavingUnionBlock(): Unit = {} } - /** - * Transforms a non-triplestore-specific CONSTRUCT query for GraphDB. - */ - class GraphDBConstructToConstructTransformer extends ConstructToConstructTransformer { - private implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance - - override def transformStatementInConstruct(statementPattern: StatementPattern): Seq[StatementPattern] = - Seq(statementPattern) - - override def transformStatementInWhere( - statementPattern: StatementPattern, - inputOrderBy: Seq[OrderCriterion] - ): Seq[StatementPattern] = - transformKnoraExplicitToGraphDBExplicit(statement = statementPattern, useInference = true) - - override def transformFilter(filterPattern: FilterPattern): Seq[QueryPattern] = Seq(filterPattern) - - override def optimiseQueryPatterns(patterns: Seq[QueryPattern]): Seq[QueryPattern] = - moveBindToBeginning(moveLuceneToBeginning(patterns)) - - override def transformLuceneQueryPattern(luceneQueryPattern: LuceneQueryPattern): Seq[QueryPattern] = - transformLuceneQueryPatternForGraphDB(luceneQueryPattern) - - override def enteringUnionBlock(): Unit = {} - - override def leavingUnionBlock(): Unit = {} - } - /** * Transforms a non-triplestore-specific CONSTRUCT query for a triplestore that does not have inference enabled (e.g., Fuseki). */ @@ -389,63 +323,6 @@ object SparqlTransformer { } } - /** - * Transforms the the Knora explicit graph name to GraphDB explicit graph name. - * - * @param statement the given statement whose graph name has to be renamed. - * @param useInference `true` if the triplestore's inference should be used. - * @return the statement with the renamed graph, if given. - */ - private def transformKnoraExplicitToGraphDBExplicit( - statement: StatementPattern, - useInference: Boolean - ): Seq[StatementPattern] = { - implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance - - val transformedPattern = statement.copy( - pred = statement.pred, - namedGraph = statement.namedGraph match { - case Some(IriRef(SmartIri(OntologyConstants.NamedGraphs.KnoraExplicitNamedGraph), _)) => - if (useInference) { - Some(IriRef(OntologyConstants.NamedGraphs.GraphDBExplicitNamedGraph.toSmartIri)) - } else { - // Inference will be turned off in a FROM clause, so there's no need to specify a named graph here. - None - } - - case Some(IriRef(_, _)) => - throw AssertionException( - s"Named graphs other than ${OntologyConstants.NamedGraphs.KnoraExplicitNamedGraph} cannot occur in non-triplestore-specific generated search query SPARQL" - ) - - case None => None - } - ) - - Seq(transformedPattern) - } - - /** - * Transforms a [[LuceneQueryPattern]] for GraphDB. - * - * @param luceneQueryPattern the query pattern. - * @return GraphDB-specific statements implementing the query. - */ - private def transformLuceneQueryPatternForGraphDB(luceneQueryPattern: LuceneQueryPattern): Seq[QueryPattern] = { - implicit val stringFormatter: StringFormatter = StringFormatter.getGeneralInstance - - Seq( - StatementPattern( - subj = luceneQueryPattern.obj, // In GraphDB, an index entry is associated with a literal. - pred = IriRef("http://www.ontotext.com/owlim/lucene#fullTextSearchIndex".toSmartIri), - obj = XsdLiteral( - value = luceneQueryPattern.queryString.getQueryString, - datatype = OntologyConstants.Xsd.String.toSmartIri - ) - ) - ) ++ luceneQueryPattern.literalStatement - } - /** * Transforms a [[LuceneQueryPattern]] for Fuseki. * diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/SearchResponderV2.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/SearchResponderV2.scala index 3e2b293d4e..755172557a 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/SearchResponderV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/SearchResponderV2.scala @@ -311,19 +311,12 @@ class SearchResponderV2(responderData: ResponderData) extends ResponderWithStand settings = settings ) - val triplestoreSpecificQueryPatternTransformerConstruct: ConstructToConstructTransformer = { - if (settings.triplestoreType.startsWith("graphdb")) { - // GraphDB - new SparqlTransformer.GraphDBConstructToConstructTransformer - } else { - // Other - new SparqlTransformer.NoInferenceConstructToConstructTransformer - } - } + val queryPatternTransformerConstruct: ConstructToConstructTransformer = + new SparqlTransformer.NoInferenceConstructToConstructTransformer val triplestoreSpecificQuery = QueryTraverser.transformConstructToConstruct( inputQuery = mainQuery, - transformer = triplestoreSpecificQueryPatternTransformerConstruct + transformer = queryPatternTransformerConstruct ) // println(triplestoreSpecificQuery.toSparql) @@ -444,19 +437,10 @@ class SearchResponderV2(responderData: ResponderData) extends ResponderWithStand // Convert the non-triplestore-specific query to a triplestore-specific one. - triplestoreSpecificQueryPatternTransformerSelect: SelectToSelectTransformer = { - if (settings.triplestoreType.startsWith("graphdb")) { - // GraphDB - new SparqlTransformer.GraphDBSelectToSelectTransformer( - useInference = nonTriplestoreSpecificConstructToSelectTransformer.useInference - ) - } else { - // Other - new SparqlTransformer.NoInferenceSelectToSelectTransformer( - simulateInference = nonTriplestoreSpecificConstructToSelectTransformer.useInference - ) - } - } + triplestoreSpecificQueryPatternTransformerSelect: SelectToSelectTransformer = + new SparqlTransformer.NoInferenceSelectToSelectTransformer( + simulateInference = nonTriplestoreSpecificConstructToSelectTransformer.useInference + ) triplestoreSpecificCountQuery = QueryTraverser.transformSelectToSelect( inputQuery = nonTriplestoreSpecificPrequery, @@ -539,19 +523,10 @@ class SearchResponderV2(responderData: ResponderData) extends ResponderWithStand mainResourceVar: QueryVariable = nonTriplestoreSpecificConstructToSelectTransformer.mainResourceVariable // Convert the non-triplestore-specific query to a triplestore-specific one. - triplestoreSpecificQueryPatternTransformerSelect: SelectToSelectTransformer = { - if (settings.triplestoreType.startsWith("graphdb")) { - // GraphDB - new SparqlTransformer.GraphDBSelectToSelectTransformer( - useInference = nonTriplestoreSpecificConstructToSelectTransformer.useInference - ) - } else { - // Other - new SparqlTransformer.NoInferenceSelectToSelectTransformer( - simulateInference = nonTriplestoreSpecificConstructToSelectTransformer.useInference - ) - } - } + triplestoreSpecificQueryPatternTransformerSelect: SelectToSelectTransformer = + new SparqlTransformer.NoInferenceSelectToSelectTransformer( + simulateInference = nonTriplestoreSpecificConstructToSelectTransformer.useInference + ) // Convert the preprocessed query to a non-triplestore-specific query. @@ -638,19 +613,12 @@ class SearchResponderV2(responderData: ResponderData) extends ResponderWithStand settings = settings ) - val triplestoreSpecificQueryPatternTransformerConstruct: ConstructToConstructTransformer = { - if (settings.triplestoreType.startsWith("graphdb")) { - // GraphDB - new SparqlTransformer.GraphDBConstructToConstructTransformer - } else { - // Other - new SparqlTransformer.NoInferenceConstructToConstructTransformer - } - } + val queryPatternTransformerConstruct: ConstructToConstructTransformer = + new SparqlTransformer.NoInferenceConstructToConstructTransformer val triplestoreSpecificMainQuery = QueryTraverser.transformConstructToConstruct( inputQuery = mainQuery, - transformer = triplestoreSpecificQueryPatternTransformerConstruct + transformer = queryPatternTransformerConstruct ) // Convert the result to a SPARQL string and send it to the triplestore. diff --git a/webapi/src/main/scala/org/knora/webapi/settings/KnoraSettings.scala b/webapi/src/main/scala/org/knora/webapi/settings/KnoraSettings.scala index 81884673a5..08386b50ef 100644 --- a/webapi/src/main/scala/org/knora/webapi/settings/KnoraSettings.scala +++ b/webapi/src/main/scala/org/knora/webapi/settings/KnoraSettings.scala @@ -206,29 +206,21 @@ class KnoraSettingsImpl(config: Config, log: LoggingAdapter) extends Extension { val triplestoreAutoInit: Boolean = config.getBoolean("app.triplestore.auto-init") val triplestorePort: Int = triplestoreType match { - case TriplestoreTypes.HttpGraphDBSE | TriplestoreTypes.HttpGraphDBFree => - config.getInt("app.triplestore.graphdb.port") case TriplestoreTypes.HttpFuseki => config.getInt("app.triplestore.fuseki.port") case _ => 9999 } val triplestoreDatabaseName: String = triplestoreType match { - case TriplestoreTypes.HttpGraphDBSE | TriplestoreTypes.HttpGraphDBFree => - config.getString("app.triplestore.graphdb.repository-name") case TriplestoreTypes.HttpFuseki => config.getString("app.triplestore.fuseki.repository-name") case _ => "" } val triplestoreUsername: String = triplestoreType match { - case TriplestoreTypes.HttpGraphDBSE | TriplestoreTypes.HttpGraphDBFree => - config.getString("app.triplestore.graphdb.username") case TriplestoreTypes.HttpFuseki => config.getString("app.triplestore.fuseki.username") case _ => "" } val triplestorePassword: String = triplestoreType match { - case TriplestoreTypes.HttpGraphDBSE | TriplestoreTypes.HttpGraphDBFree => - config.getString("app.triplestore.graphdb.password") case TriplestoreTypes.HttpFuseki => config.getString("app.triplestore.fuseki.password") case _ => "" } diff --git a/webapi/src/main/scala/org/knora/webapi/settings/KnoraSettingsConstants.scala b/webapi/src/main/scala/org/knora/webapi/settings/KnoraSettingsConstants.scala index d2c65cf36d..1563cf80e9 100644 --- a/webapi/src/main/scala/org/knora/webapi/settings/KnoraSettingsConstants.scala +++ b/webapi/src/main/scala/org/knora/webapi/settings/KnoraSettingsConstants.scala @@ -10,11 +10,7 @@ package org.knora.webapi.settings * the 'application.conf' file, which can be accessed by the application 'Settings' */ object TriplestoreTypes { - val EmbeddedJenaTdb = "embedded-jena-tdb" - val EmbeddedGraphDBSE = "embedded-jena-graphdb" - val HttpGraphDBSE = "graphdb-se" - val HttpGraphDBFree = "graphdb-free" val HttpFuseki = "fuseki" } diff --git a/webapi/src/main/scala/org/knora/webapi/settings/package.scala b/webapi/src/main/scala/org/knora/webapi/settings/package.scala index a649eaf2d0..a276770d2d 100644 --- a/webapi/src/main/scala/org/knora/webapi/settings/package.scala +++ b/webapi/src/main/scala/org/knora/webapi/settings/package.scala @@ -106,7 +106,6 @@ package object settings { val HttpTriplestoreActorName: String = "httpTriplestoreRouter" val EmbeddedJenaActorName: String = "embeddedJenaTDB" - val EmbeddedGraphDBActorNAme: String = "embeddedJenaGraphDB" val FakeTriplestoreActorName: String = "fakeTriplestore" /* Sipi */ diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/TriplestoreManager.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/TriplestoreManager.scala index 4ef1042aeb..e6e47cfe8e 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/triplestore/TriplestoreManager.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/TriplestoreManager.scala @@ -71,7 +71,7 @@ class TriplestoreManager( log.debug("TriplestoreManagerActor: start with preStart") storeActorRef = settings.triplestoreType match { - case TriplestoreTypes.HttpGraphDBSE | TriplestoreTypes.HttpGraphDBFree | TriplestoreTypes.HttpFuseki => + case TriplestoreTypes.HttpFuseki => makeActor( FromConfig.props(Props[HttpTriplestoreConnector]()).withDispatcher(KnoraDispatchers.KnoraActorDispatcher), name = HttpTriplestoreActorName diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/HttpTriplestoreConnector.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/HttpTriplestoreConnector.scala index f1dcff1463..5cec34bc38 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/HttpTriplestoreConnector.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/http/HttpTriplestoreConnector.scala @@ -5,28 +5,38 @@ package org.knora.webapi.store.triplestore.http -import java.io.BufferedInputStream -import java.net.URI -import java.nio.file.{Files, Path, Paths, StandardCopyOption} -import java.nio.charset.StandardCharsets -import java.util - -import akka.actor.{Actor, ActorLogging, ActorSystem, Status} +import akka.actor.Actor +import akka.actor.ActorLogging +import akka.actor.ActorSystem +import akka.actor.Status import akka.event.LoggingAdapter import org.apache.commons.lang3.StringUtils -import org.apache.http.auth.{AuthScope, UsernamePasswordCredentials} +import org.apache.http.Consts +import org.apache.http.HttpEntity +import org.apache.http.HttpHost +import org.apache.http.HttpRequest +import org.apache.http.NameValuePair +import org.apache.http.auth.AuthScope +import org.apache.http.auth.UsernamePasswordCredentials import org.apache.http.client.AuthCache import org.apache.http.client.config.RequestConfig import org.apache.http.client.entity.UrlEncodedFormEntity -import org.apache.http.client.methods.{CloseableHttpResponse, HttpGet, HttpPost, HttpPut} +import org.apache.http.client.methods.CloseableHttpResponse +import org.apache.http.client.methods.HttpGet +import org.apache.http.client.methods.HttpPost +import org.apache.http.client.methods.HttpPut import org.apache.http.client.protocol.HttpClientContext import org.apache.http.client.utils.URIBuilder -import org.apache.http.entity.{ContentType, FileEntity, StringEntity} +import org.apache.http.entity.ContentType +import org.apache.http.entity.FileEntity +import org.apache.http.entity.StringEntity import org.apache.http.impl.auth.BasicScheme -import org.apache.http.impl.client.{BasicAuthCache, BasicCredentialsProvider, CloseableHttpClient, HttpClients} +import org.apache.http.impl.client.BasicAuthCache +import org.apache.http.impl.client.BasicCredentialsProvider +import org.apache.http.impl.client.CloseableHttpClient +import org.apache.http.impl.client.HttpClients import org.apache.http.message.BasicNameValuePair import org.apache.http.util.EntityUtils -import org.apache.http.{Consts, HttpEntity, HttpHost, HttpRequest, NameValuePair} import org.knora.webapi._ import org.knora.webapi.exceptions._ import org.knora.webapi.feature.FeatureFactoryConfig @@ -35,16 +45,28 @@ import org.knora.webapi.messages.store.triplestoremessages.SparqlResultProtocol. import org.knora.webapi.messages.store.triplestoremessages._ import org.knora.webapi.messages.util.FakeTriplestore import org.knora.webapi.messages.util.rdf._ -import org.knora.webapi.settings.{KnoraDispatchers, KnoraSettings, TriplestoreTypes} +import org.knora.webapi.settings.KnoraDispatchers +import org.knora.webapi.settings.KnoraSettings +import org.knora.webapi.settings.TriplestoreTypes import org.knora.webapi.store.triplestore.RdfDataObjectFactory import org.knora.webapi.util.ActorUtil._ import org.knora.webapi.util.FileUtil import spray.json._ -import scala.jdk.CollectionConverters._ +import java.io.BufferedInputStream +import java.net.URI +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.Paths +import java.nio.file.StandardCopyOption +import java.util import scala.collection.mutable import scala.concurrent.ExecutionContext -import scala.util.{Failure, Success, Try} +import scala.jdk.CollectionConverters._ +import scala.util.Failure +import scala.util.Success +import scala.util.Try /** * Submits SPARQL queries and updates to a triplestore over HTTP. Supports different triplestores, which can be configured in @@ -120,45 +142,35 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat .build private val queryPath: String = - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - s"/repositories/${settings.triplestoreDatabaseName}" - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { s"/${settings.triplestoreDatabaseName}/query" } else { throw UnsupportedTriplestoreException(s"Unsupported triplestore type: $triplestoreType") } private val sparqlUpdatePath: String = - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - s"/repositories/${settings.triplestoreDatabaseName}/statements" - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { s"/${settings.triplestoreDatabaseName}/update" } else { throw UnsupportedTriplestoreException(s"Unsupported triplestore type: $triplestoreType") } private val checkRepositoryPath: String = - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - "/rest/repositories" - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { "/$/server" } else { throw UnsupportedTriplestoreException(s"Unsupported triplestore type: $triplestoreType") } private val graphPath: String = - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - s"/repositories/${settings.triplestoreDatabaseName}/statements" - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { s"/${settings.triplestoreDatabaseName}/get" } else { throw UnsupportedTriplestoreException(s"Unsupported triplestore type: $triplestoreType") } private val repositoryDownloadPath = - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - s"/repositories/${settings.triplestoreDatabaseName}/statements" - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { s"/${settings.triplestoreDatabaseName}" } else { throw UnsupportedTriplestoreException(s"Unsupported triplestore type: $triplestoreType") @@ -169,9 +181,7 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat private val logDelimiter = "\n" + StringUtils.repeat('=', 80) + "\n" private val dataInsertPath = - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - s"/repositories/${settings.triplestoreDatabaseName}/rdf-graphs/service" - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { s"/${settings.triplestoreDatabaseName}/data" } else { throw TriplestoreUnsupportedFeatureException(s"$triplestoreType is not supported!") @@ -218,7 +228,7 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat case HelloTriplestore(msg: String) if msg == triplestoreType => sender() ! HelloTriplestore(triplestoreType) case CheckTriplestoreRequest() => try2Message(sender(), checkTriplestore(), log) case SearchIndexUpdateRequest(subjectIri: Option[String]) => - try2Message(sender(), updateLuceneIndex(subjectIri), log) + try2Message(sender(), Success(SparqlUpdateResponse()), log) case DownloadRepositoryRequest(outputFile: Path, featureFactoryConfig: FeatureFactoryConfig) => try2Message(sender(), downloadRepository(outputFile, featureFactoryConfig), log) case UploadRepositoryRequest(inputFile: Path) => try2Message(sender(), uploadRepository(inputFile), log) @@ -410,32 +420,6 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat } } - /** - * Updates the Lucene full-text search index. - */ - private def updateLuceneIndex(subjectIri: Option[IRI] = None): Try[SparqlUpdateResponse] = - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - val indexUpdateSparqlString = subjectIri match { - case Some(definedSubjectIri) => - // A subject's content has changed. Update the index for that subject. - s"""PREFIX luc: - |INSERT DATA { luc:fullTextSearchIndex luc:addToIndex <$definedSubjectIri> . } - """.stripMargin - - case None => - // Add new subjects to the index. - """PREFIX luc: - |INSERT DATA { luc:fullTextSearchIndex luc:updateIndex _:b1 . } - """.stripMargin - } - - for { - _ <- getSparqlHttpResponse(indexUpdateSparqlString, isUpdate = true) - } yield SparqlUpdateResponse() - } else { - Success(SparqlUpdateResponse()) - } - /** * Performs a SPARQL update operation. * @@ -447,9 +431,6 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat for { // Send the request to the triplestore. _ <- getSparqlHttpResponse(sparqlUpdate, isUpdate = true) - - // If we're using GraphDB, update the full-text search index. - _ = updateLuceneIndex() } yield SparqlUpdateResponse() /** @@ -574,10 +555,6 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat log.debug(s"added: $graphName") } - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE || triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - updateLuceneIndex() - } - log.debug("==>> Loading Data End") // Return success if all graphs are inserted successfully. @@ -593,9 +570,7 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat * Checks connection to the triplestore. */ private def checkTriplestore(): Try[CheckTriplestoreResponse] = - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - checkGraphDBTriplestore() - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { checkFusekiTriplestore() } else { throw UnsupportedTriplestoreException(s"Unsupported triplestore type: $triplestoreType") @@ -723,79 +698,6 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat checkFusekiTriplestore(true) } - /** - * Checks the connection to a GraphDB triplestore. - */ - private def checkGraphDBTriplestore(): Try[CheckTriplestoreResponse] = { - // needs to be a local import or other things don't work (spray json black magic) - import org.knora.webapi.messages.store.triplestoremessages.GraphDBJsonProtocol._ - - try { - log.debug("checkGraphDBRepository entered") - - // call endpoint returning all repositories - - val context: HttpClientContext = makeHttpContext - - val httpGet = new HttpGet(checkRepositoryPath) - httpGet.addHeader("Accept", mimeTypeApplicationJson) - - val responseStr: String = { - var maybeResponse: Option[CloseableHttpResponse] = None - - val responseTry: Try[String] = Try { - maybeResponse = Some(queryHttpClient.execute(targetHost, httpGet, context)) - EntityUtils.toString(maybeResponse.get.getEntity, StandardCharsets.UTF_8) - } - - maybeResponse.foreach(_.close()) - responseTry.get - } - - val jsonArr: JsArray = JsonParser(responseStr).asInstanceOf[JsArray] - - // parse json and check if the repository defined in 'application.conf' is present and correctly defined - - val repositories: Seq[GraphDBRepository] = jsonArr.elements.map(_.convertTo[GraphDBRepository]) - - val idShouldBe: String = settings.triplestoreDatabaseName - val sesameTypeForSEShouldBe = "owlim:MonitorRepository" - val sesameTypeForFreeShouldBe = "graphdb:FreeSailRepository" - - val neededRepo: Option[GraphDBRepository] = repositories.find(repo => - repo.id == idShouldBe && (repo.sesameType == sesameTypeForSEShouldBe || repo.sesameType == sesameTypeForFreeShouldBe) - ) - - if (neededRepo.nonEmpty) { - // everything looks good - Success( - CheckTriplestoreResponse( - triplestoreStatus = TriplestoreStatus.ServiceAvailable, - msg = "Triplestore is available." - ) - ) - } else { - // none of the available repositories meet our requirements - Success( - CheckTriplestoreResponse( - triplestoreStatus = TriplestoreStatus.NotInitialized, - msg = - s"None of the available repositories meet our requirements of id: $idShouldBe, sesameType: $sesameTypeForSEShouldBe or $sesameTypeForFreeShouldBe." - ) - ) - } - } catch { - case e: Exception => - // println("checkRepository - exception", e) - Success( - CheckTriplestoreResponse( - triplestoreStatus = TriplestoreStatus.ServiceUnavailable, - msg = s"Triplestore not available: ${e.getMessage}" - ) - ) - } - } - /** * Makes a triplestore URI for downloading a named graph. * @@ -805,9 +707,7 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat private def makeNamedGraphDownloadUri(graphIri: IRI): URI = { val uriBuilder: URIBuilder = new URIBuilder(graphPath) - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - uriBuilder.setParameter("infer", "false").setParameter("context", s"<$graphIri>") - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { uriBuilder.setParameter("graph", s"$graphIri") } else { throw UnsupportedTriplestoreException(s"Unsupported triplestore type: $triplestoreType") @@ -896,13 +796,7 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat } else { // Send queries as application/x-www-form-urlencoded (as per SPARQL 1.1 Protocol §2.1.2, // "query via POST with URL-encoded parameters"), so we can include the "infer" parameter when using GraphDB. - val formParams = new util.ArrayList[NameValuePair]() - - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE || triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - formParams.add(new BasicNameValuePair("infer", "true")) - } - formParams.add(new BasicNameValuePair("query", sparql)) val requestEntity: UrlEncodedFormEntity = new UrlEncodedFormEntity(formParams, Consts.UTF_8) val queryHttpPost: HttpPost = new HttpPost(queryPath) @@ -935,9 +829,7 @@ class HttpTriplestoreConnector extends Actor with ActorLogging with Instrumentat val uriBuilder: URIBuilder = new URIBuilder(repositoryDownloadPath) - if (triplestoreType == TriplestoreTypes.HttpGraphDBSE | triplestoreType == TriplestoreTypes.HttpGraphDBFree) { - uriBuilder.setParameter("infer", "false") - } else if (triplestoreType == TriplestoreTypes.HttpFuseki) { + if (triplestoreType == TriplestoreTypes.HttpFuseki) { // do nothing } else { throw UnsupportedTriplestoreException(s"Unsupported triplestore type: $triplestoreType") diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/changeParentNode.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/changeParentNode.scala.txt index f3347d6ced..822d3634f5 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/changeParentNode.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/changeParentNode.scala.txt @@ -30,17 +30,13 @@ PREFIX xsd: PREFIX knora-base: WITH <@dataNamedGraph> DELETE { - ?currentParentNode knora-base:hasSubListNode ?node . +} -} INSERT { +INSERT { ?newParentNode knora-base:hasSubListNode ?node . } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@nodeIri") AS ?node) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewAdministrativePermission.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewAdministrativePermission.scala.txt index a422e229f9..7322f9fa36 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewAdministrativePermission.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewAdministrativePermission.scala.txt @@ -43,20 +43,7 @@ INSERT { ?permissionIri knora-base:hasPermissions "@permissions"^^xsd:string . } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. -*@ -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} WHERE { BIND(IRI("@namedGraphIri") AS ?namedGraphIri) BIND(IRI("@permissionIri") AS ?permissionIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewDefaultObjectAccessPermission.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewDefaultObjectAccessPermission.scala.txt index 47b2a746a1..6fbca33d34 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewDefaultObjectAccessPermission.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewDefaultObjectAccessPermission.scala.txt @@ -53,20 +53,7 @@ INSERT { ?permissionIri knora-base:hasPermissions "@permissions"^^xsd:string . } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. -*@ -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} WHERE { BIND(IRI("@namedGraphIri") AS ?namedGraphIri) BIND(IRI("@permissionIri") AS ?permissionIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewGroup.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewGroup.scala.txt index 7f7674a58b..bb958f49a7 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewGroup.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewGroup.scala.txt @@ -60,20 +60,7 @@ INSERT { ?groupIri knora-admin:hasSelfJoinEnabled "@hasSelfJoinEnabled"^^xsd:boolean . } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. -*@ -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} WHERE { BIND(IRI("@adminNamedGraphIri") AS ?adminNamedGraphIri) BIND(IRI("@groupIri") AS ?groupIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewListNode.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewListNode.scala.txt index b5cb78d174..e1a01cc0c8 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewListNode.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewListNode.scala.txt @@ -87,20 +87,7 @@ INSERT { } } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. -*@ -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@nodeIri") AS ?nodeIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewProject.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewProject.scala.txt index 1475c10cdc..cac732bf07 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewProject.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewProject.scala.txt @@ -81,20 +81,7 @@ INSERT { knora-admin:hasSelfJoinEnabled "@hasSelfJoinEnabled"^^xsd:boolean . } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. -*@ -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} WHERE { BIND(IRI("@adminNamedGraphIri") AS ?adminNamedGraphIri) BIND(IRI("@projectIri") AS ?projectIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewUser.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewUser.scala.txt index d90b140d69..0501cefca4 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewUser.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/createNewUser.scala.txt @@ -62,20 +62,7 @@ INSERT { ?userIri knora-admin:isInSystemAdminGroup "@systemAdmin"^^xsd:boolean . } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. -*@ -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} WHERE { BIND(IRI("@adminNamedGraphIri") AS ?adminNamedGraphIri) BIND(IRI("@userIri") AS ?userIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/deleteNode.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/deleteNode.scala.txt index fb39ca441f..ad69549805 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/deleteNode.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/deleteNode.scala.txt @@ -35,10 +35,6 @@ DELETE { } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@nodeIri") AS ?node) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/deletePermission.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/deletePermission.scala.txt index 3f80ff5e82..097c231e25 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/deletePermission.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/deletePermission.scala.txt @@ -31,22 +31,6 @@ DELETE { } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@permissionIri") AS ?permission) BIND(IRI("@namedGraphIri") AS ?dataNamedGraph) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValue.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValue.scala.txt index 51db491bf4..8fa3f12aa7 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValue.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValue.scala.txt @@ -6,24 +6,38 @@ @import org.knora.webapi.IRI @** - * Given a knora-base:internalFilename, retrieves the file value and information attached to it. - * - * If the triplestore type is GraphDB, this template delegates to getFileValueGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to getFileValueStandard.sparql.txt. + * Given a knora:base:internalFilename, retrieves the file value and information + * attached to it using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. - * @param filename the file value's knora-base:internalFilename. + * @param fileValueIri the IRI of the file value. *@ @(triplestore: String, filename: String) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.admin.txt.getFileValueGraphDB(filename = filename) - } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.admin.txt.getFileValueStandard(triplestore = triplestore, - filename = filename) - } +PREFIX xsd: +PREFIX rdf: +PREFIX rdfs: +PREFIX knora-base: + +CONSTRUCT { + ?fileValue ?objPred ?objObj . + ?fileValue knora-base:attachedToProject ?resourceProject . + ?fileValue knora-base:hasPermissions ?currentFileValuePermissions . +} WHERE { + ?fileValue knora-base:internalFilename "@filename" . + + ?currentFileValue knora-base:previousValue* ?fileValue ; + knora-base:hasPermissions ?currentFileValuePermissions . + + ?resource ?prop ?currentFileValue ; + knora-base:attachedToProject ?resourceProject . + + ?fileValue ?objPred ?objObj . + + @* This FILTER is unnecessary, but it makes Jena run the query faster. *@ + FILTER(?objPred != knora-base:previousValue) + + ?currentFileValue knora-base:isDeleted false . + ?resource knora-base:isDeleted false . } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValueGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValueGraphDB.scala.txt deleted file mode 100644 index cfbbce6b4f..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValueGraphDB.scala.txt +++ /dev/null @@ -1,42 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Given a knora:base:internalFilename, retrieves the file value and information attached to it, using GraphDB. - * - * This template is used only by getFileValue.scala.txt. - * - * Since the triplestore type is GraphDB, we turn off inference in this query because it is not needed. - * - * @param fileValueIri the IRI of the file value. - *@ -@(filename: String) - -PREFIX xsd: -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -CONSTRUCT { - ?fileValue ?objPred ?objObj . - ?fileValue knora-base:attachedToProject ?resourceProject . - ?fileValue knora-base:hasPermissions ?currentFileValuePermissions . -} -FROM -WHERE { - ?fileValue knora-base:internalFilename "@filename" . - - ?currentFileValue knora-base:previousValue* ?fileValue ; - knora-base:hasPermissions ?currentFileValuePermissions . - - ?resource ?prop ?currentFileValue ; - knora-base:attachedToProject ?resourceProject . - - ?fileValue ?objPred ?objObj . - ?currentFileValue knora-base:isDeleted false . - ?resource knora-base:isDeleted false . -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValueStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValueStandard.scala.txt deleted file mode 100644 index d4b89a664f..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getFileValueStandard.scala.txt +++ /dev/null @@ -1,45 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Given a knora:base:internalFilename, retrieves the file value and information attached to it, using standard - * SPARQL, without inference. - * - * This template is used only by getFileValue.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param fileValueIri the IRI of the file value. - *@ -@(triplestore: String, - filename: String) - -PREFIX xsd: -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -CONSTRUCT { - ?fileValue ?objPred ?objObj . - ?fileValue knora-base:attachedToProject ?resourceProject . - ?fileValue knora-base:hasPermissions ?currentFileValuePermissions . -} WHERE { - ?fileValue knora-base:internalFilename "@filename" . - - ?currentFileValue knora-base:previousValue* ?fileValue ; - knora-base:hasPermissions ?currentFileValuePermissions . - - ?resource ?prop ?currentFileValue ; - knora-base:attachedToProject ?resourceProject . - - ?fileValue ?objPred ?objObj . - - @* This FILTER is unnecessary, but it makes Jena run the query faster. *@ - FILTER(?objPred != knora-base:previousValue) - - ?currentFileValue knora-base:isDeleted false . - ?resource knora-base:isDeleted false . -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getGroups.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getGroups.scala.txt index d8d14f0f61..069099adf2 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getGroups.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getGroups.scala.txt @@ -19,10 +19,7 @@ PREFIX rdf: PREFIX knora-admin: CONSTRUCT { ?s ?p ?o } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { @maybeIri match { diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getListNode.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getListNode.scala.txt index e450b5839b..41b90dfd2a 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getListNode.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getListNode.scala.txt @@ -20,10 +20,7 @@ PREFIX rdfs: PREFIX knora-base: CONSTRUCT { ?s ?p ?o } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@nodeIri") as ?s) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getListNodeWithChildren.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getListNodeWithChildren.scala.txt index 425fc8e6b6..72a4ffe88a 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getListNodeWithChildren.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getListNodeWithChildren.scala.txt @@ -22,10 +22,7 @@ PREFIX rdfs: PREFIX knora-base: CONSTRUCT { ?node ?p ?o } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@startNodeIri") as ?startNode) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getLists.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getLists.scala.txt index bf883ee1a8..1fe01bcb7e 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getLists.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getLists.scala.txt @@ -21,10 +21,7 @@ PREFIX rdfs: PREFIX knora-base: CONSTRUCT { ?s ?p ?o . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-base:ListNode . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getNodePath.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getNodePath.scala.txt index fd52ac6110..42f8c1a07e 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getNodePath.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getNodePath.scala.txt @@ -26,10 +26,7 @@ PREFIX xsd: PREFIX knora-base: SELECT DISTINCT ?node ?nodeName ?label ?child -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@queryNodeIri") as ?leafNode) BIND(str("@preferredLanguage") as ?preferredLanguage) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getParentNode.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getParentNode.scala.txt index 54065876fe..27dd4c1031 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getParentNode.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getParentNode.scala.txt @@ -20,10 +20,7 @@ PREFIX rdfs: PREFIX knora-base: CONSTRUCT { ?s ?p ?o } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@nodeIri") as ?nodeIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getPermissionByIRI.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getPermissionByIRI.scala.txt index a259943072..671b7e1da4 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getPermissionByIRI.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getPermissionByIRI.scala.txt @@ -18,10 +18,7 @@ prefix rdf: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@permissionIri") as ?s) { diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectAdminData.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectAdminData.scala.txt index 1eaf9200da..0033511db5 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectAdminData.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectAdminData.scala.txt @@ -21,10 +21,7 @@ CONSTRUCT { ?user ?userPred ?userObj . ?group ?groupPred ?groupObj . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?project) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectAdminMembers.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectAdminMembers.scala.txt index ea43c94726..41b96f14ac 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectAdminMembers.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectAdminMembers.scala.txt @@ -24,10 +24,7 @@ PREFIX rdf: PREFIX knora-admin: CONSTRUCT {?s knora-admin:isInProjectAdminGroup ?project . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { @if(maybeIri.nonEmpty) { diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectMembers.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectMembers.scala.txt index cf17d3917a..2620fd34db 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectMembers.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectMembers.scala.txt @@ -24,10 +24,7 @@ PREFIX rdf: PREFIX knora-admin: CONSTRUCT { ?s knora-admin:isInProject ?project .} -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { @if(maybeIri.nonEmpty) { diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectOfEntity.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectOfEntity.scala.txt index ade58ac4f7..934ed2b2ea 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectOfEntity.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectOfEntity.scala.txt @@ -22,22 +22,6 @@ PREFIX knora-base: SELECT ?entity ?projectIri -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@entityIri") AS ?entity) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectPermissions.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectPermissions.scala.txt index 7677d84883..63b91d60e4 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectPermissions.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjectPermissions.scala.txt @@ -19,10 +19,7 @@ prefix knora-admin: CONSTRUCT { ?permission ?p ?o . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?project) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjects.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjects.scala.txt index 5eaf43d238..2a02a8235d 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjects.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getProjects.scala.txt @@ -23,10 +23,7 @@ PREFIX rdf: PREFIX knora-admin: CONSTRUCT { ?s ?p ?o . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { @if(maybeIri.nonEmpty) { diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getUsers.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getUsers.scala.txt index 96a9880ac0..3bc13420d6 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getUsers.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/getUsers.scala.txt @@ -24,10 +24,7 @@ PREFIX rdf: PREFIX knora-admin: CONSTRUCT { ?s ?p ?o . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { @if(maybeIri.nonEmpty) { diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/isEntityUsed.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/isEntityUsed.scala.txt index 0761bcd603..ded61726a0 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/isEntityUsed.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/isEntityUsed.scala.txt @@ -22,10 +22,7 @@ PREFIX knora-base: PREFIX salsah-gui: SELECT DISTINCT ?isUsed -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@entityIri") AS ?entity) BIND(true AS ?isUsed) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/isNodeUsed.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/isNodeUsed.scala.txt index 6c2b9ca0e9..2295919c13 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/isNodeUsed.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/isNodeUsed.scala.txt @@ -22,10 +22,7 @@ PREFIX knora-base: PREFIX salsah-gui: SELECT DISTINCT ?isUsed -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@nodeIri") AS ?node) BIND(true AS ?isUsed) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateGroup.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateGroup.scala.txt index be4e6678ca..e55aea4f03 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateGroup.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateGroup.scala.txt @@ -91,22 +91,6 @@ DELETE { } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@groupIri") AS ?group) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateListInfo.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateListInfo.scala.txt index 88a043d0f3..221bde4e8b 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateListInfo.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateListInfo.scala.txt @@ -83,22 +83,6 @@ DELETE { } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@nodeIri") AS ?nodeIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateNodePosition.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateNodePosition.scala.txt index 5f6226f220..d0d266273e 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateNodePosition.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateNodePosition.scala.txt @@ -41,22 +41,6 @@ DELETE { ?nodeIri knora-base:listNodePosition "@newPosition"^^xsd:integer . } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@nodeIri") AS ?nodeIri) BIND(IRI("@newPosition") AS ?newPosition) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updatePermission.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updatePermission.scala.txt index ed23abcbfc..9b0044b942 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updatePermission.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updatePermission.scala.txt @@ -74,22 +74,6 @@ DELETE { } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@permissionIri") AS ?permissionIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateProject.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateProject.scala.txt index a0db690e1c..4daaaf8e79 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateProject.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateProject.scala.txt @@ -113,22 +113,6 @@ DELETE { } } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@projectIri") AS ?project) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateUser.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateUser.scala.txt index ac2b715620..1ff6fa1a96 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateUser.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateUser.scala.txt @@ -140,22 +140,6 @@ DELETE { } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@userIri") AS ?user) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateUserPassword.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateUserPassword.scala.txt index 7815cb836d..e99acd56d9 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateUserPassword.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/admin/updateUserPassword.scala.txt @@ -44,22 +44,6 @@ DELETE { } -@* - -GraphDB's consistency checking requires reasoning, but reasoning interferes with certain things -in the WHERE clauses of our SPARQL updates, so we set a GraphDB-specific flag to return only -explicit statements in the WHERE clause here. - -*@ - -@triplestore match { - case "graphdb" | "graphdb-free" => { - USING - } - - case other => {} -} - WHERE { BIND(IRI("@userIri") AS ?user) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/addValueVersion.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/addValueVersion.scala.txt index 44fa0abfd5..e06226726e 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/addValueVersion.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/addValueVersion.scala.txt @@ -487,10 +487,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeComment.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeComment.scala.txt index 5926ef7d70..8e64d50162 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeComment.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeComment.scala.txt @@ -72,10 +72,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeLink.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeLink.scala.txt index 0a8409dc51..d53d4dce71 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeLink.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeLink.scala.txt @@ -126,10 +126,7 @@ INSERT { ?linkSource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { @if(linkUpdateForCurrentLink.linkPropertyIri != linkUpdateForNewLink.linkPropertyIri) { @{throw SparqlGenerationException(s"linkUpdateForCurrentLink.linkPropertyIri <${linkUpdateForCurrentLink.linkPropertyIri}> must be equal to linkUpdateForNewLink.linkPropertyIri <${linkUpdateForNewLink.linkPropertyIri}> in this SPARQL template"); ()} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeResourceLabel.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeResourceLabel.scala.txt index d31370d786..54ac03054f 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeResourceLabel.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/changeResourceLabel.scala.txt @@ -43,10 +43,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkResourceDeletion.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkResourceDeletion.scala.txt index 021eb9079a..a8f8264eae 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkResourceDeletion.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkResourceDeletion.scala.txt @@ -19,10 +19,7 @@ prefix rdfs: prefix knora-base: SELECT ?isDeleted -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkResourceLabelChange.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkResourceLabelChange.scala.txt index acd7b356dd..f2a1d68a3f 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkResourceLabelChange.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkResourceLabelChange.scala.txt @@ -21,10 +21,7 @@ prefix rdfs: prefix knora-base: SELECT ?resource ?newLabel -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@resourceIri") AS ?resource) BIND("@label" AS ?newLabel) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkValueDeletion.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkValueDeletion.scala.txt index 025a59487d..35f441f796 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkValueDeletion.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/checkValueDeletion.scala.txt @@ -19,10 +19,7 @@ prefix rdfs: prefix knora-base: SELECT ?isDeleted -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@valueIri") AS ?value) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/ckanDokubib.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/ckanDokubib.scala.txt index afd9aee398..a28d1381b2 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/ckanDokubib.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/ckanDokubib.scala.txt @@ -22,10 +22,7 @@ prefix knora-base: prefix dokubib: SELECT ?bild -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?projectIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/ckanIncunabula.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/ckanIncunabula.scala.txt index 7b19273720..d505a6c306 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/ckanIncunabula.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/ckanIncunabula.scala.txt @@ -22,10 +22,7 @@ prefix knora-base: prefix incunabula: SELECT ?book ?page -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?projectIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/createLink.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/createLink.scala.txt index a315847294..e683624f48 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/createLink.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/createLink.scala.txt @@ -58,10 +58,7 @@ DELETE { } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/createValue.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/createValue.scala.txt index dc08e308fb..1be7c370c5 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/createValue.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/createValue.scala.txt @@ -27,9 +27,6 @@ * @param valuePermissions the permissions that should be attached to the value. * @param creationDate an xsd:dateTimeStamp to be attached to the value. * @param stringFormatter a [[StringFormatter]]. - * - * The generated WHERE clause does some consistency checks. If these fail, the operation will do nothing. - * To find out whether the update succeeded, the application must query the property's version history. *@ @(dataNamedGraph: IRI, triplestore: String, @@ -98,10 +95,7 @@ DELETE { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteLink.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteLink.scala.txt index 151dc2790c..29524b712d 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteLink.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteLink.scala.txt @@ -98,10 +98,7 @@ INSERT { ?linkSource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@linkSourceIri") AS ?linkSource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteResource.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteResource.scala.txt index 70be6c6f97..d4caf91947 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteResource.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteResource.scala.txt @@ -58,10 +58,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteValue.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteValue.scala.txt index 263990e254..dcdc9eb8b9 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteValue.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/deleteValue.scala.txt @@ -133,10 +133,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findLinkValueByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findLinkValueByIri.scala.txt index 3da79d46e3..983944b0e1 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findLinkValueByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findLinkValueByIri.scala.txt @@ -26,10 +26,7 @@ prefix rdfs: prefix knora-base: SELECT ?linkValue ?directLinkExists ?targetResourceClass ?objPred ?objObj -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@linkValueIri") AS ?linkValue) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findLinkValueByObject.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findLinkValueByObject.scala.txt index 628dfe6cb5..6121d114ce 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findLinkValueByObject.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findLinkValueByObject.scala.txt @@ -28,10 +28,7 @@ prefix rdfs: prefix knora-base: SELECT ?linkValue ?directLinkExists ?targetResourceClass ?objPred ?objObj -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { <@subjectIri> <@{predicateIri}Value> ?linkValue . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findResourceWithValue.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findResourceWithValue.scala.txt index 975c5422db..bbb3f9ba7c 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findResourceWithValue.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findResourceWithValue.scala.txt @@ -19,10 +19,7 @@ prefix rdfs: prefix knora-base: SELECT ?resource ?project ?property -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@searchValueIri") as ?searchValue) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findValueInVersions.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findValueInVersions.scala.txt index 32e0b04df9..e2b0321bc3 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findValueInVersions.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/findValueInVersions.scala.txt @@ -24,10 +24,7 @@ prefix rdfs: prefix knora-base: SELECT ?objPred ?objObj ?predStandoff ?objStandoff -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { { BIND(IRI("@resourceIri") as ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/generateWhereStatementsForGetMapping.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/generateWhereStatementsForGetMapping.scala.txt deleted file mode 100644 index 96b40be83c..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/generateWhereStatementsForGetMapping.scala.txt +++ /dev/null @@ -1,43 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@* - * Generates statements to be added to the WHERE clause of a SPAQRL query that gets a mapping. - *@ -@() - -?mapping rdfs:label ?label . - -?mapping rdf:type ?mappingType . - -OPTIONAL { - ?mapping knora-base:mappingHasDefaultXSLTransformation ?defaultXSLTransformation . -} - -?mapping knora-base:hasMappingElement ?mappingElement . -?mappingElement rdf:type ?mappingElementType . -?mappingElement knora-base:mappingHasXMLTagname ?tagName . -?mappingElement knora-base:mappingHasXMLNamespace ?tagNamespace . -?mappingElement knora-base:mappingHasXMLClass ?tagClass . -?mappingElement knora-base:mappingHasStandoffClass ?standoffClass . -?mappingElement knora-base:mappingElementRequiresSeparator ?separatorRequired . - -OPTIONAL { - - ?mappingElement knora-base:mappingHasXMLAttribute ?attribute . - ?attribute rdf:type ?attributeType . - ?attribute knora-base:mappingHasXMLAttributename ?attributeName . - ?attribute knora-base:mappingHasXMLNamespace ?attributeNamespace . - ?attribute knora-base:mappingHasStandoffProperty ?standoffProperty . -} - -OPTIONAL { - - ?mappingElement knora-base:mappingHasStandoffDataTypeClass ?datatypeClass . - ?datatypeClass rdf:type ?datatypeType . - ?datatypeClass knora-base:mappingHasXMLAttributename ?datatypeAttributeName . - ?datatypeClass knora-base:mappingHasStandoffClass ?datatypeStandoffClass . - -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionByIri.scala.txt index ac08e58563..2407efc809 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionByIri.scala.txt @@ -19,10 +19,7 @@ prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@administrativePermissionIri") as ?s) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionForProjectAndGroup.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionForProjectAndGroup.scala.txt index 8ffabeed2d..11949de1cd 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionForProjectAndGroup.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionForProjectAndGroup.scala.txt @@ -20,10 +20,7 @@ prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:AdministrativePermission . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionsForProject.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionsForProject.scala.txt index 47313b35f6..b39ec03e88 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionsForProject.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getAdministrativePermissionsForProject.scala.txt @@ -19,10 +19,7 @@ prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:AdministrativePermission . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContext.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContext.scala.txt index 47909b73b6..f0b2587945 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContext.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContext.scala.txt @@ -6,10 +6,8 @@ @import org.knora.webapi.IRI @** - * Given the IRI of a resource, gets information about the resources that are part of that resource. - * - * If the triplestore type is GraphDB, this template delegates to getContextGraphDB.sparql.txt, which is optimised for - * GraphDB. Otherwise, it delegates to getContextStandard.sparql.txt. + * Given the IRI of a resource, gets information about the resources that are part of that resource + * using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param resourceIri the IRI of the resource. @@ -17,13 +15,92 @@ @(triplestore: String, resourceIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getContextGraphDB(resourceIri = resourceIri) +prefix rdf: +prefix rdfs: +prefix knora-base: +prefix xsd: + +SELECT ?sourceObject + ?sourceObjectAttachedToUser + ?sourceObjectAttachedToProject + ?sourceObjectPermissions + ?seqnum + ?linkValue + ?linkValueCreator + ?linkValuePermissions + ?firstprop + ?fileValue + ?internalFilename + ?internalMimeType + ?originalFilename + ?dimX + ?dimY + ?fileValuePermissions + ?fileValueAttachedToUser +WHERE { + BIND(IRI("@resourceIri") as ?resource) + + ?resource rdf:type ?resourceClass . + + ?resourceClass rdfs:subClassOf* knora-base:Resource . + + # Find something that relates to this resource via knora-base:isPartOf. + + ?linkingProp rdfs:subPropertyOf* knora-base:isPartOf . + + ?sourceObject ?linkingProp ?resource . + + OPTIONAL { + ?seqProp rdfs:subPropertyOf* knora-base:seqnum . + ?sourceObject ?seqProp ?seqnumVal . + ?seqnumVal knora-base:valueHasInteger ?seqnum . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getContextStandard(triplestore = triplestore, - resourceIri = resourceIri) + + ?sourceObject rdfs:label ?firstprop ; + knora-base:attachedToUser ?sourceObjectAttachedToUser ; + knora-base:attachedToProject ?sourceObjectAttachedToProject ; + knora-base:hasPermissions ?sourceObjectPermissions . + + BIND(IRI(CONCAT(STR(?linkingProp), "Value")) AS ?linkValueProp) + + ?sourceObject ?linkValueProp ?linkValue . + + ?linkValue rdf:type knora-base:LinkValue ; + rdf:subject ?sourceObject ; + rdf:predicate ?linkingProp ; + rdf:object ?resource ; + knora-base:attachedToUser ?linkValueCreator ; + knora-base:hasPermissions ?linkValuePermissions . + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . + } + + FILTER NOT EXISTS { + ?sourceObject knora-base:isDeleted true . + } + + FILTER NOT EXISTS { + ?linkValue knora-base:isDeleted true . + } + + OPTIONAL { + ?fileValueProp rdfs:subPropertyOf* knora-base:hasFileValue . + ?sourceObject ?fileValueProp ?fileValue . + + ?fileValue a knora-base:StillImageFileValue . + + FILTER NOT EXISTS { + ?fileValue knora-base:isDeleted true . + } + + ?fileValue knora-base:internalMimeType ?internalMimeType ; + knora-base:originalFilename ?originalFilename ; + knora-base:internalFilename ?internalFilename ; + knora-base:dimX ?dimX ; + knora-base:dimY ?dimY ; + knora-base:attachedToUser ?fileValueAttachedToUser ; + knora-base:hasPermissions ?fileValuePermissions . } } +ORDER BY ?seqnum ?sourceObject ?isPreview diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContextGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContextGraphDB.scala.txt deleted file mode 100644 index 48181ee5dc..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContextGraphDB.scala.txt +++ /dev/null @@ -1,94 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Given the IRI of a resource, gets information about the resources that are part of that resource, using GraphDB. - * - * This template is used only by getContext.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subproperties of Knora base properties - * such as knora-base:isPartOf. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param resourceIri the IRI of the resource. - *@ -@(resourceIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: -prefix xsd: - -SELECT ?sourceObject - ?sourceObjectAttachedToUser - ?sourceObjectAttachedToProject - ?sourceObjectPermissions - ?seqnum - ?linkValue - ?linkValueCreator - ?linkValuePermissions - ?firstprop - ?fileValue - ?internalFilename - ?internalMimeType - ?originalFilename - ?dimX - ?dimY - ?fileValuePermissions - ?fileValueAttachedToUser -WHERE { - BIND(IRI("@resourceIri") as ?resource) - - ?resource rdf:type knora-base:Resource ; - knora-base:isDeleted false . - - # Find something that relates to this resource via knora-base:isPartOf. - - ?sourceObject knora-base:isPartOf ?resource ; - knora-base:isDeleted false . - - GRAPH { - ?sourceObject ?linkingProp ?resource . - } - - OPTIONAL { - ?sourceObject knora-base:seqnum ?seqnumVal . - ?seqnumVal knora-base:valueHasInteger ?seqnum . - } - - ?sourceObject rdfs:label ?firstprop ; - knora-base:attachedToUser ?sourceObjectAttachedToUser ; - knora-base:attachedToProject ?sourceObjectAttachedToProject ; - knora-base:hasPermissions ?sourceObjectPermissions . - - ?sourceObject knora-base:hasLinkToValue ?linkValue . - - ?linkValue rdf:type knora-base:LinkValue ; - rdf:subject ?sourceObject ; - rdf:predicate ?linkingProp ; - rdf:object ?resource ; - knora-base:isDeleted false ; - knora-base:attachedToUser ?linkValueCreator ; - knora-base:hasPermissions ?linkValuePermissions . - - OPTIONAL { - ?sourceObject knora-base:hasFileValue ?fileValue . - - ?fileValue a knora-base:StillImageFileValue ; - knora-base:isDeleted false . - - ?fileValue knora-base:internalMimeType ?internalMimeType ; - knora-base:originalFilename ?originalFilename ; - knora-base:internalFilename ?internalFilename ; - knora-base:dimX ?dimX ; - knora-base:dimY ?dimY ; - knora-base:attachedToUser ?fileValueAttachedToUser ; - knora-base:hasPermissions ?fileValuePermissions . - } -} -ORDER BY ?seqnum ?sourceObject ?isPreview diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContextStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContextStandard.scala.txt deleted file mode 100644 index 1624ee99a4..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getContextStandard.scala.txt +++ /dev/null @@ -1,108 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Given the IRI of a resource, gets information about the resources that are part of that resource, using standard - * SPARQL, without inference. - * - * This template is used only by getContext.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param resourceIri the IRI of the resource. - *@ -@(triplestore: String, - resourceIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: -prefix xsd: - -SELECT ?sourceObject - ?sourceObjectAttachedToUser - ?sourceObjectAttachedToProject - ?sourceObjectPermissions - ?seqnum - ?linkValue - ?linkValueCreator - ?linkValuePermissions - ?firstprop - ?fileValue - ?internalFilename - ?internalMimeType - ?originalFilename - ?dimX - ?dimY - ?fileValuePermissions - ?fileValueAttachedToUser -WHERE { - BIND(IRI("@resourceIri") as ?resource) - - ?resource rdf:type ?resourceClass . - - ?resourceClass rdfs:subClassOf* knora-base:Resource . - - # Find something that relates to this resource via knora-base:isPartOf. - - ?linkingProp rdfs:subPropertyOf* knora-base:isPartOf . - - ?sourceObject ?linkingProp ?resource . - - OPTIONAL { - ?seqProp rdfs:subPropertyOf* knora-base:seqnum . - ?sourceObject ?seqProp ?seqnumVal . - ?seqnumVal knora-base:valueHasInteger ?seqnum . - } - - ?sourceObject rdfs:label ?firstprop ; - knora-base:attachedToUser ?sourceObjectAttachedToUser ; - knora-base:attachedToProject ?sourceObjectAttachedToProject ; - knora-base:hasPermissions ?sourceObjectPermissions . - - BIND(IRI(CONCAT(STR(?linkingProp), "Value")) AS ?linkValueProp) - - ?sourceObject ?linkValueProp ?linkValue . - - ?linkValue rdf:type knora-base:LinkValue ; - rdf:subject ?sourceObject ; - rdf:predicate ?linkingProp ; - rdf:object ?resource ; - knora-base:attachedToUser ?linkValueCreator ; - knora-base:hasPermissions ?linkValuePermissions . - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - FILTER NOT EXISTS { - ?sourceObject knora-base:isDeleted true . - } - - FILTER NOT EXISTS { - ?linkValue knora-base:isDeleted true . - } - - OPTIONAL { - ?fileValueProp rdfs:subPropertyOf* knora-base:hasFileValue . - ?sourceObject ?fileValueProp ?fileValue . - - ?fileValue a knora-base:StillImageFileValue . - - FILTER NOT EXISTS { - ?fileValue knora-base:isDeleted true . - } - - ?fileValue knora-base:internalMimeType ?internalMimeType ; - knora-base:originalFilename ?originalFilename ; - knora-base:internalFilename ?internalFilename ; - knora-base:dimX ?dimX ; - knora-base:dimY ?dimY ; - knora-base:attachedToUser ?fileValueAttachedToUser ; - knora-base:hasPermissions ?fileValuePermissions . - } -} -ORDER BY ?seqnum ?sourceObject ?isPreview diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getCreatedResource.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getCreatedResource.scala.txt index 779f0dfaee..9979149493 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getCreatedResource.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getCreatedResource.scala.txt @@ -15,10 +15,7 @@ resourceIri: IRI) SELECT ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { <@resourceIri> ?p ?o . } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermission.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermission.scala.txt index ec8e17e40a..16768a4b0d 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermission.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermission.scala.txt @@ -25,10 +25,7 @@ prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:DefaultObjectAccessPermission . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermissionByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermissionByIri.scala.txt index 785b05d886..09ab5b6485 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermissionByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermissionByIri.scala.txt @@ -19,10 +19,7 @@ prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@defaultObjectAccessPermissionIri") as ?s) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermissionsForProject.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermissionsForProject.scala.txt index 7a528375e9..157c7cf6e5 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermissionsForProject.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getDefaultObjectAccessPermissionsForProject.scala.txt @@ -19,10 +19,7 @@ prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:DefaultObjectAccessPermission . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getFileValuesForResource.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getFileValuesForResource.scala.txt index 30b3eecd11..0b9f09c261 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getFileValuesForResource.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getFileValuesForResource.scala.txt @@ -20,10 +20,7 @@ PREFIX rdf: PREFIX rdfs: SELECT ?p ?fileValueIri ?quality -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@resourceIri") as ?resIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphData.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphData.scala.txt index af94a14105..5c9b98af3c 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphData.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphData.scala.txt @@ -6,11 +6,8 @@ @import org.knora.webapi._ @** - * Gets the outbound or inbound links from/to a resource. This query is used recursively to get a graph of - * resources reachable from a given resource. - * - * If the triplestore type is GraphDB, this template delegates to getGraphDataGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to getGraphDataStandard.sparql.txt. + * Gets the outbound or inbound links from/to a resource, using SPARQL w/o inference. This query is used + * recursively to get a graph of resources reachable from a given resource. * * @param triplestore the name of the triplestore being used. * @param startNodeIri the IRI of the resource to use as the starting point of the query. @@ -22,17 +19,65 @@ startNodeOnly: Boolean, outbound: Boolean = true) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getGraphDataGraphDB(startNodeIri = startNodeIri, - startNodeOnly = startNodeOnly, - outbound = outbound) - } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getGraphDataStandard(triplestore = triplestore, - startNodeIri = startNodeIri, - startNodeOnly = startNodeOnly, - outbound = outbound) +PREFIX rdf: +PREFIX rdfs: +PREFIX knora-base: + +SELECT ?node ?nodeClass ?nodeLabel ?nodeCreator ?nodeProject ?nodePermissions + ?linkValue ?linkProp ?linkValueCreator ?linkValuePermissions +WHERE { + @if(startNodeOnly) { + BIND(IRI("@startNodeIri") AS ?node) . + + ?node a ?nodeClass ; + rdfs:label ?nodeLabel ; + knora-base:attachedToUser ?nodeCreator ; + knora-base:attachedToProject ?nodeProject ; + knora-base:isDeleted false ; + knora-base:hasPermissions ?nodePermissions . + } else { + BIND(IRI("@startNodeIri") AS ?startNode) . + + ?linkProp rdfs:subPropertyOf* knora-base:hasLinkTo . + + @if(outbound) { + ?startNode ?linkProp ?node . + + FILTER NOT EXISTS { + ?isPartOfProp rdfs:subPropertyOf* knora-base:isPartOf . + ?startNode ?isPartOfProp ?node . + } + + ?node knora-base:isDeleted false . + + ?linkValue a knora-base:LinkValue ; + rdf:subject ?startNode ; + rdf:predicate ?linkProp ; + rdf:object ?node . + } else { + ?node ?linkProp ?startNode . + + FILTER NOT EXISTS { + ?isPartOfProp rdfs:subPropertyOf* knora-base:isPartOf . + ?node ?isPartOfProp ?startNode . + } + + ?node knora-base:isDeleted false . + + ?linkValue a knora-base:LinkValue ; + rdf:subject ?node ; + rdf:predicate ?linkProp ; + rdf:object ?startNode . + } + + ?node a ?nodeClass ; + rdfs:label ?nodeLabel ; + knora-base:attachedToUser ?nodeCreator ; + knora-base:attachedToProject ?nodeProject ; + knora-base:hasPermissions ?nodePermissions . + + ?linkValue knora-base:attachedToUser ?linkValueCreator ; + knora-base:hasPermissions ?linkValuePermissions . } } +LIMIT 50 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphDataGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphDataGraphDB.scala.txt deleted file mode 100644 index 6beaa9f5b4..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphDataGraphDB.scala.txt +++ /dev/null @@ -1,98 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi._ - -@** - * Gets the outbound or inbound links from/to a resource, using GraphDB. This query is used recursively to get a graph - * of resources reachable from a given resource. - * - * This template is used only by getGraphData.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to find subproperties of knora-base:hasLinkTo and knora-base:isPartOf. - * This requires us to use GraphDB's GRAPH whenever we need to get explicit - * (non-inferred) statements. - * - * @param startNodeIri the IRI of the resource to use as the starting point of the query. - * @param startNodeOnly if true, returns information only about the start node. - * @param outbound true to get outbound links, false to get inbound links. - *@ -@(startNodeIri: IRI, - startNodeOnly: Boolean, - outbound: Boolean = true) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT ?node ?nodeClass ?nodeLabel ?nodeCreator ?nodeProject ?nodePermissions - ?linkValue ?linkProp ?linkValueCreator ?linkValuePermissions -WHERE { - @if(startNodeOnly) { - BIND(IRI("@startNodeIri") AS ?node) . - - GRAPH { - ?node a ?nodeClass . - } - - ?node rdfs:label ?nodeLabel ; - knora-base:attachedToUser ?nodeCreator ; - knora-base:attachedToProject ?nodeProject ; - knora-base:isDeleted false ; - knora-base:hasPermissions ?nodePermissions . - } else { - BIND(IRI("@startNodeIri") AS ?startNode) . - - @if(outbound) { - ?startNode knora-base:hasLinkTo ?node . - - FILTER NOT EXISTS { - ?startNode knora-base:isPartOf ?node . - } - - GRAPH { - ?startNode ?linkProp ?node . - } - - ?node knora-base:isDeleted false . - - ?linkValue a knora-base:LinkValue ; - rdf:subject ?startNode ; - rdf:predicate ?linkProp ; - rdf:object ?node . - } else { - ?node knora-base:hasLinkTo ?startNode . - - FILTER NOT EXISTS { - ?node knora-base:isPartOf ?startNode . - } - - GRAPH { - ?node ?linkProp ?startNode . - } - - ?node knora-base:isDeleted false . - - ?linkValue a knora-base:LinkValue ; - rdf:subject ?node ; - rdf:predicate ?linkProp ; - rdf:object ?startNode . - } - - GRAPH { - ?node a ?nodeClass . - } - - ?node rdfs:label ?nodeLabel ; - knora-base:attachedToUser ?nodeCreator ; - knora-base:attachedToProject ?nodeProject ; - knora-base:hasPermissions ?nodePermissions . - - ?linkValue knora-base:attachedToUser ?linkValueCreator ; - knora-base:hasPermissions ?linkValuePermissions . - } -} -LIMIT 50 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphDataStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphDataStandard.scala.txt deleted file mode 100644 index af0c311ee2..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGraphDataStandard.scala.txt +++ /dev/null @@ -1,85 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi._ - -@** - * Gets the outbound or inbound links from/to a resource, using standard SPARQL, without inference. This query is used - * recursively to get a graph of resources reachable from a given resource. - * - * This template is used only by getGraphData.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param startNodeIri the IRI of the resource to use as the starting point of the query. - * @param startNodeOnly if true, returns information only about the start node. - * @param outbound true to get outbound links, false to get inbound links. - *@ -@(triplestore: String, - startNodeIri: IRI, - startNodeOnly: Boolean, - outbound: Boolean = true) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT ?node ?nodeClass ?nodeLabel ?nodeCreator ?nodeProject ?nodePermissions - ?linkValue ?linkProp ?linkValueCreator ?linkValuePermissions -WHERE { - @if(startNodeOnly) { - BIND(IRI("@startNodeIri") AS ?node) . - - ?node a ?nodeClass ; - rdfs:label ?nodeLabel ; - knora-base:attachedToUser ?nodeCreator ; - knora-base:attachedToProject ?nodeProject ; - knora-base:isDeleted false ; - knora-base:hasPermissions ?nodePermissions . - } else { - BIND(IRI("@startNodeIri") AS ?startNode) . - - ?linkProp rdfs:subPropertyOf* knora-base:hasLinkTo . - - @if(outbound) { - ?startNode ?linkProp ?node . - - FILTER NOT EXISTS { - ?isPartOfProp rdfs:subPropertyOf* knora-base:isPartOf . - ?startNode ?isPartOfProp ?node . - } - - ?node knora-base:isDeleted false . - - ?linkValue a knora-base:LinkValue ; - rdf:subject ?startNode ; - rdf:predicate ?linkProp ; - rdf:object ?node . - } else { - ?node ?linkProp ?startNode . - - FILTER NOT EXISTS { - ?isPartOfProp rdfs:subPropertyOf* knora-base:isPartOf . - ?node ?isPartOfProp ?startNode . - } - - ?node knora-base:isDeleted false . - - ?linkValue a knora-base:LinkValue ; - rdf:subject ?node ; - rdf:predicate ?linkProp ; - rdf:object ?startNode . - } - - ?node a ?nodeClass ; - rdfs:label ?nodeLabel ; - knora-base:attachedToUser ?nodeCreator ; - knora-base:attachedToProject ?nodeProject ; - knora-base:hasPermissions ?nodePermissions . - - ?linkValue knora-base:attachedToUser ?linkValueCreator ; - knora-base:hasPermissions ?linkValuePermissions . - } -} -LIMIT 50 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupByIri.scala.txt index 44539ff8cb..9632fe09db 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupByIri.scala.txt @@ -18,10 +18,7 @@ prefix rdf: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@groupIri") as ?s) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupByName.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupByName.scala.txt index b4f121af85..5b375b7182 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupByName.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupByName.scala.txt @@ -22,10 +22,7 @@ prefix rdfs: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:UserGroup . ?s knora-admin:groupName "@name"^^xsd:string . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupMembersByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupMembersByIri.scala.txt index d307b71239..1eee42731d 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupMembersByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupMembersByIri.scala.txt @@ -18,10 +18,7 @@ prefix rdf: prefix knora-admin: SELECT ?s -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@groupIri") as ?group) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupMembersByName.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupMembersByName.scala.txt index 9efdf3364f..918b877887 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupMembersByName.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroupMembersByName.scala.txt @@ -20,10 +20,7 @@ prefix knora-admin: prefix xsd: SELECT ?s -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?project) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroups.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroups.scala.txt index 68552d35ac..6166ec831a 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroups.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getGroups.scala.txt @@ -16,10 +16,7 @@ prefix rdf: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:UserGroup . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferences.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferences.scala.txt index c2670f7890..764d4900d3 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferences.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferences.scala.txt @@ -6,10 +6,8 @@ @import org.knora.webapi.IRI @** - * Gets information about the incoming references to a resource, as well as about the referring resources. - * - * If the triplestore type is GraphDB, this template delegates to getIncomingReferencesGraphDB.sparql.txt, which is - * optimised for GraphDB. Otherwise, it delegates to getIncomingReferencesStandard.sparql.txt. + * Gets information about the incoming references to a resource, as well as about the referring resourceClass + * using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param resourceIri the IRI of the resource. @@ -17,13 +15,76 @@ @(triplestore: String, resourceIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getIncomingReferencesGraphDB(resourceIri = resourceIri) +PREFIX rdf: +PREFIX rdfs: +PREFIX knora-base: + +SELECT ?referringResource ?linkProp ?prop ?obj ?isLinkValue ?objPred ?objObj +WHERE { + + @* + + Find incoming links that are subproperties of knora-base:hasLinkTo but not knora-base:isPartOf. + + Makes use of a subquery in order to limit the number of referring resources. + + *@ + + { + SELECT ?resource ?referringResource ?linkProp + WHERE { + + BIND(IRI("@resourceIri") as ?resource) + + ?linkProp rdfs:subPropertyOf* knora-base:hasLinkTo . + + FILTER NOT EXISTS { + ?linkProp rdfs:subPropertyOf* knora-base:isPartOf . + } + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . + } + + ?referringResource ?linkProp ?resource . + + FILTER NOT EXISTS { + ?referringResource knora-base:isDeleted true . + } + } LIMIT 50 } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getIncomingReferencesStandard(triplestore = triplestore, - resourceIri = resourceIri) + + { + @* Get basic information about the source of each link. *@ + + ?referringResource ?prop ?obj . + + FILTER NOT EXISTS { + ?prop rdfs:subPropertyOf* knora-base:resourceProperty . + } + + BIND(false as ?isLinkValue) + } + UNION + { + @* Get the LinkValue for each link from ?referringResource to ?resource, so its permissions can be checked. *@ + + ?prop rdfs:subPropertyOf* knora-base:hasLinkToValue . + ?referringResource ?prop ?obj . + + ?obj ?objPred ?objObj . + + FILTER NOT EXISTS { + ?obj knora-base:isDeleted true . + } + + BIND(true as ?isLinkValue) } + + OPTIONAL { + ?obj rdf:predicate ?linkValuePredicate ; + rdf:object ?linkValueObject . + } + + FILTER(!?isLinkValue || (?linkValuePredicate = ?linkProp && ?linkValueObject = ?resource)) } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferencesGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferencesGraphDB.scala.txt deleted file mode 100644 index df5989ca56..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferencesGraphDB.scala.txt +++ /dev/null @@ -1,86 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Gets information about the incoming references to a resource, as well as about the referring resources. - * - * This template is used only by getIncomingReferences.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subproperties of Knora base properties - * such as knora-base:hasLinkTo. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param resourceIri the IRI of the resource. - *@ -@(resourceIri: IRI) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT ?referringResource ?linkProp ?prop ?obj ?isLinkValue ?objPred ?objObj -WHERE { - - @* - - Find incoming links that are subproperties of knora-base:hasLinkTo but not knora-base:isPartOf. - - Makes use of a subquery in order to limit the number of referring resources. - - *@ - - { - SELECT ?resource ?referringResource ?linkProp - WHERE { - BIND(IRI("@resourceIri") as ?resource) - - ?resource a knora-base:Resource ; - knora-base:isDeleted false . - - @* Find incoming links that are subproperties of knora-base:hasLinkTo but not knora-base:isPartOf. *@ - - ?referringResource knora-base:hasLinkTo ?resource ; - knora-base:isDeleted false . - - FILTER NOT EXISTS { - ?referringResource knora-base:isPartOf ?resource . - } - - GRAPH { - ?referringResource ?linkProp ?resource . - } - } LIMIT 50 - } - - { - @* Get basic information about the source of each link. *@ - - GRAPH { - ?referringResource ?prop ?obj . - } - - FILTER NOT EXISTS { - ?referringResource knora-base:resourceProperty ?obj . - } - } - UNION - { - @* Get the LinkValue for each link from ?referringResource to ?resource, so its permissions can be checked. *@ - - ?referringResource knora-base:hasLinkToValue ?obj . - - GRAPH { - ?obj rdf:predicate ?linkProp ; - rdf:object ?resource ; - knora-base:isDeleted false ; - ?objPred ?objObj . - } - - BIND(true as ?isLinkValue) - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferencesStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferencesStandard.scala.txt deleted file mode 100644 index 3dcad7900c..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getIncomingReferencesStandard.scala.txt +++ /dev/null @@ -1,92 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Gets information about the incoming references to a resource, as well as about the referring resources, using - * standard SPARQL, without inference. - * - * This template is used only by getIncomingReferences.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param resourceIri the IRI of the resource. - *@ -@(triplestore: String, - resourceIri: IRI) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT ?referringResource ?linkProp ?prop ?obj ?isLinkValue ?objPred ?objObj -WHERE { - - @* - - Find incoming links that are subproperties of knora-base:hasLinkTo but not knora-base:isPartOf. - - Makes use of a subquery in order to limit the number of referring resources. - - *@ - - { - SELECT ?resource ?referringResource ?linkProp - WHERE { - - BIND(IRI("@resourceIri") as ?resource) - - ?linkProp rdfs:subPropertyOf* knora-base:hasLinkTo . - - FILTER NOT EXISTS { - ?linkProp rdfs:subPropertyOf* knora-base:isPartOf . - } - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - ?referringResource ?linkProp ?resource . - - FILTER NOT EXISTS { - ?referringResource knora-base:isDeleted true . - } - } LIMIT 50 - } - - { - @* Get basic information about the source of each link. *@ - - ?referringResource ?prop ?obj . - - FILTER NOT EXISTS { - ?prop rdfs:subPropertyOf* knora-base:resourceProperty . - } - - BIND(false as ?isLinkValue) - } - UNION - { - @* Get the LinkValue for each link from ?referringResource to ?resource, so its permissions can be checked. *@ - - ?prop rdfs:subPropertyOf* knora-base:hasLinkToValue . - ?referringResource ?prop ?obj . - - ?obj ?objPred ?objObj . - - FILTER NOT EXISTS { - ?obj knora-base:isDeleted true . - } - - BIND(true as ?isLinkValue) - } - - OPTIONAL { - ?obj rdf:predicate ?linkValuePredicate ; - rdf:object ?linkValueObject . - } - - FILTER(!?isLinkValue || (?linkValuePredicate = ?linkProp && ?linkValueObject = ?resource)) -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getLastModificationDate.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getLastModificationDate.scala.txt index c0cd2a6e3f..f5cbd763af 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getLastModificationDate.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getLastModificationDate.scala.txt @@ -17,10 +17,7 @@ prefix knora-base: SELECT ?lastModificationDate -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getLinkSourceAndTargetPermissions.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getLinkSourceAndTargetPermissions.scala.txt index 10363ad65f..edd5ce52ad 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getLinkSourceAndTargetPermissions.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getLinkSourceAndTargetPermissions.scala.txt @@ -19,10 +19,7 @@ prefix rdfs: prefix knora-base: SELECT ?source ?sourceCreator ?sourceProject ?sourcePermissions ?target ?targetCreator ?targetProject ?targetPermissions -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@linkValueIri") AS ?linkValue) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getList.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getList.scala.txt index 5f7453c186..40f161796e 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getList.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getList.scala.txt @@ -23,10 +23,7 @@ prefix rdfs: prefix knora-base: SELECT DISTINCT ?node ?isRoot ?project ?position ?nodeName ?label ?child -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@rootNodeIri") as ?rootNode) BIND(str("@preferredLanguage") as ?preferredLanguage) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getNodePath.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getNodePath.scala.txt index 1835ff4cd4..60e3d20085 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getNodePath.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getNodePath.scala.txt @@ -25,10 +25,7 @@ prefix xsd: prefix knora-base: SELECT DISTINCT ?node ?nodeName ?label ?child -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@queryNodeIri") as ?leafNode) BIND(str("@preferredLanguage") as ?preferredLanguage) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getObjectAccessPermission.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getObjectAccessPermission.scala.txt index db946ca35e..8b94f15a80 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getObjectAccessPermission.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getObjectAccessPermission.scala.txt @@ -23,10 +23,7 @@ prefix knora-base: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectAdminMembersByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectAdminMembersByIri.scala.txt index 6332af7773..f47f77822a 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectAdminMembersByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectAdminMembersByIri.scala.txt @@ -18,10 +18,7 @@ prefix rdf: prefix knora-admin: SELECT ?s -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?projectIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectAdminMembersByShortname.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectAdminMembersByShortname.scala.txt index 24effb3eb4..78740dbfa3 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectAdminMembersByShortname.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectAdminMembersByShortname.scala.txt @@ -19,10 +19,7 @@ prefix knora-admin: prefix xsd: SELECT ?s -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?projectIri rdf:type knora-admin:knoraProject . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByIri.scala.txt index 3a722404d4..15deb79993 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByIri.scala.txt @@ -18,10 +18,7 @@ prefix rdf: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?s) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByShortcode.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByShortcode.scala.txt index 1548cac6ba..89f6df6a8e 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByShortcode.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByShortcode.scala.txt @@ -20,10 +20,7 @@ prefix rdfs: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:knoraProject . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByShortname.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByShortname.scala.txt index 8cc26151ea..5c29b9ada9 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByShortname.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectByShortname.scala.txt @@ -20,10 +20,7 @@ prefix rdfs: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:knoraProject . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectMembersByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectMembersByIri.scala.txt index 2ebd51ab41..17d4a50dea 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectMembersByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectMembersByIri.scala.txt @@ -18,10 +18,7 @@ prefix rdf: prefix knora-admin: SELECT ?s -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?projectIri) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectMembersByShortname.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectMembersByShortname.scala.txt index 3384ca6f5f..4f58b77f65 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectMembersByShortname.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjectMembersByShortname.scala.txt @@ -19,10 +19,7 @@ prefix knora-admin: prefix xsd: SELECT ?s -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?projectIri rdf:type knora-admin:knoraProject . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjects.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjects.scala.txt index b5114caa06..8b39e6b665 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjects.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getProjects.scala.txt @@ -16,10 +16,7 @@ prefix rdf: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:knoraProject . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegions.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegions.scala.txt index 9cfa7230fd..fbef6ffb44 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegions.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegions.scala.txt @@ -6,10 +6,8 @@ @import org.knora.webapi.IRI @** - * Given the IRI of a resource, gets the regions that point to this resource. - * - * If the triplestore type is GraphDB, this template delegates to getRegionsGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to getRegionsStandard.sparql.txt. + * Given the IRI of a resource, gets the regions that point to this resource + * using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param resourceIri the IRI of the resource. @@ -17,13 +15,28 @@ @(triplestore: String, resourceIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getRegionsGraphDB(resourceIri = resourceIri) +PREFIX knora-base: +PREFIX rdfs: +PREFIX rdf: + +SELECT ?region ?resclass ?regionObjectPermissions ?owner ?project +WHERE { + BIND(IRI("@resourceIri") as ?resource) + ?linkingProp rdfs:subPropertyOf* knora-base:isRegionOf . + ?region ?linkingProp ?resource . + + ?resclass rdfs:subClassOf* knora-base:Region . + ?region a ?resclass . + + ?region knora-base:attachedToUser ?owner ; + knora-base:attachedToProject ?project ; + knora-base:hasPermissions ?regionObjectPermissions . + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getRegionsStandard(triplestore = triplestore, - resourceIri = resourceIri) + + FILTER NOT EXISTS { + ?region knora-base:isDeleted true . } } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegionsGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegionsGraphDB.scala.txt deleted file mode 100644 index 10f66c9be7..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegionsGraphDB.scala.txt +++ /dev/null @@ -1,41 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Given the IRI of a resource, gets the regions that point to this resource, using GraphDB. - * - * This template is used only by getRegions.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subproperties of Knora base properties - * such as knora-base:isRegionOf. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param resourceIri the IRI of the resource. - *@ - @(resourceIri: IRI) - -PREFIX knora-base: -PREFIX rdfs: -PREFIX rdf: - -SELECT ?region ?resclass ?regionObjectPermissions ?owner ?project -WHERE { - BIND(IRI("@resourceIri") as ?resource) - ?resource knora-base:isDeleted false . - - ?region knora-base:isRegionOf ?resource ; - rdf:type knora-base:Region ; - knora-base:isDeleted false ; - knora-base:attachedToUser ?owner ; - knora-base:attachedToProject ?project ; - knora-base:hasPermissions ?regionObjectPermissions . - - GRAPH { - ?region rdf:type ?resclass . - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegionsStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegionsStandard.scala.txt deleted file mode 100644 index 576363e8a7..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getRegionsStandard.scala.txt +++ /dev/null @@ -1,44 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Given the IRI of a resource, gets the regions that point to this resource, using standard SPARQL, without - * inference. - * - * This template is used only by getRegions.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param resourceIri the IRI of the resource. - *@ - @(triplestore: String, - resourceIri: IRI) - -PREFIX knora-base: -PREFIX rdfs: -PREFIX rdf: - -SELECT ?region ?resclass ?regionObjectPermissions ?owner ?project -WHERE { - BIND(IRI("@resourceIri") as ?resource) - ?linkingProp rdfs:subPropertyOf* knora-base:isRegionOf . - ?region ?linkingProp ?resource . - - ?resclass rdfs:subClassOf* knora-base:Region . - ?region a ?resclass . - - ?region knora-base:attachedToUser ?owner ; - knora-base:attachedToProject ?project ; - knora-base:hasPermissions ?regionObjectPermissions . - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - FILTER NOT EXISTS { - ?region knora-base:isDeleted true . - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceClass.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceClass.scala.txt index 69e653d678..5dd7192668 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceClass.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceClass.scala.txt @@ -17,10 +17,7 @@ PREFIX rdf: SELECT ?resourceClass -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@resourceIri") as ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfo.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfo.scala.txt index 75a07bca80..f54c5883c6 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfo.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfo.scala.txt @@ -6,11 +6,8 @@ @import org.knora.webapi.IRI @** - * Gets all the properties of a resource, along with the properties of its file values, but not - * including subproperties of knora-base:hasValue. - * - * If the triplestore type is GraphDB, this template delegates to getResourceInfoGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to getResourceInfoStandard.sparql.txt. + * Gets all the properties of a resource, along with the properties of its file values, but not including subproperties + * of knora-base:hasValue, using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param resourceIri the IRI of the resource to be queried. @@ -18,13 +15,37 @@ @(triplestore: String, resourceIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getResourceInfoGraphDB(resourceIri = resourceIri) +prefix rdf: +prefix rdfs: +prefix knora-base: + +SELECT ?prop ?obj ?isFileValue ?objPred ?objObj +WHERE { + BIND(IRI("@resourceIri") AS ?resource) + + ?resource rdf:type ?resourceClass ; + knora-base:isDeleted false . + + ?resourceClass rdfs:subClassOf* knora-base:Resource . + + { + @* Query statements about the resource's file values. *@ + + ?prop rdfs:subPropertyOf* knora-base:hasFileValue . + BIND(true AS ?isFileValue) + + ?resource ?prop ?obj . + ?obj knora-base:isDeleted false . + ?obj ?objPred ?objObj . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getResourceInfoStandard(triplestore = triplestore, - resourceIri = resourceIri) + UNION + { + @* Query other statements about the resource. *@ + + ?resource ?prop ?obj . + + FILTER NOT EXISTS { + ?prop rdfs:subPropertyOf* knora-base:resourceProperty . + } } } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfoGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfoGraphDB.scala.txt deleted file mode 100644 index 579a4b8994..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfoGraphDB.scala.txt +++ /dev/null @@ -1,63 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Gets all the properties of a resource, along with the properties of its file values, but not - * including subproperties of knora-base:hasValue, using GraphDB. - * - * This template is used only by getResourceInfo.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subproperties of Knora base properties - * such as knora-base:hasFileValue. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param resourceIri the IRI of the resource to be queried. - *@ -@(resourceIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?prop ?obj ?isFileValue ?objPred ?objObj -WHERE { - BIND(IRI("@resourceIri") AS ?resource) - - ?resource rdf:type knora-base:Resource ; - knora-base:isDeleted false . - - { - @* Query statements about the resource's file values. *@ - - ?resource knora-base:hasFileValue ?obj . - - GRAPH { - ?resource ?prop ?obj . - } - - ?obj knora-base:isDeleted false . - - BIND(true AS ?isFileValue) - - GRAPH { - ?obj ?objPred ?objObj . - } - } - UNION - { - @* Query other statements about the resource. *@ - - GRAPH { - ?resource ?prop ?obj . - } - - FILTER NOT EXISTS { - ?resource knora-base:resourceProperty ?obj . - } - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfoStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfoStandard.scala.txt deleted file mode 100644 index 61a21533f2..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceInfoStandard.scala.txt +++ /dev/null @@ -1,53 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Gets all the properties of a resource, along with the properties of its file values, but not including subproperties - * of knora-base:hasValue, using standard SPARQL, without inference. - * - * This template is used only by getResourceInfo.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param resourceIri the IRI of the resource to be queried. - *@ -@(triplestore: String, - resourceIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?prop ?obj ?isFileValue ?objPred ?objObj -WHERE { - BIND(IRI("@resourceIri") AS ?resource) - - ?resource rdf:type ?resourceClass ; - knora-base:isDeleted false . - - ?resourceClass rdfs:subClassOf* knora-base:Resource . - - { - @* Query statements about the resource's file values. *@ - - ?prop rdfs:subPropertyOf* knora-base:hasFileValue . - BIND(true AS ?isFileValue) - - ?resource ?prop ?obj . - ?obj knora-base:isDeleted false . - ?obj ?objPred ?objObj . - } - UNION - { - @* Query other statements about the resource. *@ - - ?resource ?prop ?obj . - - FILTER NOT EXISTS { - ?prop rdfs:subPropertyOf* knora-base:resourceProperty . - } - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValues.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValues.scala.txt index 50376543df..0623c4dc4e 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValues.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValues.scala.txt @@ -6,10 +6,7 @@ @import org.knora.webapi.IRI @** - * Gets the values of all the Knora properties of a resource that have values. - * - * If the triplestore type is GraphDB, this template delegates to getResourcePropertiesAndValuesGraphDB.sparql.txt, - * which is optimised for GraphDB. Otherwise, it delegates to getResourcePropertiesAndValuesStandard.sparql.txt. + * Gets the values of all the Knora properties of a resource that have values using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param resourceIri the IRI of the resource to be queried. @@ -17,13 +14,94 @@ @(triplestore: String, resourceIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getResourcePropertiesAndValuesGraphDB(resourceIri = resourceIri) +prefix rdf: +prefix rdfs: +prefix knora-base: + +SELECT ?prop ?isLinkProp ?isLinkValueProp ?obj ?objPred ?objObj ?predStandoff ?objStandoff +WHERE { + BIND(IRI("@resourceIri") as ?resource) + + ?resource rdf:type ?resourceClass . + ?resourceClass rdfs:subClassOf* knora-base:Resource . + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getResourcePropertiesAndValuesStandard(triplestore = triplestore, - resourceIri = resourceIri) + + { + @* Get properties that point to Value objects. *@ + + ?prop rdfs:subPropertyOf* knora-base:hasValue . + + @* Exclude FileValue objects, because if the resource is a representation, we get its file values with its resource info. *@ + FILTER NOT EXISTS { + ?prop rdfs:subPropertyOf* knora-base:hasFileValue . + } + + @* Identify properties that point to LinkValue objects. *@ + OPTIONAL { + ?prop rdfs:subPropertyOf* knora-base:hasLinkToValue . + + BIND(true as ?isLinkValueProp) + } + + { + @* Get the project of the containing resource. *@ + + ?resource ?prop ?obj . + + FILTER NOT EXISTS { + ?obj knora-base:isDeleted true . + } + + ?resource knora-base:attachedToProject ?resourceProject . + BIND(knora-base:attachedToProject AS ?objPred) + BIND(COALESCE(?valueProject, ?resourceProject) AS ?objObj) + } + UNION + { + @* Get the value's standoff markup nodes if it has any. *@ + + ?resource ?prop ?obj . + + FILTER NOT EXISTS { + ?obj knora-base:isDeleted true . + } + + ?obj a knora-base:TextValue . + BIND(knora-base:valueHasStandoff AS ?objPred) + ?obj ?objPred ?objObj . + ?objObj ?predStandoff ?objStandoff . + } + UNION + { + @* Get any other statements about the value. *@ + + ?resource ?prop ?obj . + + FILTER NOT EXISTS { + ?obj knora-base:isDeleted true . + } + + ?obj ?objPred ?objObj . + + FILTER(!(?objPred = knora-base:attachedToProject || ?objPred = knora-base:valueHasStandoff)) + } + } + UNION + { + @* Get link properties, i.e. properties that point to other Resource objects. *@ + + ?prop rdfs:subPropertyOf* knora-base:hasLinkTo . + BIND(true AS ?isLinkProp) + + ?resource ?prop ?obj . + + FILTER NOT EXISTS { + ?obj knora-base:isDeleted true . + } + + ?obj ?objPred ?objObj . } } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValuesGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValuesGraphDB.scala.txt deleted file mode 100644 index b31d579288..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValuesGraphDB.scala.txt +++ /dev/null @@ -1,102 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Gets the values of all the Knora properties of a resource that have values, using GraphDB. - * - * This template is used only by getResourcePropertiesAndValues.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subproperties of Knora base properties - * such as knora-base:hasValue. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param resourceIri the IRI of the resource to be queried. - *@ -@(resourceIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?prop ?isLinkProp ?isLinkValueProp ?obj ?objPred ?objObj ?predStandoff ?objStandoff -WHERE { - BIND(IRI("@resourceIri") as ?resource) - - ?resource rdf:type knora-base:Resource ; - knora-base:isDeleted false ; - knora-base:attachedToProject ?resourceProject . - - { - @* Get properties that point to Value objects. *@ - ?resource knora-base:hasValue ?obj . - - @* Exclude FileValue objects, because if the resource is a representation, we get its file values with its resource info. *@ - FILTER NOT EXISTS { - ?resource knora-base:hasFileValue ?obj . - } - - @* Identify properties that point to LinkValue objects. *@ - OPTIONAL { - ?resource knora-base:hasLinkToValue ?obj . - - BIND(true as ?isLinkValueProp) - } - - GRAPH { - ?resource ?prop ?obj . - } - - { - @* Get the project of the containing resource. *@ - - ?obj knora-base:isDeleted false . - ?resource knora-base:attachedToProject ?resourceProject . - BIND(knora-base:attachedToProject AS ?objPred) - BIND(?resourceProject AS ?objObj) - } - UNION - { - @* Get the value's standoff markup nodes if it has any. *@ - - ?obj knora-base:isDeleted false . - ?obj a knora-base:TextValue . - BIND(knora-base:valueHasStandoff AS ?objPred) - - GRAPH { - ?obj ?objPred ?objObj . - ?objObj ?predStandoff ?objStandoff . - } - } - UNION - { - @* Get any other statements about the value. *@ - - ?obj knora-base:isDeleted false . - - GRAPH { - ?obj ?objPred ?objObj . - } - - FILTER(?objPred != knora-base:valueHasStandoff) - } - } - UNION - { - @* Get link properties, i.e. properties that point to other Resource objects. *@ - - ?resource knora-base:hasLinkTo ?obj . - - GRAPH { - ?resource ?prop ?obj . - ?obj knora-base:isDeleted false . - ?obj ?objPred ?objObj . - } - - BIND(true AS ?isLinkProp) - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValuesStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValuesStandard.scala.txt deleted file mode 100644 index 6ae4856a94..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcePropertiesAndValuesStandard.scala.txt +++ /dev/null @@ -1,109 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Gets the values of all the Knora properties of a resource that have values, using standard SPARQL, without inference. - * - * This template is used only by getResourcePropertiesAndValues.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param resourceIri the IRI of the resource to be queried. - *@ -@(triplestore: String, - resourceIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?prop ?isLinkProp ?isLinkValueProp ?obj ?objPred ?objObj ?predStandoff ?objStandoff -WHERE { - BIND(IRI("@resourceIri") as ?resource) - - ?resource rdf:type ?resourceClass . - ?resourceClass rdfs:subClassOf* knora-base:Resource . - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - { - @* Get properties that point to Value objects. *@ - - ?prop rdfs:subPropertyOf* knora-base:hasValue . - - @* Exclude FileValue objects, because if the resource is a representation, we get its file values with its resource info. *@ - FILTER NOT EXISTS { - ?prop rdfs:subPropertyOf* knora-base:hasFileValue . - } - - @* Identify properties that point to LinkValue objects. *@ - OPTIONAL { - ?prop rdfs:subPropertyOf* knora-base:hasLinkToValue . - - BIND(true as ?isLinkValueProp) - } - - { - @* Get the project of the containing resource. *@ - - ?resource ?prop ?obj . - - FILTER NOT EXISTS { - ?obj knora-base:isDeleted true . - } - - ?resource knora-base:attachedToProject ?resourceProject . - BIND(knora-base:attachedToProject AS ?objPred) - BIND(COALESCE(?valueProject, ?resourceProject) AS ?objObj) - } - UNION - { - @* Get the value's standoff markup nodes if it has any. *@ - - ?resource ?prop ?obj . - - FILTER NOT EXISTS { - ?obj knora-base:isDeleted true . - } - - ?obj a knora-base:TextValue . - BIND(knora-base:valueHasStandoff AS ?objPred) - ?obj ?objPred ?objObj . - ?objObj ?predStandoff ?objStandoff . - } - UNION - { - @* Get any other statements about the value. *@ - - ?resource ?prop ?obj . - - FILTER NOT EXISTS { - ?obj knora-base:isDeleted true . - } - - ?obj ?objPred ?objObj . - - FILTER(!(?objPred = knora-base:attachedToProject || ?objPred = knora-base:valueHasStandoff)) - } - } - UNION - { - @* Get link properties, i.e. properties that point to other Resource objects. *@ - - ?prop rdfs:subPropertyOf* knora-base:hasLinkTo . - BIND(true AS ?isLinkProp) - - ?resource ?prop ?obj . - - FILTER NOT EXISTS { - ?obj knora-base:isDeleted true . - } - - ?obj ?objPred ?objObj . - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResult.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResult.scala.txt index bbfa05aa28..d4a0f2ff3e 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResult.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResult.scala.txt @@ -8,10 +8,8 @@ @import org.knora.webapi.util.ApacheLuceneSupport.MatchStringWhileTyping @* - * Performs a search for resources matching the given criteria. - * - * If the triplestore type is GraphDB, this template delegates to getResourceSearchResultGraphDB.sparql.txt, which is - * optimised for GraphDB. Otherwise, it delegates to getResourceSearchResultStandard.sparql.txt. + * Performs a search for resources matching the given criteria, using SPARQL w/o inference + * (except for the interface to Lucene, which is triplestore-specific). * * @param triplestore the name of the triplestore being used. * @param phrase the search phrase (e.g. "Reise ins"). @@ -29,21 +27,78 @@ limitOfResults: Int, separator: Char) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getResourceSearchResultGraphDB(searchPhrase = searchPhrase, - restypeIriOption = restypeIriOption, - numberOfProps = numberOfProps, - limitOfResults = limitOfResults, - separator = separator) +PREFIX knora-base: +PREFIX salsah-gui: +PREFIX rdfs: + +SELECT DISTINCT ?resourceIri ?resourceClass ?firstProp ?attachedToUser ?attachedToProject ?resourcePermissions +@if(numberOfProps > 1) { + (GROUP_CONCAT(?valueString; separator="@separator") AS ?values) (GROUP_CONCAT(?property; separator="@separator") AS ?properties) (GROUP_CONCAT(?valueOrder; separator="@separator") AS ?valueOrders) +} +WHERE { + + @triplestore match { + + case "embedded-jena-tdb" | "fuseki" => { + + ?resourceIri '@searchPhrase.generateLiteralForLuceneIndexWithExactSequence' . + ?resourceIri rdfs:label ?firstProp . + @searchPhrase.generateRegexFilterStatementForExactSequenceMatch("firstProp") + + } + + case other => { + @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} + } + } + + FILTER NOT EXISTS { + ?resourceIri knora-base:isDeleted true . + } + + @restypeIriOption match { + + case Some(restypeIri) => { + + # Filter by resource class. + + ?resClass rdfs:subClassOf* <@restypeIri> . + ?resourceIri a ?resClass . + + } + + case None => { + + @* Ensure that each matching resource is a knora-base:Resource. *@ + + ?resClass rdfs:subClassOf* knora-base:Resource . + ?resourceIri a ?resClass . + + } } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getResourceSearchResultStandard(triplestore = triplestore, - searchPhrase = searchPhrase, - restypeIriOption = restypeIriOption, - numberOfProps = numberOfProps, - limitOfResults = limitOfResults, - separator = separator) + + @if(numberOfProps > 1) { + + OPTIONAL { + + ?resourceIri ?property ?valueObjectIri . + ?property knora-base:objectClassConstraint knora-base:TextValue . + ?valueObjectIri knora-base:valueHasString ?valueString ; + knora-base:valueHasOrder ?valueOrder . + + FILTER NOT EXISTS { + ?valueObjectIri knora-base:isDeleted true . + } + } + } + + ?resourceIri a ?resourceClass ; + knora-base:attachedToUser ?attachedToUser ; + knora-base:attachedToProject ?attachedToProject ; + knora-base:hasPermissions ?resourcePermissions . } + +GROUP BY ?resourceIri ?resourceClass ?firstProp ?attachedToUser ?attachedToProject ?resourcePermissions + +LIMIT @limitOfResults diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResultGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResultGraphDB.scala.txt deleted file mode 100644 index 75181b3402..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResultGraphDB.scala.txt +++ /dev/null @@ -1,97 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions._ -@import org.knora.webapi.util.ApacheLuceneSupport.MatchStringWhileTyping - -@* - * Performs a search for resources matching the given criteria, using GraphDB. - * - * This template is used only by getResourceSearchResult.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subclasses of the resource class - * specified by the user. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param phrase the search phrase (e.g. "Reise ins"). - * @param lastTerm the last search term (e.g. "Heili"). - * @param resourceTypeIri if set, restricts search to this resource class and its subclasses. - * @param numberOfProps the amount of describing properties to be returned for each found resource (e.g if set to two, - * for an incunabula book its title and creator would be returned). - * @param limitOfResults limits number of resources to be returned. - * @param separator the separator to be used when concatenating the value strings. - *@ -@(searchPhrase: MatchStringWhileTyping, - restypeIriOption: Option[IRI], - numberOfProps: Int, - limitOfResults: Int, - separator: Char) - - -PREFIX knora-base: -PREFIX salsah-gui: -PREFIX rdfs: - -SELECT DISTINCT ?resourceIri ?resourceClass ?firstProp ?attachedToUser ?attachedToProject ?resourcePermissions -@if(numberOfProps > 1) { - (GROUP_CONCAT(?valueString; separator="@separator") AS ?values) (GROUP_CONCAT(?property; separator="@separator") AS ?properties) (GROUP_CONCAT(?valueOrder; separator="@separator") AS ?valueOrders) -} -WHERE { - - ?resourceIri rdfs:label ?firstProp . - ?firstProp '@searchPhrase.generateLiteralForLuceneIndexWithExactSequence' . - @searchPhrase.generateRegexFilterStatementForExactSequenceMatch("firstProp") - - ?resourceIri knora-base:isDeleted false . - - @restypeIriOption match { - - case Some(restypeIri) => { - - # Filter by resource class. - - ?resourceIri a <@restypeIri> . - - } - - case None => { - - @* Ensure that each matching resource is a knora-base:Resource. *@ - - ?resourceIri a knora-base:Resource . - } - } - - @if(numberOfProps > 1) { - - OPTIONAL { - - GRAPH { - ?resourceIri ?property ?valueObjectIri . - } - - ?property knora-base:objectClassConstraint knora-base:TextValue . - ?valueObjectIri knora-base:valueHasString ?valueString ; - knora-base:isDeleted false ; - knora-base:valueHasOrder ?valueOrder . - - } - - } - - GRAPH { - ?resourceIri a ?resourceClass ; - knora-base:attachedToUser ?attachedToUser ; - knora-base:attachedToProject ?attachedToProject ; - knora-base:hasPermissions ?resourcePermissions . - } - -} - -GROUP BY ?resourceIri ?resourceClass ?firstProp ?attachedToUser ?attachedToProject ?resourcePermissions - -LIMIT @limitOfResults diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResultStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResultStandard.scala.txt deleted file mode 100644 index 1c2e56c10f..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceSearchResultStandard.scala.txt +++ /dev/null @@ -1,106 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.util.ApacheLuceneSupport.MatchStringWhileTyping - -@* - * Performs a search for resources matching the given criteria, using standard SPARQL (except for the interface to - * Lucene, which is triplestore-specific), and without inference. - * - * This template is used only by getResourceSearchResult.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param phrase the search phrase (e.g. "Reise ins"). - * @param lastTerm the last search term (e.g. "Heili"). - * @param resourceTypeIri if set, restricts search to this resource class and its subclasses. - * @param numberOfProps the amount of describing properties to be returned for each found resource (e.g if set to two, - * for an incunabula book its title and creator would be returned). - * @param limitOfResults limits number of resources to be returned. - * @param separator the separator to be used when concatenating the value strings. - *@ -@(triplestore: String, - searchPhrase: MatchStringWhileTyping, - restypeIriOption: Option[IRI], - numberOfProps: Int, - limitOfResults: Int, - separator: Char) - -PREFIX knora-base: -PREFIX salsah-gui: -PREFIX rdfs: - -SELECT DISTINCT ?resourceIri ?resourceClass ?firstProp ?attachedToUser ?attachedToProject ?resourcePermissions -@if(numberOfProps > 1) { - (GROUP_CONCAT(?valueString; separator="@separator") AS ?values) (GROUP_CONCAT(?property; separator="@separator") AS ?properties) (GROUP_CONCAT(?valueOrder; separator="@separator") AS ?valueOrders) -} -WHERE { - - @triplestore match { - - case "embedded-jena-tdb" | "fuseki" => { - - ?resourceIri '@searchPhrase.generateLiteralForLuceneIndexWithExactSequence' . - ?resourceIri rdfs:label ?firstProp . - @searchPhrase.generateRegexFilterStatementForExactSequenceMatch("firstProp") - - } - - case other => { - @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} - } - } - - FILTER NOT EXISTS { - ?resourceIri knora-base:isDeleted true . - } - - @restypeIriOption match { - - case Some(restypeIri) => { - - # Filter by resource class. - - ?resClass rdfs:subClassOf* <@restypeIri> . - ?resourceIri a ?resClass . - - } - - case None => { - - @* Ensure that each matching resource is a knora-base:Resource. *@ - - ?resClass rdfs:subClassOf* knora-base:Resource . - ?resourceIri a ?resClass . - - } - } - - @if(numberOfProps > 1) { - - OPTIONAL { - - ?resourceIri ?property ?valueObjectIri . - ?property knora-base:objectClassConstraint knora-base:TextValue . - ?valueObjectIri knora-base:valueHasString ?valueString ; - knora-base:valueHasOrder ?valueOrder . - - FILTER NOT EXISTS { - ?valueObjectIri knora-base:isDeleted true . - } - } - - } - - ?resourceIri a ?resourceClass ; - knora-base:attachedToUser ?attachedToUser ; - knora-base:attachedToProject ?attachedToProject ; - knora-base:hasPermissions ?resourcePermissions . -} - -GROUP BY ?resourceIri ?resourceClass ?firstProp ?attachedToUser ?attachedToProject ?resourcePermissions - -LIMIT @limitOfResults diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceTypesForNamedGraph.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceTypesForNamedGraph.scala.txt index f204343165..0b8b7b7b54 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceTypesForNamedGraph.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourceTypesForNamedGraph.scala.txt @@ -20,10 +20,7 @@ PREFIX owl: PREFIX knora-base: SELECT ?class -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { GRAPH <@namedGraph> { ?class rdf:type owl:Class . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcesByProjectAndType.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcesByProjectAndType.scala.txt index 59e12f6d33..4d6ad9dded 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcesByProjectAndType.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getResourcesByProjectAndType.scala.txt @@ -20,10 +20,7 @@ prefix rdf: prefix knora-base: SELECT ?s -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@projectIri") as ?projectIri) BIND(IRI("@resType") as ?resType) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUserByEmail.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUserByEmail.scala.txt index 70d8ab40e5..2db9e2ab4d 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUserByEmail.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUserByEmail.scala.txt @@ -18,10 +18,7 @@ prefix xsd: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s knora-admin:email "@email"^^xsd:string . ?s ?p ?o . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUserByIri.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUserByIri.scala.txt index 9f45ea3d34..b35c574061 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUserByIri.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUserByIri.scala.txt @@ -15,10 +15,7 @@ userIri: IRI) SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@userIri") as ?s) ?s ?p ?o . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUsers.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUsers.scala.txt index 9fe91af8a5..5ce66a32e3 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUsers.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getUsers.scala.txt @@ -16,10 +16,7 @@ prefix rdf: prefix knora-admin: SELECT ?s ?p ?o -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?s rdf:type knora-admin:User . ?s ?p ?o . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValue.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValue.scala.txt index 95b8927f98..24ea467070 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValue.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValue.scala.txt @@ -6,10 +6,7 @@ @import org.knora.webapi.IRI @** - * Queries a knora-base:Value. - * - * If the triplestore type is GraphDB, this template delegates to getValueGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to getValueStandard.sparql.txt. + * Queries a knora-base:Value using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param iri the IRI of the Value. @@ -17,13 +14,53 @@ @(triplestore: String, valueIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getValueGraphDB(valueIri = valueIri) +prefix rdf: +prefix rdfs: +prefix knora-base: + +SELECT ?objPred ?objObj ?predStandoff ?objStandoff +WHERE { + BIND(IRI("@valueIri") AS ?obj) + + ?resourceProp rdfs:subPropertyOf* knora-base:hasValue . + + { + ?resource ?resourceProp ?obj . + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . + } + + FILTER NOT EXISTS { + ?obj knora-base:isDeleted true . + } + + ?obj ?objPred ?objObj . + + FILTER(?objPred != knora-base:attachedToProject) + + OPTIONAL { + FILTER(?objPred = knora-base:valueHasStandoff) + ?objObj ?predStandoff ?objStandoff . + } } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getValueStandard(triplestore = triplestore, - valueIri = valueIri) + UNION + { + @* Return the project of the resource that contains the value. *@ + + ?resource ?resourceProp ?obj . + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . + } + + FILTER NOT EXISTS { + ?obj knora-base:isDeleted true . + } + + ?resource knora-base:attachedToProject ?resourceProject . + + BIND(knora-base:attachedToProject AS ?objPred) + BIND(?resourceProject AS ?objObj) } } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValueGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValueGraphDB.scala.txt deleted file mode 100644 index 0e6ea3d85f..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValueGraphDB.scala.txt +++ /dev/null @@ -1,60 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Queries a knora-base:Value using GraphDB. - * - * This template is used only by getValue.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subproperties of Knora base properties - * such as knora-base:hasValue. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param iri the IRI of the Value. - *@ -@(valueIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?objPred ?objObj ?predStandoff ?objStandoff -WHERE { - BIND(IRI("@valueIri") AS ?obj) - - ?resource knora-base:hasValue ?obj ; - knora-base:isDeleted false . - - { - ?obj knora-base:isDeleted false . - - GRAPH { - ?obj ?objPred ?objObj . - } - - FILTER(?objPred != knora-base:attachedToProject) - - OPTIONAL { - FILTER(?objPred = knora-base:valueHasStandoff) - - GRAPH { - ?objObj ?predStandoff ?objStandoff . - } - } - } - UNION - { - @* Return the project of the resource that contains the value. *@ - - ?obj knora-base:isDeleted false . - ?resource knora-base:attachedToProject ?resourceProject . - - BIND(knora-base:attachedToProject AS ?objPred) - BIND(?resourceProject AS ?objObj) - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValueStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValueStandard.scala.txt deleted file mode 100644 index 1919cfafab..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getValueStandard.scala.txt +++ /dev/null @@ -1,68 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Queries a knora-base:Value using standard SPARQL, without inference. - * - * This template is used only by getValue.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param iri the IRI of the Value. - *@ -@(triplestore: String, - valueIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?objPred ?objObj ?predStandoff ?objStandoff -WHERE { - BIND(IRI("@valueIri") AS ?obj) - - ?resourceProp rdfs:subPropertyOf* knora-base:hasValue . - - { - ?resource ?resourceProp ?obj . - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - FILTER NOT EXISTS { - ?obj knora-base:isDeleted true . - } - - ?obj ?objPred ?objObj . - - FILTER(?objPred != knora-base:attachedToProject) - - OPTIONAL { - FILTER(?objPred = knora-base:valueHasStandoff) - ?objObj ?predStandoff ?objStandoff . - } - } - UNION - { - @* Return the project of the resource that contains the value. *@ - - ?resource ?resourceProp ?obj . - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - FILTER NOT EXISTS { - ?obj knora-base:isDeleted true . - } - - ?resource knora-base:attachedToProject ?resourceProject . - - BIND(knora-base:attachedToProject AS ?objPred) - BIND(?resourceProject AS ?objObj) - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistory.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistory.scala.txt index 2e92af736d..dfec14e714 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistory.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistory.scala.txt @@ -6,10 +6,7 @@ @import org.knora.webapi.IRI @** - * Returns all versions of a value. - * - * If the triplestore type is GraphDB, this template delegates to getVersionHistoryGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to getVersionHistoryStandard.sparql.txt. + * Returns all versions of a value using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param resourceIri the resource to search. @@ -23,17 +20,45 @@ propertyIri: IRI, currentValueIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getVersionHistoryGraphDB(resourceIri = resourceIri, - propertyIri = propertyIri, - currentValueIri = currentValueIri) +prefix rdf: +prefix rdfs: +prefix knora-base: + +SELECT ?value ?valueCreationDate ?previousValue ?isLinkValue ?linkValuePredicate ?valueCreator ?project ?valuePermissions +WHERE { + BIND(IRI("@resourceIri") AS ?resource) + BIND(IRI("@propertyIri") AS ?prop) + BIND(IRI("@currentValueIri") AS ?currentValue) + + ?currentValue knora-base:hasPermissions ?valuePermissions . + + FILTER NOT EXISTS { + ?currentValue knora-base:isDeleted true . + } + + ?resource ?prop ?currentValue . + ?prop rdfs:subPropertyOf* knora-base:hasValue . + ?resource knora-base:attachedToProject ?project . + + ?currentValue knora-base:previousValue* ?value . + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . + } + + OPTIONAL { + ?value knora-base:valueCreationDate ?valueCreationDate . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.getVersionHistoryStandard(triplestore = triplestore, - resourceIri = resourceIri, - propertyIri = propertyIri, - currentValueIri = currentValueIri) + + OPTIONAL { + ?value knora-base:previousValue ?previousValue . } + + OPTIONAL { + ?value rdf:type knora-base:LinkValue . + ?value rdf:predicate ?linkValuePredicate . + BIND(true as ?isLinkValue) + } + + ?value knora-base:attachedToUser ?valueCreator . } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistoryGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistoryGraphDB.scala.txt deleted file mode 100644 index 059949dbcd..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistoryGraphDB.scala.txt +++ /dev/null @@ -1,63 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Returns all versions of a value. - * - * This template is used only by getVersionHistory.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subproperties of Knora base properties - * such as knora-base:hasValue. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param resourceIri the resource to search. - * @param propertyIri the property to search. - * @param currentValueIri the most recent version of the value. - * - * Returns nothing if currentValueIri is not the most recent version. - *@ - @(resourceIri: IRI, - propertyIri: IRI, - currentValueIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?value ?valueCreationDate ?previousValue ?isLinkValue ?linkValuePredicate ?valueCreator ?project ?valuePermissions -WHERE { - BIND(IRI("@resourceIri") AS ?resource) - BIND(IRI("@propertyIri") AS ?prop) - BIND(IRI("@currentValueIri") AS ?currentValue) - - ?resource knora-base:isDeleted false . - - ?currentValue knora-base:isDeleted false ; - knora-base:hasPermissions ?valuePermissions . - - ?resource knora-base:hasValue ?currentValue ; - knora-base:attachedToProject ?project . - - ?currentValue knora-base:previousValue* ?value . - - OPTIONAL { - ?value knora-base:valueCreationDate ?valueCreationDate . - } - - OPTIONAL { - ?value knora-base:previousValue ?previousValue . - } - - OPTIONAL { - ?value rdf:type knora-base:LinkValue . - ?value rdf:predicate ?linkValuePredicate . - BIND(true as ?isLinkValue) - } - - ?value knora-base:attachedToUser ?valueCreator . -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistoryStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistoryStandard.scala.txt deleted file mode 100644 index 9a0db72387..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/getVersionHistoryStandard.scala.txt +++ /dev/null @@ -1,66 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Returns all versions of a value, using standard SPARQL, without inference. - * - * This template is used only by getVersionHistory.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param resourceIri the resource to search. - * @param propertyIri the property to search. - * @param currentValueIri the most recent version of the value. - * - * Returns nothing if currentValueIri is not the most recent version. - *@ - @(triplestore: String, - resourceIri: IRI, - propertyIri: IRI, - currentValueIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?value ?valueCreationDate ?previousValue ?isLinkValue ?linkValuePredicate ?valueCreator ?project ?valuePermissions -WHERE { - BIND(IRI("@resourceIri") AS ?resource) - BIND(IRI("@propertyIri") AS ?prop) - BIND(IRI("@currentValueIri") AS ?currentValue) - - ?currentValue knora-base:hasPermissions ?valuePermissions . - - FILTER NOT EXISTS { - ?currentValue knora-base:isDeleted true . - } - - ?resource ?prop ?currentValue . - ?prop rdfs:subPropertyOf* knora-base:hasValue . - ?resource knora-base:attachedToProject ?project . - - ?currentValue knora-base:previousValue* ?value . - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - OPTIONAL { - ?value knora-base:valueCreationDate ?valueCreationDate . - } - - OPTIONAL { - ?value knora-base:previousValue ?previousValue . - } - - OPTIONAL { - ?value rdf:type knora-base:LinkValue . - ?value rdf:predicate ?linkValuePredicate . - BIND(true as ?isLinkValue) - } - - ?value knora-base:attachedToUser ?valueCreator . -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOf.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOf.scala.txt index 5d081a33ac..a8e77d0e8c 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOf.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOf.scala.txt @@ -6,10 +6,8 @@ @import org.knora.webapi.IRI @** - * Given the IRI of a resource, finds any other resource that contains the specified resource. - * - * If the triplestore type is GraphDB, this template delegates to isPartOfGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to isPartOfStandard.sparql.txt. + * Given the IRI of a resource, finds any other resource that contains the specified resource + * using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param resourceIri the resource whose containing resource, if any, is to be returned. @@ -17,13 +15,36 @@ @(triplestore: String, resourceIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.isPartOfGraphDB(resourceIri = resourceIri) +prefix rdf: +prefix rdfs: +prefix knora-base: + +SELECT ?containingResource ?containingResourceProject ?linkValue ?linkValueCreator ?linkValuePermissions +WHERE { + BIND(IRI("@resourceIri") as ?resource) + + ?linkingProp rdfs:subPropertyOf* knora-base:isPartOf . + ?resource ?linkingProp ?containingResource . + ?containingResource knora-base:isDeleted false ; + knora-base:attachedToProject ?containingResourceProject . + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.isPartOfStandard(triplestore = triplestore, - resourceIri = resourceIri) + + BIND(IRI(CONCAT(STR(?linkingProp), "Value")) AS ?linkValueProp) + + ?resource ?linkValueProp ?linkValue . + + ?linkValue rdf:type knora-base:LinkValue ; + rdf:subject ?resource ; + rdf:predicate ?linkingProp ; + rdf:object ?containingResource ; + knora-base:attachedToUser ?linkValueCreator ; + knora-base:hasPermissions ?linkValuePermissions . + + FILTER NOT EXISTS { + ?linkValue knora-base:isDeleted true . } } +LIMIT 1 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOfGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOfGraphDB.scala.txt deleted file mode 100644 index e678341db2..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOfGraphDB.scala.txt +++ /dev/null @@ -1,52 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Given the IRI of a resource, finds any other resource that contains the specified resource, using GraphDB. - * - * This template is used only by isPartOf.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subproperties of Knora base properties - * such as knora-base:isPartOf. This requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param resourceIri the resource whose containing resource, if any, is to be returned. - *@ -@(resourceIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?containingResource ?containingResourceProject ?linkValue ?linkValueCreator ?linkValuePermissions -WHERE { - BIND(IRI("@resourceIri") as ?resource) - - ?resource a knora-base:Resource ; - knora-base:isDeleted false ; - knora-base:isPartOf ?containingResource . - - ?containingResource a knora-base:Resource ; - knora-base:isDeleted false ; - knora-base:attachedToProject ?containingResourceProject . - - GRAPH { - ?resource ?linkingProp ?containingResource . - } - - ?resource knora-base:hasLinkToValue ?linkValue . - - ?linkValue rdf:type knora-base:LinkValue ; - rdf:subject ?resource ; - rdf:predicate ?linkingProp ; - rdf:object ?containingResource ; - knora-base:isDeleted false ; - knora-base:attachedToUser ?linkValueCreator ; - knora-base:hasPermissions ?linkValuePermissions . -} -LIMIT 1 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOfStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOfStandard.scala.txt deleted file mode 100644 index 535b14c796..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/isPartOfStandard.scala.txt +++ /dev/null @@ -1,52 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI - -@** - * Given the IRI of a resource, finds any other resource that contains the specified resource, using standard SPARQL, - * without inference. - * - * This template is used only by isPartOf.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param resourceIri the resource whose containing resource, if any, is to be returned. - *@ -@(triplestore: String, - resourceIri: IRI) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT ?containingResource ?containingResourceProject ?linkValue ?linkValueCreator ?linkValuePermissions -WHERE { - BIND(IRI("@resourceIri") as ?resource) - - ?linkingProp rdfs:subPropertyOf* knora-base:isPartOf . - ?resource ?linkingProp ?containingResource . - ?containingResource knora-base:isDeleted false ; - knora-base:attachedToProject ?containingResourceProject . - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - BIND(IRI(CONCAT(STR(?linkingProp), "Value")) AS ?linkValueProp) - - ?resource ?linkValueProp ?linkValue . - - ?linkValue rdf:type knora-base:LinkValue ; - rdf:subject ?resource ; - rdf:predicate ?linkingProp ; - rdf:object ?containingResource ; - knora-base:attachedToUser ?linkValueCreator ; - knora-base:hasPermissions ?linkValuePermissions . - - FILTER NOT EXISTS { - ?linkValue knora-base:isDeleted true . - } -} -LIMIT 1 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtended.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtended.scala.txt index 594ddad3b3..fc0f9ae217 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtended.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtended.scala.txt @@ -9,11 +9,10 @@ @import org.knora.webapi.messages.v1.responder.searchmessages.SearchComparisonOperatorV1 @** - * Performs an extended search. The number of rows returned per matching resource is the product of the number of - * values that each search criterion matched in the resource. + * Performs an extended search using SPARQL w/o inference (except for the interface to Lucene, which is triplestore-specific). * - * If the triplestore type is GraphDB, this template delegates to searchExtendedGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to searchExtendedStandard.sparql.txt. + * The number of rows returned per matching resource is the product of the number of values that each search criterion + * matched in the resource. * * @param triplestore the name of the triplestore being used. * @param searchCriteria a list of maps containing search criteria, each of which contains: @@ -31,23 +30,606 @@ restypeIriOption: Option[IRI], ownerIriOption: Option[IRI]) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.searchExtendedGraphDB(searchCriteria = searchCriteria, - preferredLanguage = preferredLanguage, - fallbackLanguage = fallbackLanguage, - projectIriOption = projectIriOption, - restypeIriOption = restypeIriOption, - ownerIriOption = ownerIriOption) +prefix rdf: +prefix rdfs: +prefix knora-base: +prefix xsd: + +SELECT DISTINCT + ?resource + ?resourceLabel @* The label of a matching resource. This is called "firstprop" in the v1 API. *@ + ?resourceClass + ?previewPath + ?previewDimX + ?previewDimY + ?resourceCreator + ?resourceProject + ?resourcePermissions + @for((searchCriterion, index) <- searchCriteria.zipWithIndex) { + ?valueObject@index + ?valueCreator@index + ?valuePermissions@index + ?targetResource@index + ?targetResourceCreator@index + ?targetResourceProject@index + ?targetResourcePermissions@index + ?literal@index + } +WHERE { + BIND(STR("@preferredLanguage") AS ?preferredLanguage) + BIND(STR("@fallbackLanguage") AS ?fallbackLanguage) + + @for((searchCriterion, index) <- searchCriteria.zipWithIndex) { + + # Search criterion @index: operator @searchCriterion.comparisonOperator + + @* + + If this search criterion involves a property that points to a knora-base:Value, find a resource that has + that property pointing to some value. If this search criterion involves a link property, the property will + point to another resource, and this is handled in the cases for comparison operators EQ and EXISTS in the + match-case expression below. + + *@ + + @if(searchCriterion.valueType != "http://www.knora.org/ontology/knora-base#Resource") { + + ?p@index rdfs:subPropertyOf* <@searchCriterion.propertyIri> . + ?resource ?p@index ?valueObject@index . + + } + + @* + + possible values of searchCriterion.comparisonOperator: EXISTS, EQ, NOT_EQ, GT, GT_EQ, LT, LT_EQ, MATCH, MATCH_BOOLEAN, LIKE, NOT_LIKE, IN + + *@ + + @searchCriterion.comparisonOperator match { + + case SearchComparisonOperatorV1.MATCH => { + + @* + + TODO: Handle single search terms correctly: combine them with an AND + + *@ + + @triplestore match { + + case "embedded-jena-tdb" | "fuseki" => { + + ?valueObject@index ( '@searchCriterion.searchValue' ) . + ?valueObject@index knora-base:valueHasString ?literal@index . + + } + + case other => { + @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} + } + } + } + + case SearchComparisonOperatorV1.LIKE => { + + @* TODO: escape regex metachars *@ + ?valueObject@index knora-base:valueHasString ?literal@index . + + FILTER regex(?literal@index, '@searchCriterion.searchValue', "i") + } + + case SearchComparisonOperatorV1.NOT_LIKE => { + + @* + + Previously we used FILTER NOT EXISTS here, but then we couldn't get the value of ?literal + (the literal that doesn't match the regex). So now we use just a negated regex. However, if a + resource has two instances of the same property and one of them matches and the other doesn't, + it will be returned in the search results. + + *@ + + ?valueObject@index knora-base:valueHasString ?literal@index . + + FILTER (!regex(?literal@index, '@searchCriterion.searchValue', "i")) + } + + case SearchComparisonOperatorV1.EXISTS => { + + @searchCriterion.valueType match { + case "http://www.knora.org/ontology/knora-base#Resource" => { + + ?linkProperty@index rdfs:subPropertyOf* <@searchCriterion.propertyIri> . + ?resource ?linkProperty@index ?targetResource@index . + ?linkValueProperty@index rdfs:subPropertyOf* <@{searchCriterion.propertyIri}Value> . + ?resource ?linkValueProperty@index ?valueObject@index . + + ?targetResource@index rdfs:label ?literal@index ; + knora-base:isDeleted false ; + knora-base:attachedToUser ?targetResourceCreator@index ; + knora-base:attachedToProject ?targetResourceProject@index ; + knora-base:hasPermissions ?targetResourcePermissions@index . + + ?valueObject@index rdf:type knora-base:LinkValue ; + rdf:subject ?resource ; + rdf:predicate ?linkProperty@index ; + rdf:object ?targetResource@index . + } + + case other => { + + ?valueObject@index knora-base:valueHasString ?literal@index . + + } + } + } + + case SearchComparisonOperatorV1.EQ => { + + @searchCriterion.valueType match { + + case "http://www.knora.org/ontology/knora-base#TextValue" => { + + ?valueObject@index knora-base:valueHasString '@searchCriterion.searchValue' . + + BIND('@searchCriterion.searchValue' AS ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#IntValue" => { + + ?valueObject@index knora-base:valueHasInteger @searchCriterion.searchValue . + + BIND('@searchCriterion.searchValue' AS ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#DecimalValue" => { + + ?valueObject@index knora-base:valueHasDecimal "@searchCriterion.searchValue"^^xsd:decimal . + + BIND('@searchCriterion.searchValue' AS ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#TimeValue" => { + + ?valueObject@index knora-base:valueHasTimeStamp "@searchCriterion.searchValue"^^xsd:dateTime . + + BIND('@searchCriterion.searchValue' AS ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#DateValue" => { + + ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . + ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . + ?valueObject@index knora-base:valueHasString ?dateString@index . + + FILTER (@searchCriterion.dateStart <= ?dateEnd@index && @searchCriterion.dateEnd >= ?dateStart@index) + BIND(?dateString@index as ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#Resource" => { + + BIND(IRI("@searchCriterion.searchValue") AS ?targetResource@index) + + ?linkProperty@index rdfs:subPropertyOf* <@searchCriterion.propertyIri> . + ?resource ?linkProperty@index <@searchCriterion.searchValue> . + ?linkValueProperty@index rdfs:subPropertyOf* <@{searchCriterion.propertyIri}Value> . + ?resource ?linkValueProperty@index ?valueObject@index . + + <@searchCriterion.searchValue> rdfs:label ?literal@index ; + knora-base:isDeleted false ; + knora-base:attachedToUser ?targetResourceCreator@index ; + knora-base:attachedToProject ?targetResourceProject@index ; + knora-base:hasPermissions ?targetResourcePermissions@index . + + ?valueObject@index rdf:type knora-base:LinkValue ; + rdf:subject ?resource ; + rdf:predicate ?linkProperty@index ; + rdf:object <@searchCriterion.searchValue> . + } + + case "http://www.knora.org/ontology/knora-base#ListValue" => { + + @* + + Get all the subnodes of the given node, including the given node (operator *) + + *@ + + ?valueObject@index knora-base:valueHasListNode ?listNode@index . + <@searchCriterion.searchValue> knora-base:hasSubListNode* ?listNode@index . + + ?listNode@index rdfs:label ?listNodeLabel@index . + BIND(?listNodeLabel@index AS ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#BooleanValue" => { + + ?valueObject@index knora-base:valueHasBoolean @searchCriterion.searchValue . + + BIND('@searchCriterion.searchValue' AS ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#GeonameValue" => { + + ?valueObject@index knora-base:valueHasGeonameCode '@searchCriterion.searchValue' . + + BIND('@searchCriterion.searchValue' AS ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#UriValue" => { + + ?valueObject@index knora-base:valueHasUri '@searchCriterion.searchValue'^^xsd:anyURI . + + BIND('@searchCriterion.searchValue' AS ?literal@index) + + } + + case other => { + @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} + } + } + } + + case SearchComparisonOperatorV1.NOT_EQ => { + + @searchCriterion.valueType match { + + case "http://www.knora.org/ontology/knora-base#TextValue" => { + + ?valueObject@index knora-base:valueHasString ?literal@index . + + FILTER (?literal@index != '@searchCriterion.searchValue') + + } + + case "http://www.knora.org/ontology/knora-base#IntValue" => { + + ?valueObject@index knora-base:valueHasInteger ?literal@index . + + FILTER (?literal@index != @searchCriterion.searchValue) + + } + + case "http://www.knora.org/ontology/knora-base#DecimalValue" => { + + ?valueObject@index knora-base:valueHasDecimal ?literal@index . + + FILTER (?literal@index != "@searchCriterion.searchValue"^^xsd:decimal) + + } + + case "http://www.knora.org/ontology/knora-base#TimeValue" => { + + ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . + + FILTER (?literal@index != "@searchCriterion.searchValue"^^xsd:dateTime) + + } + + case "http://www.knora.org/ontology/knora-base#DateValue" => { + + ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . + ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . + ?valueObject@index knora-base:valueHasString ?dateString@index . + + FILTER (@searchCriterion.dateEnd < ?dateStart@index || @searchCriterion.dateStart > ?dateEnd@index ) + BIND(?dateString@index as ?literal@index) + + } + + case "http://www.knora.org/ontology/knora-base#BooleanValue" => { + + ?valueObject@index knora-base:valueHasBoolean ?literal@index . + + FILTER (?literal@index != @searchCriterion.searchValue) + + } + + case other => { + @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} + } + } + } + + case SearchComparisonOperatorV1.GT => { + + @searchCriterion.valueType match { + + case "http://www.knora.org/ontology/knora-base#IntValue" => { + + ?valueObject@index knora-base:valueHasInteger ?literal@index . + + FILTER (?literal@index > @searchCriterion.searchValue) + + } + + case "http://www.knora.org/ontology/knora-base#DecimalValue" => { + + ?valueObject@index knora-base:valueHasDecimal ?literal@index . + + FILTER (?literal@index > "@searchCriterion.searchValue"^^xsd:decimal ) + + } + + case "http://www.knora.org/ontology/knora-base#TimeValue" => { + + ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . + + FILTER (?literal@index > "@searchCriterion.searchValue"^^xsd:dateTime ) + + } + + case "http://www.knora.org/ontology/knora-base#DateValue" => { + + ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . + ?valueObject@index knora-base:valueHasString ?dateString@index . + + FILTER (?dateStart@index > @searchCriterion.dateEnd) + BIND(?dateString@index as ?literal@index) + + } + + case other => { + @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} + } + } + } + + case SearchComparisonOperatorV1.GT_EQ => { + + @searchCriterion.valueType match { + + case "http://www.knora.org/ontology/knora-base#IntValue" => { + + ?valueObject@index knora-base:valueHasInteger ?literal@index . + + FILTER (?literal@index >= @searchCriterion.searchValue) + + } + + case "http://www.knora.org/ontology/knora-base#DecimalValue" => { + + ?valueObject@index knora-base:valueHasDecimal ?literal@index . + + FILTER (?literal@index >= "@searchCriterion.searchValue"^^xsd:decimal) + + } + + case "http://www.knora.org/ontology/knora-base#TimeValue" => { + + ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . + + FILTER (?literal@index >= "@searchCriterion.searchValue"^^xsd:dateTime) + + } + + case "http://www.knora.org/ontology/knora-base#DateValue" => { + + ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . + ?valueObject@index knora-base:valueHasString ?dateString@index . + + FILTER(?dateEnd@index >= @searchCriterion.dateStart) + BIND(?dateString@index as ?literal@index) + + } + + case other => { + @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} + } + } + } + + case SearchComparisonOperatorV1.LT => { + + @searchCriterion.valueType match { + + case "http://www.knora.org/ontology/knora-base#IntValue" => { + + ?valueObject@index knora-base:valueHasInteger ?literal@index . + + FILTER (?literal@index < @searchCriterion.searchValue) + + } + + case "http://www.knora.org/ontology/knora-base#DecimalValue" => { + + ?valueObject@index knora-base:valueHasDecimal ?literal@index . + + FILTER (?literal@index < "@searchCriterion.searchValue"^^xsd:decimal) + + } + + case "http://www.knora.org/ontology/knora-base#TimeValue" => { + + ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . + + FILTER (?literal@index < "@searchCriterion.searchValue"^^xsd:dateTime) + + } + + case "http://www.knora.org/ontology/knora-base#DateValue" => { + + ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . + ?valueObject@index knora-base:valueHasString ?dateString@index . + + FILTER (?dateEnd@index < @searchCriterion.dateStart) + BIND(?dateString@index as ?literal@index) + + } + + case other => { + @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} + } + } + } + + case SearchComparisonOperatorV1.LT_EQ => { + + @searchCriterion.valueType match { + + case "http://www.knora.org/ontology/knora-base#IntValue" => { + + ?valueObject@index knora-base:valueHasInteger ?literal@index . + + FILTER (?literal@index <= @searchCriterion.searchValue) + + } + + case "http://www.knora.org/ontology/knora-base#DecimalValue" => { + + ?valueObject@index knora-base:valueHasDecimal ?literal@index . + + FILTER (?literal@index <= "@searchCriterion.searchValue"^^xsd:decimal) + + } + + case "http://www.knora.org/ontology/knora-base#TimeValue" => { + + ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . + + FILTER (?literal@index <= "@searchCriterion.searchValue"^^xsd:dateTime) + + } + + case "http://www.knora.org/ontology/knora-base#DateValue" => { + + ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . + ?valueObject@index knora-base:valueHasString ?dateString@index . + + FILTER (?dateStart@index <= @searchCriterion.dateEnd) + BIND(?dateString@index as ?literal@index) + + } + + case other => { + @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} + } + } + } + + case SearchComparisonOperatorV1.MATCH_BOOLEAN => { + + @* see https://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html *@ + + ?valueObject@index knora-base:valueHasString ?literal@index . + + @for(positiveTerm <- searchCriterion.matchBooleanPositiveTerms) { + + @triplestore match { + + case "embedded-jena-tdb" | "fuseki" => { + + ?valueObject@index ( '@positiveTerm' ) . + + } + + case other => { + @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} + } + } + } + + @if(searchCriterion.matchBooleanNegativeTerms.nonEmpty) { + FILTER NOT EXISTS { + @for(negativeTerm <- searchCriterion.matchBooleanNegativeTerms) { + + @triplestore match { + + case "embedded-jena-tdb" | "fuseki" => { + + ?valueObject@index ( '@negativeTerm' ) . + + } + + case other => { + @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} + } + } + } + } + } + } + + case other => { + @{throw SparqlGenerationException(s"Comparison operator $other is not supported in this SPARQL template"); ()} + } + } + + ?valueObject@index knora-base:isDeleted false ; + knora-base:attachedToUser ?valueCreator@index ; + knora-base:hasPermissions ?valuePermissions@index . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.searchExtendedStandard(triplestore = triplestore, - searchCriteria = searchCriteria, - preferredLanguage = preferredLanguage, - fallbackLanguage = fallbackLanguage, - projectIriOption = projectIriOption, - restypeIriOption = restypeIriOption, - ownerIriOption = ownerIriOption) + + @projectIriOption match { + case Some(projectIri) => { + + # filter by projectIri + ?resource knora-base:attachedToProject <@projectIri> . + + } + + case None => {} } + + @restypeIriOption match { + + case Some(restypeIri) => { + + # Filter by resource class. + + ?resClass rdfs:subClassOf* <@restypeIri> . + ?resource a ?resClass . + + } + + case None => { + + @* Ensure that each matching resource is a knora-base:Resource. *@ + + ?resClass rdfs:subClassOf* knora-base:Resource . + ?resource a ?resClass . + + } + } + + @ownerIriOption match { + case Some(ownerIri) => { + + # filter by ownerIri + ?resource knora-base:attachedToUser <@ownerIri> . + } + + case None => {} + } + + ?resource rdfs:label ?resourceLabel . + + OPTIONAL { + ?resource knora-base:hasStillImageFileValue ?fileValue . + ?fileValue a knora-base:StillImageFileValue . + ?fileValue knora-base:internalFilename ?previewPath . + + OPTIONAL { + ?fileValue knora-base:dimX ?previewDimX . + ?fileValue knora-base:dimY ?previewDimY . + } + } + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . + } + + ?resource a ?resourceClass ; + knora-base:hasPermissions ?resourcePermissions ; + knora-base:attachedToUser ?resourceCreator ; + knora-base:attachedToProject ?resourceProject . } +LIMIT 500 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtendedGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtendedGraphDB.scala.txt deleted file mode 100644 index ca855b2ef1..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtendedGraphDB.scala.txt +++ /dev/null @@ -1,644 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.messages.twirl.SearchCriterion -@import org.knora.webapi.messages.v1.responder.searchmessages.SearchComparisonOperatorV1 - -@** - * Performs an extended search using GraphDB. The number of rows returned per matching resource is the product of the - * number of values that each search criterion matched in the resource. - * - * This template is used only by searchExtended.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subclasses and subproperties of the ones - * specified in the search criteria. This inference requires us to use GraphDB's GRAPH - * whenever we need to get explicit (non-inferred) statements. - * - * @param searchCriteria a list of maps containing search criteria, each of which contains: - * @param preferredLanguage the language code of the user's preferred language. - * @param fallbackLanguage the language code of the application's default language. - * @param projectIriOption if filtering by project is desired, the IRI of the project to search. - * @param restypeIriOption if given, returns only resources of this class and its subclasses. - * @param ownerIriOption if filtering by owner is desired, the IRI of the resource owner to search for. - *@ -@(searchCriteria: Seq[SearchCriterion], - preferredLanguage: String, - fallbackLanguage: String, - projectIriOption: Option[IRI], - restypeIriOption: Option[IRI], - ownerIriOption: Option[IRI]) - -prefix rdf: -prefix rdfs: -prefix knora-base: -prefix xsd: - -SELECT DISTINCT - ?resource - ?resourceLabel @* The label of a matching resource. This is called "firstprop" in the v1 API. *@ - ?resourceClass - ?previewPath - ?previewDimX - ?previewDimY - ?resourceCreator - ?resourceProject - ?resourcePermissions - @for((searchCriterion, index) <- searchCriteria.zipWithIndex) { - ?valueObject@index - ?valueCreator@index - ?valuePermissions@index - ?targetResource@index - ?targetResourceCreator@index - ?targetResourceProject@index - ?targetResourcePermissions@index - ?literal@index - } -WHERE { - BIND(STR("@preferredLanguage") AS ?preferredLanguage) - BIND(STR("@fallbackLanguage") AS ?fallbackLanguage) - - @for((searchCriterion, index) <- searchCriteria.zipWithIndex) { - - # Search criterion @index: operator @searchCriterion.comparisonOperator - - @* - - If this search criterion involves a property that points to a knora-base:Value, find a resource that has - that property pointing to some value. If this search criterion involves a link property, the property will - point to another resource, and this is handled in the cases for comparison operators EQ and EXISTS in the - match-case expression below. - - *@ - - @if(searchCriterion.valueType != "http://www.knora.org/ontology/knora-base#Resource") { - - ?resource <@searchCriterion.propertyIri> ?valueObject@index . - - } - - @* - - possible values of searchCriterion.comparisonOperator: EXISTS, EQ, NOT_EQ, GT, GT_EQ, LT, LT_EQ, MATCH, MATCH_BOOLEAN, LIKE, NOT_LIKE, IN - - *@ - - @searchCriterion.comparisonOperator match { - - case SearchComparisonOperatorV1.MATCH => { - - ?valueObject@index knora-base:valueHasString ?literal@index . - ?literal@index '@searchCriterion.searchValue' . - - } - - case SearchComparisonOperatorV1.LIKE => { - - @* TODO: escape regex metachars *@ - ?valueObject@index knora-base:valueHasString ?literal@index . - - FILTER regex(?literal@index, '@searchCriterion.searchValue', "i") - } - - case SearchComparisonOperatorV1.NOT_LIKE => { - - @* - - Previously we used FILTER NOT EXISTS here, but then we couldn't get the value of ?literal - (the literal that doesn't match the regex). So now we use just a negated regex. However, if a - resource has two instances of the same property and one of them matches and the other doesn't, - it will be returned in the search results. - - *@ - - ?valueObject@index knora-base:valueHasString ?literal@index . - - FILTER (!regex(?literal@index, '@searchCriterion.searchValue', "i")) - } - - case SearchComparisonOperatorV1.EXISTS => { - - @searchCriterion.valueType match { - case "http://www.knora.org/ontology/knora-base#Resource" => { - - ?resource <@searchCriterion.propertyIri> ?targetResource@index . - ?resource <@{searchCriterion.propertyIri}Value> ?valueObject@index . - - GRAPH { - ?resource ?linkProperty@index ?targetResource@index . - } - - ?targetResource@index rdfs:label ?literal@index ; - knora-base:isDeleted false ; - knora-base:attachedToUser ?targetResourceCreator@index ; - knora-base:attachedToProject ?targetResourceProject@index ; - knora-base:hasPermissions ?targetResourcePermissions@index . - - ?valueObject@index rdf:type knora-base:LinkValue ; - rdf:subject ?resource ; - rdf:predicate ?linkProperty@index ; - rdf:object ?targetResource@index . - } - - case other => { - - ?valueObject@index knora-base:valueHasString ?literal@index . - - } - } - } - - case SearchComparisonOperatorV1.EQ => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#TextValue" => { - - ?valueObject@index knora-base:valueHasString '@searchCriterion.searchValue' . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger @searchCriterion.searchValue . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal "@searchCriterion.searchValue"^^xsd:decimal . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp "@searchCriterion.searchValue"^^xsd:dateTime . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . - ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - @* - - This condition checks whether the defined criterion for a date value and a resource's date value overlap. - - Since dates are represented as periods, equality is given if a date value's period ends after or equals the start of the defined period (search criterion date start) and - a date value's period starts before or equals the end of the defined period (search criterion date end). - - Formally, equality is the negation of inequality of two given dates. Inequality (see below) is given if a date value's period starts after the end of the defined period (search criterion date end) or - ends before the start of the defined period (search criterion date start). - - Negation of the filter expression for inequality: - - FILTER (!(@searchCriterion.dateStart > ?dateEnd@index || @searchCriterion.dateEnd < ?dateStart@index)) - - Following De Morgan's laws, the expression can be rewritten by negating both parts of the expression and combining them with a logical AND: - - FILTER(!(@searchCriterion.dateStart > ?dateEnd@index) && !(@searchCriterion.dateEnd < ?dateStart@index)) - - which can be then further simplified to the expression stated below. - - *@ - FILTER (@searchCriterion.dateStart <= ?dateEnd@index && @searchCriterion.dateEnd >= ?dateStart@index) - BIND(?dateString@index as ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#Resource" => { - - BIND(IRI("@searchCriterion.searchValue") AS ?targetResource@index) - - ?resource <@searchCriterion.propertyIri> <@searchCriterion.searchValue> . - ?resource <@{searchCriterion.propertyIri}Value> ?valueObject@index . - - GRAPH { - ?resource ?linkProperty@index <@searchCriterion.searchValue> . - } - - <@searchCriterion.searchValue> rdfs:label ?literal@index ; - knora-base:isDeleted false ; - knora-base:attachedToUser ?targetResourceCreator@index ; - knora-base:attachedToProject ?targetResourceProject@index ; - knora-base:hasPermissions ?targetResourcePermissions@index . - - ?valueObject@index rdf:type knora-base:LinkValue ; - rdf:subject ?resource ; - rdf:predicate ?linkProperty@index ; - rdf:object <@searchCriterion.searchValue> . - } - - case "http://www.knora.org/ontology/knora-base#ListValue" => { - - @* - - Get all the subnodes of the given node, including the given node (operator *) - - *@ - - ?valueObject@index knora-base:valueHasListNode ?listNode@index . - <@searchCriterion.searchValue> knora-base:hasSubListNode* ?listNode@index . - - ?listNode@index rdfs:label ?listNodeLabel@index . - BIND(?listNodeLabel@index AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#BooleanValue" => { - - ?valueObject@index knora-base:valueHasBoolean @searchCriterion.searchValue . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#GeonameValue" => { - - ?valueObject@index knora-base:valueHasGeonameCode '@searchCriterion.searchValue' . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#UriValue" => { - - ?valueObject@index knora-base:valueHasUri '@searchCriterion.searchValue'^^xsd:anyURI . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.NOT_EQ => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#TextValue" => { - - ?valueObject@index knora-base:valueHasString ?literal@index . - - FILTER (?literal@index != '@searchCriterion.searchValue') - - } - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index != @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index != "@searchCriterion.searchValue"^^xsd:decimal) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index != "@searchCriterion.searchValue"^^xsd:dateTime) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . - ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER (@searchCriterion.dateEnd < ?dateStart@index || @searchCriterion.dateStart > ?dateEnd@index ) - BIND(?dateString@index as ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#BooleanValue" => { - - ?valueObject@index knora-base:valueHasBoolean ?literal@index . - - FILTER (?literal@index != @searchCriterion.searchValue) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.GT => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index > @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index > "@searchCriterion.searchValue"^^xsd:decimal ) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index > "@searchCriterion.searchValue"^^xsd:dateTime ) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER (?dateStart@index > @searchCriterion.dateEnd) - BIND(?dateString@index as ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.GT_EQ => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index >= @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index >= "@searchCriterion.searchValue"^^xsd:decimal) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index >= "@searchCriterion.searchValue"^^xsd:dateTime) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - @* - - Logically, GT_EQ is the negation of LT (see below): - - FILTER (!(?dateEnd@index < @searchCriterion.dateStart)) - - This can be further simplified to the expression stated below. - - *@ - - FILTER(?dateEnd@index >= @searchCriterion.dateStart) - BIND(?dateString@index as ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.LT => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index < @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index < "@searchCriterion.searchValue"^^xsd:decimal) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index < "@searchCriterion.searchValue"^^xsd:dateTime) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER (?dateEnd@index < @searchCriterion.dateStart) - BIND(?dateString@index as ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.LT_EQ => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index <= @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index <= "@searchCriterion.searchValue"^^xsd:decimal) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index <= "@searchCriterion.searchValue"^^xsd:dateTime) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - @* - - Logically, LT_EQ is the negation of GT (see above): - - FILTER (!(?dateStart@index > @searchCriterion.dateEnd)) - - This can be further simplified to the expression stated below. - - *@ - - FILTER (?dateStart@index <= @searchCriterion.dateEnd) - BIND(?dateString@index as ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.MATCH_BOOLEAN => { - - @* see https://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html *@ - - ?valueObject@index knora-base:valueHasString ?literal@index . - - @for(positiveTerm <- searchCriterion.matchBooleanPositiveTerms) { - - ?literal@index '@positiveTerm' . - - } - - @if(searchCriterion.matchBooleanNegativeTerms.nonEmpty) { - FILTER NOT EXISTS { - @for(negativeTerm <- searchCriterion.matchBooleanNegativeTerms) { - - ?literal@index '@negativeTerm' . - - } - } - } - } - - case other => { - @{throw SparqlGenerationException(s"Comparison operator $other is not supported in this SPARQL template"); ()} - } - } - - ?valueObject@index knora-base:isDeleted false ; - knora-base:attachedToUser ?valueCreator@index ; - knora-base:hasPermissions ?valuePermissions@index . - } - - ?resource knora-base:isDeleted false . - - @projectIriOption match { - case Some(projectIri) => { - - # filter by projectIri - ?resource knora-base:attachedToProject <@projectIri> . - - } - - case None => {} - } - - GRAPH { - ?resource a ?resourceClass . - } - - @restypeIriOption match { - - case Some(restypeIri) => { - - # Filter by resource class. - - ?resource a <@restypeIri> . - - } - - case None => { - - @* Ensure that each matching resource is a knora-base:Resource. *@ - - ?resource a knora-base:Resource . - } - } - - @ownerIriOption match { - case Some(ownerIri) => { - - # filter by ownerIri - ?resource knora-base:attachedToUser <@ownerIri> . - } - - case None => {} - } - - ?resource rdfs:label ?resourceLabel . - - OPTIONAL { - ?resource knora-base:hasStillImageFileValue ?fileValue . - ?fileValue a knora-base:StillImageFileValue . - ?fileValue knora-base:internalFilename ?previewPath . - - OPTIONAL { - ?fileValue knora-base:dimX ?previewDimX . - ?fileValue knora-base:dimY ?previewDimY . - } - } - - ?resource knora-base:hasPermissions ?resourcePermissions ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:attachedToProject ?resourceProject . -} -LIMIT 500 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtendedStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtendedStandard.scala.txt deleted file mode 100644 index f810a3584c..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchExtendedStandard.scala.txt +++ /dev/null @@ -1,638 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.messages.twirl.SearchCriterion -@import org.knora.webapi.messages.v1.responder.searchmessages.SearchComparisonOperatorV1 - -@** - * Performs an extended search using standard SPARQL (except for the interface to Lucene, which is triplestore-specific), - * and without inference. - * - * The number of rows returned per matching resource is the product of the number of values that each search criterion - * matched in the resource. - * - * This template is used only by searchExtended.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param searchCriteria a list of maps containing search criteria, each of which contains: - * @param preferredLanguage the language code of the user's preferred language. - * @param fallbackLanguage the language code of the application's default language. - * @param projectIriOption if filtering by project is desired, the IRI of the project to search. - * @param restypeIriOption if given, returns only resources of this class and its subclasses. - * @param ownerIriOption if filtering by owner is desired, the IRI of the resource owner to search for. - *@ -@(triplestore: String, - searchCriteria: Seq[SearchCriterion], - preferredLanguage: String, - fallbackLanguage: String, - projectIriOption: Option[IRI], - restypeIriOption: Option[IRI], - ownerIriOption: Option[IRI]) - -prefix rdf: -prefix rdfs: -prefix knora-base: -prefix xsd: - -SELECT DISTINCT - ?resource - ?resourceLabel @* The label of a matching resource. This is called "firstprop" in the v1 API. *@ - ?resourceClass - ?previewPath - ?previewDimX - ?previewDimY - ?resourceCreator - ?resourceProject - ?resourcePermissions - @for((searchCriterion, index) <- searchCriteria.zipWithIndex) { - ?valueObject@index - ?valueCreator@index - ?valuePermissions@index - ?targetResource@index - ?targetResourceCreator@index - ?targetResourceProject@index - ?targetResourcePermissions@index - ?literal@index - } -WHERE { - BIND(STR("@preferredLanguage") AS ?preferredLanguage) - BIND(STR("@fallbackLanguage") AS ?fallbackLanguage) - - @for((searchCriterion, index) <- searchCriteria.zipWithIndex) { - - # Search criterion @index: operator @searchCriterion.comparisonOperator - - @* - - If this search criterion involves a property that points to a knora-base:Value, find a resource that has - that property pointing to some value. If this search criterion involves a link property, the property will - point to another resource, and this is handled in the cases for comparison operators EQ and EXISTS in the - match-case expression below. - - *@ - - @if(searchCriterion.valueType != "http://www.knora.org/ontology/knora-base#Resource") { - - ?p@index rdfs:subPropertyOf* <@searchCriterion.propertyIri> . - ?resource ?p@index ?valueObject@index . - - } - - @* - - possible values of searchCriterion.comparisonOperator: EXISTS, EQ, NOT_EQ, GT, GT_EQ, LT, LT_EQ, MATCH, MATCH_BOOLEAN, LIKE, NOT_LIKE, IN - - *@ - - @searchCriterion.comparisonOperator match { - - case SearchComparisonOperatorV1.MATCH => { - - @* - - TODO: Handle single search terms correctly: combine them with an AND - - *@ - - @triplestore match { - - case "embedded-jena-tdb" | "fuseki" => { - - ?valueObject@index ( '@searchCriterion.searchValue' ) . - ?valueObject@index knora-base:valueHasString ?literal@index . - - } - - case other => { - @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} - } - } - } - - case SearchComparisonOperatorV1.LIKE => { - - @* TODO: escape regex metachars *@ - ?valueObject@index knora-base:valueHasString ?literal@index . - - FILTER regex(?literal@index, '@searchCriterion.searchValue', "i") - } - - case SearchComparisonOperatorV1.NOT_LIKE => { - - @* - - Previously we used FILTER NOT EXISTS here, but then we couldn't get the value of ?literal - (the literal that doesn't match the regex). So now we use just a negated regex. However, if a - resource has two instances of the same property and one of them matches and the other doesn't, - it will be returned in the search results. - - *@ - - ?valueObject@index knora-base:valueHasString ?literal@index . - - FILTER (!regex(?literal@index, '@searchCriterion.searchValue', "i")) - } - - case SearchComparisonOperatorV1.EXISTS => { - - @searchCriterion.valueType match { - case "http://www.knora.org/ontology/knora-base#Resource" => { - - ?linkProperty@index rdfs:subPropertyOf* <@searchCriterion.propertyIri> . - ?resource ?linkProperty@index ?targetResource@index . - ?linkValueProperty@index rdfs:subPropertyOf* <@{searchCriterion.propertyIri}Value> . - ?resource ?linkValueProperty@index ?valueObject@index . - - ?targetResource@index rdfs:label ?literal@index ; - knora-base:isDeleted false ; - knora-base:attachedToUser ?targetResourceCreator@index ; - knora-base:attachedToProject ?targetResourceProject@index ; - knora-base:hasPermissions ?targetResourcePermissions@index . - - ?valueObject@index rdf:type knora-base:LinkValue ; - rdf:subject ?resource ; - rdf:predicate ?linkProperty@index ; - rdf:object ?targetResource@index . - } - - case other => { - - ?valueObject@index knora-base:valueHasString ?literal@index . - - } - } - } - - case SearchComparisonOperatorV1.EQ => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#TextValue" => { - - ?valueObject@index knora-base:valueHasString '@searchCriterion.searchValue' . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger @searchCriterion.searchValue . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal "@searchCriterion.searchValue"^^xsd:decimal . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp "@searchCriterion.searchValue"^^xsd:dateTime . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . - ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER (@searchCriterion.dateStart <= ?dateEnd@index && @searchCriterion.dateEnd >= ?dateStart@index) - BIND(?dateString@index as ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#Resource" => { - - BIND(IRI("@searchCriterion.searchValue") AS ?targetResource@index) - - ?linkProperty@index rdfs:subPropertyOf* <@searchCriterion.propertyIri> . - ?resource ?linkProperty@index <@searchCriterion.searchValue> . - ?linkValueProperty@index rdfs:subPropertyOf* <@{searchCriterion.propertyIri}Value> . - ?resource ?linkValueProperty@index ?valueObject@index . - - <@searchCriterion.searchValue> rdfs:label ?literal@index ; - knora-base:isDeleted false ; - knora-base:attachedToUser ?targetResourceCreator@index ; - knora-base:attachedToProject ?targetResourceProject@index ; - knora-base:hasPermissions ?targetResourcePermissions@index . - - ?valueObject@index rdf:type knora-base:LinkValue ; - rdf:subject ?resource ; - rdf:predicate ?linkProperty@index ; - rdf:object <@searchCriterion.searchValue> . - } - - case "http://www.knora.org/ontology/knora-base#ListValue" => { - - @* - - Get all the subnodes of the given node, including the given node (operator *) - - *@ - - ?valueObject@index knora-base:valueHasListNode ?listNode@index . - <@searchCriterion.searchValue> knora-base:hasSubListNode* ?listNode@index . - - ?listNode@index rdfs:label ?listNodeLabel@index . - BIND(?listNodeLabel@index AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#BooleanValue" => { - - ?valueObject@index knora-base:valueHasBoolean @searchCriterion.searchValue . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#GeonameValue" => { - - ?valueObject@index knora-base:valueHasGeonameCode '@searchCriterion.searchValue' . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#UriValue" => { - - ?valueObject@index knora-base:valueHasUri '@searchCriterion.searchValue'^^xsd:anyURI . - - BIND('@searchCriterion.searchValue' AS ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.NOT_EQ => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#TextValue" => { - - ?valueObject@index knora-base:valueHasString ?literal@index . - - FILTER (?literal@index != '@searchCriterion.searchValue') - - } - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index != @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index != "@searchCriterion.searchValue"^^xsd:decimal) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index != "@searchCriterion.searchValue"^^xsd:dateTime) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . - ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER (@searchCriterion.dateEnd < ?dateStart@index || @searchCriterion.dateStart > ?dateEnd@index ) - BIND(?dateString@index as ?literal@index) - - } - - case "http://www.knora.org/ontology/knora-base#BooleanValue" => { - - ?valueObject@index knora-base:valueHasBoolean ?literal@index . - - FILTER (?literal@index != @searchCriterion.searchValue) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.GT => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index > @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index > "@searchCriterion.searchValue"^^xsd:decimal ) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index > "@searchCriterion.searchValue"^^xsd:dateTime ) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER (?dateStart@index > @searchCriterion.dateEnd) - BIND(?dateString@index as ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.GT_EQ => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index >= @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index >= "@searchCriterion.searchValue"^^xsd:decimal) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index >= "@searchCriterion.searchValue"^^xsd:dateTime) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER(?dateEnd@index >= @searchCriterion.dateStart) - BIND(?dateString@index as ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.LT => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index < @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index < "@searchCriterion.searchValue"^^xsd:decimal) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index < "@searchCriterion.searchValue"^^xsd:dateTime) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasEndJDN ?dateEnd@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER (?dateEnd@index < @searchCriterion.dateStart) - BIND(?dateString@index as ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.LT_EQ => { - - @searchCriterion.valueType match { - - case "http://www.knora.org/ontology/knora-base#IntValue" => { - - ?valueObject@index knora-base:valueHasInteger ?literal@index . - - FILTER (?literal@index <= @searchCriterion.searchValue) - - } - - case "http://www.knora.org/ontology/knora-base#DecimalValue" => { - - ?valueObject@index knora-base:valueHasDecimal ?literal@index . - - FILTER (?literal@index <= "@searchCriterion.searchValue"^^xsd:decimal) - - } - - case "http://www.knora.org/ontology/knora-base#TimeValue" => { - - ?valueObject@index knora-base:valueHasTimeStamp ?literal@index . - - FILTER (?literal@index <= "@searchCriterion.searchValue"^^xsd:dateTime) - - } - - case "http://www.knora.org/ontology/knora-base#DateValue" => { - - ?valueObject@index knora-base:valueHasStartJDN ?dateStart@index . - ?valueObject@index knora-base:valueHasString ?dateString@index . - - FILTER (?dateStart@index <= @searchCriterion.dateEnd) - BIND(?dateString@index as ?literal@index) - - } - - case other => { - @{throw SparqlGenerationException(s"Value type $other is not supported with comparison operator ${searchCriterion.comparisonOperator}"); ()} - } - } - } - - case SearchComparisonOperatorV1.MATCH_BOOLEAN => { - - @* see https://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html *@ - - ?valueObject@index knora-base:valueHasString ?literal@index . - - @for(positiveTerm <- searchCriterion.matchBooleanPositiveTerms) { - - @triplestore match { - - case "embedded-jena-tdb" | "fuseki" => { - - ?valueObject@index ( '@positiveTerm' ) . - - } - - case other => { - @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} - } - } - } - - @if(searchCriterion.matchBooleanNegativeTerms.nonEmpty) { - FILTER NOT EXISTS { - @for(negativeTerm <- searchCriterion.matchBooleanNegativeTerms) { - - @triplestore match { - - case "embedded-jena-tdb" | "fuseki" => { - - ?valueObject@index ( '@negativeTerm' ) . - - } - - case other => { - @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} - } - } - } - } - } - } - - case other => { - @{throw SparqlGenerationException(s"Comparison operator $other is not supported in this SPARQL template"); ()} - } - } - - ?valueObject@index knora-base:isDeleted false ; - knora-base:attachedToUser ?valueCreator@index ; - knora-base:hasPermissions ?valuePermissions@index . - } - - @projectIriOption match { - case Some(projectIri) => { - - # filter by projectIri - ?resource knora-base:attachedToProject <@projectIri> . - - } - - case None => {} - } - - @restypeIriOption match { - - case Some(restypeIri) => { - - # Filter by resource class. - - ?resClass rdfs:subClassOf* <@restypeIri> . - ?resource a ?resClass . - - } - - case None => { - - @* Ensure that each matching resource is a knora-base:Resource. *@ - - ?resClass rdfs:subClassOf* knora-base:Resource . - ?resource a ?resClass . - - } - } - - @ownerIriOption match { - case Some(ownerIri) => { - - # filter by ownerIri - ?resource knora-base:attachedToUser <@ownerIri> . - } - - case None => {} - } - - ?resource rdfs:label ?resourceLabel . - - OPTIONAL { - ?resource knora-base:hasStillImageFileValue ?fileValue . - ?fileValue a knora-base:StillImageFileValue . - ?fileValue knora-base:internalFilename ?previewPath . - - OPTIONAL { - ?fileValue knora-base:dimX ?previewDimX . - ?fileValue knora-base:dimY ?previewDimY . - } - } - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - ?resource a ?resourceClass ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:attachedToProject ?resourceProject . -} -LIMIT 500 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltext.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltext.scala.txt index f4125a47c2..2ee01f66cc 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltext.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltext.scala.txt @@ -8,11 +8,11 @@ @import org.knora.webapi.util.ApacheLuceneSupport.LuceneQueryString @* - * Performs a simple full-text search. The number of rows returned per matching resource is equal to the - * number of values that matched in the resource, plus one if the resource's label matched. + * Performs a simple full-text search using SPARQL w/o inference (except for the interface to Lucene, which is + * triplestore-specific). * - * If the triplestore type is GraphDB, this template delegates to searchFulltextGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to searchFulltextStandard.sparql.txt. + * The number of rows returned per matching resource is equal to the number of values that matched in the resource, + * plus one if the resource's label matched. * * @param triplestore the name of the triplestore being used. * @param searchTerms search terms to be combined with AND in Lucene full-text search syntax. @@ -28,21 +28,124 @@ projectIriOption: Option[IRI], restypeIriOption: Option[IRI]) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.searchFulltextGraphDB(searchTerms = searchTerms, - preferredLanguage = preferredLanguage, - fallbackLanguage = fallbackLanguage, - projectIriOption = projectIriOption, - restypeIriOption = restypeIriOption) +prefix rdf: +prefix rdfs: +prefix knora-base: + +SELECT DISTINCT + ?resource + ?resourceLabel @* The label of a matching resource. This is called "firstprop" in the v1 API. *@ + ?resourceClass + ?previewPath + ?previewDimX + ?previewDimY + ?resourceCreator + ?resourceProject + ?resourcePermissions + ?resourceProperty + ?valueObject + ?valueObjectType + ?valueCreator + ?valuePermissions + ?literal +WHERE { + BIND(STR("@preferredLanguage") AS ?preferredLanguage) + BIND(STR("@fallbackLanguage") AS ?fallbackLanguage) + + @triplestore match { + case "embedded-jena-tdb" | "fuseki" => { + + ?matchingSubject '@searchTerms.getQueryString' . + + } + + case other => { + @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} + } } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.searchFulltextStandard(triplestore = triplestore, - searchTerms = searchTerms, - preferredLanguage = preferredLanguage, - fallbackLanguage = fallbackLanguage, - projectIriOption = projectIriOption, - restypeIriOption = restypeIriOption) + + FILTER NOT EXISTS { + ?matchingSubject knora-base:isDeleted true . } + + # ?matchingSubject could be a resource (whose rdfs:label matched) or a value object + + OPTIONAL { + # If this clause is executed, it is a value object. We set ?containingResource to the resource that contains the matching value object. + + ?matchingSubject a ?valueObjectType . + ?valueObjectType rdfs:subClassOf* knora-base:Value . + ?containingResource ?resourceProperty ?matchingSubject . + ?resourceProperty rdfs:subPropertyOf* knora-base:hasValue . + + FILTER(?valueObjectType != knora-base:LinkValue) + + FILTER NOT EXISTS { + ?containingResource knora-base:isDeleted true . + } + + BIND(?matchingSubject AS ?valueObject) + + ?valueObject knora-base:attachedToUser ?valueCreator ; + knora-base:hasPermissions ?valuePermissions . + + @if(triplestore == "embedded-jena-tdb" || triplestore == "fuseki") { + ?valueObject knora-base:valueHasString ?literal . + } + } + + # If the previous OPTIONAL clause executed, ?matchingSubject is a value, and ?containingResource will be set. Otherwise, ?matchingSubject is a resource. + BIND(COALESCE(?containingResource, ?matchingSubject) AS ?resource) + + @projectIriOption match { + case Some(projectIri) => { + + # filter by projectIri + ?resource knora-base:attachedToProject <@projectIri> . + + } + + case None => {} + } + + ?resource a ?resourceClass . + + @restypeIriOption match { + + case Some(restypeIri) => { + + # Filter by resource class. + + ?resClass rdfs:subClassOf* <@restypeIri> . + ?resource a ?resClass . + + } + + case None => { + + @* Ensure that each matching resource is a knora-base:Resource. *@ + + ?resClass rdfs:subClassOf* knora-base:Resource . + ?resource a ?resClass . + + } + } + + ?resource rdfs:label ?resourceLabel . + + OPTIONAL { + ?resource knora-base:hasStillImageFileValue ?fileValue . + ?fileValue a knora-base:StillImageFileValue . + ?fileValue knora-base:internalFilename ?previewPath . + + OPTIONAL { + ?fileValue knora-base:dimX ?previewDimX . + ?fileValue knora-base:dimY ?previewDimY . + } + } + + ?resource knora-base:attachedToUser ?resourceCreator ; + knora-base:attachedToProject ?resourceProject ; + knora-base:hasPermissions ?resourcePermissions . } +LIMIT 500 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltextGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltextGraphDB.scala.txt deleted file mode 100644 index fd8af1190d..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltextGraphDB.scala.txt +++ /dev/null @@ -1,138 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.util.ApacheLuceneSupport.LuceneQueryString - -@* - * Performs a simple full-text search using GraphDB. The number of rows returned per matching resource is equal to the - * number of values that matched in the resource, plus one if the resource's label matched. - * - * This template is used only by searchFulltext.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subclasses of the resource class - * specified by the user. This requires us to use GraphDB's GRAPH whenever - * we need to get explicit (non-inferred) statements. - * - * @param searchTerms search terms to be combined with AND in Lucene full-text search syntax. - * @param preferredLanguage the language code of the user's preferred language. - * @param fallbackLanguage the language code of the application's default language. - * @param projectIriOption if filtering by project is desired, the IRI of the project to search. - * @param restypeIriOption if given, searches only for resources of this class and its subclasses. - *@ -@(searchTerms: LuceneQueryString, - preferredLanguage: String, - fallbackLanguage: String, - projectIriOption: Option[IRI], - restypeIriOption: Option[IRI]) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT DISTINCT - ?resource - ?resourceLabel @* The label of a matching resource. This is called "firstprop" in the v1 API. *@ - ?resourceClass - ?previewPath - ?previewDimX - ?previewDimY - ?resourceCreator - ?resourceProject - ?resourcePermissions - ?resourceProperty - ?valueObject - ?valueObjectType - ?valueCreator - ?valuePermissions - ?literal -WHERE { - BIND(STR("@preferredLanguage") AS ?preferredLanguage) - BIND(STR("@fallbackLanguage") AS ?fallbackLanguage) - - ?matchingSubject ?matchingProperty ?literal . - ?literal '@searchTerms.getQueryString' . - ?matchingSubject knora-base:isDeleted false . - - # ?matchingSubject could be a resource (whose rdfs:label matched) or a value object - - OPTIONAL { - # If this clause is executed, it is a value object. We set ?containingResource to the resource that contains the matching value object. - - ?matchingSubject a knora-base:Value . - ?containingResource knora-base:hasValue ?matchingSubject . - - GRAPH { - ?matchingSubject a ?valueObjectType . - ?containingResource ?resourceProperty ?matchingSubject . - } - - FILTER(?valueObjectType != knora-base:LinkValue) - ?containingResource knora-base:isDeleted false . - - BIND(?matchingSubject AS ?valueObject) - - ?valueObject knora-base:attachedToUser ?valueCreator ; - knora-base:hasPermissions ?valuePermissions . - } - - # If the previous OPTIONAL clause executed, ?matchingSubject is a value, and ?containingResource will be set. Otherwise, ?matchingSubject is a resource. - BIND(COALESCE(?containingResource, ?matchingSubject) AS ?resource) - - @projectIriOption match { - case Some(projectIri) => { - - # filter by projectIri - ?resource knora-base:attachedToProject <@projectIri> . - - } - - case None => {} - } - - GRAPH { - ?resource a ?resourceClass . - } - - @restypeIriOption match { - - case Some(restypeIri) => { - - # Filter by resource class. - - ?resource a <@restypeIri> . - - } - - case None => { - - @* Ensure that each matching resource is a knora-base:Resource. *@ - - ?resource a knora-base:Resource . - } - } - - - ?resource rdfs:label ?resourceLabel . - - OPTIONAL { - ?resource knora-base:hasStillImageFileValue ?fileValue . - ?fileValue a knora-base:StillImageFileValue . - ?fileValue knora-base:isPreview true . - ?fileValue knora-base:internalFilename ?previewPath . - - OPTIONAL { - ?fileValue knora-base:dimX ?previewDimX . - ?fileValue knora-base:dimY ?previewDimY . - } - } - - ?resource knora-base:attachedToUser ?resourceCreator ; - knora-base:attachedToProject ?resourceProject ; - knora-base:hasPermissions ?resourcePermissions . -} -LIMIT 500 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltextStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltextStandard.scala.txt deleted file mode 100644 index e09cc3d684..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v1/searchFulltextStandard.scala.txt +++ /dev/null @@ -1,153 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.util.ApacheLuceneSupport.LuceneQueryString - -@* - * Performs a simple full-text search using standard SPARQL (except for the interface to Lucene, which is - * triplestore-specific), and without inference. - * - * The number of rows returned per matching resource is equal to the number of values that matched in the resource, - * plus one if the resource's label matched. - * - * This template is used only by searchFulltext.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param searchTerms search terms to be combined with AND in Lucene full-text search syntax. - * @param preferredLanguage the language code of the user's preferred language. - * @param fallbackLanguage the language code of the application's default language. - * @param projectIriOption if filtering by project is desired, the IRI of the project to search. - * @param restypeIriOption if given, searches only for resources of this class and its subclasses. - *@ -@(triplestore: String, - searchTerms: LuceneQueryString, - preferredLanguage: String, - fallbackLanguage: String, - projectIriOption: Option[IRI], - restypeIriOption: Option[IRI]) - -prefix rdf: -prefix rdfs: -prefix knora-base: - -SELECT DISTINCT - ?resource - ?resourceLabel @* The label of a matching resource. This is called "firstprop" in the v1 API. *@ - ?resourceClass - ?previewPath - ?previewDimX - ?previewDimY - ?resourceCreator - ?resourceProject - ?resourcePermissions - ?resourceProperty - ?valueObject - ?valueObjectType - ?valueCreator - ?valuePermissions - ?literal -WHERE { - BIND(STR("@preferredLanguage") AS ?preferredLanguage) - BIND(STR("@fallbackLanguage") AS ?fallbackLanguage) - - @triplestore match { - case "embedded-jena-tdb" | "fuseki" => { - - ?matchingSubject '@searchTerms.getQueryString' . - - } - - case other => { - @{throw SparqlGenerationException(s"Triplestore type $other is not supported in this SPARQL template"); ()} - } - } - - FILTER NOT EXISTS { - ?matchingSubject knora-base:isDeleted true . - } - - # ?matchingSubject could be a resource (whose rdfs:label matched) or a value object - - OPTIONAL { - # If this clause is executed, it is a value object. We set ?containingResource to the resource that contains the matching value object. - - ?matchingSubject a ?valueObjectType . - ?valueObjectType rdfs:subClassOf* knora-base:Value . - ?containingResource ?resourceProperty ?matchingSubject . - ?resourceProperty rdfs:subPropertyOf* knora-base:hasValue . - - FILTER(?valueObjectType != knora-base:LinkValue) - - FILTER NOT EXISTS { - ?containingResource knora-base:isDeleted true . - } - - BIND(?matchingSubject AS ?valueObject) - - ?valueObject knora-base:attachedToUser ?valueCreator ; - knora-base:hasPermissions ?valuePermissions . - - @if(triplestore == "embedded-jena-tdb" || triplestore == "fuseki") { - ?valueObject knora-base:valueHasString ?literal . - } - } - - # If the previous OPTIONAL clause executed, ?matchingSubject is a value, and ?containingResource will be set. Otherwise, ?matchingSubject is a resource. - BIND(COALESCE(?containingResource, ?matchingSubject) AS ?resource) - - @projectIriOption match { - case Some(projectIri) => { - - # filter by projectIri - ?resource knora-base:attachedToProject <@projectIri> . - - } - - case None => {} - } - - ?resource a ?resourceClass . - - @restypeIriOption match { - - case Some(restypeIri) => { - - # Filter by resource class. - - ?resClass rdfs:subClassOf* <@restypeIri> . - ?resource a ?resClass . - - } - - case None => { - - @* Ensure that each matching resource is a knora-base:Resource. *@ - - ?resClass rdfs:subClassOf* knora-base:Resource . - ?resource a ?resClass . - - } - } - - ?resource rdfs:label ?resourceLabel . - - OPTIONAL { - ?resource knora-base:hasStillImageFileValue ?fileValue . - ?fileValue a knora-base:StillImageFileValue . - ?fileValue knora-base:internalFilename ?previewPath . - - OPTIONAL { - ?fileValue knora-base:dimX ?previewDimX . - ?fileValue knora-base:dimY ?previewDimY . - } - } - - ?resource knora-base:attachedToUser ?resourceCreator ; - knora-base:attachedToProject ?resourceProject ; - knora-base:hasPermissions ?resourcePermissions . -} -LIMIT 500 diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/addCardinalitiesToClass.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/addCardinalitiesToClass.scala.txt index 24a95d4572..9ba5619cc5 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/addCardinalitiesToClass.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/addCardinalitiesToClass.scala.txt @@ -64,10 +64,7 @@ DELETE { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/addValueVersion.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/addValueVersion.scala.txt index 31191ffde2..ab647612d7 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/addValueVersion.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/addValueVersion.scala.txt @@ -170,10 +170,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeClassLabelsOrComments.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeClassLabelsOrComments.scala.txt index 997a31b4c3..76fe2b078a 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeClassLabelsOrComments.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeClassLabelsOrComments.scala.txt @@ -52,10 +52,7 @@ DELETE { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeLinkMetadata.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeLinkMetadata.scala.txt index ab36e0132c..cf3d8b61b6 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeLinkMetadata.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeLinkMetadata.scala.txt @@ -81,10 +81,7 @@ INSERT { ?linkSource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@linkSourceIri") AS ?linkSource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeLinkTarget.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeLinkTarget.scala.txt index 94be6d930a..be1d1ad640 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeLinkTarget.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeLinkTarget.scala.txt @@ -128,10 +128,7 @@ INSERT { ?linkSource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { @if(linkUpdateForCurrentLink.linkPropertyIri != linkUpdateForNewLink.linkPropertyIri) { @{throw SparqlGenerationException(s"linkUpdateForCurrentLink.linkPropertyIri <${linkUpdateForCurrentLink.linkPropertyIri}> must be equal to linkUpdateForNewLink.linkPropertyIri <${linkUpdateForNewLink.linkPropertyIri}> in this SPARQL template"); ()} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeOntologyMetadata.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeOntologyMetadata.scala.txt index a17e1ff28c..cb0bdd97ec 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeOntologyMetadata.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeOntologyMetadata.scala.txt @@ -57,10 +57,7 @@ DELETE { ?ontology knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changePropertyGuiElement.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changePropertyGuiElement.scala.txt index bf59619c16..f69e42431f 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changePropertyGuiElement.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changePropertyGuiElement.scala.txt @@ -53,10 +53,7 @@ DELETE { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { GRAPH <@ontologyNamedGraphIri> { <@ontologyIri> rdf:type owl:Ontology ; @@ -118,10 +115,7 @@ INSERT { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { GRAPH <@ontologyNamedGraphIri> { <@ontologyIri> rdf:type owl:Ontology ; @@ -138,10 +132,7 @@ INSERT { <@ontologyIri> knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { GRAPH <@ontologyNamedGraphIri> { <@ontologyIri> rdf:type owl:Ontology ; diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changePropertyLabelsOrComments.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changePropertyLabelsOrComments.scala.txt index 250b77dba6..5cdd818dea 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changePropertyLabelsOrComments.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changePropertyLabelsOrComments.scala.txt @@ -81,10 +81,7 @@ DELETE { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeResourceMetadata.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeResourceMetadata.scala.txt index b294812514..ea653980a8 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeResourceMetadata.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeResourceMetadata.scala.txt @@ -81,10 +81,7 @@ DELETE { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeValuePermissions.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeValuePermissions.scala.txt index 0e7b50ca8c..eed3a26499 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeValuePermissions.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/changeValuePermissions.scala.txt @@ -63,10 +63,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/checkResourceDeletion.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/checkResourceDeletion.scala.txt index ab5b9a0b65..540e1fdd0f 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/checkResourceDeletion.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/checkResourceDeletion.scala.txt @@ -19,10 +19,7 @@ prefix rdfs: prefix knora-base: SELECT ?isDeleted -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/checkValueDeletion.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/checkValueDeletion.scala.txt index 025a59487d..35f441f796 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/checkValueDeletion.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/checkValueDeletion.scala.txt @@ -19,10 +19,7 @@ prefix rdfs: prefix knora-base: SELECT ?isDeleted -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@valueIri") AS ?value) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createClass.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createClass.scala.txt index 823b082648..1a12266443 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createClass.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createClass.scala.txt @@ -80,10 +80,7 @@ DELETE { } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createLink.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createLink.scala.txt index 74cfd65361..5a0f2bff26 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createLink.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createLink.scala.txt @@ -61,10 +61,7 @@ DELETE { } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createNewMapping.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createNewMapping.scala.txt index 44297dce10..59a53f9da1 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createNewMapping.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createNewMapping.scala.txt @@ -74,10 +74,7 @@ INSERT { } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@mappingIri") AS ?mapping) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createOntology.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createOntology.scala.txt index 6ee84f7c1d..1397535a01 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createOntology.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createOntology.scala.txt @@ -42,10 +42,7 @@ INSERT { knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createProperty.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createProperty.scala.txt index ab7ff36366..8294dfb7c6 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createProperty.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createProperty.scala.txt @@ -67,10 +67,7 @@ DELETE { } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createValue.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createValue.scala.txt index 83e1b58d56..e977597f7f 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createValue.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/createValue.scala.txt @@ -27,9 +27,6 @@ * @param valuePermissions the permissions that should be attached to the value. * @param creationDate an xsd:dateTimeStamp that should be attached to the value. * @param stringFormatter a [[StringFormatter]]. - * - * The generated WHERE clause does some consistency checks. If these fail, the operation will do nothing. - * To find out whether the update succeeded, the application must query the property's version history. *@ @(dataNamedGraph: IRI, triplestore: String, @@ -97,10 +94,7 @@ DELETE { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteClass.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteClass.scala.txt index 8296c5d950..dc0b6775ec 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteClass.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteClass.scala.txt @@ -42,10 +42,7 @@ DELETE { ?ontology knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteLink.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteLink.scala.txt index 2e1877b175..fe869526c4 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteLink.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteLink.scala.txt @@ -96,10 +96,7 @@ INSERT { ?linkSource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@linkSourceIri") AS ?linkSource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteOntology.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteOntology.scala.txt index 6797e8d21a..95e2b1cd68 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteOntology.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteOntology.scala.txt @@ -25,10 +25,7 @@ DELETE { ?s ?p ?o . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteProperty.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteProperty.scala.txt index ec14e8a753..74576a9846 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteProperty.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteProperty.scala.txt @@ -56,10 +56,7 @@ DELETE { ?ontology knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@ontologyNamedGraphIri") AS ?ontologyNamedGraph) BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteResource.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteResource.scala.txt index 54a0ebf75e..ea7d60b608 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteResource.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteResource.scala.txt @@ -59,10 +59,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteValue.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteValue.scala.txt index bab53664b1..a39f4730c1 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteValue.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/deleteValue.scala.txt @@ -124,10 +124,7 @@ DELETE { ?resource knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) BIND(IRI("@resourceIri") AS ?resource) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResource.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResource.scala.txt index 0cf475f5ba..22d433fbb9 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResource.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResource.scala.txt @@ -7,7 +7,7 @@ @import org.knora.webapi._ @** - * Erases a resource from the triplestore. + * Erases a resource from the triplestore using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param dataNamedGraph the named graph to update. @@ -17,15 +17,55 @@ dataNamedGraph: IRI, resourceIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.eraseResourceGraphDB(dataNamedGraph = dataNamedGraph, - resourceIri = resourceIri) - } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.eraseResourceStandard(triplestore: String, - dataNamedGraph = dataNamedGraph, - resourceIri = resourceIri) - } +PREFIX rdf: +PREFIX rdfs: +PREFIX owl: +PREFIX xsd: +PREFIX knora-base: + +DELETE { + GRAPH ?dataNamedGraph { + <@resourceIri> ?resourcePred ?resourceObj . + ?value ?valuePred ?valueObj . + ?standoff ?standoffPred ?standoffObj . + ?otherResource ?otherResourceProp ?otherResourceCurrentLinkValue . + ?otherResourceLinkValue ?otherResourceLinkValuePred ?otherResourceLinkValueObj . + } +} WHERE { + BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) + + @* Make sure the resource is really a resource. *@ + <@resourceIri> a ?resourceClass . + ?resourceClass rdfs:subClassOf* knora-base:Resource . + + { + @* Collect all statements whose subject is the resource. *@ + + <@resourceIri> ?resourcePred ?resourceObj . + } UNION { + @* Collect all statements whose subject is a value of the resource. *@ + + <@resourceIri> ?valueProp ?currentValue . + ?currentValue a ?currentValueClass . + ?currentValueClass rdfs:subClassOf* knora-base:Value . + ?currentValue knora-base:previousValue* ?value . + ?value ?valuePred ?valueObj . + } UNION { + @* Collect all statements whose subject is a standoff tag attached to a value of the resource. *@ + + <@resourceIri> ?valueProp ?currentTextValue . + ?currentTextValue a knora-base:TextValue ; + knora-base:previousValue* ?textValue . + ?textValue knora-base:valueHasStandoff ?standoff . + ?standoff ?standoffPred ?standoffObj . + } UNION { + @* Collect all statements about marked-as-deleted link values that point to the resource. *@ + + ?otherResourceCurrentLinkValue rdf:object <@resourceIri> ; + a knora-base:LinkValue ; + knora-base:isDeleted true ; + knora-base:previousValue* ?otherResourceLinkValue . + ?otherResourceLinkValue ?otherResourceLinkValuePred ?otherResourceLinkValueObj . + ?otherResource ?otherResourceProp ?otherResourceCurrentLinkValue . + } } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResourceGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResourceGraphDB.scala.txt deleted file mode 100644 index 84a0d9134a..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResourceGraphDB.scala.txt +++ /dev/null @@ -1,79 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import java.time.Instant -@import org.knora.webapi._ - -@** - * Erases a resource from the triplestore using GraphDB. - * - * @param dataNamedGraph the named graph to update. - * @param resourceIri the IRI of the resource to be marked as deleted. - *@ -@(dataNamedGraph: IRI, - resourceIri: IRI) - -PREFIX rdf: -PREFIX rdfs: -PREFIX owl: -PREFIX xsd: -PREFIX knora-base: - -DELETE { - GRAPH ?dataNamedGraph { - <@resourceIri> ?resourcePred ?resourceObj . - ?value ?valuePred ?valueObj . - ?standoff ?standoffPred ?standoffObj . - ?otherResource ?otherResourceProp ?otherResourceCurrentLinkValue . - ?otherResourceLinkValue ?otherResourceLinkValuePred ?otherResourceLinkValueObj . - } -} WHERE { - BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) - - @* Make sure the resource is really a resource. *@ - <@resourceIri> a knora-base:Resource . - - { - @* Collect all statements whose subject is the resource. *@ - - GRAPH { - <@resourceIri> ?resourcePred ?resourceObj . - } - } UNION { - @* Collect all statements whose subject is a value of the resource. *@ - - GRAPH { - <@resourceIri> ?valueProp ?currentValue . - } - - ?currentValue a knora-base:Value . - - GRAPH { - ?currentValue knora-base:previousValue* ?value . - ?value ?valuePred ?valueObj . - } - } UNION { - @* Collect all statements whose subject is a standoff tag attached to a value of the resource. *@ - - GRAPH { - <@resourceIri> ?valueProp ?currentTextValue . - ?currentTextValue a knora-base:TextValue ; - knora-base:previousValue* ?textValue . - ?textValue knora-base:valueHasStandoff ?standoff . - ?standoff ?standoffPred ?standoffObj . - } - } UNION { - @* Collect all statements about marked-as-deleted link values that point to the resource. *@ - - GRAPH { - ?otherResourceCurrentLinkValue rdf:object <@resourceIri> ; - knora-base:isDeleted true ; - a knora-base:LinkValue ; - knora-base:previousValue* ?otherResourceLinkValue . - ?otherResourceLinkValue ?otherResourceLinkValuePred ?otherResourceLinkValueObj . - ?otherResource ?otherResourceProp ?otherResourceCurrentLinkValue . - } - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResourceStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResourceStandard.scala.txt deleted file mode 100644 index 5dff2aaf9e..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/eraseResourceStandard.scala.txt +++ /dev/null @@ -1,71 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import java.time.Instant -@import org.knora.webapi._ - -@** - * Erases a resource from the triplestore using standard SPARQL. - * - * @param triplestore the name of the triplestore being used. - * @param dataNamedGraph the named graph to update. - * @param resourceIri the IRI of the resource to be marked as deleted. - *@ -@(triplestore: String, - dataNamedGraph: IRI, - resourceIri: IRI) - -PREFIX rdf: -PREFIX rdfs: -PREFIX owl: -PREFIX xsd: -PREFIX knora-base: - -DELETE { - GRAPH ?dataNamedGraph { - <@resourceIri> ?resourcePred ?resourceObj . - ?value ?valuePred ?valueObj . - ?standoff ?standoffPred ?standoffObj . - ?otherResource ?otherResourceProp ?otherResourceCurrentLinkValue . - ?otherResourceLinkValue ?otherResourceLinkValuePred ?otherResourceLinkValueObj . - } -} WHERE { - BIND(IRI("@dataNamedGraph") AS ?dataNamedGraph) - - @* Make sure the resource is really a resource. *@ - <@resourceIri> a ?resourceClass . - ?resourceClass rdfs:subClassOf* knora-base:Resource . - - { - @* Collect all statements whose subject is the resource. *@ - - <@resourceIri> ?resourcePred ?resourceObj . - } UNION { - @* Collect all statements whose subject is a value of the resource. *@ - - <@resourceIri> ?valueProp ?currentValue . - ?currentValue a ?currentValueClass . - ?currentValueClass rdfs:subClassOf* knora-base:Value . - ?currentValue knora-base:previousValue* ?value . - ?value ?valuePred ?valueObj . - } UNION { - @* Collect all statements whose subject is a standoff tag attached to a value of the resource. *@ - - <@resourceIri> ?valueProp ?currentTextValue . - ?currentTextValue a knora-base:TextValue ; - knora-base:previousValue* ?textValue . - ?textValue knora-base:valueHasStandoff ?standoff . - ?standoff ?standoffPred ?standoffObj . - } UNION { - @* Collect all statements about marked-as-deleted link values that point to the resource. *@ - - ?otherResourceCurrentLinkValue rdf:object <@resourceIri> ; - a knora-base:LinkValue ; - knora-base:isDeleted true ; - knora-base:previousValue* ?otherResourceLinkValue . - ?otherResourceLinkValue ?otherResourceLinkValuePred ?otherResourceLinkValueObj . - ?otherResource ?otherResourceProp ?otherResourceCurrentLinkValue . - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllOntologyMetadata.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllOntologyMetadata.scala.txt index e8442994b4..378a76c888 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllOntologyMetadata.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllOntologyMetadata.scala.txt @@ -19,10 +19,7 @@ PREFIX xsd: PREFIX knora-base: SELECT ?ontologyGraph ?ontologyIri ?ontologyPred ?ontologyObj -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { GRAPH ?ontologyGraph { ?ontologyIri rdf:type owl:Ontology ; diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequery.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequery.scala.txt index 06771cac4d..cd5423f483 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequery.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequery.scala.txt @@ -7,20 +7,23 @@ @import org.knora.webapi.messages.SmartIri @* - * Constructs a prequery that gets the IRIs of all resources of a specified project. + * Constructs a prequery that gets all resources from the specified project + * using SPARQL w/o inference. * - * @param triplestore the name of the triplestore being used. - * @param projectIri the IRI of the project. + * @param projectIri the IRI of the project. *@ @(triplestore: String, projectIri: IRI) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getAllResourcesInProjectPrequeryGraphDB(projectIri = projectIri) - } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getAllResourcesInProjectPrequeryStandard(projectIri = projectIri) - } +PREFIX rdf: +PREFIX rdfs: +PREFIX knora-base: + +SELECT DISTINCT ?resource +WHERE { + ?resource knora-base:attachedToProject <@projectIri> . + ?resourceType rdfs:subClassOf* knora-base:Resource . + ?resource rdf:type ?resourceType . + ?resource knora-base:creationDate ?creationDate. } +ORDER BY DESC(?creationDate) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequeryGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequeryGraphDB.scala.txt deleted file mode 100644 index ae577542e1..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequeryGraphDB.scala.txt +++ /dev/null @@ -1,30 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi._ -@import org.knora.webapi.messages.SmartIri - -@* - * Constructs a prequery that gets the IRIs of resources of a specified project, using GraphDB. - * This template is used only by getAllResourcesInProjectPrequery.sparql.txt. - * - * @param projectIri the IRI of the project. - *@ -@(projectIri: IRI) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT DISTINCT ?resource -FROM -WHERE { - ?resource knora-base:attachedToProject <@projectIri> . - ?resourceType rdfs:subClassOf* knora-base:Resource . - ?resource rdf:type ?resourceType . - ?resource knora-base:creationDate ?creationDate. - -} -ORDER BY DESC(?creationDate) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequeryStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequeryStandard.scala.txt deleted file mode 100644 index 8d79c32469..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getAllResourcesInProjectPrequeryStandard.scala.txt +++ /dev/null @@ -1,28 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi._ -@import org.knora.webapi.messages.SmartIri - -@* - * Constructs a prequery that gets all resources from the specified project using standard SPARQL. - * This template is used only by getAllResourcesInProjectPrequery.sparql.txt. - * - * @param projectIri the IRI of the project. - *@ -@(projectIri: IRI) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT DISTINCT ?resource -WHERE { - ?resource knora-base:attachedToProject <@projectIri> . - ?resourceType rdfs:subClassOf* knora-base:Resource . - ?resource rdf:type ?resourceType . - ?resource knora-base:creationDate ?creationDate. -} -ORDER BY DESC(?creationDate) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getClassDefinition.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getClassDefinition.scala.txt index c7744d6a91..73b5a3527c 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getClassDefinition.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getClassDefinition.scala.txt @@ -27,10 +27,7 @@ CONSTRUCT { ?bnode rdf:type owl:Restriction ; ?cardinalityPred ?cardinalityValue . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@classIri") AS ?class) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getDeleteDate.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getDeleteDate.scala.txt index 0769dc0a9a..9cb06a1fdd 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getDeleteDate.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getDeleteDate.scala.txt @@ -21,10 +21,7 @@ PREFIX xsd: PREFIX knora-base: SELECT ?deleteDate -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@entityIri") AS ?entity) ?entity knora-base:deleteDate ?deleteDate . diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphData.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphData.scala.txt index b7db140740..eace346e1c 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphData.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphData.scala.txt @@ -7,11 +7,8 @@ @import org.knora.webapi.messages.SmartIri @** - * Gets the outbound or inbound links from/to a resource. This query is used recursively to get a graph of - * resources reachable from a given resource. - * - * If the triplestore type is GraphDB, this template delegates to getGraphDataGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to getGraphDataStandard.sparql.txt. + * Gets the outbound or inbound links from/to a resource using SPARQL w/o inference. This query is used + * recursively to get a graph of resources reachable from a given resource. * * @param triplestore the name of the triplestore being used. * @param startNodeIri the IRI of the resource to use as the starting point of the query. @@ -27,21 +24,88 @@ outbound: Boolean, limit: Int) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getGraphDataGraphDB(startNodeIri = startNodeIri, - startNodeOnly = startNodeOnly, - maybeExcludeLinkProperty = maybeExcludeLinkProperty, - outbound = outbound, - limit = limit) - } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getGraphDataStandard(triplestore = triplestore, - startNodeIri = startNodeIri, - startNodeOnly = startNodeOnly, - maybeExcludeLinkProperty = maybeExcludeLinkProperty, - outbound = outbound, - limit = limit) +PREFIX rdf: +PREFIX rdfs: +PREFIX knora-base: + +SELECT ?node ?nodeClass ?nodeLabel ?nodeCreator ?nodeProject ?nodePermissions + ?linkValue ?linkProp ?linkValueCreator ?linkValuePermissions +WHERE { + @if(startNodeOnly) { + BIND(IRI("@startNodeIri") AS ?node) . + + ?node a ?nodeClass ; + rdfs:label ?nodeLabel ; + knora-base:attachedToUser ?nodeCreator ; + knora-base:attachedToProject ?nodeProject ; + knora-base:hasPermissions ?nodePermissions . + + FILTER NOT EXISTS { + ?node knora-base:isDeleted true . + } + } else { + BIND(IRI("@startNodeIri") AS ?startNode) . + + ?linkProp rdfs:subPropertyOf* knora-base:hasLinkTo . + + @if(outbound) { + ?startNode ?linkProp ?node . + + @maybeExcludeLinkProperty match { + case Some(excludeLinkProperty) => { + + FILTER NOT EXISTS { + ?excludedProp rdfs:subPropertyOf* <@excludeLinkProperty> . + ?startNode ?excludedProp ?node . + } + + } + + case None => {} + } + + FILTER NOT EXISTS { + ?node knora-base:isDeleted true . + } + + ?linkValue a knora-base:LinkValue ; + rdf:subject ?startNode ; + rdf:predicate ?linkProp ; + rdf:object ?node . + } else { + ?node ?linkProp ?startNode . + + @maybeExcludeLinkProperty match { + case Some(excludeLinkProperty) => { + + FILTER NOT EXISTS { + ?excludedProp rdfs:subPropertyOf* <@excludeLinkProperty> . + ?node ?excludedProp ?startNode . + } + + } + + case None => {} + } + + FILTER NOT EXISTS { + ?node knora-base:isDeleted true . + } + + ?linkValue a knora-base:LinkValue ; + rdf:subject ?node ; + rdf:predicate ?linkProp ; + rdf:object ?startNode . + } + + ?node a ?nodeClass ; + rdfs:label ?nodeLabel ; + knora-base:attachedToUser ?nodeCreator ; + knora-base:attachedToProject ?nodeProject ; + knora-base:hasPermissions ?nodePermissions . + + ?linkValue knora-base:attachedToUser ?linkValueCreator ; + knora-base:hasPermissions ?linkValuePermissions . } } +LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphDataGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphDataGraphDB.scala.txt deleted file mode 100644 index 77f561f653..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphDataGraphDB.scala.txt +++ /dev/null @@ -1,119 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi._ -@import org.knora.webapi.messages.SmartIri - -@** - * Gets the outbound or inbound links from/to a resource, using GraphDB. This query is used recursively to get a graph - * of resources reachable from a given resource. - * - * This template is used only by getGraphData.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to find subproperties of knora-base:hasLinkTo and knora-base:isPartOf. - * This requires us to use GraphDB's GRAPH whenever we need to get explicit - * (non-inferred) statements. - * - * @param startNodeIri the IRI of the resource to use as the starting point of the query. - * @param startNodeOnly if true, returns information only about the start node. - * @param maybeExcludeLinkProperty if provided, a link property that should be excluded from the results. - * @param outbound true to get outbound links, false to get inbound links. - * @param limit the maximum number of edges to return. - *@ -@(startNodeIri: IRI, - startNodeOnly: Boolean, - maybeExcludeLinkProperty: Option[SmartIri], - outbound: Boolean, - limit: Int) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT ?node ?nodeClass ?nodeLabel ?nodeCreator ?nodeProject ?nodePermissions - ?linkValue ?linkProp ?linkValueCreator ?linkValuePermissions -WHERE { - @if(startNodeOnly) { - BIND(IRI("@startNodeIri") AS ?node) . - - GRAPH { - ?node a ?nodeClass . - } - - ?node rdfs:label ?nodeLabel ; - knora-base:attachedToUser ?nodeCreator ; - knora-base:attachedToProject ?nodeProject ; - knora-base:isDeleted false ; - knora-base:hasPermissions ?nodePermissions . - } else { - BIND(IRI("@startNodeIri") AS ?startNode) . - - @if(outbound) { - ?startNode knora-base:hasLinkTo ?node . - - @maybeExcludeLinkProperty match { - case Some(excludeLinkProperty) => { - - FILTER NOT EXISTS { - ?startNode <@excludeLinkProperty> ?node . - } - - } - - case None => {} - } - - GRAPH { - ?startNode ?linkProp ?node . - } - - ?node knora-base:isDeleted false . - - ?linkValue a knora-base:LinkValue ; - rdf:subject ?startNode ; - rdf:predicate ?linkProp ; - rdf:object ?node . - } else { - ?node knora-base:hasLinkTo ?startNode . - - @maybeExcludeLinkProperty match { - case Some(excludeLinkProperty) => { - - FILTER NOT EXISTS { - ?node <@excludeLinkProperty> ?startNode . - } - - } - - case None => {} - } - - GRAPH { - ?node ?linkProp ?startNode . - } - - ?node knora-base:isDeleted false . - - ?linkValue a knora-base:LinkValue ; - rdf:subject ?node ; - rdf:predicate ?linkProp ; - rdf:object ?startNode . - } - - GRAPH { - ?node a ?nodeClass . - } - - ?node rdfs:label ?nodeLabel ; - knora-base:attachedToUser ?nodeCreator ; - knora-base:attachedToProject ?nodeProject ; - knora-base:hasPermissions ?nodePermissions . - - ?linkValue knora-base:attachedToUser ?linkValueCreator ; - knora-base:hasPermissions ?linkValuePermissions . - } -} -LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphDataStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphDataStandard.scala.txt deleted file mode 100644 index 01eb6904b5..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getGraphDataStandard.scala.txt +++ /dev/null @@ -1,113 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi._ -@import org.knora.webapi.messages.SmartIri - -@** - * Gets the outbound or inbound links from/to a resource, using standard SPARQL, without inference. This query is used - * recursively to get a graph of resources reachable from a given resource. - * - * This template is used only by getGraphData.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param startNodeIri the IRI of the resource to use as the starting point of the query. - * @param startNodeOnly if true, returns information only about the start node. - * @param maybeExcludeLinkProperty if provided, a link property that should be excluded from the results. - * @param outbound true to get outbound links, false to get inbound links. - * @param limit the maximum number of edges to return. - *@ -@(triplestore: String, - startNodeIri: IRI, - startNodeOnly: Boolean, - maybeExcludeLinkProperty: Option[SmartIri], - outbound: Boolean, - limit: Int) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT ?node ?nodeClass ?nodeLabel ?nodeCreator ?nodeProject ?nodePermissions - ?linkValue ?linkProp ?linkValueCreator ?linkValuePermissions -WHERE { - @if(startNodeOnly) { - BIND(IRI("@startNodeIri") AS ?node) . - - ?node a ?nodeClass ; - rdfs:label ?nodeLabel ; - knora-base:attachedToUser ?nodeCreator ; - knora-base:attachedToProject ?nodeProject ; - knora-base:hasPermissions ?nodePermissions . - - FILTER NOT EXISTS { - ?node knora-base:isDeleted true . - } - } else { - BIND(IRI("@startNodeIri") AS ?startNode) . - - ?linkProp rdfs:subPropertyOf* knora-base:hasLinkTo . - - @if(outbound) { - ?startNode ?linkProp ?node . - - @maybeExcludeLinkProperty match { - case Some(excludeLinkProperty) => { - - FILTER NOT EXISTS { - ?excludedProp rdfs:subPropertyOf* <@excludeLinkProperty> . - ?startNode ?excludedProp ?node . - } - - } - - case None => {} - } - - FILTER NOT EXISTS { - ?node knora-base:isDeleted true . - } - - ?linkValue a knora-base:LinkValue ; - rdf:subject ?startNode ; - rdf:predicate ?linkProp ; - rdf:object ?node . - } else { - ?node ?linkProp ?startNode . - - @maybeExcludeLinkProperty match { - case Some(excludeLinkProperty) => { - - FILTER NOT EXISTS { - ?excludedProp rdfs:subPropertyOf* <@excludeLinkProperty> . - ?node ?excludedProp ?startNode . - } - - } - - case None => {} - } - - FILTER NOT EXISTS { - ?node knora-base:isDeleted true . - } - - ?linkValue a knora-base:LinkValue ; - rdf:subject ?node ; - rdf:predicate ?linkProp ; - rdf:object ?startNode . - } - - ?node a ?nodeClass ; - rdfs:label ?nodeLabel ; - knora-base:attachedToUser ?nodeCreator ; - knora-base:attachedToProject ?nodeProject ; - knora-base:hasPermissions ?nodePermissions . - - ?linkValue knora-base:attachedToUser ?linkValueCreator ; - knora-base:hasPermissions ?linkValuePermissions . - } -} -LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getMapping.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getMapping.scala.txt index 268875c3a3..fe40d1494a 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getMapping.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getMapping.scala.txt @@ -42,23 +42,45 @@ CONSTRUCT { ?datatypeClass knora-base:mappingHasXMLAttributename ?datatypeAttributeName . ?datatypeClass knora-base:mappingHasStandoffClass ?datatypeStandoffClass . - - } WHERE { BIND(IRI("@mappingIri") as ?mapping) -@if(triplestore.startsWith("graphdb")) { - GRAPH { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.generateWhereStatementsForGetMapping() + @* + * Generates statements to be added to the WHERE clause of a SPAQRL query that gets a mapping. + *@ + @() + + ?mapping rdfs:label ?label . + + ?mapping rdf:type ?mappingType . - } + OPTIONAL { + ?mapping knora-base:mappingHasDefaultXSLTransformation ?defaultXSLTransformation . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v1.txt.generateWhereStatementsForGetMapping() + + ?mapping knora-base:hasMappingElement ?mappingElement . + ?mappingElement rdf:type ?mappingElementType . + ?mappingElement knora-base:mappingHasXMLTagname ?tagName . + ?mappingElement knora-base:mappingHasXMLNamespace ?tagNamespace . + ?mappingElement knora-base:mappingHasXMLClass ?tagClass . + ?mappingElement knora-base:mappingHasStandoffClass ?standoffClass . + ?mappingElement knora-base:mappingElementRequiresSeparator ?separatorRequired . + + OPTIONAL { + + ?mappingElement knora-base:mappingHasXMLAttribute ?attribute . + ?attribute rdf:type ?attributeType . + ?attribute knora-base:mappingHasXMLAttributename ?attributeName . + ?attribute knora-base:mappingHasXMLNamespace ?attributeNamespace . + ?attribute knora-base:mappingHasStandoffProperty ?standoffProperty . } -} -} + OPTIONAL { + + ?mappingElement knora-base:mappingHasStandoffDataTypeClass ?datatypeClass . + ?datatypeClass rdf:type ?datatypeType . + ?datatypeClass knora-base:mappingHasXMLAttributename ?datatypeAttributeName . + ?datatypeClass knora-base:mappingHasStandoffClass ?datatypeStandoffClass . +} +} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getOntologyGraph.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getOntologyGraph.scala.txt index 4f493b7e69..3170352872 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getOntologyGraph.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getOntologyGraph.scala.txt @@ -23,10 +23,7 @@ PREFIX knora-base: CONSTRUCT { ?s ?p ?o . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@ontologyGraph") AS ?ontologyGraph) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getOntologyInfo.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getOntologyInfo.scala.txt index ab4aceb2b1..d6e680f7e7 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getOntologyInfo.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getOntologyInfo.scala.txt @@ -23,10 +23,7 @@ PREFIX knora-base: CONSTRUCT { ?ontology ?ontologyPred ?ontologyObj . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@ontologyIri") AS ?ontology) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getPropertyDefinition.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getPropertyDefinition.scala.txt index 9b51ca6230..b431412419 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getPropertyDefinition.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getPropertyDefinition.scala.txt @@ -23,10 +23,7 @@ PREFIX knora-base: CONSTRUCT { ?property ?propertyPred ?propertyObj . } -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@propertyIri") AS ?property) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValues.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValues.scala.txt index d2f2e4009c..1f86b6bca8 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValues.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValues.scala.txt @@ -9,11 +9,8 @@ @import org.knora.webapi.exceptions.SparqlGenerationException @import org.knora.webapi.messages.{SmartIri, StringFormatter} -@** - * Gets the values of all the Knora properties of one or more resources. - * - * If the triplestore type is GraphDB, this template delegates to getResourcePropertiesAndValuesGraphDB.sparql.txt, - * which is optimised for GraphDB. Otherwise, it delegates to getResourcePropertiesAndValuesStandard.sparql.txt. +@* + * Gets the values of all the Knora properties of one or more resources, using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param resourceIris the IRIs of the requested resources. @@ -47,37 +44,250 @@ maybeStandoffMaxStartIndex: Option[Int] = None, stringFormatter: StringFormatter) -@if(preview && (maybeVersionDate.isDefined || maybePropertyIri.isDefined)) { - @{throw SparqlGenerationException(s"A preview cannot be requested with a property or a version date"); ()} -} +PREFIX xsd: +PREFIX rdf: +PREFIX rdfs: +PREFIX knora-base: + +CONSTRUCT { + @* include this inferred information in the results, needed to identify resources *@ + ?resource a knora-base:Resource ; + knora-base:isMainResource true ; + knora-base:attachedToProject ?resourceProject ; + rdfs:label ?label ; + a ?resourceType ; + knora-base:attachedToUser ?resourceCreator ; + knora-base:hasPermissions ?resourcePermissions ; + knora-base:creationDate ?creationDate ; + knora-base:lastModificationDate ?lastModificationDate . + + @*If deleted resources are wanted return deletion info, otherwise just indicated that resource is not deleted. *@ + @if(!withDeleted) { + ?resource knora-base:isDeleted false . + } else { + ?resource knora-base:isDeleted ?isDeleted ; + knora-base:deleteDate ?deletionDate ; + knora-base:deleteComment ?deleteComment . + } + + @* include this inferred information in the results, needed to identify value properties *@ + ?resource knora-base:hasValue ?valueObject ; + ?resourceValueProperty ?valueObject . + + ?valueObject ?valueObjectProperty ?valueObjectValue ; + knora-base:valueHasUUID ?currentValueUUID ; + knora-base:hasPermissions ?currentValuePermissions . -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getResourcePropertiesAndValuesGraphDB(resourceIris = resourceIris, - preview = preview, - withDeleted= withDeleted, - maybePropertyIri = maybePropertyIri, - maybeValueUuid = maybeValueUuid, - maybeVersionDate = maybeVersionDate, - maybeValueIri = maybeValueIri, - queryAllNonStandoff = queryAllNonStandoff, - maybeStandoffMinStartIndex = maybeStandoffMinStartIndex, - maybeStandoffMaxStartIndex = maybeStandoffMaxStartIndex, - stringFormatter = stringFormatter) + @if(maybeStandoffMinStartIndex.nonEmpty) { + ?valueObject knora-base:valueHasStandoff ?standoffNode . + ?standoffNode ?standoffProperty ?standoffValue ; + knora-base:targetHasOriginalXMLID ?targetOriginalXMLID . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getResourcePropertiesAndValuesStandard(triplestore = triplestore, - resourceIris = resourceIris, - preview = preview, - withDeleted= withDeleted, - maybePropertyIri = maybePropertyIri, - maybeValueUuid = maybeValueUuid, - maybeVersionDate = maybeVersionDate, - maybeValueIri = maybeValueIri, - queryAllNonStandoff = queryAllNonStandoff, - maybeStandoffMinStartIndex = maybeStandoffMinStartIndex, - maybeStandoffMaxStartIndex = maybeStandoffMaxStartIndex, - stringFormatter = stringFormatter) + + @if(queryAllNonStandoff) { + @* include this inferred information in the results, needed to identify linking properties *@ + ?resource knora-base:hasLinkTo ?referredResource ; + ?resourceLinkProperty ?referredResource . + + ?referredResource a knora-base:Resource ; + ?referredResourcePred ?referredResourceObj . + } + +} WHERE { + VALUES ?resource { @for(resIri <- resourceIris) { <@resIri> } } + + ?resource rdf:type ?resourceType . + ?resourceType rdfs:subClassOf* knora-base:Resource . + + ?resource knora-base:attachedToProject ?resourceProject ; + knora-base:attachedToUser ?resourceCreator ; + knora-base:hasPermissions ?resourcePermissions ; + knora-base:creationDate ?creationDate ; + rdfs:label ?label . + + @* If deleted resource is not wanted, ignore deleted resources. *@ + @if(!withDeleted) { + ?resource knora-base:isDeleted false . + } else { + OPTIONAL { + ?resource knora-base:isDeleted ?isDeleted ; + knora-base:deleteDate ?deletionDate . + } + OPTIONAL { + ?resource knora-base:deleteComment ?deleteComment . + } + } + + @* Is this a version history request? *@ + @maybeVersionDate match { + case Some(versionDate) => { + @* Yes. Ensure that the resource was created on or before the target date. *@ + + FILTER(?creationDate <= "@versionDate"^^xsd:dateTime) + } + + case None => {} + } + + OPTIONAL { + ?resource knora-base:lastModificationDate ?lastModificationDate . + } + + @* If this isn't a preview request, return the resource's values. *@ + @if(!preview) { + @* There might be resources with no values. *@ + OPTIONAL { + @* Is this a version history request? *@ + @maybeVersionDate match { + case Some(versionDate) => { + @* Yes. Find the values that existed at the target date. *@ + + @* Get the current version of each value. *@ + + ?resource ?resourceValueProperty ?currentValue . + ?resourceValueProperty rdfs:subPropertyOf* knora-base:hasValue . + + @maybePropertyIri match { + case Some(propertyIri) => { + FILTER(?resourceValueProperty = <@propertyIri>) + } + + case None => {} + } + + @* If deleted values are not required and the value was deleted on or before the target date, ignore all its versions. *@ + @if(!withDeleted) { + FILTER NOT EXISTS { + ?currentValue knora-base:deleteDate ?currentValueDeleteDate . + FILTER(?currentValueDeleteDate <= "@versionDate"^^xsd:dateTime) + } + } + + @* Get the current version's UUID, because we're going to return it with the requested version. *@ + ?currentValue knora-base:valueHasUUID ?currentValueUUID . + + @* Filter by value UUID if requested. *@ + @maybeValueUuid match { + case Some(valueUuid) => { + FILTER(?currentValueUUID = "@{stringFormatter.base64EncodeUuid(valueUuid)}") + } + + case None => {} + } + + @* In each value's history, find a version that was created on or before the target date. *@ + ?currentValue knora-base:previousValue* ?valueObject . + ?valueObject knora-base:valueCreationDate ?valueObjectCreationDate . + FILTER(?valueObjectCreationDate <= "@versionDate"^^xsd:dateTime) + + @* + + If the value's history contains another version that was also created on or before + the target date, and is more recent than this one, ignore this one. This should leave at most + one version, which is the most recent version that was created on or before the target date. + + *@ + FILTER NOT EXISTS { + ?currentValue knora-base:previousValue* ?otherValueObject . + ?otherValueObject knora-base:valueCreationDate ?otherValueObjectCreationDate . + + FILTER( + (?otherValueObjectCreationDate <= "@versionDate"^^xsd:dateTime) && + (?otherValueObjectCreationDate > ?valueObjectCreationDate) + ) + } + + @* Use the permissions from the current version. *@ + ?currentValue knora-base:hasPermissions ?currentValuePermissions + } + + case None => { + @* This isn't a version history request. Return the current version of each value. *@ + + ?resource ?resourceValueProperty ?valueObject . + ?resourceValueProperty rdfs:subPropertyOf* knora-base:hasValue . + + @maybePropertyIri match { + case Some(propertyIri) => { + FILTER(?resourceValueProperty = <@propertyIri>) + } + + case None => {} + } + + @* Filter by value UUID if requested. *@ + @maybeValueUuid match { + case Some(valueUuid) => { + ?valueObject knora-base:valueHasUUID "@{stringFormatter.base64EncodeUuid(valueUuid)}" . + } + + case None => {} + } + + ?valueObject knora-base:hasPermissions ?currentValuePermissions . + } + } + + @* Filter by value IRI if requested. *@ + @maybeValueIri match { + case Some(valueIri) => { + FILTER(?valueObject = <@valueIri>) + } + + case None => {} + } + + { + ?valueObject a ?valueObjectType ; + ?valueObjectProperty ?valueObjectValue . + + FILTER(?valueObjectProperty != knora-base:valueHasStandoff && ?valueObjectProperty != knora-base:hasPermissions) + + @* Exclude knora-base:valueHasString if requested. *@ + + @if(!queryAllNonStandoff) { + FILTER(?valueObjectProperty != knora-base:valueHasString) + } + } + @* Query standoff if requested. *@ + @maybeStandoffMinStartIndex match { + case Some(standoffMinStartIndex) => { + @if(maybeStandoffMaxStartIndex.isEmpty) { + @{throw SparqlGenerationException("maybeStandoffMaxStartIndex must be defined if maybeStandoffMinStartIndex is defined"); ()} + } + + UNION { + ?valueObject knora-base:valueHasStandoff ?standoffNode . + ?standoffNode ?standoffProperty ?standoffValue ; + knora-base:standoffTagHasStartIndex ?startIndex . + + OPTIONAL { + ?standoffTag knora-base:standoffTagHasInternalReference ?targetStandoffTag . + ?targetStandoffTag knora-base:standoffTagHasOriginalXMLID ?targetOriginalXMLID . + } + + FILTER(?startIndex >= @standoffMinStartIndex && ?startIndex <= @{maybeStandoffMaxStartIndex.get}) + } + } + + case None => {} + } + @if(queryAllNonStandoff) { + UNION { + @* + + If the value is a link value, get the referred resource, as long as it hasn't been + marked as deleted. + + *@ + ?valueObject a knora-base:LinkValue ; + rdf:predicate ?resourceLinkProperty ; + rdf:object ?referredResource . + + ?referredResource ?referredResourcePred ?referredResourceObj ; + knora-base:isDeleted false . + } + } + } } } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValuesGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValuesGraphDB.scala.txt deleted file mode 100644 index a4a45c7b46..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValuesGraphDB.scala.txt +++ /dev/null @@ -1,314 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import java.time.Instant -@import java.util.UUID -@import org.knora.webapi._ -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.messages.{SmartIri, StringFormatter} - -@* - * Gets the values of all the Knora properties of one or more resources, using GraphDB. - * - * This template is used only by getResourcePropertiesAndValues.scala.txt. - * - * @param resourceIris the IRIs of the requested resources. - * @param preview indicates if the request should only return preview information. - * @param withDeleted indicates if the deleted resources and values should be returned or not. - * @param maybePropertyIri if defined, only returns values of the specified explicit property. - * Cannot be used in conjunction with preview. - * @param maybeValueUuid if defined, requests only the value with the specified UUID. - * @param maybeVersionDate if defined, requests the state of the resources at the specified - * time in the past. Cannot be used in conjunction with preview. - * @param maybeValueIri if defined, the specified value will be the only value returned. - * @param queryAllNonStandoff if true, knora-base:valueHasString and other non-standoff content will be returned. - * @param maybeStandoffMinStartIndex if defined, the minimum knora-base:standoffTagHasStartIndex to be returned. - * Requires maybeStandoffMaxStartIndex. If undefined, standoff will - * not be returned. - * @param maybeStandoffMaxStartIndex if defined, the maximum knora-base:standoffTagHasStartIndex to be returned. - * Requires maybeStandoffMinStartIndex. If undefined, standoff will - * not be returned. - * @param stringFormatter a StringFormatter. - *@ -@(resourceIris: Seq[IRI], - preview: Boolean, - withDeleted: Boolean, - maybePropertyIri: Option[SmartIri], - maybeValueUuid: Option[UUID], - maybeVersionDate: Option[Instant], - maybeValueIri: Option[IRI], - queryAllNonStandoff: Boolean, - maybeStandoffMinStartIndex: Option[Int], - maybeStandoffMaxStartIndex: Option[Int], - stringFormatter: StringFormatter) - -PREFIX rdf: -PREFIX knora-base: -PREFIX rdfs: - -CONSTRUCT { - @* include this inferred information in the results, needed to identify resources *@ - ?resource a knora-base:Resource ; - knora-base:isMainResource true ; - knora-base:attachedToProject ?resourceProject ; - rdfs:label ?label ; - a ?resourceType ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:creationDate ?creationDate ; - knora-base:lastModificationDate ?lastModificationDate . - - @*If deleted resources are wanted return deletion info, otherwise just indicated that resource is not deleted. *@ - @if(!withDeleted) { - ?resource knora-base:isDeleted false . - } else { - ?resource knora-base:isDeleted ?isDeleted ; - knora-base:deleteDate ?deletionDate ; - knora-base:deleteComment ?deleteComment . - } - @* include this inferred information in the results, needed to identify value properties *@ - ?resource knora-base:hasValue ?valueObject ; - ?resourceValueProperty ?valueObject . - - ?valueObject ?valueObjectProperty ?valueObjectValue ; - knora-base:valueHasUUID ?currentValueUUID ; - knora-base:hasPermissions ?currentValuePermissions . - - @if(maybeStandoffMinStartIndex.nonEmpty) { - ?valueObject knora-base:valueHasStandoff ?standoffTag . - ?standoffTag ?standoffProperty ?standoffValue ; - knora-base:targetHasOriginalXMLID ?targetOriginalXMLID . - } - - @if(queryAllNonStandoff) { - @* include this inferred information in the results, needed to identify linking properties *@ - ?resource knora-base:hasLinkTo ?referredResource ; - ?resourceLinkProperty ?referredResource . - - ?referredResource a knora-base:Resource ; - ?referredResourcePred ?referredResourceObj . - } - -} WHERE { - VALUES ?resource { @for(resIri <- resourceIris) { <@resIri> } } - - ?resource rdf:type knora-base:Resource ; - knora-base:attachedToProject ?resourceProject ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:creationDate ?creationDate ; - rdfs:label ?label . - - @* If deleted resource is not wanted, ignore deleted resources. *@ - @if(!withDeleted) { - ?resource knora-base:isDeleted false . - } else { - OPTIONAL { - ?resource knora-base:isDeleted ?isDeleted ; - knora-base:deleteDate ?deletionDate . - } - OPTIONAL { - ?resource knora-base:deleteComment ?deleteComment . - } - } - - @* Is this a version history request? *@ - @maybeVersionDate match { - case Some(versionDate) => { - @* Yes. Ensure that the resource was created on or before the target date. *@ - - FILTER(?creationDate <= "@versionDate"^^xsd:dateTime) - } - - case None => {} - } - - OPTIONAL { - ?resource knora-base:lastModificationDate ?lastModificationDate . - } - - GRAPH { - ?resource a ?resourceType . - } - - @* If this isn't a preview request, return the resource's values. *@ - @if(!preview) { - @* There might be resources with no values. *@ - OPTIONAL { - @* Is this a version history request? *@ - @maybeVersionDate match { - case Some(versionDate) => { - @* Yes. Find the values that existed at the target date. *@ - - @* Get the current version of each value. *@ - - @maybePropertyIri match { - case Some(propertyIri) => { - GRAPH { - ?resource <@propertyIri> ?currentValue . - } - } - - case None => { - ?resource knora-base:hasValue ?currentValue . - } - } - - @* If deleted values are not required and the value was deleted on or before the target date, ignore all its versions. *@ - @if(!withDeleted) { - FILTER NOT EXISTS { - ?currentValue knora-base:deleteDate ?currentValueDeleteDate . - FILTER(?currentValueDeleteDate <= "@versionDate"^^xsd:dateTime) - } - } - - @* Get the current version's UUID, because we're going to return it with the requested version. *@ - ?currentValue knora-base:valueHasUUID ?currentValueUUID . - - @* Filter by value UUID if requested. *@ - @maybeValueUuid match { - case Some(valueUuid) => { - FILTER(?currentValueUUID = "@{stringFormatter.base64EncodeUuid(valueUuid)}") - } - - case None => {} - } - - @* In each value's history, find a version that was created on or before the target date. *@ - ?currentValue knora-base:previousValue* ?valueObject . - ?valueObject knora-base:valueCreationDate ?valueObjectCreationDate . - FILTER(?valueObjectCreationDate <= "@versionDate"^^xsd:dateTime) - - @* - - If the value's history contains another version that was also created on or before - the target date, and is more recent than this one, ignore this one. This should leave at most - one version, which is the most recent version that was created on or before the target date. - - *@ - FILTER NOT EXISTS { - ?currentValue knora-base:previousValue* ?otherValueObject . - ?otherValueObject knora-base:valueCreationDate ?otherValueObjectCreationDate . - - FILTER( - (?otherValueObjectCreationDate <= "@versionDate"^^xsd:dateTime) && - (?otherValueObjectCreationDate > ?valueObjectCreationDate) - ) - } - - GRAPH { - ?resource ?resourceValueProperty ?currentValue . - } - - @* Use the permissions from the current version. *@ - ?currentValue knora-base:hasPermissions ?currentValuePermissions . - } - - case None => { - @* This isn't a version history request. Return the current version of each value. *@ - - ?resource knora-base:hasValue ?valueObject . - ?valueObject knora-base:isDeleted false . - - @maybePropertyIri match { - case Some(propertyIri) => { - GRAPH { - ?resource <@propertyIri> ?valueObject . - } - } - - case None => { - ?resource knora-base:hasValue ?valueObject . - } - } - - GRAPH { - ?resource ?resourceValueProperty ?valueObject . - } - - @* Filter by value UUID if requested. *@ - @maybeValueUuid match { - case Some(valueUuid) => { - ?valueObject knora-base:valueHasUUID "@{stringFormatter.base64EncodeUuid(valueUuid)}" . - } - - case None => {} - } - - ?valueObject knora-base:hasPermissions ?currentValuePermissions . - } - } - - @* Filter by value IRI if requested. *@ - @maybeValueIri match { - case Some(valueIri) => { - FILTER(?valueObject = <@valueIri>) - } - - case None => {} - } - - { - GRAPH { - ?valueObject a ?valueObjectType ; - ?valueObjectProperty ?valueObjectValue . - } - - FILTER(?valueObjectProperty != knora-base:valueHasStandoff && ?valueObjectProperty != knora-base:hasPermissions) - - @* Exclude knora-base:valueHasString if requested. *@ - - @if(!queryAllNonStandoff) { - FILTER(?valueObjectProperty != knora-base:valueHasString) - } - } - @* Query standoff if requested. *@ - @maybeStandoffMinStartIndex match { - case Some(standoffMinStartIndex) => { - @if(maybeStandoffMaxStartIndex.isEmpty) { - @{throw SparqlGenerationException("maybeStandoffMaxStartIndex must be defined if maybeStandoffMinStartIndex is defined"); ()} - } - - UNION { - GRAPH { - ?valueObject knora-base:valueHasStandoff ?standoffTag . - ?standoffTag ?standoffProperty ?standoffValue ; - knora-base:standoffTagHasStartIndex ?startIndex . - } - - OPTIONAL { - GRAPH { - ?standoffTag knora-base:standoffTagHasInternalReference ?targetStandoffTag . - ?targetStandoffTag knora-base:standoffTagHasOriginalXMLID ?targetOriginalXMLID . - } - } - - FILTER(?startIndex >= @standoffMinStartIndex && ?startIndex <= @{maybeStandoffMaxStartIndex.get}) - } - } - - case None => {} - } - @if(queryAllNonStandoff) { - UNION { - @* - - If the value is a link value, get the referred resource, as long as it hasn't been - marked as deleted. - - *@ - GRAPH { - ?valueObject a knora-base:LinkValue ; - rdf:predicate ?resourceLinkProperty ; - rdf:object ?referredResource . - - ?referredResource knora-base:isDeleted false ; - ?referredResourcePred ?referredResourceObj . - } - } - } - } - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValuesStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValuesStandard.scala.txt deleted file mode 100644 index af6800e62c..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcePropertiesAndValuesStandard.scala.txt +++ /dev/null @@ -1,295 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import java.time.Instant -@import java.util.UUID -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.messages.{SmartIri, StringFormatter} - -@* - * Gets the values of all the Knora properties of one or more resources, using standard SPARQL. - * - * This template is used only by getResourcePropertiesAndValues.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param resourceIris the IRIs of the requested resources. - * @param preview indicates if the request should only return preview information. - * @param withDeleted indicates if the deleted resources and values should be returned or not. - * @param maybePropertyIri if defined, only returns values of the specified explicit property. - * Cannot be used in conjunction with preview. - * @param maybeValueUuid if defined, requests only the value with the specified UUID. - * @param maybeVersionDate if defined, requests the state of the resources at the specified - * time in the past. Cannot be used in conjunction with preview. - * @param maybeValueIri if defined, the specified value will be the only value returned. - * @param queryAllNonStandoff if true, knora-base:valueHasString and other non-standoff content will be returned. - * @param maybeStandoffMinStartIndex if defined, the minimum knora-base:standoffTagHasStartIndex to be returned. - * Requires maybeStandoffMaxStartIndex. If undefined, standoff will - * not be returned. - * @param maybeStandoffMaxStartIndex if defined, the maximum knora-base:standoffTagHasStartIndex to be returned. - * Requires maybeStandoffMinStartIndex. If undefined, standoff will - * not be returned. - * @param stringFormatter a StringFormatter. - *@ -@(triplestore: String, - resourceIris: Seq[IRI], - preview: Boolean, - withDeleted: Boolean, - maybePropertyIri: Option[SmartIri], - maybeValueUuid: Option[UUID], - maybeVersionDate: Option[Instant], - maybeValueIri: Option[IRI], - queryAllNonStandoff: Boolean, - maybeStandoffMinStartIndex: Option[Int], - maybeStandoffMaxStartIndex: Option[Int], - stringFormatter: StringFormatter) - -PREFIX xsd: -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -CONSTRUCT { - @* include this inferred information in the results, needed to identify resources *@ - ?resource a knora-base:Resource ; - knora-base:isMainResource true ; - knora-base:attachedToProject ?resourceProject ; - rdfs:label ?label ; - a ?resourceType ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:creationDate ?creationDate ; - knora-base:lastModificationDate ?lastModificationDate . - - @*If deleted resources are wanted return deletion info, otherwise just indicated that resource is not deleted. *@ - @if(!withDeleted) { - ?resource knora-base:isDeleted false . - } else { - ?resource knora-base:isDeleted ?isDeleted ; - knora-base:deleteDate ?deletionDate ; - knora-base:deleteComment ?deleteComment . - } - - @* include this inferred information in the results, needed to identify value properties *@ - ?resource knora-base:hasValue ?valueObject ; - ?resourceValueProperty ?valueObject . - - ?valueObject ?valueObjectProperty ?valueObjectValue ; - knora-base:valueHasUUID ?currentValueUUID ; - knora-base:hasPermissions ?currentValuePermissions . - - @if(maybeStandoffMinStartIndex.nonEmpty) { - ?valueObject knora-base:valueHasStandoff ?standoffNode . - ?standoffNode ?standoffProperty ?standoffValue ; - knora-base:targetHasOriginalXMLID ?targetOriginalXMLID . - } - - @if(queryAllNonStandoff) { - @* include this inferred information in the results, needed to identify linking properties *@ - ?resource knora-base:hasLinkTo ?referredResource ; - ?resourceLinkProperty ?referredResource . - - ?referredResource a knora-base:Resource ; - ?referredResourcePred ?referredResourceObj . - } - -} WHERE { - VALUES ?resource { @for(resIri <- resourceIris) { <@resIri> } } - - ?resource rdf:type ?resourceType . - ?resourceType rdfs:subClassOf* knora-base:Resource . - - ?resource knora-base:attachedToProject ?resourceProject ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:creationDate ?creationDate ; - rdfs:label ?label . - - @* If deleted resource is not wanted, ignore deleted resources. *@ - @if(!withDeleted) { - ?resource knora-base:isDeleted false . - } else { - OPTIONAL { - ?resource knora-base:isDeleted ?isDeleted ; - knora-base:deleteDate ?deletionDate . - } - OPTIONAL { - ?resource knora-base:deleteComment ?deleteComment . - } - } - - @* Is this a version history request? *@ - @maybeVersionDate match { - case Some(versionDate) => { - @* Yes. Ensure that the resource was created on or before the target date. *@ - - FILTER(?creationDate <= "@versionDate"^^xsd:dateTime) - } - - case None => {} - } - - OPTIONAL { - ?resource knora-base:lastModificationDate ?lastModificationDate . - } - - @* If this isn't a preview request, return the resource's values. *@ - @if(!preview) { - @* There might be resources with no values. *@ - OPTIONAL { - @* Is this a version history request? *@ - @maybeVersionDate match { - case Some(versionDate) => { - @* Yes. Find the values that existed at the target date. *@ - - @* Get the current version of each value. *@ - - ?resource ?resourceValueProperty ?currentValue . - ?resourceValueProperty rdfs:subPropertyOf* knora-base:hasValue . - - @maybePropertyIri match { - case Some(propertyIri) => { - FILTER(?resourceValueProperty = <@propertyIri>) - } - - case None => {} - } - - @* If deleted values are not required and the value was deleted on or before the target date, ignore all its versions. *@ - @if(!withDeleted) { - FILTER NOT EXISTS { - ?currentValue knora-base:deleteDate ?currentValueDeleteDate . - FILTER(?currentValueDeleteDate <= "@versionDate"^^xsd:dateTime) - } - } - - @* Get the current version's UUID, because we're going to return it with the requested version. *@ - ?currentValue knora-base:valueHasUUID ?currentValueUUID . - - @* Filter by value UUID if requested. *@ - @maybeValueUuid match { - case Some(valueUuid) => { - FILTER(?currentValueUUID = "@{stringFormatter.base64EncodeUuid(valueUuid)}") - } - - case None => {} - } - - @* In each value's history, find a version that was created on or before the target date. *@ - ?currentValue knora-base:previousValue* ?valueObject . - ?valueObject knora-base:valueCreationDate ?valueObjectCreationDate . - FILTER(?valueObjectCreationDate <= "@versionDate"^^xsd:dateTime) - - @* - - If the value's history contains another version that was also created on or before - the target date, and is more recent than this one, ignore this one. This should leave at most - one version, which is the most recent version that was created on or before the target date. - - *@ - FILTER NOT EXISTS { - ?currentValue knora-base:previousValue* ?otherValueObject . - ?otherValueObject knora-base:valueCreationDate ?otherValueObjectCreationDate . - - FILTER( - (?otherValueObjectCreationDate <= "@versionDate"^^xsd:dateTime) && - (?otherValueObjectCreationDate > ?valueObjectCreationDate) - ) - } - - @* Use the permissions from the current version. *@ - ?currentValue knora-base:hasPermissions ?currentValuePermissions - } - - case None => { - @* This isn't a version history request. Return the current version of each value. *@ - - ?resource ?resourceValueProperty ?valueObject . - ?resourceValueProperty rdfs:subPropertyOf* knora-base:hasValue . - - @maybePropertyIri match { - case Some(propertyIri) => { - FILTER(?resourceValueProperty = <@propertyIri>) - } - - case None => {} - } - - @* Filter by value UUID if requested. *@ - @maybeValueUuid match { - case Some(valueUuid) => { - ?valueObject knora-base:valueHasUUID "@{stringFormatter.base64EncodeUuid(valueUuid)}" . - } - - case None => {} - } - - ?valueObject knora-base:hasPermissions ?currentValuePermissions . - } - } - - @* Filter by value IRI if requested. *@ - @maybeValueIri match { - case Some(valueIri) => { - FILTER(?valueObject = <@valueIri>) - } - - case None => {} - } - - { - ?valueObject a ?valueObjectType ; - ?valueObjectProperty ?valueObjectValue . - - FILTER(?valueObjectProperty != knora-base:valueHasStandoff && ?valueObjectProperty != knora-base:hasPermissions) - - @* Exclude knora-base:valueHasString if requested. *@ - - @if(!queryAllNonStandoff) { - FILTER(?valueObjectProperty != knora-base:valueHasString) - } - } - @* Query standoff if requested. *@ - @maybeStandoffMinStartIndex match { - case Some(standoffMinStartIndex) => { - @if(maybeStandoffMaxStartIndex.isEmpty) { - @{throw SparqlGenerationException("maybeStandoffMaxStartIndex must be defined if maybeStandoffMinStartIndex is defined"); ()} - } - - UNION { - ?valueObject knora-base:valueHasStandoff ?standoffNode . - ?standoffNode ?standoffProperty ?standoffValue ; - knora-base:standoffTagHasStartIndex ?startIndex . - - OPTIONAL { - ?standoffTag knora-base:standoffTagHasInternalReference ?targetStandoffTag . - ?targetStandoffTag knora-base:standoffTagHasOriginalXMLID ?targetOriginalXMLID . - } - - FILTER(?startIndex >= @standoffMinStartIndex && ?startIndex <= @{maybeStandoffMaxStartIndex.get}) - } - } - - case None => {} - } - @if(queryAllNonStandoff) { - UNION { - @* - - If the value is a link value, get the referred resource, as long as it hasn't been - marked as deleted. - - *@ - ?valueObject a knora-base:LinkValue ; - rdf:predicate ?resourceLinkProperty ; - rdf:object ?referredResource . - - ?referredResource ?referredResourcePred ?referredResourceObj ; - knora-base:isDeleted false . - } - } - } - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistory.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistory.scala.txt index e137987545..6e79699d58 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistory.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistory.scala.txt @@ -7,12 +7,8 @@ @import org.knora.webapi.IRI @** - * Gets the the version history of the values of a resource. + * Gets the the version history of the values of a resource, using SPARQL w/o inference. * - * If the triplestore type is GraphDB, this template delegates to getResourceVersionHistoryGraphDB.sparql.txt, - * which is optimised for GraphDB. Otherwise, it delegates to getResourceVersionHistoryStandard.sparql.txt. - * - * @param triplestore the name of the triplestore being used. * @param resourceIri the IRI of the resource. * @param withDeletedResource indicates if the version history of a deleted resource should be returned or not. * @param maybeStartDate the start of the time period to return, inclusive. @@ -24,18 +20,46 @@ maybeStartDate: Option[Instant] = None, maybeEndDate: Option[Instant] = None) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getResourceValueVersionHistoryGraphDB(resourceIri = resourceIri, - withDeletedResource = withDeletedResource, - maybeStartDate = maybeStartDate, - maybeEndDate = maybeEndDate) +PREFIX xsd: +PREFIX rdfs: +PREFIX knora-base: + +SELECT DISTINCT ?versionDate ?author WHERE { + <@resourceIri> ?property ?currentValue . + @if(!withDeletedResource) { + <@resourceIri> knora-base:isDeleted false . + } + ?property rdfs:subPropertyOf* knora-base:hasValue . + + ?currentValue knora-base:previousValue* ?valueObject . + + { + ?valueObject knora-base:valueCreationDate ?versionDate . + ?valueObject knora-base:attachedToUser ?author . + } UNION { + ?valueObject knora-base:deleteDate ?versionDate . + ?valueObject knora-base:deletedBy ?author . + } + @if(withDeletedResource) { + UNION { + <@resourceIri> knora-base:deleteDate ?versionDate . + <@resourceIri> knora-base:attachedToUser ?author . + } } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getResourceValueVersionHistoryStandard(resourceIri = resourceIri, - withDeletedResource = withDeletedResource, - maybeStartDate = maybeStartDate, - maybeEndDate = maybeEndDate) + + @maybeStartDate match { + case Some(startDate) => { + FILTER(?versionDate >= "@startDate"^^xsd:dateTime) + } + + case None => {} + } + + @maybeEndDate match { + case Some(endDate) => { + FILTER(?versionDate < "@endDate"^^xsd:dateTime) + } + + case None => {} } -} +} ORDER BY DESC(?versionDate) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistoryGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistoryGraphDB.scala.txt deleted file mode 100644 index c854419692..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistoryGraphDB.scala.txt +++ /dev/null @@ -1,62 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import java.time.Instant -@import org.knora.webapi.IRI - -@** - * Gets the the version history of the values of a resource, using GraphDB. - * - * @param resourceIri the IRI of the resource. - * @param withDeletedResource indicates if the version history of a deleted resource should be returned or not. - * @param maybeStartDate the start of the time period to return, inclusive. - * @param maybeEndDate the end of the time period to return, exclusive. - *@ -@(resourceIri: IRI, - withDeletedResource: Boolean = false, - maybeStartDate: Option[Instant] = None, - maybeEndDate: Option[Instant] = None) - -PREFIX xsd: -PREFIX rdfs: -PREFIX knora-base: - -SELECT DISTINCT ?versionDate ?author WHERE { - <@resourceIri> knora-base:hasValue ?currentValue . - @if(!withDeletedResource) { - <@resourceIri> knora-base:isDeleted false . - } - - ?currentValue knora-base:previousValue* ?valueObject . - - { - ?valueObject knora-base:valueCreationDate ?versionDate . - ?valueObject knora-base:attachedToUser ?author . - } UNION { - ?valueObject knora-base:deleteDate ?versionDate . - ?valueObject knora-base:deletedBy ?author . - } - @if(withDeletedResource) { - UNION { - <@resourceIri> knora-base:deleteDate ?versionDate . - <@resourceIri> knora-base:attachedToUser ?author . - } - } - @maybeStartDate match { - case Some(startDate) => { - FILTER(?versionDate >= "@startDate"^^xsd:dateTime) - } - - case None => {} - } - - @maybeEndDate match { - case Some(endDate) => { - FILTER(?versionDate < "@endDate"^^xsd:dateTime) - } - - case None => {} - } -} ORDER BY DESC(?versionDate) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistoryStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistoryStandard.scala.txt deleted file mode 100644 index ab4c81e299..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourceValueVersionHistoryStandard.scala.txt +++ /dev/null @@ -1,64 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import java.time.Instant -@import org.knora.webapi.IRI - -@** - * Gets the the version history of the values of a resource, using standard SPARQL. - * - * @param resourceIri the IRI of the resource. - * @param withDeletedResource indicates if the version history of a deleted resource should be returned or not. - * @param maybeStartDate the start of the time period to return, inclusive. - * @param maybeEndDate the end of the time period to return, exclusive. - *@ -@(resourceIri: IRI, - withDeletedResource: Boolean = false, - maybeStartDate: Option[Instant] = None, - maybeEndDate: Option[Instant] = None) - -PREFIX xsd: -PREFIX rdfs: -PREFIX knora-base: - -SELECT DISTINCT ?versionDate ?author WHERE { - <@resourceIri> ?property ?currentValue . - @if(!withDeletedResource) { - <@resourceIri> knora-base:isDeleted false . - } - ?property rdfs:subPropertyOf* knora-base:hasValue . - - ?currentValue knora-base:previousValue* ?valueObject . - - { - ?valueObject knora-base:valueCreationDate ?versionDate . - ?valueObject knora-base:attachedToUser ?author . - } UNION { - ?valueObject knora-base:deleteDate ?versionDate . - ?valueObject knora-base:deletedBy ?author . - } - @if(withDeletedResource) { - UNION { - <@resourceIri> knora-base:deleteDate ?versionDate . - <@resourceIri> knora-base:attachedToUser ?author . - } - } - - @maybeStartDate match { - case Some(startDate) => { - FILTER(?versionDate >= "@startDate"^^xsd:dateTime) - } - - case None => {} - } - - @maybeEndDate match { - case Some(endDate) => { - FILTER(?versionDate < "@endDate"^^xsd:dateTime) - } - - case None => {} - } -} ORDER BY DESC(?versionDate) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequery.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequery.scala.txt index 3b061f14f2..bbb4cbfed2 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequery.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequery.scala.txt @@ -7,13 +7,13 @@ @import org.knora.webapi.messages.SmartIri @* - * Constructs a prequery that gets the IRIs of resources from the specified project. + * Constructs a prequery that gets resources from the specified project, using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. * @param projectIri the IRI of the project. * @param resourceClassIri the IRI of the resource class. * @param maybeOrderByProperty the IRI of the property to order by. - * @param maybeOrderByValuePredicate the predicate of a Knora value class whose object will be used in ORDER BY. + * @param maybeOrderByValuePredicate the predicate of a Knora value class whose object will. * @param offset the OFFSET to be used. * @param limit the LIMIT to be used. *@ @@ -25,23 +25,40 @@ offset: Int, limit: Int) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getResourcesByClassInProjectPrequeryGraphDB(projectIri = projectIri, - resourceClassIri = resourceClassIri, - maybeOrderByProperty = maybeOrderByProperty, - maybeOrderByValuePredicate = maybeOrderByValuePredicate, - offset = offset, - limit = limit) +PREFIX rdf: +PREFIX rdfs: +PREFIX knora-base: + +SELECT DISTINCT ?resource +WHERE { + ?resource knora-base:attachedToProject <@projectIri> ; + rdf:type <@resourceClassIri> . + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.getResourcesByClassInProjectPrequeryStandard(triplestore = triplestore, - projectIri = projectIri, - resourceClassIri = resourceClassIri, - maybeOrderByProperty = maybeOrderByProperty, - maybeOrderByValuePredicate = maybeOrderByValuePredicate, - offset = offset, - limit = limit) + + @maybeOrderByProperty match { + case Some(orderByProperty) => { + OPTIONAL { + ?resource <@orderByProperty> ?orderByValue . + ?orderByValue <@{maybeOrderByValuePredicate.get}> ?orderByValueLiteral . + + FILTER NOT EXISTS { + ?resource <@orderByProperty> ?otherOrderByValue . + ?otherOrderByValue <@{maybeOrderByValuePredicate.get}> ?otherOrderByValueLiteral . + FILTER(?otherOrderByValueLiteral < ?orderByValueLiteral) + } + } + } + + case None => {} } } +ORDER BY + @if(maybeOrderByProperty.nonEmpty) { + ASC(?orderByValueLiteral) + } + ASC(?resource) +OFFSET @offset +LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequeryGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequeryGraphDB.scala.txt deleted file mode 100644 index c63b77c6e7..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequeryGraphDB.scala.txt +++ /dev/null @@ -1,61 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi._ -@import org.knora.webapi.messages.SmartIri - -@* - * Constructs a prequery that gets the IRIs of resources from the specified project, using GraphDB. - * This template is used only by getResourcesInProjectPrequery.sparql.txt. - * - * @param projectIri the IRI of the project. - * @param resourceClassIri the IRI of the resource class. - * @param maybeOrderByProperty the IRI of the property to order by. - * @param maybeOrderByValuePredicate the predicate of a Knora value class whose object will be used in ORDER BY. - * @param offset the OFFSET to be used. - * @param limit the LIMIT to be used. - *@ -@(projectIri: IRI, - resourceClassIri: SmartIri, - maybeOrderByProperty: Option[SmartIri], - maybeOrderByValuePredicate: Option[SmartIri], - offset: Int, - limit: Int) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT DISTINCT ?resource -FROM -WHERE { - ?resource knora-base:attachedToProject <@projectIri> ; - rdf:type <@resourceClassIri> ; - knora-base:isDeleted false . - - @maybeOrderByProperty match { - case Some(orderByProperty) => { - OPTIONAL { - ?resource <@orderByProperty> ?orderByValue . - ?orderByValue <@{maybeOrderByValuePredicate.get}> ?orderByValueLiteral . - - FILTER NOT EXISTS { - ?resource <@orderByProperty> ?otherOrderByValue . - ?otherOrderByValue <@{maybeOrderByValuePredicate.get}> ?otherOrderByValueLiteral . - FILTER(?otherOrderByValueLiteral < ?orderByValueLiteral) - } - } - } - - case None => {} - } -} -ORDER BY - @if(maybeOrderByProperty.nonEmpty) { - ASC(?orderByValueLiteral) - } - ASC(?resource) -OFFSET @offset -LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequeryStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequeryStandard.scala.txt deleted file mode 100644 index 7a88f96f12..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getResourcesByClassInProjectPrequeryStandard.scala.txt +++ /dev/null @@ -1,65 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi._ -@import org.knora.webapi.messages.SmartIri - -@* - * Constructs a prequery that gets resources from the specified project, using standard SPARQL. - * This template is used only by getResourcesInProjectPrequery.sparql.txt. - * - * @param triplestore the name of the triplestore being used. - * @param projectIri the IRI of the project. - * @param resourceClassIri the IRI of the resource class. - * @param orderByProperty the IRI of the property to order by. - * @param orderByValuePredicate the predicate of a Knora value class whose object will be used in ORDER BY. - * @param offset the OFFSET to be used. - * @param limit the LIMIT to be used. - *@ -@(triplestore: String, - projectIri: IRI, - resourceClassIri: SmartIri, - maybeOrderByProperty: Option[SmartIri], - maybeOrderByValuePredicate: Option[SmartIri], - offset: Int, - limit: Int) - -PREFIX rdf: -PREFIX rdfs: -PREFIX knora-base: - -SELECT DISTINCT ?resource -WHERE { - ?resource knora-base:attachedToProject <@projectIri> ; - rdf:type <@resourceClassIri> . - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } - - @maybeOrderByProperty match { - case Some(orderByProperty) => { - OPTIONAL { - ?resource <@orderByProperty> ?orderByValue . - ?orderByValue <@{maybeOrderByValuePredicate.get}> ?orderByValueLiteral . - - FILTER NOT EXISTS { - ?resource <@orderByProperty> ?otherOrderByValue . - ?otherOrderByValue <@{maybeOrderByValuePredicate.get}> ?otherOrderByValueLiteral . - FILTER(?otherOrderByValueLiteral < ?orderByValueLiteral) - } - } - } - - case None => {} - } -} -ORDER BY - @if(maybeOrderByProperty.nonEmpty) { - ASC(?orderByValueLiteral) - } - ASC(?resource) -OFFSET @offset -LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getStandoffTagByUUID.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getStandoffTagByUUID.scala.txt index fa962d84ec..ea9d16e5e8 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getStandoffTagByUUID.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/getStandoffTagByUUID.scala.txt @@ -24,10 +24,7 @@ PREFIX xsd: PREFIX knora-base: SELECT DISTINCT ?standoffTag -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { ?standoffTag knora-base:standoffTagHasUUID "@{stringFormatter.base64EncodeUuid(uuid)}" . } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/isEntityUsed.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/isEntityUsed.scala.txt index 6a3cd3ef0d..88121f89e1 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/isEntityUsed.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/isEntityUsed.scala.txt @@ -27,10 +27,7 @@ PREFIX xsd: PREFIX knora-base: SELECT DISTINCT ?isUsed -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@entityIri") AS ?entity) BIND(true AS ?isUsed) diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/isOntologyUsed.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/isOntologyUsed.scala.txt index aeef2fca66..ab4a85bd90 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/isOntologyUsed.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/isOntologyUsed.scala.txt @@ -26,10 +26,7 @@ PREFIX xsd: PREFIX knora-base: SELECT DISTINCT ?s -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { @for((propertyIri, index) <- propertyIris.toVector.zipWithIndex) { diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/replaceClassCardinalities.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/replaceClassCardinalities.scala.txt index ec9ab93048..dfd1cc8c6a 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/replaceClassCardinalities.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/replaceClassCardinalities.scala.txt @@ -46,10 +46,7 @@ DELETE { ?restriction ?restrictionPred ?restrictionObj . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { GRAPH <@ontologyNamedGraphIri> { <@ontologyIri> rdf:type owl:Ontology ; @@ -88,10 +85,7 @@ INSERT { } } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { GRAPH <@ontologyNamedGraphIri> { <@ontologyIri> rdf:type owl:Ontology ; @@ -109,10 +103,7 @@ DELETE { <@ontologyIri> knora-base:lastModificationDate "@currentTime"^^xsd:dateTime . } } -@* Ensure that inference is not used in the WHERE clause of this update. *@ -@if(triplestore.startsWith("graphdb")) { - USING -} + WHERE { GRAPH <@ontologyNamedGraphIri> { <@ontologyIri> rdf:type owl:Ontology ; diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltext.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltext.scala.txt index bffe005b61..09ffeafc93 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltext.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltext.scala.txt @@ -7,11 +7,15 @@ @import org.knora.webapi.exceptions.SparqlGenerationException @import org.knora.webapi.util.ApacheLuceneSupport.LuceneQueryString + @* - * Performs a simple full-text search. + * Performs a simple full-text search using SPARQL w/o inference, except for the interface to Lucene, which is + * triplestore-specific. + * + * The number of rows returned per matching resource is equal to the number of values that matched in the resource, + * plus one if the resource's label matched. * - * If the triplestore type is GraphDB, this template delegates to searchFulltextGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to searchFulltextStandard.sparql.txt. + * This template is used only by searchFulltext.scala.txt. * * @param triplestore the name of the triplestore being used. * @param searchTerms search terms. @@ -35,29 +39,134 @@ offset: Int, countQuery: Boolean) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchFulltextGraphDB(searchTerms = searchTerms, - limitToProject = limitToProject, - limitToResourceClass = limitToResourceClass, - limitToStandoffClass = limitToStandoffClass, - returnFiles = returnFiles, - separator = separator, - limit = limit, - offset = offset, - countQuery = countQuery) - } +PREFIX knora-base: +PREFIX rdfs: + +@if(!countQuery) { +SELECT DISTINCT ?resource + (GROUP_CONCAT(IF(BOUND(?valueObject), STR(?valueObject), ""); + separator="@separator.getOrElse(throw SparqlGenerationException("Separator expected for non count query, but none given"))") + AS ?valueObjectConcat) } else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchFulltextStandard(triplestore = triplestore, - searchTerms = searchTerms, - limitToProject = limitToProject, - limitToResourceClass = limitToResourceClass, - limitToStandoffClass = limitToStandoffClass, - returnFiles = returnFiles, - separator = separator, - limit = limit, - offset = offset, - countQuery = countQuery) + SELECT (count(distinct ?resource) as ?count) +} +WHERE { + + { + SELECT DISTINCT ?matchingSubject WHERE { + + ?matchingSubject '@searchTerms.getQueryString' . + + @* standoff search *@ + @if(limitToStandoffClass.nonEmpty) { + + # ?matchingSubject is expected to be a TextValue + ?matchingSubject a knora-base:TextValue ; + knora-base:valueHasString ?literal ; + knora-base:valueHasStandoff ?standoffNode . + + ?standoffNode a <@limitToStandoffClass.get> ; + knora-base:standoffTagHasStart ?start ; + knora-base:standoffTagHasEnd ?end . + + # https://www.w3.org/TR/xpath-functions/#func-substring + # The first character of a string is located at position 1, not position 0. -> standoff uses a 0 based index + BIND(SUBSTR(?literal, ?start+1, ?end - ?start) AS ?markedup) + + @* Loop over search terms and make sure they are all contained in the specified standoff markup *@ + @for(term <- searchTerms.getSingleTerms) { + @* TODO: Ignore Lucene operators *@ + FILTER REGEX(?markedup, '@term', "i") + } + + } + } + } + + OPTIONAL { + ?matchingSubject a ?valueObjectType . + + ?valueObjectType rdfs:subClassOf *knora-base:Value . + + FILTER(?valueObjectType != knora-base:LinkValue && ?valueObjectType != knora-base:ListValue) + + ?containingResource ?property ?matchingSubject . + + ?property rdfs:subPropertyOf* knora-base:hasValue . + + FILTER NOT EXISTS { + ?matchingSubject knora-base:isDeleted true + } + + # this variable will only be bound if the search matched a value object + BIND(?matchingSubject AS ?valueObject) } + + OPTIONAL { + # get all list nodes that match the search term + ?matchingSubject a knora-base:ListNode . + + # get sub-node(s) of that node(s) (recursively) + ?matchingSubject knora-base:hasSubListNode* ?subListNode . + + # get all values that point to the node(s) and sub-node(s) + ?listValue knora-base:valueHasListNode ?subListNode . + + # get all resources that have that values + ?subjectWithListValue ?predicate ?listValue . + + FILTER NOT EXISTS { + ?matchingSubject knora-base:isDeleted true + } + + # this variable will only be bound if the search matched a list node + BIND(?listValue AS ?valueObject) + } + + # If the first OPTIONAL clause was executed, ?matchingSubject is a value object, and ?containingResource will be set as ?valueObject. + # If the second OPTIONAL clause was executed, ?matchingSubject is a list node, and ?listValue will be set as ?valueObject. + # Otherwise, ?matchingSubject is a resource (its rdfs:label matched the search pattern). + BIND( + COALESCE( + ?containingResource, + ?subjectWithListValue, + ?matchingSubject) + AS ?resource) + + ?resource a ?resourceClass . + + ?resourceClass rdfs:subClassOf* knora-base:Resource . + + @limitToResourceClass match { + case Some(definedLimitToResourceClass) => { + ?resourceClass rdfs:subClassOf* <@definedLimitToResourceClass> . + } + + case None => {} + } + + @limitToProject match { + case Some(definedLimitToProject) => { + ?resource knora-base:attachedToProject <@definedLimitToProject> . + } + + case None => {} + } + + @if(returnFiles) { + OPTIONAL { + ?fileValueProp rdfs:subPropertyOf* knora-base:hasFileValue . + ?resource ?fileValueProp ?valueObject . + } + } + + FILTER NOT EXISTS { + ?resource knora-base:isDeleted true . + } +} +@if(!countQuery) { +GROUP BY ?resource +ORDER BY ?resource +OFFSET @offset } +LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltextGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltextGraphDB.scala.txt deleted file mode 100644 index 84143d0ceb..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltextGraphDB.scala.txt +++ /dev/null @@ -1,138 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.util.ApacheLuceneSupport.LuceneQueryString - -@* - * Performs a simple full-text search using GraphDB. - * - * This template is used only by searchFulltext.scala.txt. - * - * Since the triplestore type is GraphDB, we assume that inference is enabled, and we use it to optimise the generated - * SPARQL. Specifically, we use inference to return search results matching subclasses of the resource class - * specified by the user. This requires us to use GraphDB's GRAPH whenever - * we need to get explicit (non-inferred) statements. - * - * @param searchTerms search terms. - * @param separator the separator to be used in aggregation functions. - * @param limitToProject limit search to the given project. - * @param limitToResourceClass limit search to given resource class. - * @param limitToStandoffClass limit the search to given standoff class. - * @param returnFiles if true, return any file value attached to each matching resource. - * @param limit maximal amount of rows to be returned - * @param offset offset for paging (starts with 0) - * @param countQuery indicates whether it is a count query or the actual resources should be returned. - *@ -@(searchTerms: LuceneQueryString, - limitToProject: Option[IRI], - limitToResourceClass: Option[IRI], - limitToStandoffClass: Option[IRI], - returnFiles: Boolean, - separator: Option[Char], - limit: Int, - offset: Int, - countQuery: Boolean) - -PREFIX knora-base: -PREFIX rdfs: - -@if(!countQuery) { -SELECT DISTINCT ?resource - (GROUP_CONCAT(IF(BOUND(?valueObject), STR(?valueObject), ""); - separator="@separator.getOrElse(throw SparqlGenerationException("Separator expected for non count query, but none given"))") - AS ?valueObjectConcat) -} else { - SELECT (count(distinct ?resource) as ?count) -} -WHERE { - - { - SELECT DISTINCT ?matchingSubject WHERE { - - GRAPH { - ?matchingSubject ?matchingProperty ?literal . - } - - ?literal '@searchTerms.getQueryString' . - - @* standoff search *@ - @if(limitToStandoffClass.nonEmpty) { - - # ?matchingSubject is expected to be a TextValue - ?matchingSubject a knora-base:TextValue ; - knora-base:valueHasStandoff ?standoffNode . - - ?standoffNode a <@limitToStandoffClass.get> ; - knora-base:standoffTagHasStart ?start ; - knora-base:standoffTagHasEnd ?end . - - # https://www.w3.org/TR/xpath-functions/#func-substring - # The first character of a string is located at position 1, not position 0. -> standoff uses a 0 based index - BIND(SUBSTR(?literal, ?start+1, ?end - ?start) AS ?markedup) - - @* Loop over search terms and make sure they are all contained in the specified standoff markup *@ - @for(term <- searchTerms.getSingleTerms) { - @* TODO: Ignore Lucene operators *@ - FILTER REGEX(?markedup, '@term', "i") - } - - } - } - } - - OPTIONAL { - ?matchingSubject a knora-base:Value . - - GRAPH { - ?matchingSubject knora-base:isDeleted false . - ?matchingSubject a ?valueObjectType . - } - - FILTER(?valueObjectType != knora-base:LinkValue && ?valueObjectType != knora-base:ListValue) - - ?containingResource knora-base:hasValue ?matchingSubject . - - # this variable will only be bound if the search matched a value object - BIND(?matchingSubject AS ?valueObject) - - } - - # If the previous OPTIONAL clause was executed, ?matchingSubject is a value object, and ?containingResource will be set. - # Otherwise, ?matchingSubject is a resource (its rdfs:label matched the search pattern). - BIND(COALESCE(?containingResource, ?matchingSubject) AS ?resource) - - ?resource a knora-base:Resource ; - knora-base:isDeleted false . - - @limitToResourceClass match { - case Some(definedLimitToResourceClass) => { - ?resource a <@definedLimitToResourceClass> . - } - - case None => {} - } - - @limitToProject match { - case Some(definedLimitToProject) => { - ?resource knora-base:attachedToProject <@definedLimitToProject> . - } - - case None => {} - } - - @if(returnFiles) { - OPTIONAL { - ?resource knora-base:hasFileValue ?valueObject . - } - } -} -@if(!countQuery) { -GROUP BY ?resource -ORDER BY ?resource -OFFSET @offset -} -LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltextStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltextStandard.scala.txt deleted file mode 100644 index 77d272e89d..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchFulltextStandard.scala.txt +++ /dev/null @@ -1,172 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.util.ApacheLuceneSupport.LuceneQueryString - - -@* - * Performs a simple full-text search using standard SPARQL (except for the interface to Lucene, which is - * triplestore-specific), and without inference. - * - * The number of rows returned per matching resource is equal to the number of values that matched in the resource, - * plus one if the resource's label matched. - * - * This template is used only by searchFulltext.scala.txt. - * - * @param triplestore the name of the triplestore being used. - * @param searchTerms search terms. - * @param limitToProject limit search to the given project. - * @param limitToResourceClass limit search to given resource class. - * @param limitToStandoffClass limit the search to given standoff class. - * @param returnFiles if true, return any file value attached to each matching resource. - * @param separator the separator to be used in aggregation functions. - * @param limit maximal amount of rows to be returned - * @param offset offset for paging (starts with 0) - * @param countQuery indicates whether it is a count query or the actual resources should be returned. - *@ -@(triplestore: String, - searchTerms: LuceneQueryString, - limitToProject: Option[IRI], - limitToResourceClass: Option[IRI], - limitToStandoffClass: Option[IRI], - returnFiles: Boolean, - separator: Option[Char], - limit: Int, - offset: Int, - countQuery: Boolean) - -PREFIX knora-base: -PREFIX rdfs: - -@if(!countQuery) { -SELECT DISTINCT ?resource - (GROUP_CONCAT(IF(BOUND(?valueObject), STR(?valueObject), ""); - separator="@separator.getOrElse(throw SparqlGenerationException("Separator expected for non count query, but none given"))") - AS ?valueObjectConcat) -} else { - SELECT (count(distinct ?resource) as ?count) -} -WHERE { - - { - SELECT DISTINCT ?matchingSubject WHERE { - - ?matchingSubject '@searchTerms.getQueryString' . - - @* standoff search *@ - @if(limitToStandoffClass.nonEmpty) { - - # ?matchingSubject is expected to be a TextValue - ?matchingSubject a knora-base:TextValue ; - knora-base:valueHasString ?literal ; - knora-base:valueHasStandoff ?standoffNode . - - ?standoffNode a <@limitToStandoffClass.get> ; - knora-base:standoffTagHasStart ?start ; - knora-base:standoffTagHasEnd ?end . - - # https://www.w3.org/TR/xpath-functions/#func-substring - # The first character of a string is located at position 1, not position 0. -> standoff uses a 0 based index - BIND(SUBSTR(?literal, ?start+1, ?end - ?start) AS ?markedup) - - @* Loop over search terms and make sure they are all contained in the specified standoff markup *@ - @for(term <- searchTerms.getSingleTerms) { - @* TODO: Ignore Lucene operators *@ - FILTER REGEX(?markedup, '@term', "i") - } - - } - } - } - - OPTIONAL { - ?matchingSubject a ?valueObjectType . - - ?valueObjectType rdfs:subClassOf *knora-base:Value . - - FILTER(?valueObjectType != knora-base:LinkValue && ?valueObjectType != knora-base:ListValue) - - ?containingResource ?property ?matchingSubject . - - ?property rdfs:subPropertyOf* knora-base:hasValue . - - FILTER NOT EXISTS { - ?matchingSubject knora-base:isDeleted true - } - - # this variable will only be bound if the search matched a value object - BIND(?matchingSubject AS ?valueObject) - } - - OPTIONAL { - # get all list nodes that match the search term - ?matchingSubject a knora-base:ListNode . - - # get sub-node(s) of that node(s) (recursively) - ?matchingSubject knora-base:hasSubListNode* ?subListNode . - - # get all values that point to the node(s) and sub-node(s) - ?listValue knora-base:valueHasListNode ?subListNode . - - # get all resources that have that values - ?subjectWithListValue ?predicate ?listValue . - - FILTER NOT EXISTS { - ?matchingSubject knora-base:isDeleted true - } - - # this variable will only be bound if the search matched a list node - BIND(?listValue AS ?valueObject) - } - - # If the first OPTIONAL clause was executed, ?matchingSubject is a value object, and ?containingResource will be set as ?valueObject. - # If the second OPTIONAL clause was executed, ?matchingSubject is a list node, and ?listValue will be set as ?valueObject. - # Otherwise, ?matchingSubject is a resource (its rdfs:label matched the search pattern). - BIND( - COALESCE( - ?containingResource, - ?subjectWithListValue, - ?matchingSubject) - AS ?resource) - - ?resource a ?resourceClass . - - ?resourceClass rdfs:subClassOf* knora-base:Resource . - - @limitToResourceClass match { - case Some(definedLimitToResourceClass) => { - ?resourceClass rdfs:subClassOf* <@definedLimitToResourceClass> . - } - - case None => {} - } - - @limitToProject match { - case Some(definedLimitToProject) => { - ?resource knora-base:attachedToProject <@definedLimitToProject> . - } - - case None => {} - } - - @if(returnFiles) { - OPTIONAL { - ?fileValueProp rdfs:subPropertyOf* knora-base:hasFileValue . - ?resource ?fileValueProp ?valueObject . - } - } - - FILTER NOT EXISTS { - ?resource knora-base:isDeleted true . - } -} -@if(!countQuery) { -GROUP BY ?resource -ORDER BY ?resource -OFFSET @offset -} -LIMIT @limit diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabel.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabel.scala.txt index 1c29c86e3b..02785e8fa0 100644 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabel.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabel.scala.txt @@ -8,13 +8,10 @@ @import org.knora.webapi.util.ApacheLuceneSupport.MatchStringWhileTyping @* - * Performs a search for resources by their label. - * - * If the triplestore type is GraphDB, this template delegates to searchResourceByLabelGraphDB.sparql.txt, which is optimised - * for GraphDB. Otherwise, it delegates to searchResourceByLabelStandard.sparql.txt. + * Performs a search for resources by their label using SPARQL w/o inference. * * @param triplestore the name of the triplestore being used. - * @param searchTerms search terms. + * @param searchTerm search terms. * @param limitToProject limit search to the given project. * @param limitToResourceClass limit search to given resource class. * @param limit maximum amount of resources to be returned. @@ -29,27 +26,93 @@ offset: Int, countQuery: Boolean) -@if(triplestore.startsWith("graphdb")) { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelGraphDB( - searchTerm = searchTerm, - limitToProject = limitToProject, - limitToResourceClass = limitToResourceClass, - limit = limit, - offset = offset, - countQuery = countQuery - ) +PREFIX rdfs: +PREFIX knora-base: + +@if(!countQuery) { + CONSTRUCT { + ?resource rdfs:label ?label ; + a knora-base:Resource ; + knora-base:isMainResource true ; + knora-base:isDeleted false ; + a ?resourceType ; + knora-base:attachedToUser ?resourceCreator ; + knora-base:hasPermissions ?resourcePermissions ; + knora-base:attachedToProject ?resourceProject ; + knora-base:creationDate ?creationDate ; + knora-base:lastModificationDate ?lastModificationDate . + + # include this inferred information in the results, needed to identify value properties + ?resource knora-base:hasValue ?valueObject ; + ?resourceValueProperty ?valueObject . + ?valueObject ?valueObjectProperty ?valueObjectValue . + + } WHERE { + { + { + @{ + org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelSubQuery( + searchTerm = searchTerm, + limitToProject = limitToProject, + limitToResourceClass = limitToResourceClass, + limit = limit, + offset = offset, + countQuery = countQuery) + } + } + + ?resource a ?resourceType ; + knora-base:attachedToUser ?resourceCreator ; + knora-base:hasPermissions ?resourcePermissions ; + knora-base:attachedToProject ?resourceProject ; + knora-base:creationDate ?creationDate ; + rdfs:label ?label . + + OPTIONAL { + ?resource knora-base:lastModificationDate ?lastModificationDate . + } + } + # there might be resources that have neither values nor links + UNION { + { + @{ + org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelSubQuery( + searchTerm = searchTerm, + limitToProject = limitToProject, + limitToResourceClass = limitToResourceClass, + limit = limit, + offset = offset, + countQuery = countQuery) + } + } + + ?resource ?resourceValueProperty ?valueObject . + ?resourceValueProperty rdfs:subPropertyOf* knora-base:hasValue . + + ?valueObject a ?valueObjectType ; + ?valueObjectProperty ?valueObjectValue . + + ?valueObjectType rdfs:subClassOf* knora-base:Value . + + FILTER(?valueObjectType != knora-base:LinkValue) + + FILTER NOT EXISTS { + ?valueObject knora-base:isDeleted true . + } + + FILTER NOT EXISTS { + ?valueObjectValue a knora-base:StandoffTag . + } + } } } else { @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelStandard( - triplestore = triplestore, + org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelSubQuery( searchTerm = searchTerm, limitToProject = limitToProject, limitToResourceClass = limitToResourceClass, limit = limit, offset = offset, - countQuery = countQuery - ) + countQuery = countQuery) } } diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelGraphDB.scala.txt deleted file mode 100644 index 08b7c3f7e5..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelGraphDB.scala.txt +++ /dev/null @@ -1,106 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.util.ApacheLuceneSupport.MatchStringWhileTyping - -@* - * Performs a search for resources by their label. - * - * @param searchTerm search terms. - * @param limitToProject limit search to the given project. - * @param limitToResourceClass limit search to given resource class. - * @param limit maximum amount of resources to be returned. - * @param offset offset to be used for paging. - * @param countQuery indicates whether it is a count query or the actual resources should be returned. - *@ -@(searchTerm: MatchStringWhileTyping, - limitToProject: Option[IRI], - limitToResourceClass: Option[IRI], - limit: Int, - offset: Int, - countQuery: Boolean) - -PREFIX rdfs: -PREFIX knora-base: - -@if(!countQuery) { - CONSTRUCT { - ?resource rdfs:label ?label ; - a knora-base:Resource ; - knora-base:isMainResource true ; - knora-base:isDeleted false ; - a ?resourceType ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:attachedToProject ?resourceProject ; - knora-base:creationDate ?creationDate ; - knora-base:lastModificationDate ?lastModificationDate . - - # include this inferred information in the results, needed to identify value properties - ?resource knora-base:hasValue ?valueObject ; - ?resourceValueProperty ?valueObject . - ?valueObject ?valueObjectProperty ?valueObjectValue . - - } WHERE { - { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelSubQuerySelectGraphDB( - searchTerm = searchTerm, - limitToProject = limitToProject, - limitToResourceClass = limitToResourceClass, - limit = limit, - offset = offset, - countQuery = countQuery) - } - } - - { - GRAPH { - ?resource a ?resourceType . - } - - ?resource knora-base:attachedToUser ?resourceCreator ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:attachedToProject ?resourceProject ; - knora-base:creationDate ?creationDate ; - rdfs:label ?label . - - OPTIONAL { - ?resource knora-base:lastModificationDate ?lastModificationDate . - } - } - # there might be resources that have neither values nor links - UNION { - ?resource knora-base:hasValue ?valueObject . - ?valueObject a knora-base:Value . - - GRAPH { - ?resource ?resourceValueProperty ?valueObject . - - ?valueObject knora-base:isDeleted false ; - a ?valueObjectType ; - ?valueObjectProperty ?valueObjectValue . - } - - FILTER(?valueObjectType != knora-base:LinkValue) - - FILTER NOT EXISTS { - ?valueObjectValue a knora-base:StandoffTag . - } - } - } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelSubQuerySelectGraphDB( - searchTerm = searchTerm, - limitToProject = limitToProject, - limitToResourceClass = limitToResourceClass, - limit = limit, - offset = offset, - countQuery = countQuery) - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelStandard.scala.txt deleted file mode 100644 index 80e69d2fd5..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelStandard.scala.txt +++ /dev/null @@ -1,118 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.util.ApacheLuceneSupport.MatchStringWhileTyping - -@* - * Performs a search for resources by their label. - * - * @param triplestore the name of the triplestore being used. - * @param searchTerm search terms. - * @param limitToProject limit search to the given project. - * @param limitToResourceClass limit search to given resource class. - * @param limit maximum amount of resources to be returned. - * @param offset offset to be used for paging. - * @param countQuery indicates whether it is a count query or the actual resources should be returned. - *@ -@(triplestore: String, - searchTerm: MatchStringWhileTyping, - limitToProject: Option[IRI], - limitToResourceClass: Option[IRI], - limit: Int, - offset: Int, - countQuery: Boolean) - -PREFIX rdfs: -PREFIX knora-base: - -@if(!countQuery) { - CONSTRUCT { - ?resource rdfs:label ?label ; - a knora-base:Resource ; - knora-base:isMainResource true ; - knora-base:isDeleted false ; - a ?resourceType ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:attachedToProject ?resourceProject ; - knora-base:creationDate ?creationDate ; - knora-base:lastModificationDate ?lastModificationDate . - - # include this inferred information in the results, needed to identify value properties - ?resource knora-base:hasValue ?valueObject ; - ?resourceValueProperty ?valueObject . - ?valueObject ?valueObjectProperty ?valueObjectValue . - - } WHERE { - { - { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelSubQuerySelectStandard( - searchTerm = searchTerm, - limitToProject = limitToProject, - limitToResourceClass = limitToResourceClass, - limit = limit, - offset = offset, - countQuery = countQuery) - } - } - - ?resource a ?resourceType ; - knora-base:attachedToUser ?resourceCreator ; - knora-base:hasPermissions ?resourcePermissions ; - knora-base:attachedToProject ?resourceProject ; - knora-base:creationDate ?creationDate ; - rdfs:label ?label . - - OPTIONAL { - ?resource knora-base:lastModificationDate ?lastModificationDate . - } - } - # there might be resources that have neither values nor links - UNION { - { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelSubQuerySelectStandard( - searchTerm = searchTerm, - limitToProject = limitToProject, - limitToResourceClass = limitToResourceClass, - limit = limit, - offset = offset, - countQuery = countQuery) - } - } - - ?resource ?resourceValueProperty ?valueObject . - ?resourceValueProperty rdfs:subPropertyOf* knora-base:hasValue . - - ?valueObject a ?valueObjectType ; - ?valueObjectProperty ?valueObjectValue . - - ?valueObjectType rdfs:subClassOf* knora-base:Value . - - FILTER(?valueObjectType != knora-base:LinkValue) - - FILTER NOT EXISTS { - ?valueObject knora-base:isDeleted true . - } - - FILTER NOT EXISTS { - ?valueObjectValue a knora-base:StandoffTag . - } - } - } -} else { - @{ - org.knora.webapi.messages.twirl.queries.sparql.v2.txt.searchResourceByLabelSubQuerySelectStandard( - searchTerm = searchTerm, - limitToProject = limitToProject, - limitToResourceClass = limitToResourceClass, - limit = limit, - offset = offset, - countQuery = countQuery) - } -} diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelSubQuerySelectStandard.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelSubQuery.scala.txt similarity index 100% rename from webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelSubQuerySelectStandard.scala.txt rename to webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelSubQuery.scala.txt diff --git a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelSubQuerySelectGraphDB.scala.txt b/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelSubQuerySelectGraphDB.scala.txt deleted file mode 100644 index 0a33d8c7d1..0000000000 --- a/webapi/src/main/twirl/org/knora/webapi/messages/twirl/queries/sparql/v2/searchResourceByLabelSubQuerySelectGraphDB.scala.txt +++ /dev/null @@ -1,55 +0,0 @@ -@* - * Copyright © 2021 - 2022 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - *@ - -@import org.knora.webapi.IRI -@import org.knora.webapi.exceptions.SparqlGenerationException -@import org.knora.webapi.util.ApacheLuceneSupport.MatchStringWhileTyping - -@* - * Select subquery for a search for resources by their label. - * - * @param searchTerm search terms. - * @param limitToProject limit search to the given project. - * @param limitToResourceClass limit search to given resource class. - * @param limit maximum amount of resources to be returned. - * @param offset offset to be used for paging. - * @param countQuery indicates whether it is a count query or the actual resources should be returned. - *@ - - @(searchTerm: MatchStringWhileTyping, - limitToProject: Option[IRI], - limitToResourceClass: Option[IRI], - limit: Int, - offset: Int, - countQuery: Boolean) - -@if(!countQuery) { - SELECT DISTINCT ?resource ?label -} else { - SELECT (count(distinct ?resource) as ?count) -} -WHERE { - ?resource a knora-base:Resource ; - knora-base:isDeleted false . - - @if(limitToResourceClass.nonEmpty) { - ?resource a <@limitToResourceClass.get> . - } - - @if(limitToProject.nonEmpty) { - ?resource knora-base:attachedToProject <@limitToProject.get> - } - - GRAPH { - ?resource rdfs:label ?label . - } - - ?label '@searchTerm.generateLiteralForLuceneIndexWithoutExactSequence' . -} -@if(!countQuery) { -ORDER BY ?resource @* Needed for paging: order needs to be deterministic *@ -} -LIMIT @limit -OFFSET @offset diff --git a/webapi/src/main/twirl/org/knora/webapi/queries/sparql/v2/isPropertyUsed.scala.txt b/webapi/src/main/twirl/org/knora/webapi/queries/sparql/v2/isPropertyUsed.scala.txt index 8d9ca8503e..59498c1747 100644 --- a/webapi/src/main/twirl/org/knora/webapi/queries/sparql/v2/isPropertyUsed.scala.txt +++ b/webapi/src/main/twirl/org/knora/webapi/queries/sparql/v2/isPropertyUsed.scala.txt @@ -28,10 +28,7 @@ PREFIX xsd: PREFIX knora-base: ASK -@* Ensure that inference is not used in this query. *@ -@if(triplestore.startsWith("graphdb")) { - FROM -} + WHERE { BIND(IRI("@internalPropertyIri") AS ?property) BIND(IRI("@internalClassIri") AS ?classIri) diff --git a/webapi/src/test/scala/org/knora/webapi/responders/v2/OntologyResponderV2Spec.scala b/webapi/src/test/scala/org/knora/webapi/responders/v2/OntologyResponderV2Spec.scala index f7786239a6..0fbc800fcd 100644 --- a/webapi/src/test/scala/org/knora/webapi/responders/v2/OntologyResponderV2Spec.scala +++ b/webapi/src/test/scala/org/knora/webapi/responders/v2/OntologyResponderV2Spec.scala @@ -6822,17 +6822,6 @@ class OntologyResponderV2Spec extends CoreSpec() with ImplicitSender { loadInvalidTestData(invalidOnto) } - "not load an ontology containing a resource property with no object class constraint" ignore { // Consistency checks don't allow this in GraphDB. - val invalidOnto = List( - RdfDataObject( - path = "test_data/responders.v2.OntologyResponderV2Spec/resource-prop-without-occ-onto.ttl", - name = "http://www.knora.org/ontology/invalid" - ) - ) - - loadInvalidTestData(invalidOnto) - } - "not load an ontology containing a resource property with no rdfs:label" in { val invalidOnto = List( RdfDataObject( @@ -6877,17 +6866,6 @@ class OntologyResponderV2Spec extends CoreSpec() with ImplicitSender { loadInvalidTestData(invalidOnto) } - "not load an ontology containing a property that contains salsah-gui:guiOrder" ignore { // Consistency checks don't allow this in GraphDB. - val invalidOnto = List( - RdfDataObject( - path = "test_data/responders.v2.OntologyResponderV2Spec/prop-with-guiorder-onto.ttl", - name = "http://www.knora.org/ontology/invalid" - ) - ) - - loadInvalidTestData(invalidOnto) - } - "not load an ontology containing a cardinality that contains salsah-gui:guiElement" in { val invalidOnto = List( RdfDataObject( diff --git a/webapi/src/test/scala/org/knora/webapi/store/triplestore/AllTriplestoreSpec.scala b/webapi/src/test/scala/org/knora/webapi/store/triplestore/AllTriplestoreSpec.scala index 2c6230de6f..f7b3dcc4a0 100644 --- a/webapi/src/test/scala/org/knora/webapi/store/triplestore/AllTriplestoreSpec.scala +++ b/webapi/src/test/scala/org/knora/webapi/store/triplestore/AllTriplestoreSpec.scala @@ -47,16 +47,6 @@ class AllTriplestoreSpec extends CoreSpec(AllTriplestoreSpec.config) with Implic ) val countTriplesQuery: String = - if (tsType.startsWith("graphdb")) - """ - SELECT (COUNT(*) AS ?no) - FROM - WHERE - { - ?s ?p ?o . - } - """ - else """ SELECT (COUNT(*) AS ?no) WHERE @@ -135,34 +125,7 @@ class AllTriplestoreSpec extends CoreSpec(AllTriplestoreSpec.config) with Implic } """ - val searchURI: String = if (tsType == TriplestoreTypes.HttpFuseki || tsType == TriplestoreTypes.EmbeddedJenaTdb) { - "" - } else { - //GraphDB - "" - } - - val textSearchQueryGraphDBValueHasString: String = - s""" - PREFIX knora-base: - - SELECT DISTINCT * - WHERE { - ?iri knora-base:valueHasString ?literal . - ?literal 'test' . - } - """ - - val textSearchQueryGraphDBRDFLabel: String = - s""" - PREFIX rdfs: - - SELECT DISTINCT * - WHERE { - ?iri rdfs:label ?literal . - ?literal 'Papa' . - } - """ + val searchURI: String = "" val textSearchQueryFusekiValueHasString: String = s""" @@ -299,9 +262,7 @@ class AllTriplestoreSpec extends CoreSpec(AllTriplestoreSpec.config) with Implic "execute the search with the lucene index for 'knora-base:valueHasString' properties" in { within(1000.millis) { tsType match { - case TriplestoreTypes.HttpGraphDBSE | TriplestoreTypes.HttpGraphDBFree => - storeManager ! SparqlSelectRequest(textSearchQueryGraphDBValueHasString) - case _ => storeManager ! SparqlSelectRequest(textSearchQueryFusekiValueHasString) + case TriplestoreTypes.HttpFuseki => storeManager ! SparqlSelectRequest(textSearchQueryFusekiValueHasString) } expectMsgPF(timeout) { case msg: SparqlSelectResult => //println(msg) @@ -313,9 +274,7 @@ class AllTriplestoreSpec extends CoreSpec(AllTriplestoreSpec.config) with Implic "execute the search with the lucene index for 'rdfs:label' properties" in { within(1000.millis) { tsType match { - case TriplestoreTypes.HttpGraphDBSE | TriplestoreTypes.HttpGraphDBFree => - storeManager ! SparqlSelectRequest(textSearchQueryGraphDBRDFLabel) - case _ => storeManager ! SparqlSelectRequest(textSearchQueryFusekiDRFLabel) + case TriplestoreTypes.HttpFuseki => storeManager ! SparqlSelectRequest(textSearchQueryFusekiDRFLabel) } expectMsgPF(timeout) { case msg: SparqlSelectResult => //println(msg) diff --git a/webapi/src/test/scala/org/knora/webapi/store/triplestore/GraphDBConsistencyCheckingSpec.scala b/webapi/src/test/scala/org/knora/webapi/store/triplestore/GraphDBConsistencyCheckingSpec.scala deleted file mode 100644 index 91dbf22303..0000000000 --- a/webapi/src/test/scala/org/knora/webapi/store/triplestore/GraphDBConsistencyCheckingSpec.scala +++ /dev/null @@ -1,2377 +0,0 @@ -package org.knora.webapi.store.triplestore - -import akka.testkit.ImplicitSender -import com.typesafe.config.ConfigFactory -import org.knora.webapi.CoreSpec -import org.knora.webapi.exceptions.TriplestoreResponseException -import org.knora.webapi.messages.store.triplestoremessages.{ - RdfDataObject, - ResetRepositoryContent, - ResetRepositoryContentACK, - SparqlUpdateRequest -} - -import scala.concurrent.duration._ -import scala.language.postfixOps - -/** - * Tests the GraphDB triplestore consistency checking rules in webapi/scripts/KnoraRules.pie. - */ -class GraphDBConsistencyCheckingSpec extends CoreSpec(GraphDBConsistencyCheckingSpec.config) with ImplicitSender { - import GraphDBConsistencyCheckingSpec._ - - private val timeout = 30.seconds - - override lazy val rdfDataObjects = List( - RdfDataObject( - path = "test_data/store.triplestore.GraphDBConsistencyCheckingSpec/incunabula-data.ttl", - name = "http://www.knora.org/data/0803/incunabula" - ), - RdfDataObject(path = "test_data/all_data/anything-data.ttl", name = "http://www.knora.org/data/0001/anything") - ) - - override def loadTestData(rdfDataObjects: Seq[RdfDataObject]): Unit = { - storeManager ! ResetRepositoryContent(rdfDataObjects) - expectMsg(5 minutes, ResetRepositoryContentACK()) - } - - if (settings.triplestoreType.startsWith("graphdb")) { - - "not create a new resource with a missing property that has owl:cardinality 1" in { - storeManager ! SparqlUpdateRequest(missingPartOf) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - (msg.contains(s"$CONSISTENCY_CHECK_ERROR cardinality_1_not_less_any_object") && - msg.trim.endsWith( - "http://rdfh.ch/0803/missingPartOf http://www.knora.org/ontology/0803/incunabula#partOf *" - )) should ===(true) - } - } - - "not create a new resource with a missing property that has owl:minCardinality 1" in { - storeManager ! SparqlUpdateRequest(missingComment) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - (msg.contains(s"$CONSISTENCY_CHECK_ERROR min_cardinality_1_any_object") && - msg.trim.endsWith( - "http://rdfh.ch/0803/missingComment http://www.knora.org/ontology/knora-base#hasComment *" - )) should ===(true) - } - } - - "not create a new resource with two values for a property that has owl:maxCardinality 1" in { - storeManager ! SparqlUpdateRequest(tooManyPublocs) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - msg.contains(s"$CONSISTENCY_CHECK_ERROR max_cardinality_1_with_deletion_flag") should ===(true) - } - } - - "not create a new resource with more than one lastModificationDate" in { - storeManager ! SparqlUpdateRequest(tooManyLastModificationDates) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - msg.contains(s"$CONSISTENCY_CHECK_ERROR max_cardinality_1_without_deletion_flag") should ===(true) - } - } - - "not create a new resource with a property that cannot have a resource as a subject" in { - storeManager ! SparqlUpdateRequest(wrongSubjectClass) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - msg.contains(s"$CONSISTENCY_CHECK_ERROR subject_class_constraint") should ===(true) - } - } - - "not create a new resource with properties whose objects have the wrong types" in { - storeManager ! SparqlUpdateRequest(wrongObjectClass) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - msg.contains(s"$CONSISTENCY_CHECK_ERROR object_class_constraint") should ===(true) - } - } - - "not create a new resource with a link to a resource of the wrong class" in { - storeManager ! SparqlUpdateRequest(wrongLinkTargetClass) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - msg.contains(s"$CONSISTENCY_CHECK_ERROR object_class_constraint") should ===(true) - } - } - - "not create a new resource with a property for which there is no cardinality" in { - storeManager ! SparqlUpdateRequest(resourcePropWithNoCardinality) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - msg.contains(s"$CONSISTENCY_CHECK_ERROR resource_prop_cardinality_any") should ===(true) - } - } - - "not create a new resource containing a value with a property for which there is no cardinality" in { - storeManager ! SparqlUpdateRequest(valuePropWithNoCardinality) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - msg.contains(s"$CONSISTENCY_CHECK_ERROR value_prop_cardinality_any") should ===(true) - } - } - - "not create a new resource with two labels" in { - storeManager ! SparqlUpdateRequest(twoLabels) - - expectMsgPF(timeout) { case akka.actor.Status.Failure(TriplestoreResponseException(msg: String, _)) => - msg.contains(s"$CONSISTENCY_CHECK_ERROR cardinality_1_not_greater_rdfs_label") should ===(true) - } - } - } else { - s"Not running GraphDBConsistencyCheckingSpec with triplestore type ${settings.triplestoreType}" in {} - } -} - -object GraphDBConsistencyCheckingSpec { - // A string that's found in all consistency check error messages from GraphDB. - private val CONSISTENCY_CHECK_ERROR = "Consistency check" - - private val config = ConfigFactory.parseString(""" - # akka.loglevel = "DEBUG" - # akka.stdout-loglevel = "DEBUG" - """.stripMargin) - - // Tries to create a new incunabula:page with a missing incunabula:partOf link. - private val missingPartOf = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource0 rdf:type ?resourceClass0 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label0 ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pagenum - | - | - | ?newValue0_1 rdf:type ?valueType0_1 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid1" . - | - | - | - | ?newValue0_1 knora-base:valueHasString "recto" . - | - | - | - | ?newValue0_1 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0_1 knora-base:valueHasOrder ?nextOrder0_1 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource0 ?property0_1 ?newValue0_1 . - | - | - | - | - | # Value 2 - | # Property: http://www.knora.org/ontology/knora-base#hasStillImageFileValue - | - | - | ?newValue0_2 rdf:type ?valueType0_2 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid2" . - | - | - | ?newValue0_2 knora-base:originalFilename "test.jpg" ; - | knora-base:originalMimeType "image/jpeg" ; - | knora-base:internalFilename "full.jp2" ; - | knora-base:internalMimeType "image/jp2" ; - | knora-base:dimX 800 ; - | knora-base:dimY 800 . - | - | - | - | ?newValue0_2 knora-base:valueHasString "test.jpg" . - | - | - | ?newValue0_2 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0_2 knora-base:valueHasOrder ?nextOrder0_2 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource0 ?property0_2 ?newValue0_2 . - | - | - | - | - | # Value 3 - | # Property: http://www.knora.org/ontology/knora-base#hasStillImageFileValue - | - | - | ?newValue0_3 rdf:type ?valueType0_3 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid3" . - | - | - | ?newValue0_3 knora-base:originalFilename "test.jpg" ; - | knora-base:originalMimeType "image/jpeg" ; - | knora-base:internalFilename "thumb.jpg" ; - | knora-base:internalMimeType "image/jpeg" ; - | knora-base:dimX 80 ; - | knora-base:dimY 80 . - | - | - | ?newValue0_3 knora-base:isPreview true . - | - | - | ?newValue0_3 knora-base:valueHasString "test.jpg" . - | - | - | - | ?newValue0_3 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0_3 knora-base:valueHasOrder ?nextOrder0_3 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource0 ?property0_3 ?newValue0_3 . - | - | - | - | - | # Value 4 - | # Property: http://www.knora.org/ontology/0803/incunabula#hasRightSideband - | - | - | - | ?resource0 ?linkProperty0_4 ?linkTarget0_4 . - | - | - | - | ?newLinkValue0_4 rdf:type knora-base:LinkValue ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid4" ; - | rdf:subject ?resource0 ; - | rdf:predicate ?linkProperty0_4 ; - | rdf:object ?linkTarget0_4 ; - | knora-base:valueHasRefCount 1 ; - | - | knora-base:valueHasOrder ?nextOrder0_4 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | ?newLinkValue0_4 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?resource0 ?linkValueProperty0_4 ?newLinkValue0_4 . - | - | - | - | - | # Value 5 - | # Property: http://www.knora.org/ontology/0803/incunabula#origname - | - | - | ?newValue0_5 rdf:type ?valueType0_5 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid5" . - | - | - | - | ?newValue0_5 knora-base:valueHasString "Blatt" . - | - | - | - | - | ?newValue0_5 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0_5 knora-base:valueHasOrder ?nextOrder0_5 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource0 ?property0_5 ?newValue0_5 . - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#seqnum - | - | - | ?newValue0_6 rdf:type ?valueType0_6 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid6" . - | - | - | - | ?newValue0_6 knora-base:valueHasInteger 1 ; - | knora-base:valueHasString "1" . - | - | - | ?newValue0_6 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0_6 knora-base:valueHasOrder ?nextOrder0_6 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource0 ?property0_6 ?newValue0_6 . - | - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0803/incunabula") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0803/missingPartOf") AS ?resource0) - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#page") AS ?resourceClass0) - | BIND(IRI("http://rdfh.ch/users/b83acc5f05") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0803") AS ?projectIri) - | BIND(str("Test-Page") AS ?label0) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pagenum - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#pagenum") AS ?property0_1) - | BIND(IRI("http://rdfh.ch/0803/missingPartOf/values/nQ3tRObaQWe74WQv2_OdCg") AS ?newValue0_1) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType0_1) - | - | - | - | ?property0_1 knora-base:objectClassConstraint ?propertyRange0_1 . - | ?valueType0_1 rdfs:subClassOf* ?propertyRange0_1 . - | - | - | - | ?resourceClass0 rdfs:subClassOf* ?restriction0_1 . - | ?restriction0_1 a owl:Restriction . - | ?restriction0_1 owl:onProperty ?property0_1 . - | - | - | - | - | BIND(0 AS ?nextOrder0_1) - | - | - | - | - | - | - | # Value 2 - | # Property: http://www.knora.org/ontology/knora-base#hasStillImageFileValue - | - | BIND(IRI("http://www.knora.org/ontology/knora-base#hasStillImageFileValue") AS ?property0_2) - | BIND(IRI("http://rdfh.ch/0803/missingPartOf/values/GVE754RbT1CykpMnwR3Csw") AS ?newValue0_2) - | BIND(IRI("http://www.knora.org/ontology/knora-base#StillImageFileValue") AS ?valueType0_2) - | - | - | - | ?property0_2 knora-base:objectClassConstraint ?propertyRange0_2 . - | ?valueType0_2 rdfs:subClassOf* ?propertyRange0_2 . - | - | - | - | ?resourceClass0 rdfs:subClassOf* ?restriction0_2 . - | ?restriction0_2 a owl:Restriction . - | ?restriction0_2 owl:onProperty ?property0_2 . - | - | - | - | - | BIND(0 AS ?nextOrder0_2) - | - | - | - | - | - | - | # Value 3 - | # Property: http://www.knora.org/ontology/knora-base#hasStillImageFileValue - | - | BIND(IRI("http://www.knora.org/ontology/knora-base#hasStillImageFileValue") AS ?property0_3) - | BIND(IRI("http://rdfh.ch/0803/missingPartOf/values/LOT71U6hSQu7shi76oRxWQ") AS ?newValue0_3) - | BIND(IRI("http://www.knora.org/ontology/knora-base#StillImageFileValue") AS ?valueType0_3) - | - | - | - | ?property0_3 knora-base:objectClassConstraint ?propertyRange0_3 . - | ?valueType0_3 rdfs:subClassOf* ?propertyRange0_3 . - | - | - | - | ?resourceClass0 rdfs:subClassOf* ?restriction0_3 . - | ?restriction0_3 a owl:Restriction . - | ?restriction0_3 owl:onProperty ?property0_3 . - | - | - | - | - | BIND(1 AS ?nextOrder0_3) - | - | - | - | - | - | - | # Value 4 - | # Property: http://www.knora.org/ontology/0803/incunabula#hasRightSideband - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#hasRightSideband") AS ?linkProperty0_4) - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#hasRightSidebandValue") AS ?linkValueProperty0_4) - | BIND(IRI("http://rdfh.ch/0803/missingPartOf/values/i5tE5i-RRLOH631soexPFw") AS ?newLinkValue0_4) - | BIND(IRI("http://rdfh.ch/0803/482a33d65c36") AS ?linkTarget0_4) - | - | - | - | ?linkTarget0_4 rdf:type ?linkTargetClass0_4 . - | ?linkTargetClass0_4 rdfs:subClassOf+ knora-base:Resource . - | - | - | - | ?linkProperty0_4 knora-base:objectClassConstraint ?expectedTargetClass0_4 . - | ?linkTargetClass0_4 rdfs:subClassOf* ?expectedTargetClass0_4 . - | - | - | - | MINUS { - | ?linkTarget4 knora-base:isDeleted true . - | } - | - | - | - | ?resourceClass0 rdfs:subClassOf* ?restriction0_4 . - | ?restriction0_4 a owl:Restriction . - | ?restriction0_4 owl:onProperty ?linkProperty0_4 . - | - | - | - | - | BIND(0 AS ?nextOrder0_4) - | - | - | - | - | - | - | # Value 5 - | # Property: http://www.knora.org/ontology/0803/incunabula#origname - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#origname") AS ?property0_5) - | BIND(IRI("http://rdfh.ch/0803/missingPartOf/values/MLWWT-F8SlKsZmRo4JMLHw") AS ?newValue0_5) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType0_5) - | - | - | - | ?property0_5 knora-base:objectClassConstraint ?propertyRange0_5 . - | ?valueType0_5 rdfs:subClassOf* ?propertyRange0_5 . - | - | - | - | ?resourceClass0 rdfs:subClassOf* ?restriction0_5 . - | ?restriction0_5 a owl:Restriction . - | ?restriction0_5 owl:onProperty ?property0_5 . - | - | - | - | - | BIND(0 AS ?nextOrder0_5) - | - | - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#seqnum - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#seqnum") AS ?property0_6) - | BIND(IRI("http://rdfh.ch/0803/missingPartOf/values/uWQtW_X3RxKjFyGrsQwbpQ") AS ?newValue0_6) - | BIND(IRI("http://www.knora.org/ontology/knora-base#IntValue") AS ?valueType0_6) - | - | - | - | ?property0_6 knora-base:objectClassConstraint ?propertyRange0_6 . - | ?valueType0_6 rdfs:subClassOf* ?propertyRange0_6 . - | - | - | - | ?resourceClass0 rdfs:subClassOf* ?restriction0_6 . - | ?restriction0_6 a owl:Restriction . - | ?restriction0_6 owl:onProperty ?property0_6 . - | - | - | - | - | BIND(0 AS ?nextOrder0_6) - | - |} - """.stripMargin - - // Tries to create a knora-base:Annotation with a missing knora-base:hasComment. - private val missingComment = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource rdf:type ?resourceClass ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/knora-base#isAnnotationOf - | - | - | - | ?resource ?linkProperty0 ?linkTarget0 . - | - | - | - | ?newLinkValue0 rdf:type knora-base:LinkValue ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid0" ; - | rdf:subject ?resource ; - | rdf:predicate ?linkProperty0 ; - | rdf:object ?linkTarget0 ; - | knora-base:valueHasRefCount 1 ; - | - | knora-base:valueHasOrder ?nextOrder0 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | ?newLinkValue0 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | - | ?resource ?linkValueProperty0 ?newLinkValue0 . - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0803/incunabula") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0803/missingComment") AS ?resource) - | BIND(IRI("http://www.knora.org/ontology/knora-base#Annotation") AS ?resourceClass) - | BIND(IRI("http://rdfh.ch/users/b83acc5f05") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0803") AS ?projectIri) - | BIND(str("Test Annotation") AS ?label) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/knora-base#isAnnotationOf - | - | BIND(IRI("http://www.knora.org/ontology/knora-base#isAnnotationOf") AS ?linkProperty0) - | BIND(IRI("http://www.knora.org/ontology/knora-base#isAnnotationOfValue") AS ?linkValueProperty0) - | BIND(IRI("http://rdfh.ch/0803/missingComment/values/RFzfHLk1R-mU66NAFrVTYQ") AS ?newLinkValue0) - | BIND(IRI("http://rdfh.ch/0803/c5058f3a") AS ?linkTarget0) - | - | - | - | ?linkTarget0 rdf:type ?linkTargetClass0 . - | ?linkTargetClass0 rdfs:subClassOf+ knora-base:Resource . - | - | - | - | ?linkProperty0 knora-base:objectClassConstraint ?expectedTargetClass0 . - | ?linkTargetClass0 rdfs:subClassOf* ?expectedTargetClass0 . - | - | - | - | MINUS { - | ?linkTarget0 knora-base:isDeleted true . - | } - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction0 . - | ?restriction0 a owl:Restriction . - | ?restriction0 owl:onProperty ?linkProperty0 . - | - | - | BIND(0 AS ?nextOrder0) - |} - """.stripMargin - - // Tries to create an incunabula:book with two incunabula:publoc values (at most one is allowed). - private val tooManyPublocs = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource rdf:type ?resourceClass ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | - | ?newValue0 rdf:type ?valueType0 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid0" . - | - | - | - | ?newValue0 knora-base:valueHasString "A beautiful book" . - | - | - | - | ?newValue0 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0 knora-base:valueHasOrder ?nextOrder0 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property0 ?newValue0 . - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | - | ?newValue1 rdf:type ?valueType1 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid1" . - | - | - | - | ?newValue1 knora-base:valueHasStartJDN 2457360 ; - | knora-base:valueHasEndJDN 2457360 ; - | knora-base:valueHasStartPrecision "DAY" ; - | knora-base:valueHasEndPrecision "DAY" ; - | knora-base:valueHasCalendar "GREGORIAN" ; - | knora-base:valueHasString "2015-12-03" . - | - | - | - | ?newValue1 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue1 knora-base:valueHasOrder ?nextOrder1 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property1 ?newValue1 . - | - | - | - | - | # Value 2 - | # Property: http://www.knora.org/ontology/0803/incunabula#citation - | - | - | ?newValue2 rdf:type ?valueType2 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid2" . - | - | - | - | ?newValue2 knora-base:valueHasString "noch ein letztes" . - | - | - | - | - | ?newValue2 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue2 knora-base:valueHasOrder ?nextOrder2 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property2 ?newValue2 . - | - | - | - | - | # Value 3 - | # Property: http://www.knora.org/ontology/0803/incunabula#citation - | - | - | ?newValue3 rdf:type ?valueType3 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid3" . - | - | - | ?newValue3 knora-base:valueHasString "ein Zitat" . - | - | - | ?newValue3 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue3 knora-base:valueHasOrder ?nextOrder3 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property3 ?newValue3 . - | - | - | - | - | # Value 4 - | # Property: http://www.knora.org/ontology/0803/incunabula#citation - | - | - | ?newValue4 rdf:type ?valueType4 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid4" . - | - | - | - | ?newValue4 knora-base:valueHasString "und noch eines" . - | - | - | - | ?newValue4 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue4 knora-base:valueHasOrder ?nextOrder4 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property4 ?newValue4 . - | - | - | - | - | # Value 5 - | # Property: http://www.knora.org/ontology/0803/incunabula#citation - | - | - | ?newValue5 rdf:type ?valueType5 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid5" . - | - | - | - | ?newValue5 knora-base:valueHasString "This citation refers to another resource" . - | - | - | - | - | ?newValue5 knora-base:valueHasStandoff - | [ - | - | - | rdf:type knora-base:StandoffVisualAttribute ; - | knora-base:standoffHasAttribute "bold" ; - | - | - | knora-base:standoffHasStart 5 ; - | knora-base:standoffHasEnd 13 - | ] . - | - | ?newValue5 knora-base:valueHasStandoff - | [ - | - | - | rdf:type knora-base:StandoffLink ; - | knora-base:standoffHasAttribute "_link" ; - | knora-base:standoffHasLink ; - | - | - | knora-base:standoffHasStart 32 ; - | knora-base:standoffHasEnd 40 - | ] . - | - | - | - | ?newValue5 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue5 knora-base:valueHasOrder ?nextOrder5 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property5 ?newValue5 . - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | - | ?newValue6 rdf:type ?valueType6 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid6" . - | - | - | - | ?newValue6 knora-base:valueHasString "Entenhausen" . - | - | - | - | - | ?newValue6 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue6 knora-base:valueHasOrder ?nextOrder6 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property6 ?newValue6 . - | - | - | - | - | # Value 7 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | - | ?newValue7 rdf:type ?valueType7 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid7" . - | - | - | - | ?newValue7 knora-base:valueHasString "Bebenhausen" . - | - | - | - | ?newValue7 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue7 knora-base:valueHasOrder ?nextOrder7 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property7 ?newValue7 . - | - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0803/incunabula") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs") AS ?resource) - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#book") AS ?resourceClass) - | BIND(IRI("http://rdfh.ch/users/b83acc5f05") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0803") AS ?projectIri) - | BIND(str("Test-Book") AS ?label) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#title") AS ?property0) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs/values/IKVNJVSWTryEtK4i9OCSIQ") AS ?newValue0) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType0) - | - | - | - | ?property0 knora-base:objectClassConstraint ?propertyRange0 . - | ?valueType0 rdfs:subClassOf* ?propertyRange0 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction0 . - | ?restriction0 a owl:Restriction . - | ?restriction0 owl:onProperty ?property0 . - | - | - | - | - | BIND(0 AS ?nextOrder0) - | - | - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#pubdate") AS ?property1) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs/values/L4YSL2SeSkKVt-J9OQAMog") AS ?newValue1) - | BIND(IRI("http://www.knora.org/ontology/knora-base#DateValue") AS ?valueType1) - | - | - | - | ?property1 knora-base:objectClassConstraint ?propertyRange1 . - | ?valueType1 rdfs:subClassOf* ?propertyRange1 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction1 . - | ?restriction1 a owl:Restriction . - | ?restriction1 owl:onProperty ?property1 . - | - | - | - | BIND(0 AS ?nextOrder1) - | - | - | - | - | - | - | # Value 2 - | # Property: http://www.knora.org/ontology/0803/incunabula#citation - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#citation") AS ?property2) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs/values/oTvvcMRgR_CC-Os-61I-Qw") AS ?newValue2) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType2) - | - | - | - | ?property2 knora-base:objectClassConstraint ?propertyRange2 . - | ?valueType2 rdfs:subClassOf* ?propertyRange2 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction2 . - | ?restriction2 a owl:Restriction . - | ?restriction2 owl:onProperty ?property2 . - | - | - | - | BIND(0 AS ?nextOrder2) - | - | - | - | - | - | - | # Value 3 - | # Property: http://www.knora.org/ontology/0803/incunabula#citation - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#citation") AS ?property3) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs/values/Jvcncu3iSr2_fWdWdOfn-w") AS ?newValue3) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType3) - | - | - | - | ?property3 knora-base:objectClassConstraint ?propertyRange3 . - | ?valueType3 rdfs:subClassOf* ?propertyRange3 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction3 . - | ?restriction3 a owl:Restriction . - | ?restriction3 owl:onProperty ?property3 . - | - | - | - | BIND(1 AS ?nextOrder3) - | - | - | - | - | - | - | # Value 4 - | # Property: http://www.knora.org/ontology/0803/incunabula#citation - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#citation") AS ?property4) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs/values/7wJJcQLtS2mG_tyPKCe1Ig") AS ?newValue4) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType4) - | - | - | - | ?property4 knora-base:objectClassConstraint ?propertyRange4 . - | ?valueType4 rdfs:subClassOf* ?propertyRange4 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction4 . - | ?restriction4 a owl:Restriction . - | ?restriction4 owl:onProperty ?property4 . - | - | - | BIND(2 AS ?nextOrder4) - | - | - | - | - | - | - | # Value 5 - | # Property: http://www.knora.org/ontology/0803/incunabula#citation - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#citation") AS ?property5) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs/values/y7zDf5oNSE6-9GNNgXSbwA") AS ?newValue5) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType5) - | - | - | - | ?property5 knora-base:objectClassConstraint ?propertyRange5 . - | ?valueType5 rdfs:subClassOf* ?propertyRange5 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction5 . - | ?restriction5 a owl:Restriction . - | ?restriction5 owl:onProperty ?property5 . - | - | - | - | BIND(3 AS ?nextOrder5) - | - | - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#publoc") AS ?property6) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs/values/1ryBgY4MSn2Y8K8QAPiJBw0") AS ?newValue6) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType6) - | - | - | - | ?property6 knora-base:objectClassConstraint ?propertyRange6 . - | ?valueType6 rdfs:subClassOf* ?propertyRange6 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction6 . - | ?restriction6 a owl:Restriction . - | ?restriction6 owl:onProperty ?property6 . - | - | - | - | BIND(0 AS ?nextOrder6) - | - | - | # Value 7 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#publoc") AS ?property7) - | BIND(IRI("http://rdfh.ch/0803/tooManyPublocs/values/1ryBgY4MSn2Y8K8QAPiJBw1") AS ?newValue7) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType7) - | - | - | - | ?property7 knora-base:objectClassConstraint ?propertyRange7 . - | ?valueType7 rdfs:subClassOf* ?propertyRange7 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction7 . - | ?restriction7 a owl:Restriction . - | ?restriction7 owl:onProperty ?property7 . - | - | - | - | BIND(1 AS ?nextOrder7) - |} - """.stripMargin - - private val tooManyLastModificationDates = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource rdf:type ?resourceClass ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:lastModificationDate "2016-01-23T11:31:24Z"^^xsd:dateTime ; - | knora-base:lastModificationDate ?currentTime ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | - | ?newValue0 rdf:type ?valueType0 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid0" . - | - | - | - | ?newValue0 knora-base:valueHasString "A beautiful book" . - | - | - | - | ?newValue0 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0 knora-base:valueHasOrder ?nextOrder0 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property0 ?newValue0 . - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | - | ?newValue1 rdf:type ?valueType1 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid1" . - | - | - | - | ?newValue1 knora-base:valueHasStartJDN 2457360 ; - | knora-base:valueHasEndJDN 2457360 ; - | knora-base:valueHasStartPrecision "DAY" ; - | knora-base:valueHasEndPrecision "DAY" ; - | knora-base:valueHasCalendar "GREGORIAN" ; - | knora-base:valueHasString "2015-12-03" . - | - | - | - | - | ?newValue1 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue1 knora-base:valueHasOrder ?nextOrder1 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property1 ?newValue1 . - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | - | ?newValue6 rdf:type ?valueType6 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid6" . - | - | - | - | ?newValue6 knora-base:valueHasString "Entenhausen" . - | - | - | - | - | - | ?newValue6 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue6 knora-base:valueHasOrder ?nextOrder6 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property6 ?newValue6 . - | - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0803/incunabula") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0803/tooManyLastModificationDates") AS ?resource) - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#book") AS ?resourceClass) - | BIND(IRI("http://rdfh.ch/users/b83acc5f05") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0803") AS ?projectIri) - | BIND(str("Test-Book") AS ?label) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#title") AS ?property0) - | BIND(IRI("http://rdfh.ch/0803/tooManyLastModificationDates/values/IKVNJVSWTryEtK4i9OCSIQ") AS ?newValue0) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType0) - | - | - | - | ?property0 knora-base:objectClassConstraint ?propertyRange0 . - | ?valueType0 rdfs:subClassOf* ?propertyRange0 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction0 . - | ?restriction0 a owl:Restriction . - | ?restriction0 owl:onProperty ?property0 . - | - | - | - | BIND(0 AS ?nextOrder0) - | - | - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#pubdate") AS ?property1) - | BIND(IRI("http://rdfh.ch/0803/tooManyLastModificationDates/values/L4YSL2SeSkKVt-J9OQAMog") AS ?newValue1) - | BIND(IRI("http://www.knora.org/ontology/knora-base#DateValue") AS ?valueType1) - | - | - | - | ?property1 knora-base:objectClassConstraint ?propertyRange1 . - | ?valueType1 rdfs:subClassOf* ?propertyRange1 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction1 . - | ?restriction1 a owl:Restriction . - | ?restriction1 owl:onProperty ?property1 . - | - | - | - | BIND(0 AS ?nextOrder1) - | - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#publoc") AS ?property6) - | BIND(IRI("http://rdfh.ch/0803/tooManyLastModificationDates/values/1ryBgY4MSn2Y8K8QAPiJBw") AS ?newValue6) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType6) - | - | - | - | ?property6 knora-base:objectClassConstraint ?propertyRange6 . - | ?valueType6 rdfs:subClassOf* ?propertyRange6 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction6 . - | ?restriction6 a owl:Restriction . - | ?restriction6 owl:onProperty ?property6 . - | - | - | - | BIND(0 AS ?nextOrder6) - | - | - | - |} - """.stripMargin - - private val wrongSubjectClass = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource rdf:type ?resourceClass ; - | knora-base:valueHasString "A resource is not allowed to have a valueHasString property" ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:lastModificationDate ?currentTime ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | - | ?newValue0 rdf:type ?valueType0 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid0" . - | - | - | - | ?newValue0 knora-base:valueHasString "A beautiful book" . - | - | - | - | - | ?newValue0 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0 knora-base:valueHasOrder ?nextOrder0 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property0 ?newValue0 . - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | - | ?newValue1 rdf:type ?valueType1 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid1" . - | - | - | - | ?newValue1 knora-base:valueHasStartJDN 2457360 ; - | knora-base:valueHasEndJDN 2457360 ; - | knora-base:valueHasStartPrecision "DAY" ; - | knora-base:valueHasEndPrecision "DAY" ; - | knora-base:valueHasCalendar "GREGORIAN" ; - | knora-base:valueHasString "2015-12-03" . - | - | - | - | ?newValue1 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue1 knora-base:valueHasOrder ?nextOrder1 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property1 ?newValue1 . - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | - | ?newValue6 rdf:type ?valueType6 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid6" . - | - | - | - | ?newValue6 knora-base:valueHasString "Entenhausen" . - | - | - | - | - | ?newValue6 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue6 knora-base:valueHasOrder ?nextOrder6 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | ?resource ?property6 ?newValue6 . - | - | - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0803/incunabula") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0803/wrongSubjectClass") AS ?resource) - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#book") AS ?resourceClass) - | BIND(IRI("http://rdfh.ch/users/b83acc5f05") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0803") AS ?projectIri) - | BIND(str("Test-Book") AS ?label) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#title") AS ?property0) - | BIND(IRI("http://rdfh.ch/0803/wrongSubjectClass/values/IKVNJVSWTryEtK4i9OCSIQ") AS ?newValue0) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType0) - | - | - | - | ?property0 knora-base:objectClassConstraint ?propertyRange0 . - | ?valueType0 rdfs:subClassOf* ?propertyRange0 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction0 . - | ?restriction0 a owl:Restriction . - | ?restriction0 owl:onProperty ?property0 . - | - | - | - | BIND(0 AS ?nextOrder0) - | - | - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#pubdate") AS ?property1) - | BIND(IRI("http://rdfh.ch/0803/wrongSubjectClass/values/L4YSL2SeSkKVt-J9OQAMog") AS ?newValue1) - | BIND(IRI("http://www.knora.org/ontology/knora-base#DateValue") AS ?valueType1) - | - | - | - | ?property1 knora-base:objectClassConstraint ?propertyRange1 . - | ?valueType1 rdfs:subClassOf* ?propertyRange1 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction1 . - | ?restriction1 a owl:Restriction . - | ?restriction1 owl:onProperty ?property1 . - | - | - | - | BIND(0 AS ?nextOrder1) - | - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#publoc") AS ?property6) - | BIND(IRI("http://rdfh.ch/0803/wrongSubjectClass/values/1ryBgY4MSn2Y8K8QAPiJBw") AS ?newValue6) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType6) - | - | - | - | ?property6 knora-base:objectClassConstraint ?propertyRange6 . - | ?valueType6 rdfs:subClassOf* ?propertyRange6 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction6 . - | ?restriction6 a owl:Restriction . - | ?restriction6 owl:onProperty ?property6 . - | - | - | - | BIND(0 AS ?nextOrder6) - | - | - | - |} - """.stripMargin - - private val wrongObjectClass = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource rdf:type ?resourceClass ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:lastModificationDate ?currentTime ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | - | ?newValue0 rdf:type ?valueType0 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid0" . - | - | - | - | ?newValue0 knora-base:valueHasString "A beautiful book" . - | - | - | - | - | ?newValue0 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0 knora-base:valueHasOrder ?nextOrder0 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property1 ?newValue0 . # ?property0 and ?property1 are reversed to cause an error. - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | - | ?newValue1 rdf:type ?valueType1 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid1" . - | - | - | - | ?newValue1 knora-base:valueHasStartJDN 2457360 ; - | knora-base:valueHasEndJDN 2457360 ; - | knora-base:valueHasStartPrecision "DAY" ; - | knora-base:valueHasEndPrecision "DAY" ; - | knora-base:valueHasCalendar "GREGORIAN" ; - | knora-base:valueHasString "2015-12-03" . - | - | ?newValue1 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue1 knora-base:valueHasOrder ?nextOrder1 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property0 ?newValue1 . # ?property0 and ?property1 are reversed to cause an error. - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | - | ?newValue6 rdf:type ?valueType6 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid6" . - | - | - | - | ?newValue6 knora-base:valueHasString "Entenhausen" . - | - | - | - | ?newValue6 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue6 knora-base:valueHasOrder ?nextOrder6 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | ?resource ?property6 ?newValue6 . - | - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0803/incunabula") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0803/wrongObjectClass") AS ?resource) - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#book") AS ?resourceClass) - | BIND(IRI("http://rdfh.ch/users/b83acc5f05") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0803") AS ?projectIri) - | BIND(str("Test-Book") AS ?label) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#title") AS ?property0) - | BIND(IRI("http://rdfh.ch/0803/wrongObjectClass/values/IKVNJVSWTryEtK4i9OCSIQ") AS ?newValue0) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType0) - | - | - | - | ?property0 knora-base:objectClassConstraint ?propertyRange0 . - | ?valueType0 rdfs:subClassOf* ?propertyRange0 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction0 . - | ?restriction0 a owl:Restriction . - | ?restriction0 owl:onProperty ?property0 . - | - | - | - | BIND(0 AS ?nextOrder0) - | - | - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#pubdate") AS ?property1) - | BIND(IRI("http://rdfh.ch/0803/wrongObjectClass/values/L4YSL2SeSkKVt-J9OQAMog") AS ?newValue1) - | BIND(IRI("http://www.knora.org/ontology/knora-base#DateValue") AS ?valueType1) - | - | - | - | ?property1 knora-base:objectClassConstraint ?propertyRange1 . - | ?valueType1 rdfs:subClassOf* ?propertyRange1 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction1 . - | ?restriction1 a owl:Restriction . - | ?restriction1 owl:onProperty ?property1 . - | - | - | - | BIND(0 AS ?nextOrder1) - | - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#publoc") AS ?property6) - | BIND(IRI("http://rdfh.ch/0803/wrongObjectClass/values/1ryBgY4MSn2Y8K8QAPiJBw") AS ?newValue6) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType6) - | - | - | - | ?property6 knora-base:objectClassConstraint ?propertyRange6 . - | ?valueType6 rdfs:subClassOf* ?propertyRange6 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction6 . - | ?restriction6 a owl:Restriction . - | ?restriction6 owl:onProperty ?property6 . - | - | - | - | BIND(0 AS ?nextOrder6) - | - | - | - |} - """.stripMargin - - private val resourcePropWithNoCardinality = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX knora-base: - |PREFIX incunabula: - |PREFIX salsah-gui: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | - | - | # A property that incunabula:book has no cardinality for. - | incunabula:unused rdf:type owl:ObjectProperty ; - | rdfs:subPropertyOf knora-base:hasValue ; - | rdfs:label "Unused property"@en ; - | rdfs:comment "A property used only in tests"@en ; - | knora-base:subjectClassConstraint incunabula:book ; - | knora-base:objectClassConstraint knora-base:TextValue ; - | salsah-gui:guiElement salsah-gui:SimpleText ; - | salsah-gui:guiAttribute "min=4" , - | "max=8" . - | - | - | ?resource rdf:type ?resourceClass ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:lastModificationDate ?currentTime ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | - | ?newValue0 rdf:type ?valueType0 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid0" . - | - | - | - | ?newValue0 knora-base:valueHasString "A beautiful book" . - | - | - | ?newValue0 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0 knora-base:valueHasOrder ?nextOrder0 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property0 ?newValue0 . - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | - | ?newValue1 rdf:type ?valueType1 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid1" . - | - | - | - | ?newValue1 knora-base:valueHasStartJDN 2457360 ; - | knora-base:valueHasEndJDN 2457360 ; - | knora-base:valueHasStartPrecision "DAY" ; - | knora-base:valueHasEndPrecision "DAY" ; - | knora-base:valueHasCalendar "GREGORIAN" ; - | knora-base:valueHasString "2015-12-03" . - | - | - | - | ?newValue1 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue1 knora-base:valueHasOrder ?nextOrder1 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property1 ?newValue1 . - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | - | ?newValue6 rdf:type ?valueType6 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid6" . - | - | - | - | ?newValue6 knora-base:valueHasString "Entenhausen" . - | - | - | ?newValue6 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue6 knora-base:valueHasOrder ?nextOrder6 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | - | ?resource ?property6 ?newValue6 . - | - | - | - | - | # Value 7 (there's no cardinality for it, so it should cause an error) - | # Property: http://www.knora.org/ontology/0803/incunabula#unused - | - | - | ?newValue7 rdf:type ?valueType7 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid7" . - | - | - | - | ?newValue7 knora-base:valueHasString "recto" . - | - | - | - | - | ?newValue7 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue7 knora-base:valueHasOrder ?nextOrder7 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property7 ?newValue7 . - | - | - | - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0803/incunabula") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0803/resourcePropWithNoCardinality") AS ?resource) - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#book") AS ?resourceClass) - | BIND(IRI("http://rdfh.ch/users/b83acc5f05") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0803") AS ?projectIri) - | BIND(str("Test-Book") AS ?label) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#title") AS ?property0) - | BIND(IRI("http://rdfh.ch/0803/resourcePropWithNoCardinality/values/IKVNJVSWTryEtK4i9OCSIQ") AS ?newValue0) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType0) - | - | - | - | ?property0 knora-base:objectClassConstraint ?propertyRange0 . - | ?valueType0 rdfs:subClassOf* ?propertyRange0 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction0 . - | ?restriction0 a owl:Restriction . - | ?restriction0 owl:onProperty ?property0 . - | - | - | - | - | BIND(0 AS ?nextOrder0) - | - | - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#pubdate") AS ?property1) - | BIND(IRI("http://rdfh.ch/0803/resourcePropWithNoCardinality/values/L4YSL2SeSkKVt-J9OQAMog") AS ?newValue1) - | BIND(IRI("http://www.knora.org/ontology/knora-base#DateValue") AS ?valueType1) - | - | - | - | ?property1 knora-base:objectClassConstraint ?propertyRange1 . - | ?valueType1 rdfs:subClassOf* ?propertyRange1 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction1 . - | ?restriction1 a owl:Restriction . - | ?restriction1 owl:onProperty ?property1 . - | - | - | - | - | BIND(0 AS ?nextOrder1) - | - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#publoc") AS ?property6) - | BIND(IRI("http://rdfh.ch/0803/resourcePropWithNoCardinality/values/1ryBgY4MSn2Y8K8QAPiJBw") AS ?newValue6) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType6) - | - | - | - | ?property6 knora-base:objectClassConstraint ?propertyRange6 . - | ?valueType6 rdfs:subClassOf* ?propertyRange6 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction6 . - | ?restriction6 a owl:Restriction . - | ?restriction6 owl:onProperty ?property6 . - | - | - | - | - | BIND(0 AS ?nextOrder6) - | - | - | - | - | # Value 7 - | # Property: http://www.knora.org/ontology/0803/incunabula#unused - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#unused") AS ?property7) - | BIND(IRI("http://rdfh.ch/0803/resourcePropWithNoCardinality/values/nQ3tRObaQWe74WQv2_OdCg") AS ?newValue7) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType7) - | - | - | - | - | BIND(0 AS ?nextOrder7) - |} - """.stripMargin - - private val valuePropWithNoCardinality = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource rdf:type ?resourceClass ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:lastModificationDate ?currentTime ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | - | ?newValue0 rdf:type ?valueType0 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid0" . - | - | - | - | ?newValue0 knora-base:valueHasString "A beautiful book" . - | - | - | ?newValue0 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue0 knora-base:valueHasOrder ?nextOrder0 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | ?resource ?property0 ?newValue0 . - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | - | ?newValue1 rdf:type ?valueType1 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid1" . - | - | - | - | ?newValue1 knora-base:valueHasStartJDN 2457360 ; - | knora-base:valueHasEndJDN 2457360 ; - | knora-base:valueHasStartPrecision "DAY" ; - | knora-base:valueHasEndPrecision "DAY" ; - | knora-base:valueHasCalendar "GREGORIAN" ; - | knora-base:valueHasString "2015-12-03" . - | - | - | - | ?newValue1 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue1 knora-base:valueHasOrder ?nextOrder1 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | ?resource ?property1 ?newValue1 . - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | - | # A property that knora-base:TextValue has no cardinality for. - | knora-base:valueHasTest rdf:type owl:DatatypeProperty ; - | rdfs:subPropertyOf knora-base:valueHas ; - | knora-base:subjectClassConstraint knora-base:TextValue ; - | knora-base:objectDatatypeConstraint xsd:integer . - | - | - | ?newValue6 rdf:type ?valueType6 ; - | knora-base:isDeleted "false"^^xsd:boolean ; - | knora-base:valueHasUUID "uuid6" . - | - | - | - | ?newValue6 knora-base:valueHasString "Entenhausen" . - | - | ?newValue6 knora-base:valueHasTest "3"^^xsd:integer . # No cardinality for this property, so it should cause an error. - | - | ?newValue6 ?creatorIri ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | ?newValue6 knora-base:valueHasOrder ?nextOrder6 ; - | knora-base:valueCreationDate ?currentTime . - | - | - | - | - | - | ?resource ?property6 ?newValue6 . - | - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0803/incunabula") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0803/valuePropWithNoCardinality") AS ?resource) - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#book") AS ?resourceClass) - | BIND(IRI("http://rdfh.ch/users/b83acc5f05") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0803") AS ?projectIri) - | BIND(str("Test-Book") AS ?label) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0803/incunabula#title - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#title") AS ?property0) - | BIND(IRI("http://rdfh.ch/0803/valuePropWithNoCardinality/values/IKVNJVSWTryEtK4i9OCSIQ") AS ?newValue0) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType0) - | - | - | - | ?property0 knora-base:objectClassConstraint ?propertyRange0 . - | ?valueType0 rdfs:subClassOf* ?propertyRange0 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction0 . - | ?restriction0 a owl:Restriction . - | ?restriction0 owl:onProperty ?property0 . - | - | - | - | - | BIND(0 AS ?nextOrder0) - | - | - | - | - | - | - | # Value 1 - | # Property: http://www.knora.org/ontology/0803/incunabula#pubdate - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#pubdate") AS ?property1) - | BIND(IRI("http://rdfh.ch/0803/valuePropWithNoCardinality/values/L4YSL2SeSkKVt-J9OQAMog") AS ?newValue1) - | BIND(IRI("http://www.knora.org/ontology/knora-base#DateValue") AS ?valueType1) - | - | - | - | ?property1 knora-base:objectClassConstraint ?propertyRange1 . - | ?valueType1 rdfs:subClassOf* ?propertyRange1 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction1 . - | ?restriction1 a owl:Restriction . - | ?restriction1 owl:onProperty ?property1 . - | - | - | - | - | BIND(0 AS ?nextOrder1) - | - | - | - | - | - | # Value 6 - | # Property: http://www.knora.org/ontology/0803/incunabula#publoc - | - | BIND(IRI("http://www.knora.org/ontology/0803/incunabula#publoc") AS ?property6) - | BIND(IRI("http://rdfh.ch/0803/valuePropWithNoCardinality/values/1ryBgY4MSn2Y8K8QAPiJBw") AS ?newValue6) - | BIND(IRI("http://www.knora.org/ontology/knora-base#TextValue") AS ?valueType6) - | - | - | - | ?property6 knora-base:objectClassConstraint ?propertyRange6 . - | ?valueType6 rdfs:subClassOf* ?propertyRange6 . - | - | - | - | ?resourceClass rdfs:subClassOf* ?restriction6 . - | ?restriction6 a owl:Restriction . - | ?restriction6 owl:onProperty ?property6 . - | - | - | - | - | BIND(0 AS ?nextOrder6) - |} - """.stripMargin - - private val wrongLinkTargetClass = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX xsd: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource0 rdf:type ?resourceClass0 ; - | knora-base:isDeleted false ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label0 ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0001/anything#hasBlueThing - | - | # The property hasBlueThing has an objectClassConstraint of BlueThing, so using a Thing as a link target should fail. - | - | ?resource0 ?linkProperty0_0 ?linkTarget0_0 . - | - | - | - | ?newLinkValue0_0 rdf:type knora-base:LinkValue ; - | rdf:subject ?resource0 ; - | rdf:predicate ?linkProperty0_0 ; - | rdf:object ?linkTarget0_0 ; - | knora-base:valueHasString "http://rdfh.ch/0001/a-thing" ; - | knora-base:valueHasRefCount 1 ; - | - | knora-base:valueHasOrder ?nextOrder0_0 ; - | knora-base:isDeleted false ; - | knora-base:valueHasUUID "uuid0" ; - | knora-base:valueCreationDate ?currentTime . - | - | ?newLinkValue0_0 knora-base:attachedToUser ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" . - | - | - | - | - | ?resource0 ?linkValueProperty0_0 ?newLinkValue0_0 . - | - | - | - | - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0001/anything") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0001/wrongTargetClass") AS ?resource0) - | BIND(IRI("http://www.knora.org/ontology/0001/anything#BlueThing") AS ?resourceClass0) - | BIND(IRI("http://rdfh.ch/users/9XBCrDV3SRa7kS1WwynB4Q") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0001") AS ?projectIri) - | BIND(str("Test Thing") AS ?label0) - | BIND(NOW() AS ?currentTime) - | - | - | - | # Value 0 - | # Property: http://www.knora.org/ontology/0001/anything#hasBlueThing - | - | BIND(IRI("http://www.knora.org/ontology/0001/anything#hasBlueThing") AS ?linkProperty0_0) - | BIND(IRI("http://www.knora.org/ontology/0001/anything#hasBlueThingValue") AS ?linkValueProperty0_0) - | BIND(IRI("http://rdfh.ch/0001/wrongTargetClass/values/GjV_4ayjRDebneEQM0zHuw") AS ?newLinkValue0_0) - | BIND(IRI("http://rdfh.ch/0001/a-thing") AS ?linkTarget0) - | - | - | - | ?linkTarget0_0 rdf:type ?linkTargetClass0_0 ; - | knora-base:isDeleted false . - | ?linkTargetClass0_0 rdfs:subClassOf+ knora-base:Resource . - | - | - | - | ?resourceClass0 rdfs:subClassOf* ?restriction0_0 . - | ?restriction0_0 a owl:Restriction . - | ?restriction0_0 owl:onProperty ?linkProperty0_0 . - | - | - | - | - | - | - | - | - | - | BIND(0 AS ?nextOrder0_0) - | - | - | - |} - """.stripMargin - - private val twoLabels = - """ - |PREFIX rdf: - |PREFIX rdfs: - |PREFIX owl: - |PREFIX xsd: - |PREFIX knora-base: - | - |INSERT { - | GRAPH ?dataNamedGraph { - | ?resource rdf:type ?resourceClass ; - | knora-base:isDeleted false ; - | knora-base:attachedToUser ?creatorIri ; - | knora-base:attachedToProject ?projectIri ; - | rdfs:label ?label; - | rdfs:label "Second label not allowed" ; - | knora-base:hasPermissions "V knora-admin:UnknownUser|M knora-admin:ProjectMember" ; - | knora-base:creationDate ?currentTime . - | } - |} - | - | - | USING - | - |WHERE { - | BIND(IRI("http://www.knora.org/data/0001/anything") AS ?dataNamedGraph) - | BIND(IRI("http://rdfh.ch/0001/twoLabels") AS ?resource) - | BIND(IRI("http://www.knora.org/ontology/0001/anything#BlueThing") AS ?resourceClass) - | BIND(IRI("http://rdfh.ch/users/9XBCrDV3SRa7kS1WwynB4Q") AS ?creatorIri) - | BIND(IRI("http://rdfh.ch/projects/0001") AS ?projectIri) - | BIND(str("Test Thing") AS ?label) - | BIND(NOW() AS ?currentTime) - |} - """.stripMargin - -}