Closed ivanbacher closed 9 months ago
Hi,
The local ID part (e.g., tgn_7009504
) is extracted with Regex from the place entity URI in the SPARQL Query line you included:
REPLACE(STR(?place__id), "^.*\\\\/(.+)", "$1")
Currently this Regex captures the text after the last slash.
Is the structure of the place entity URIs in your KG same for all the entities? If all the place entitiy URIs in your KG have this [local ID part 1]/[local ID part 2]
structure, you could just capture the first part as well by adding the text after the second-to-last slash to the capture group as well:
REPLACE(STR(?place__id), "^.*\\\\/(.+\\\\/.+)", "$1")
Otherwise you could use Regex to get everything after the expression place/
if that is consistent across all the URIs for places but the length of the local ID part is variable.
The exact way you extract the wanted part from the URI can be whatever works with SPARQL. The important thing is that you concatenate it with places/page/
and store that under the place__dataProviderUrl
variable.
Thank you very much for the quick response. I have updated the query with the new regex.
The link (as shown in the image) is now correct. However, if we click on this link to navigate to the instance page the url is automatically changed to http://localhost:8080/en/places/page/[local ID part 1]
, somehow the [local ID part 2]
is removed.
E.g. http://localhost:8080/places/page/England/Canterbury
is changed to http://localhost:8080/places/page/England
The instance page then shows the error No data found for id: England
copying this url http://localhost:8080/places/page/England/Canterbury
into the browser gives us this error: No data found for id: Canterbury
My bad, the current way URLs are parsed in Sampo-UI doesn't work with local IDs with unencoded slashes. There are at least two ways you could pretty easily get around this: You could encode the local ID part in the SPARQL query with ENCODE_FOR_URI ENCODE_FOR_URI(REPLACE(...))
and then decode it in the function that handles URI formation from local IDs by using decodeURIComponent
for localID here: https://github.com/SemanticComputing/sampo-ui/blob/3c3de7c44ca4829f20193f9e8170d32e099cf22b/src/client/helpers/helpers.js#L203
Another option would be to use the whole encoded URI as the local ID by defining the localIDAsURI
configuration option as true inside the place perspective's instanceConfig
object by adding
"localIDAsURI": true
and encoding the whole ID as the local ID in the SPARQL query:
BIND(CONCAT("/places/page/", ENCODE_FOR_URI(STR(?place__id))) AS ?place__dataProviderUrl)
Great stuff. Thank you for the info. I will give it a try
Hi,
In the demo app the
dataProviderUrl
for a place in perspective3 is extracted like this in the SPARQL Query:Which then gets converted to this url:
https://sampo-ui.demo.seco.cs.aalto.fi/en/places/page/tgn_7009504/
to get to the place instance page.The url of the place entity looks like this:
http://ldf.fi/mmm/place/tgn_7009504
A place entity in our KG looks like this:
https://.../place/England/Winchester
The main difference being that the
id
of the entity has two componentsEngland/Winchester
instead of onetgn_7009504
.It seems that sampo-ui is removing one of these
id's
e.gplaces/page/England/Abingdon
becomesplaces/page/Abingdon
, hence when clicking on the generated link, theplace
instance page cannot find any data, as it is using the incorrect id. E.g. this error message pops up: No data found for id: Abingdon -> (the id should be England/Abingdon).Any thoughts? How can we get this to work?
Thanks