Last active
April 26, 2016 20:10
-
-
Save emetsger/b89d3142174c65306e99cd6006fd9a09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Type("nodes") | |
public class Node { | |
// other fields | |
@Id | |
private String id; | |
@Relationship(value = "root", resolve = true) | |
private Node root; | |
// Getters and Setters | |
} | |
public class TestClient { | |
@Test | |
public void testFoo() throws Exception { | |
// blah blah | |
ResourceConverter converter = new ResourceConverter(objectMapper, Node.class); | |
converter.setGlobalResolver(relUrl -> { | |
com.squareup.okhttp.Call req = client.newCall(new Request.Builder().url(relUrl).build()); | |
try { | |
return req.execute().body().bytes(); | |
} catch (IOException e) { | |
throw new RuntimeException(e.getMessage(), e); | |
} | |
}); | |
JSONAPIConverterFactory converterFactory = new JSONAPIConverterFactory(converter); | |
// blah blah | |
} | |
} | |
// The JSON relattionship object | |
"root": { | |
"links": { | |
"related": { | |
"href": "http://osf:8000/v2/nodes/mrusa/", | |
"meta": {} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment