Java 类org.springframework.data.repository.support.Repositories 实例源码

项目:spring-content    文件:AbstractContentPropertyController.java   
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;
}
项目:yona-server    文件:JUnitUtil.java   
public static Repositories setUpRepositoryProviderMock(Map<Class<?>, Repository<?, ?>> repositoriesMap)
{
    Repositories mockRepositories = Mockito.mock(Repositories.class);
    when(mockRepositories.getRepositoryFor(any())).thenAnswer(new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable
        {
            Class<?> entityClass = (Class<?>) invocation.getArguments()[0];
            Repository<?, ?> repository = repositoriesMap.get(entityClass);
            if (repository == null)
            {
                throw new IllegalArgumentException("Unsupported class: " + entityClass.getName());
            }
            return repository;
        }
    });
    RepositoryProvider.setRepositories(mockRepositories);
    return mockRepositories;
}
项目:document-management-store-app    文件:RepositoryFinder.java   
@SuppressWarnings(value = "unchecked")
public CrudRepository<Object, Serializable> find(@NotNull Class<?> domainClass) {
    Repositories repositories = new Repositories(listableBeanFactory);

    Iterator<Class<?>> it = repositories.iterator();
    while (it.hasNext()) {
        Object repository = repositories.getRepositoryFor(domainClass);
        if (repository != null && repository instanceof CrudRepository) {
            return (CrudRepository<Object, Serializable>)repository;
        }
    }

    return null;
}
项目:spring-data-examples    文件:ApplicationConfigurationTest.java   
@Test
public void repositoriesAreAssignedToAppropriateStores() {

    Repositories repositories = new Repositories(context);

    assertThat(repositories.getEntityInformationFor(Customer.class), is(instanceOf(JpaEntityInformation.class)));
    assertThat(repositories.getEntityInformationFor(Order.class), is(instanceOf(MongoEntityInformation.class)));
}
项目:spring-data-jpa-extra    文件:RepoBasedConverter.java   
@Override
public void setApplicationContext(ApplicationContext context) throws BeansException {
    Class<?>[] classes = GenericTypeResolver.resolveTypeArguments(this.getClass(), RepoBasedConverter.class);
    Class<?> clazz = classes[0];
    this.repositories = new Repositories(context);
    this.entityInformation = (JpaEntityInformation<S, ID>) repositories.getEntityInformationFor(clazz);
    this.genericJpaRepository = (GenericJpaRepository<S, ID>) repositories.getRepositoryFor(clazz);
    this.useCache = genericJpaRepository instanceof CachingJpaRepository;
}
项目:spring-content    文件:ContentSearchRestController.java   
@Autowired 
public ContentSearchRestController(Repositories repositories, ContentStoreService stores, PagedResourcesAssembler<Object> assembler) {
    super(assembler);

    this.repositories = repositories;
    this.stores = stores;
    this.reflectionService = new ReflectionServiceImpl();
}
项目:spring-content    文件:ContentPropertyCollectionRestController.java   
@Autowired(required=false)
public ContentPropertyCollectionRestController(ApplicationContext context, ContentStoreService stores, StoreByteRangeHttpRequestHandler handler) {
    super();
    try {
        this.repositories = context.getBean(Repositories.class);
    } catch (BeansException be) {
        this.repositories = new Repositories(context);
    }
    this.storeService = stores;
    this.handler = handler;
}
项目:spring-content    文件:ContentEntityRestController.java   
@Autowired 
public ContentEntityRestController(ApplicationContext context, ContentStoreService storeService, StoreByteRangeHttpRequestHandler handler) {
    try {
        this.repositories = context.getBean(Repositories.class);
    } catch (BeansException be) {
        this.repositories = new Repositories(context);
    }
    this.storeService = storeService;
    this.handler = handler;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
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;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
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;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
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;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
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;
}
项目:spring-content    文件:AbstractContentPropertyController.java   
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;
}
项目:spring-content    文件:ContentPropertyRestController.java   
@Autowired(required=false)
public ContentPropertyRestController(ApplicationContext context, ContentStoreService storeService, StoreByteRangeHttpRequestHandler handler) {
    super();
    try {
        this.repositories = context.getBean(Repositories.class);
    } catch (BeansException be) {
        this.repositories = new Repositories(context);
    }
    this.storeService = storeService;
    this.handler = handler;
}
项目:spring-content    文件:ContentPropertyRestController.java   
private void replaceContentInternal(Repositories repositories,
                                    ContentStoreService stores,
                                    String repository,
                                    String id, 
                                    String contentProperty, 
                                    String contentId, 
                                    String mimeType,
                                    InputStream stream) 
        throws HttpRequestMethodNotSupportedException {

    Object domainObj = findOne(repositories, repository, id);

    PersistentProperty<?> property = this.getContentPropertyDefinition(repositories.getPersistentEntity(domainObj.getClass()), contentProperty);

    Object contentPropertyValue = this.getContentProperty(domainObj, property, contentId); 

    if (BeanUtils.hasFieldWithAnnotation(contentPropertyValue, MimeType.class)) {
        BeanUtils.setFieldWithAnnotation(contentPropertyValue, MimeType.class, mimeType);
    }

    Class<?> contentEntityClass = ContentPropertyUtils.getContentPropertyType(property);

    ContentStoreInfo info = ContentStoreUtils.findContentStore(storeService, contentEntityClass);
    info.getImpementation().setContent(contentPropertyValue, stream);

    save(repositories, domainObj);
}
项目:moserp    文件:ApplicationStructureController.java   
@Autowired
public ApplicationStructureController(ApplicationStructureBuilder applicationStructureBuilder, RepositoryRestConfiguration configuration, Repositories repositories, ResourceMappings mappings) {
    Assert.notNull(applicationStructureBuilder, "ApplicationStructureBuilder must not be null!");
    Assert.notNull(configuration, "RepositoryRestConfiguration must not be null!");
    Assert.notNull(repositories, "Repositories must not be null!");
    Assert.notNull(mappings, "ResourceMappings must not be null!");

    this.applicationStructureBuilder = applicationStructureBuilder;
    this.configuration = configuration;
    this.repositories = repositories;
    this.mappings = mappings;
}
项目:spring-content    文件:PersistentEntityUtils.java   
public static PersistentEntity<?,?> findPersistentEntity(Repositories repositories, 
                                                  Class<?> domainType) {

    PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(domainType);
    return persistentEntity;
}
项目:iVIS    文件:DomainController.java   
@PostConstruct
public void init() {
    repositories = new Repositories(applicationContext);
    repositoryInvokerFactory = new DefaultRepositoryInvokerFactory(repositories, conversionService);
}
项目:iVIS    文件:MenuPreparer.java   
@PostConstruct
public void init() {
    repositories = new Repositories(context);
}
项目:yona-server    文件:RepositoryProvider.java   
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
{
    repositories = new Repositories(applicationContext);
}
项目:yona-server    文件:RepositoryProvider.java   
public static void setRepositories(Repositories repositories)
{
    RepositoryProvider.repositories = repositories;
}
项目:spring-data-dynamodb-demo    文件:DemoRepositoryEntityLinks.java   
public DemoRepositoryEntityLinks(Repositories repositories,
        ResourceMappings mappings, RepositoryRestConfiguration config, HateoasPageableHandlerMethodArgumentResolver resolver,org.springframework.plugin.core.PluginRegistry<BackendIdConverter,Class<?>> idConverters) {
    super(repositories, mappings, config, resolver,idConverters);
    this.resourceMappings = mappings;
    this.config = config;
}
项目:recruiting-old-style    文件:MongoDBPaginationServiceImpl.java   
@PostConstruct
public void init() {
    this.repositories = new Repositories(listableBeanFactory);
}
项目:recruiting-old-style    文件:PaginationServiceImpl.java   
@PostConstruct
public void init() {
    this.repositories = new Repositories(listableBeanFactory);
}