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);
}
Aggregations