private ReferencedProperty(PersistentProperty<?> property, Object propertyValue, PersistentPropertyAccessor wrapper) { this.property = property; this.propertyValue = propertyValue; this.accessor = wrapper; this.propertyType = property.getActualType(); this.entity = repositories.getPersistentEntity(propertyType); }
@Autowired public PersistentEntityResourceProcessor(Repositories repositories, List<ResourceProcessor<Resource<?>>> resourceProcessors) { if (null != resourceProcessors) { for (ResourceProcessor<Resource<?>> rp : resourceProcessors) { TypeInformation<?> typeInfo = ClassTypeInformation.from(rp.getClass()); TypeInformation<?> domainType = typeInfo.getTypeArguments().get(0); if (null != repositories.getPersistentEntity(domainType.getType())) { this.resourceProcessors.add(new DomainTypeResourceProcessor(domainType.getType(), rp)); } } } }
/** * Translates Jackson field names within a {@link Sort} to {@link PersistentProperty} property names. * * @param input must not be {@literal null}. * @param parameter must not be {@literal null}. * @param webRequest must not be {@literal null}. * @return a {@link Sort} containing translated property names or {@literal null} the resulting {@link Sort} contains * no properties. */ protected Sort translateSort(Sort input, MethodParameter parameter, NativeWebRequest webRequest) { Assert.notNull(input, "Sort must not be null!"); Assert.notNull(parameter, "MethodParameter must not be null!"); Assert.notNull(webRequest, "NativeWebRequest must not be null!"); Class<?> domainClass = domainClassResolver.resolve(parameter.getMethod(), webRequest); if (domainClass == null) { return input; } PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(domainClass); return sortTranslator.translateSort(input, persistentEntity); }
@Override public RootResourceInformation resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { ResourceMetadata resourceMetadata = resourceMetadataResolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory); Class<?> domainType = resourceMetadata.getDomainType(); RepositoryInvoker repositoryInvoker = invokerFactory.getInvokerFor(domainType); PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(domainType); // TODO reject if ResourceMetadata cannot be resolved return new RootResourceInformation(resourceMetadata, persistentEntity, postProcess(parameter, repositoryInvoker, domainType, webRequest.getParameterMap())); }
private final void populateCache(Repositories repositories, RepositoryRestConfiguration configuration) { for (Class<?> type : repositories) { RepositoryInformation repositoryInformation = repositories.getRequiredRepositoryInformation(type); Class<?> repositoryInterface = repositoryInformation.getRepositoryInterface(); PersistentEntity<?, ?> entity = repositories.getPersistentEntity(type); RepositoryDetectionStrategy strategy = configuration.getRepositoryDetectionStrategy(); RelProvider provider = configuration.getRelProvider(); CollectionResourceMapping mapping = new RepositoryCollectionResourceMapping(repositoryInformation, strategy, provider); RepositoryAwareResourceMetadata information = new RepositoryAwareResourceMetadata(entity, mapping, this, repositoryInformation); addToCache(repositoryInterface, information); if (!hasMetadataFor(type) || information.isPrimary()) { addToCache(type, information); } } }
private ReferencedProperty(PersistentProperty<?> property, Object propertyValue, PersistentPropertyAccessor wrapper) { this.property = property; this.propertyValue = propertyValue; this.accessor = wrapper; this.propertyType = property.getActualType(); this.entity = repositories.getPersistentEntity(propertyType); }
@Autowired public PersistentEntityResourceProcessor(Repositories repositories, List<ResourceProcessor<Resource<?>>> resourceProcessors) { if (null != resourceProcessors) { for (ResourceProcessor<Resource<?>> rp : resourceProcessors) { TypeInformation<?> typeInfo = ClassTypeInformation.from(rp.getClass()); TypeInformation<?> domainType = typeInfo.getTypeArguments().get(0); if (null != repositories.getPersistentEntity(domainType.getType())) { this.resourceProcessors.add(new DomainTypeResourceProcessor(domainType.getType(), rp)); } } } }
/** * Translates Jackson field names within a {@link Sort} to {@link PersistentProperty} property names. * * @param input must not be {@literal null}. * @param parameter must not be {@literal null}. * @param webRequest must not be {@literal null}. * @return a {@link Sort} containing translated property names or {@literal null} the resulting {@link Sort} contains * no properties. */ protected Sort translateSort(Sort input, MethodParameter parameter, NativeWebRequest webRequest) { Assert.notNull(input, "Sort must not be null!"); Assert.notNull(parameter, "MethodParameter must not be null!"); Assert.notNull(webRequest, "NativeWebRequest must not be null!"); Class<?> domainClass = domainClassResolver.resolve(parameter.getMethod(), webRequest); if (domainClass == null) { return input; } PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(domainClass); return sortTranslator.translateSort(input, persistentEntity); }
@Override public RootResourceInformation resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { ResourceMetadata resourceMetadata = resourceMetadataResolver.resolveArgument(parameter, mavContainer, webRequest, binderFactory); Class<?> domainType = resourceMetadata.getDomainType(); RepositoryInvoker repositoryInvoker = invokerFactory.getInvokerFor(domainType); PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(domainType); // TODO reject if ResourceMetadata cannot be resolved return new RootResourceInformation(resourceMetadata, persistentEntity, postProcess(parameter, repositoryInvoker, domainType, webRequest.getParameterMap())); }