Search in sources :

Example 1 with ResourceRepositoryAdapter

use of io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter in project crnk-framework by crnk-project.

the class FormRelationshipRepository method findOneTarget.

@Override
public F findOneTarget(String taskId, String fieldName, QuerySpec querySpec) {
    if (RELATIONSHIP_NAME.equals(fieldName)) {
        ResourceRepositoryAdapter resourceRepository = resourceRegistry.getEntry(formClass).getResourceRepository();
        QuerySpecAdapter querySpecAdapter = new QuerySpecAdapter(querySpec, resourceRegistry);
        return (F) resourceRepository.findOne(taskId, querySpecAdapter).getEntity();
    } else {
        throw new UnsupportedOperationException("unknown fieldName '" + fieldName + "'");
    }
}
Also used : ResourceRepositoryAdapter(io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter)

Example 2 with ResourceRepositoryAdapter

use of io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter in project crnk-framework by crnk-project.

the class CrnkClient method getQueryParamsRepository.

/**
 * @param resourceClass resource class
 * @return stub for the given resourceClass
 * @deprecated make use of QuerySpec
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Deprecated
public <T, I extends Serializable> ResourceRepositoryStub<T, I> getQueryParamsRepository(Class<T> resourceClass) {
    init();
    RegistryEntry entry = resourceRegistry.findEntry(resourceClass);
    // TODO fix this in crnk, should be able to get original document
    ResourceRepositoryAdapter repositoryAdapter = entry.getResourceRepository(null);
    return (ResourceRepositoryStub<T, I>) repositoryAdapter.getResourceRepository();
}
Also used : ResourceRepositoryAdapter(io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter) ResourceRepositoryStub(io.crnk.client.legacy.ResourceRepositoryStub)

Example 3 with ResourceRepositoryAdapter

use of io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter in project crnk-framework by crnk-project.

the class CrnkClient method getRepositoryForType.

/**
 * @param resourceClass repository class
 * @return stub for the given resourceClass
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T, I extends Serializable> ResourceRepositoryV2<T, I> getRepositoryForType(Class<T> resourceClass) {
    init();
    RegistryEntry entry = resourceRegistry.findEntry(resourceClass);
    ResourceRepositoryAdapter repositoryAdapter = entry.getResourceRepository(null);
    return (ResourceRepositoryV2<T, I>) repositoryAdapter.getResourceRepository();
}
Also used : ResourceRepositoryAdapter(io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter) ResourceRepositoryV2(io.crnk.core.repository.ResourceRepositoryV2)

Example 4 with ResourceRepositoryAdapter

use of io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter in project crnk-framework by crnk-project.

the class ForwardingStrategyContext method findAll.

public <Q> Iterable<Q> findAll(RegistryEntry entry, Iterable<?> targetIds) {
    ResourceRepositoryAdapter targetAdapter = entry.getResourceRepository();
    QueryAdapter queryAdapter = new QuerySpecAdapter(new QuerySpec(entry.getResourceInformation()), resourceRegistry);
    return (Iterable) targetAdapter.findAll(targetIds, queryAdapter).getEntity();
}
Also used : ResourceRepositoryAdapter(io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter) QueryAdapter(io.crnk.core.engine.query.QueryAdapter) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Example 5 with ResourceRepositoryAdapter

use of io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter in project crnk-framework by crnk-project.

the class ForwardingStrategyContext method findOne.

public <Q> Q findOne(RegistryEntry entry, Serializable id) {
    ResourceRepositoryAdapter targetAdapter = entry.getResourceRepository();
    QueryAdapter queryAdapter = new QuerySpecAdapter(new QuerySpec(entry.getResourceInformation()), resourceRegistry);
    return (Q) targetAdapter.findOne(id, queryAdapter).getEntity();
}
Also used : ResourceRepositoryAdapter(io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter) QueryAdapter(io.crnk.core.engine.query.QueryAdapter) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) QuerySpec(io.crnk.core.queryspec.QuerySpec)

Aggregations

ResourceRepositoryAdapter (io.crnk.core.engine.internal.repository.ResourceRepositoryAdapter)22 Response (io.crnk.core.engine.dispatcher.Response)11 Document (io.crnk.core.engine.document.Document)10 Resource (io.crnk.core.engine.document.Resource)10 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)9 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)9 JsonApiResponse (io.crnk.core.repository.response.JsonApiResponse)9 ResourceField (io.crnk.core.engine.information.resource.ResourceField)7 QueryAdapter (io.crnk.core.engine.query.QueryAdapter)7 QuerySpecAdapter (io.crnk.core.queryspec.internal.QuerySpecAdapter)7 Task (io.crnk.core.mock.models.Task)6 QuerySpec (io.crnk.core.queryspec.QuerySpec)6 Test (org.junit.Test)6 RelationshipRepositoryAdapter (io.crnk.core.engine.internal.repository.RelationshipRepositoryAdapter)5 Serializable (java.io.Serializable)5 Project (io.crnk.core.mock.models.Project)4 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)3 BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)3 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)3 PathIds (io.crnk.core.engine.internal.dispatcher.path.PathIds)3