Search in sources :

Example 1 with AnnotatedRepositoryAdapter

use of io.crnk.legacy.internal.AnnotatedRepositoryAdapter in project crnk-framework by crnk-project.

the class ResponseRepositoryAdapter method doGetLinksInformation.

@SuppressWarnings({ "unchecked", "rawtypes" })
private LinksInformation doGetLinksInformation(Object repository, Iterable<?> resources, RepositoryRequestSpec requestSpec) {
    if (resources instanceof ResourceList) {
        ResourceList<?> resourceList = (ResourceList<?>) resources;
        boolean createLinksInformation = resourceList instanceof DefaultResourceList;
        LinksInformation newLinksInfo = enrichLinksInformation(resourceList.getLinks(), resources, requestSpec);
        if (createLinksInformation) {
            ((DefaultResourceList) resources).setLinks(newLinksInfo);
        }
        return resourceList.getLinks();
    }
    LinksInformation linksInformation = null;
    if (repository instanceof AnnotatedRepositoryAdapter) {
        if (((AnnotatedRepositoryAdapter) repository).linksRepositoryAvailable()) {
            linksInformation = ((LinksRepository) repository).getLinksInformation(resources, requestSpec.getQueryParams());
        }
    } else if (repository instanceof LinksRepositoryV2) {
        linksInformation = ((LinksRepositoryV2) repository).getLinksInformation(resources, requestSpec.getResponseQuerySpec());
    } else if (repository instanceof LinksRepository) {
        linksInformation = ((LinksRepository) repository).getLinksInformation(resources, requestSpec.getQueryParams());
    }
    // everything deprecated anyway
    return enrichLinksInformation(linksInformation, resources, requestSpec);
}
Also used : ResourceList(io.crnk.core.resource.list.ResourceList) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) DefaultPagedLinksInformation(io.crnk.core.resource.links.DefaultPagedLinksInformation) LinksInformation(io.crnk.core.resource.links.LinksInformation) PagedLinksInformation(io.crnk.core.resource.links.PagedLinksInformation) AnnotatedRepositoryAdapter(io.crnk.legacy.internal.AnnotatedRepositoryAdapter) LinksRepositoryV2(io.crnk.core.repository.LinksRepositoryV2) LinksRepository(io.crnk.legacy.repository.LinksRepository)

Aggregations

LinksRepositoryV2 (io.crnk.core.repository.LinksRepositoryV2)1 DefaultPagedLinksInformation (io.crnk.core.resource.links.DefaultPagedLinksInformation)1 LinksInformation (io.crnk.core.resource.links.LinksInformation)1 PagedLinksInformation (io.crnk.core.resource.links.PagedLinksInformation)1 DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)1 ResourceList (io.crnk.core.resource.list.ResourceList)1 AnnotatedRepositoryAdapter (io.crnk.legacy.internal.AnnotatedRepositoryAdapter)1 LinksRepository (io.crnk.legacy.repository.LinksRepository)1