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 UniversalResourceSingleProvider to support more RDF formats #76

Open
wants to merge 5 commits into
base: master
from

Conversation

@berezovskyi
Copy link
Member

berezovskyi commented Feb 15, 2019

2nd try, #9 has too many merge conflicts

TODO

  • clean up AbstractRdfProvider
  • add a handler for collections and arrays
  • fix a query-related exception
2nd try, #9 has too many
merge conflicts

Signed-off-by: Andrew Berezovskyi <andriib@kth.se>
Reformat
Signed-off-by: Andrew Berezovskyi <andriib@kth.se>
@berezovskyi

This comment has been minimized.

Copy link
Member Author

berezovskyi commented Feb 15, 2019

I just applied the changes from #9 but a collection-based test now fails:

java.lang.IllegalArgumentException: Query Result resources have to be constructed before marshalling

	at org.eclipse.lyo.oslc4j.provider.jena.AbstractRdfProvider.writeTo(AbstractRdfProvider.java:51)
	at org.eclipse.lyo.oslc4j.provider.jena.OslcRdfXmlArrayProvider.writeTo(OslcRdfXmlArrayProvider.java:92)
	at org.eclipse.lyo.oslc4j.provider.jena.test.JsonLdTest.testWriteArray(JsonLdTest.java:82)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
*
* @since 4.0.0
*/
public class AbstractRdfProvider {

This comment has been minimized.

Copy link
@jadelkhoury

jadelkhoury Apr 23, 2019

Contributor

should be an abstract class.

OslcMediaType.N_TRIPLES_MIME, OslcMediaType.RDF_JSON_MIME, OslcMediaType.RDF_THRIFT_MIME})
@Consumes({OslcMediaType.APPLICATION_JSON_LD, OslcMediaType.TEXT_TURTLE,
OslcMediaType.N_TRIPLES_MIME, OslcMediaType.RDF_JSON_MIME, OslcMediaType.RDF_THRIFT_MIME})
public class UniversalResourceSingleProvider extends AbstractRdfProvider

This comment has been minimized.

Copy link
@jadelkhoury

jadelkhoury Apr 23, 2019

Contributor

handle rdf/xml as well.

OslcMediaType.N_TRIPLES_MIME, OslcMediaType.RDF_JSON_MIME, OslcMediaType.RDF_THRIFT_MIME})
@Consumes({OslcMediaType.APPLICATION_JSON_LD, OslcMediaType.TEXT_TURTLE,
OslcMediaType.N_TRIPLES_MIME, OslcMediaType.RDF_JSON_MIME, OslcMediaType.RDF_THRIFT_MIME})
public class UniversalResourceSingleProvider extends AbstractRdfProvider

This comment has been minimized.

Copy link
@jadelkhoury

jadelkhoury Apr 23, 2019

Contributor

name suggestion: OslcResourceProvider

@Consumes({OslcMediaType.APPLICATION_JSON_LD, OslcMediaType.TEXT_TURTLE,
OslcMediaType.N_TRIPLES_MIME, OslcMediaType.RDF_JSON_MIME, OslcMediaType.RDF_THRIFT_MIME})
public class UniversalResourceSingleProvider extends AbstractRdfProvider
implements MessageBodyReader<IResource>, MessageBodyWriter<IResource> {

This comment has been minimized.

Copy link
@jadelkhoury

jadelkhoury Apr 23, 2019

Contributor

Can one also add?
implements MessageBodyReader<Collection<? extends IResource>>, MessageBodyWriter<Collection<? extends IResource>>

This comment has been minimized.

Copy link
@berezovskyi

berezovskyi May 3, 2019

Author Member

No, unfortunately this does not work due to type erasure in Java. See https://softwareengineering.stackexchange.com/questions/219427/implementing-multiple-generic-interfaces-in-java for the background.

This comment has been minimized.

Copy link
@jadelkhoury

jadelkhoury May 5, 2019

Contributor

Ok. We simply need to provide other Providers for collection.
Don’t even remember why we said we can do it all in 1 class.

berezovskyi added 3 commits Jul 11, 2019
# Conflicts:
#	oslc4j-jena-provider/src/main/java/org/eclipse/lyo/oslc4j/provider/jena/AbstractOslcRdfXmlProvider.java
#	oslc4j-jena-provider/src/test/java/org/eclipse/lyo/oslc4j/provider/jena/test/JsonLdTest.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.