Search in sources :

Example 6 with JsonLinksInformation

use of io.crnk.client.response.JsonLinksInformation in project crnk-framework by crnk-project.

the class ClientStubBase method toResourceResponse.

private static Object toResourceResponse(Document document, ObjectMapper objectMapper) {
    Object data = document.getData().get();
    if (data instanceof List) {
        DefaultResourceList<Resource> list = new DefaultResourceList<>();
        list.addAll((List<Resource>) data);
        if (document.getMeta() != null) {
            list.setMeta(new JsonMetaInformation(document.getMeta(), objectMapper));
        }
        if (document.getLinks() != null) {
            list.setLinks(new JsonLinksInformation(document.getMeta(), objectMapper));
        }
        return list;
    } else {
        return data;
    }
}
Also used : JsonLinksInformation(io.crnk.client.response.JsonLinksInformation) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) JsonMetaInformation(io.crnk.client.response.JsonMetaInformation) Resource(io.crnk.core.engine.document.Resource) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) List(java.util.List)

Aggregations

JsonLinksInformation (io.crnk.client.response.JsonLinksInformation)6 JsonMetaInformation (io.crnk.client.response.JsonMetaInformation)6 QuerySpec (io.crnk.core.queryspec.QuerySpec)4 AbstractJpaJerseyTest (io.crnk.jpa.AbstractJpaJerseyTest)4 TestEntity (io.crnk.jpa.model.TestEntity)4 Test (org.junit.Test)4 Resource (io.crnk.core.engine.document.Resource)2 DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)2 RelatedEntity (io.crnk.jpa.model.RelatedEntity)2 OtherRelatedEntity (io.crnk.jpa.model.OtherRelatedEntity)1 List (java.util.List)1