当前位置: 首页>>代码示例>>Java>>正文


Java RepositoryInformation类代码示例

本文整理汇总了Java中org.springframework.data.repository.core.RepositoryInformation的典型用法代码示例。如果您正苦于以下问题:Java RepositoryInformation类的具体用法?Java RepositoryInformation怎么用?Java RepositoryInformation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RepositoryInformation类属于org.springframework.data.repository.core包,在下文中一共展示了RepositoryInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTargetRepository

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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;
}
 
开发者ID:rubasace,项目名称:spring-data-jdbc,代码行数:17,代码来源:JdbcRepositoryFactory.java

示例2: save

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:22,代码来源:AbstractContentPropertyController.java

示例3: getTargetRepository

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
 
开发者ID:lordlothar99,项目名称:strategy-spring-security-acl,代码行数:19,代码来源:AclJpaRepositoryFactoryBean.java

示例4: getTargetRepository

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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;
}
 
开发者ID:lordlothar99,项目名称:strategy-spring-security-acl,代码行数:20,代码来源:AclElasticsearchRepositoryFactoryBean.java

示例5: convert

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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()));
        }
 
开发者ID:imCodePartnerAB,项目名称:iVIS,代码行数:20,代码来源:IdToDomainClassConverter.java

示例6: getTargetRepository

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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;
}
 
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:24,代码来源:SolrRepositoryFactory.java

示例7: getTargetRepository

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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);
}
 
开发者ID:onsoul,项目名称:os,代码行数:8,代码来源:DefaultRepositoryFactory.java

示例8: getEntityInformation

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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);
}
 
开发者ID:saturnism,项目名称:spring-data-spanner,代码行数:14,代码来源:SpannerRepositoryFactory.java

示例9: getTargetRepository

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@Override
protected Object getTargetRepository(RepositoryInformation information) {
	EntityInformation<?, Serializable> entityInformation = getEntityInformation(
			information.getDomainType());
	return getTargetRepositoryViaReflection(information, entityInformation,
			this.datastoreOptions);
}
 
开发者ID:tkob,项目名称:spring-data-gclouddatastore,代码行数:8,代码来源:GcloudDatastoreRepositoryFactory.java

示例10: GenericJpaRepositoryFactory

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
/**
 * 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);
		}
	});
}
 
开发者ID:slyak,项目名称:spring-data-jpa-extra,代码行数:19,代码来源:GenericJpaRepositoryFactory.java

示例11: repositoryPath

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:8,代码来源:RepositoryUtils.java

示例12: findOne

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:29,代码来源:AbstractContentPropertyController.java

示例13: findAll

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:28,代码来源:AbstractContentPropertyController.java

示例14: findRepositoryInformation

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
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;
}
 
开发者ID:paulcwarren,项目名称:spring-content,代码行数:15,代码来源:AbstractContentPropertyController.java

示例15: getTargetRepository

import org.springframework.data.repository.core.RepositoryInformation; //导入依赖的package包/类
@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);
}
 
开发者ID:xiangxik,项目名称:java-platform,代码行数:11,代码来源:CustomRepositoryFactoryBean.java


注:本文中的org.springframework.data.repository.core.RepositoryInformation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。