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

Add a class to represent the primary resource and any number of resources to be inlined #145

Open
berezovskyi opened this issue Feb 18, 2019 · 3 comments

Comments

@berezovskyi
Copy link
Contributor

I have a need to return an object of a certain class (the one that corresponds to the resource attached to a given capability). However, I need to inline a bunch of other resources in a response. This is a legit use case for OSLC requests, as shapes explicitly allow non-local resources to be inlined.

The solution I am currently using is a pair of custom classes that are then transformed into a simple Object[] (see eclipse-lyo/lyo.core#21; blocked by eclipse-lyo/lyo.core#22). I believe Lyo Core can do the transformation behind the scenes. Also, I cannot solve eclipse/lyo.core#30 myself but if the transformation happens in the JMH, it can keep a mapping between the System.identityHashCode(Object) and the org.apache.jena.graph.BlankNodeId (I had to stop using RDF BNodes / OSLC LocalResources completely as a workaround).

The classes I use right now (warning, Kotlin ahead):

data class InstanceWithResources<T : IResource>(val instance: T,
                                                val resources: Collection<IResource>)

data class InstanceMultiWithResources<T : IResource>(val instance: Collection<T>,
                                                val resources: Collection<IResource>)

Please comment on the proposal and I will switch the Status to PR Welcome or Abandoned (and remove you from assignees).

@berezovskyi
Copy link
Contributor Author

cc @neormx

@berezovskyi
Copy link
Contributor Author

BTW, to ensure no BNodes exist in a Model, I wrote an in-place skolemization method:

    public static void skolemize(final Model m) {
        final ResIterator resIterator = m.listSubjects();
        while(resIterator.hasNext()) {
            final Resource resource = resIterator.nextResource();
            if(resource != null && resource.isAnon()) {
                final String skolemURI = "urn:skolem:" + resource.getId()
                        .getBlankNodeId()
                        .getLabelString();
                final Resource skolemizedResource = ResourceUtils.renameResource(resource,
                                                                                 skolemURI);
            }
        }
    }

@berezovskyi
Copy link
Contributor Author

berezovskyi commented Aug 21, 2021

Partly resolved by #111/#112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants