Search in sources :

Example 1 with RelationshipRepositoryNotFoundException

use of io.crnk.core.exception.RelationshipRepositoryNotFoundException in project crnk-framework by crnk-project.

the class RegistryEntry method getRelationshipRepository.

@SuppressWarnings("unchecked")
public RelationshipRepositoryAdapter getRelationshipRepository(ResourceField field, RepositoryMethodParameterProvider parameterProvider) {
    ResponseRelationshipEntry relationshipEntry = relationshipEntries.get(field);
    if (relationshipEntry == null) {
        throw new RelationshipRepositoryNotFoundException(getResourceInformation().getResourceType(), field.getUnderlyingName());
    }
    Object repoInstance;
    if (relationshipEntry instanceof AnnotatedRelationshipEntryBuilder) {
        repoInstance = ((AnnotatedRelationshipEntryBuilder) relationshipEntry).build(parameterProvider);
    } else {
        repoInstance = ((DirectResponseRelationshipEntry) relationshipEntry).getRepositoryInstanceBuilder();
    }
    if (repoInstance instanceof ResourceRegistryAware) {
        ((ResourceRegistryAware) repoInstance).setResourceRegistry(moduleRegistry.getResourceRegistry());
    }
    return new RelationshipRepositoryAdapter(getResourceInformation(), moduleRegistry, repoInstance);
}
Also used : DirectResponseRelationshipEntry(io.crnk.legacy.internal.DirectResponseRelationshipEntry) RelationshipRepositoryNotFoundException(io.crnk.core.exception.RelationshipRepositoryNotFoundException) AnnotatedRelationshipEntryBuilder(io.crnk.legacy.registry.AnnotatedRelationshipEntryBuilder) RelationshipRepositoryAdapter(io.crnk.core.engine.internal.repository.RelationshipRepositoryAdapter)

Aggregations

RelationshipRepositoryAdapter (io.crnk.core.engine.internal.repository.RelationshipRepositoryAdapter)1 RelationshipRepositoryNotFoundException (io.crnk.core.exception.RelationshipRepositoryNotFoundException)1 DirectResponseRelationshipEntry (io.crnk.legacy.internal.DirectResponseRelationshipEntry)1 AnnotatedRelationshipEntryBuilder (io.crnk.legacy.registry.AnnotatedRelationshipEntryBuilder)1