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

getResource() in LyoStore does not handle inlined properties #363

Open
jadelkhoury opened this issue Jun 18, 2023 · 0 comments
Open

getResource() in LyoStore does not handle inlined properties #363

jadelkhoury opened this issue Jun 18, 2023 · 0 comments

Comments

@jadelkhoury
Copy link
Contributor

Consider a ResourceShape ObjectType that has an inlined property "targets", as examplified below.
Creating such an insstance (with inlined resources) works fine with LyoStore.
However, when calling getResource() on the uri http://localhost:8080/oslc-server1/oslc/pm/ObjectType/12, the properties of the inlined AnotherObjectType resources are not returned as part of the request.
That is, getResource() does not consider the resourceShape properties of ObjectType in its query.
This an be easily seen in the code of getResource() which is too simple to deal with this scenario.

<rdf:RDF
    <pref:ObjectType rdf:about="http://localhost:8080/oslc-server1/oslc/pm/ObjectType/12">
        <dcterms:identifier>12</dcterms:identifier>
        <pref:targets>
            <pref:AnotherObjectType rdf:about="http://localhost:8080/oslc-server1/oslc/pm/AnotherObjectType/1">
                <dcterms:identifier>1</dcterms:identifier>
            </pref:AnotherObjectType>
        </pref:targets>
        <pref:targets>
            <pref:AnotherObjectType rdf:about="http://localhost:8080/oslc-server1/oslc/pm/AnotherObjectType/2">
                <dcterms:identifier>2</dcterms:identifier>
            </pref:AnotherObjectType>
        </pref:targets>
    </pref:ObjectType>
</rdf:RDF>

A very simple workaround is to do another getResource() call on the set of target properties, to construct the complete instance.

        //Individually get the set of inlined resources the aResource points to.
        Set<AnotherObjectType> inlinedTargets = new HashSet<>();
		for (AnotherObjectType obj : aResource.getTargets()) {
			AnotherObjectType r = store.getResource(...., obj.getAbout(), AnotherObjectType.class);
			inlinedTargets.add(r);
		}
        aResource.setTargets(inlinedTargets);

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

No branches or pull requests

1 participant