@Override protected Object getTargetRepository(RepositoryInformation metadata) { entityClass = metadata.getDomainType(); @SuppressWarnings("rawtypes") ReflectionJdbcRepository repository = getTargetRepositoryViaReflection(metadata, entityClass); repository.setDataSource(datasource); repository.afterPropertiesSet(); this.repository = repository; generator = SqlGeneratorFactory.getInstance().getGenerator(datasource); template = new NamedParameterJdbcTemplate((JdbcOperations) extractRepositoryField(repository, FIELD_JDBC_OPS)); rowMapper = extractRepositoryField(repository, FIELD_ROWMAPPER); tableDescription = extractRepositoryField(repository, FIELD_TABLE_DESCRIPTION); return repository; }
public static Object save(Repositories repositories, Object domainObj) throws HttpRequestMethodNotSupportedException { RepositoryInformation ri = findRepositoryInformation(repositories, domainObj.getClass()); if (ri == null) { throw new ResourceNotFoundException(); } Class<?> domainObjClazz = ri.getDomainType(); if (domainObjClazz != null) { Method saveMethod = ri.getCrudMethods().getSaveMethod(); if (saveMethod == null) { throw new HttpRequestMethodNotSupportedException("save"); } domainObj = ReflectionUtils.invokeMethod(saveMethod, repositories.getRepositoryFor(domainObjClazz), domainObj); } return domainObj; }
protected SimpleJpaRepository<?, ?> getTargetRepository(RepositoryInformation information, EntityManager entityManager) { Class<?> domainType = information.getDomainType(); if (!hasAclStrategyAnnotation(domainType)) { return super.getTargetRepository(information, entityManager); } JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(domainType); // invokes // com.github.lothar.security.acl.jpa.repository.AclJpaRepository.AclJpaRepository(JpaEntityInformation<T, // ?>, EntityManager, JpaSpecProvider<T>) SimpleJpaRepository<?, ?> repository = getTargetRepositoryViaReflection(information, entityInformation, entityManager, jpaSpecProvider); logger.debug("Created {}", repository); return repository; }
@Override protected Object getTargetRepository(RepositoryInformation metadata) { Class<?> domainType = metadata.getDomainType(); ElasticsearchEntityInformation<?, Serializable> entityInformation = getEntityInformation(domainType); if (!hasAclStrategyAnnotation(domainType)) { return getTargetRepositoryViaReflection(metadata, entityInformation, elasticsearchOperations); } // invokes // com.github.lothar.security.acl.elasticsearch.repository.AclElasticsearchRepository.AclNumberKeyedRepository(ElasticsearchEntityInformation<T, // ID>, ElasticsearchOperations, AclFilterProvider) ElasticsearchRepository<?, ?> repository = getTargetRepositoryViaReflection(metadata, entityInformation, elasticsearchOperations, filterProvider); logger.debug("Created {}", repository); return repository; }
@Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (source == null || !StringUtils.hasText(source.toString())) { return null; } // if (sourceType.equals(targetType)) { if (isTypesEqual(sourceType, targetType)) { return source; } Class<?> domainType = targetType.getType(); RepositoryInformation info = repositories.getRepositoryInformationFor(domainType); RepositoryInvoker invoker = repositoryInvokerFactory.getInvokerFor(domainType); return invoker.invokeFindOne(conversionService.convert(source, info.getIdType())); }
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) protected Object getTargetRepository(RepositoryInformation metadata) { SolrOperations operations = this.solrOperations; if (factory != null) { SolrTemplate template = new SolrTemplate(factory); if (this.solrOperations.getConverter() != null) { template.setMappingContext(this.solrOperations.getConverter().getMappingContext()); } template.setSolrCore(SolrClientUtils.resolveSolrCoreName(metadata.getDomainType())); addSchemaCreationFeaturesIfEnabled(template); template.afterPropertiesSet(); operations = template; } SimpleSolrRepository repository = getTargetRepositoryViaReflection(metadata, getEntityInformation(metadata.getDomainType()), operations); repository.setEntityClass(metadata.getDomainType()); this.templateHolder.add(metadata.getDomainType(), operations); return repository; }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override protected <T, ID extends Serializable> SimpleJpaRepository<?, ?> getTargetRepository( RepositoryInformation information, EntityManager entityManager) { JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType()); return new GenericRepositoryImpl(entityInformation, entityManager); }
@SuppressWarnings("unchecked") private <T, ID extends Serializable> SpannerEntityInformation<T, ID> getEntityInformation(Class<T> domainClass, RepositoryInformation information) { SpannerPersistentEntity<?> entity = mappingContext.getPersistentEntity(domainClass); if (entity == null) { throw new MappingException( String.format("Could not lookup mapping metadata for domain class %s!", domainClass.getName())); } BasicSpannerPersistentEntity<T> persistentEntity = (BasicSpannerPersistentEntity<T>) mappingContext.getPersistentEntity(domainClass); return new MappingSpannerEntityInformation<T, ID>(persistentEntity); }
@Override protected Object getTargetRepository(RepositoryInformation information) { EntityInformation<?, Serializable> entityInformation = getEntityInformation( information.getDomainType()); return getTargetRepositoryViaReflection(information, entityInformation, this.datastoreOptions); }
/** * Creates a new {@link JpaRepositoryFactory}. * * @param entityManager must not be {@literal null} */ public GenericJpaRepositoryFactory(EntityManager entityManager) { super(entityManager); this.entityManager = entityManager; this.extractor = PersistenceProvider.fromEntityManager(entityManager); final AssemblerInterceptor assemblerInterceptor = new AssemblerInterceptor(); addRepositoryProxyPostProcessor(new RepositoryProxyPostProcessor() { @Override public void postProcess(ProxyFactory factory, RepositoryInformation repositoryInformation) { factory.addAdvice(assemblerInterceptor); } }); }
public static String repositoryPath(RepositoryInformation info) { Class<?> clazz = info.getRepositoryInterface(); RepositoryRestResource annotation = AnnotationUtils.findAnnotation(clazz, RepositoryRestResource.class); String path = annotation == null ? null : annotation.path().trim(); path = StringUtils.hasText(path) ? path : English.plural(StringUtils.uncapitalize(info.getDomainType().getSimpleName())); return path; }
public static Object findOne(Repositories repositories, String repository, String id) throws HttpRequestMethodNotSupportedException { Object domainObj = null; RepositoryInformation ri = findRepositoryInformation(repositories, repository); if (ri == null) { throw new ResourceNotFoundException(); } Class<?> domainObjClazz = ri.getDomainType(); Class<?> idClazz = ri.getIdType(); Method findOneMethod = ri.getCrudMethods().getFindOneMethod(); if (findOneMethod == null) { throw new HttpRequestMethodNotSupportedException("fineOne"); } Object oid = new DefaultConversionService().convert(id, idClazz); domainObj = ReflectionUtils.invokeMethod(findOneMethod, repositories.getRepositoryFor(domainObjClazz), oid); if (null == domainObj) { throw new ResourceNotFoundException(); } return domainObj; }
public static Object findOne(Repositories repositories, Class<?> domainObjClass, String id) throws HttpRequestMethodNotSupportedException { Object domainObj = null; RepositoryInformation ri = findRepositoryInformation(repositories, domainObjClass); if (ri == null) { throw new ResourceNotFoundException(); } Class<?> domainObjClazz = ri.getDomainType(); Class<?> idClazz = ri.getIdType(); Method findOneMethod = ri.getCrudMethods().getFindOneMethod(); if (findOneMethod == null) { throw new HttpRequestMethodNotSupportedException("fineOne"); } Object oid = new DefaultConversionService().convert(id, idClazz); domainObj = ReflectionUtils.invokeMethod(findOneMethod, repositories.getRepositoryFor(domainObjClazz), oid); if (null == domainObj) { throw new ResourceNotFoundException(); } return domainObj; }
public static Iterable findAll(Repositories repositories, String repository) throws HttpRequestMethodNotSupportedException { Iterable entities = null; RepositoryInformation ri = findRepositoryInformation(repositories, repository); if (ri == null) { throw new ResourceNotFoundException(); } Class<?> domainObjClazz = ri.getDomainType(); Class<?> idClazz = ri.getIdType(); Method findAllMethod = ri.getCrudMethods().getFindAllMethod(); if (findAllMethod == null) { throw new HttpRequestMethodNotSupportedException("fineAll"); } entities = (Iterable)ReflectionUtils.invokeMethod(findAllMethod, repositories.getRepositoryFor(domainObjClazz)); if (null == entities) { throw new ResourceNotFoundException(); } return entities; }
public static RepositoryInformation findRepositoryInformation(Repositories repositories, String repository) { RepositoryInformation ri = null; for (Class<?> clazz : repositories) { RepositoryInformation candidate = repositories.getRepositoryInformationFor(clazz); if (candidate == null) { continue; } if (repository.equals(RepositoryUtils.repositoryPath(candidate))) { ri = repositories.getRepositoryInformationFor(clazz); break; } } return ri; }
public static RepositoryInformation findRepositoryInformation(Repositories repositories, Class<?> domainObjectClass) { RepositoryInformation ri = null; for (Class<?> clazz : repositories) { if (clazz.equals(domainObjectClass)) { return repositories.getRepositoryInformationFor(clazz); } } return ri; }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override protected Object getTargetRepository(RepositoryInformation information) { return isBaseRepository(information.getRepositoryInterface()) ? (isTreeRepository(information.getRepositoryInterface()) ? new TreeRepositoryImpl(getEntityInformation(information.getDomainType()), entityManager) : new BaseRepositoryImpl<>(getEntityInformation(information.getDomainType()), entityManager)) : super.getTargetRepository(information); }
@Override protected Object getTargetRepository(RepositoryInformation information) { final EntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType()); return getTargetRepositoryViaReflection(information, entityInformation, this.applicationContext); }
@Override protected SimpleJpaRepository getTargetRepository(RepositoryInformation metadata) { return new BaseRepositoryImpl<T, I>((Class<T>) metadata.getDomainType(), entityManager); }
@Override protected Object getTargetRepository(RepositoryInformation information) { SpannerEntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType(), information); return getTargetRepositoryViaReflection(information, entityInformation, operations); }
@Override public void postProcess(ProxyFactory factory, RepositoryInformation repositoryInformation) { factory.addAdvice(INFO_ADVICE); }
@Override protected Object getTargetRepository(RepositoryInformation info) { return getTargetRepositoryViaReflection(info, snowdropOperations, getEntityInformation(info.getDomainType())); }
@Override protected Object getTargetRepository(RepositoryInformation information) { return new BaseRepositoryImpl<T, I>((Class<T>) information.getDomainType(), em); }
@Override protected Object getTargetRepository(RepositoryInformation metadata) { return getTargetRepositoryViaReflection(metadata, getEntityInformation(metadata.getDomainType()), operation); }
@Override @SuppressWarnings("unchecked") protected Object getTargetRepository(RepositoryInformation information) { return new AbstractObjectifyRepository(objectify, searchService, information.getDomainType(), information.getIdType()); }
@Override protected Object getTargetRepository(RepositoryInformation metadata) { return new JdbcTemplateRepositoryInternal<>(beanFactory, configuration, metadata.getDomainType()); }
@SuppressWarnings("unchecked") @Override protected Object getTargetRepository(RepositoryInformation information) { return new BaseRepositoryImpl<T, I>((Class<T>) information.getDomainType(), entityManager); }
@Override protected Object getTargetRepository(RepositoryInformation repositoryInformation) { EntityInformation<?, Serializable> entityInformation = getEntityInformation(repositoryInformation.getDomainType()); return super.getTargetRepositoryViaReflection(repositoryInformation, entityInformation); }
@Override protected Object getTargetRepository(RepositoryInformation information) { SimpleEbeanRepository<?, ?> repository = getTargetRepository(information, ebeanServer); return repository; }
@Override protected Object getTargetRepository(RepositoryInformation information) { return getTargetRepositoryViaReflection(information, information.getDomainType()); }
@Override @SuppressWarnings("unchecked") protected Object getTargetRepository(RepositoryInformation information) { return new SoftDeletesRepositoryImpl<T, ID>((Class<T>) information.getDomainType(), entityManager); }
@Override protected PlatformJpaRepositoryImpl getTargetRepository(RepositoryInformation information) { JpaEntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType()); return new PlatformJpaRepositoryImpl(entityInformation, em); }
@Override @SuppressWarnings("unchecked") protected Object getTargetRepository(final RepositoryInformation metadata) { final MyBatisEntityInformation<?, Serializable> entityInformation = getEntityInformation(metadata.getDomainType()); return new SimpleMyBatisRepository(entityInformation, mapperProvider.getSqlSessionTemplate()); }
@Override public void postProcess(ProxyFactory factory, RepositoryInformation repositoryInformation) { factory.addAdvice( new JpaEntityGraphMethodInterceptor(entityManager, repositoryInformation.getDomainType())); }
@Override protected Object getTargetRepository(RepositoryInformation repoInfo) { return this.getTargetRepositoryViaReflection(repoInfo, entityManager, SdcctRepositoryFactoryBean.this.entityClass, SdcctRepositoryFactoryBean.this.entityImplClass, SdcctRepositoryFactoryBean.this.entityMetadata); }
/** {@inheritDoc} */ @Override protected Object getTargetRepository(RepositoryInformation metadata) { return getTargetRepositoryViaReflection(metadata, ignite.getOrCreateCache(repoToCache.get(metadata.getRepositoryInterface()))); }
@Override protected Object getTargetRepository(RepositoryInformation information) { return new FetchableJpaRepositoryImpl<T, ID>((Class<T>) information.getDomainType(), em); }
@Override protected Object getTargetRepository(RepositoryInformation information) { JpaEntityInformation entityInformation = getEntityInformation(information.getDomainType()); return new CentromereJpaRepository<>(entityInformation, entityManager); }
@Override protected Object getTargetRepository(RepositoryInformation information) { MongoEntityInformation entityInformation = getEntityInformation(information.getDomainType()); return new CentromereMongoRepository<>(entityInformation, mongoOperations); }