Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New transform utility functions #299

Open
rompetroll opened this issue Apr 9, 2024 · 0 comments
Open

New transform utility functions #299

rompetroll opened this issue Apr 9, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@rompetroll
Copy link
Contributor

rompetroll commented Apr 9, 2024

It is a common transform requirement to create a new URI based on an exiting URI, just with a different namespace.

For example, in a transform loop we filter a population dataset and produce a new dataset only containing adults. When we process an entity with entity.ID="ns24:17", where ns24 is a prefix for http://people/. And we want the outgoing entity after filtration to have entity.ID="ns25:17", where ns25 stands for http://adults/.

Currently, this has to be solved using manual string splitting and concatination. E.g.

const adultsPrefix = AssertNamespacePrefix("http://adults/");
SetId(newEntity, adultsPrefix + ":" + GetId(e).split(":").pop())

I am not sure what the utility function(s) should look like exactly. Maybe something like this:

const newId = WithNamespacePrefix(GetId(e), adultsPrefix);
SetId(newEntity, newId)

It would not be much conciser, but add robustness for this common use case.

A utility function to extract the namespace/namespace prefix from URIs without manual string splitting would also be welcome.

@rompetroll rompetroll added the enhancement New feature or request label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant