org.springframework.boot.autoconfigure.domain.EntityScanner Java Examples

The following examples show how to use org.springframework.boot.autoconfigure.domain.EntityScanner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpELCosmosDBAnnotationIT.java    From spring-data-cosmosdb with MIT License 6 votes vote down vote up
@Test
public void testDatabaseOperationsOnDynamicallyNamedCollection() throws ClassNotFoundException {
  final CosmosDBConfig dbConfig = CosmosDBConfig.builder(dbUri, dbKey, TestConstants.DB_NAME).build();
  final CosmosDbFactory dbFactory = new CosmosDbFactory(dbConfig);

  cosmosEntityInformation = new CosmosEntityInformation<>(SpELPropertyStudent.class);
  final CosmosMappingContext dbContext = new CosmosMappingContext();
  dbContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));

  final ObjectMapper objectMapper = ObjectMapperFactory.getObjectMapper();
  final MappingCosmosConverter mappingConverter = new MappingCosmosConverter(dbContext, objectMapper);
  staticTemplate = new CosmosTemplate(dbFactory, mappingConverter, TestConstants.DB_NAME);
  
  staticTemplate.createContainerIfNotExists(cosmosEntityInformation);

  final SpELPropertyStudent insertedRecord = 
          staticTemplate.insert(cosmosEntityInformation.getContainerName(), TEST_PROPERTY_STUDENT, null);
  assertNotNull(insertedRecord);
  
  final SpELPropertyStudent readRecord = 
          staticTemplate.findById(TestConstants.DYNAMIC_PROPERTY_COLLECTION_NAME,
                  insertedRecord.getId(), SpELPropertyStudent.class);
  assertNotNull(readRecord);
}
 
Example #2
Source File: CosmosAnnotationIT.java    From spring-data-cosmosdb with MIT License 6 votes vote down vote up
@Before
public void setUp() throws ClassNotFoundException {
    if (!initialized) {
        final CosmosDbFactory cosmosDbFactory = new CosmosDbFactory(dbConfig);

        roleInfo = new CosmosEntityInformation<>(Role.class);
        sampleInfo = new CosmosEntityInformation<>(TimeToLiveSample.class);
        final CosmosMappingContext dbContext = new CosmosMappingContext();

        dbContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));

        final MappingCosmosConverter mappingConverter = new MappingCosmosConverter(dbContext, null);

        cosmosTemplate = new CosmosTemplate(cosmosDbFactory, mappingConverter, dbConfig.getDatabase());
        initialized = true;
    }
    collectionRole = cosmosTemplate.createContainerIfNotExists(roleInfo);

    collectionSample = cosmosTemplate.createContainerIfNotExists(sampleInfo);

    cosmosTemplate.insert(roleInfo.getContainerName(), TEST_ROLE, null);
}
 
Example #3
Source File: ReactiveCosmosTemplatePartitionIT.java    From spring-data-cosmosdb with MIT License 6 votes vote down vote up
@Before
public void setUp() throws ClassNotFoundException {
    if (!initialized) {
        final CosmosDbFactory dbFactory = new CosmosDbFactory(dbConfig);

        final CosmosMappingContext mappingContext = new CosmosMappingContext();
        personInfo =
            new CosmosEntityInformation<>(PartitionPerson.class);
        containerName = personInfo.getContainerName();

        mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));

        final MappingCosmosConverter dbConverter = new MappingCosmosConverter(mappingContext,
            null);
        cosmosTemplate = new ReactiveCosmosTemplate(dbFactory, dbConverter, dbConfig.getDatabase());
        cosmosTemplate.createContainerIfNotExists(personInfo).block();

        initialized = true;
    }
    cosmosTemplate.insert(TEST_PERSON).block();
}
 
Example #4
Source File: CosmosTemplatePartitionIT.java    From spring-data-cosmosdb with MIT License 6 votes vote down vote up
@Before
public void setUp() throws ClassNotFoundException {
    if (!initialized) {
        final CosmosDbFactory cosmosDbFactory = new CosmosDbFactory(dbConfig);
        final CosmosMappingContext mappingContext = new CosmosMappingContext();

        personInfo = new CosmosEntityInformation<>(PartitionPerson.class);
        mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));

        final MappingCosmosConverter dbConverter = new MappingCosmosConverter(mappingContext, null);

        cosmosTemplate = new CosmosTemplate(cosmosDbFactory, dbConverter, dbConfig.getDatabase());
        containerName = personInfo.getContainerName();

        cosmosTemplate.createContainerIfNotExists(personInfo);
        initialized = true;
    }

    cosmosTemplate.insert(PartitionPerson.class.getSimpleName(), TEST_PERSON,
            new PartitionKey(TEST_PERSON.getLastName()));
}
 
Example #5
Source File: CosmosTemplateIT.java    From spring-data-cosmosdb with MIT License 6 votes vote down vote up
@Before
public void setUp() throws ClassNotFoundException {
    if (!initialized) {
        final CosmosDbFactory cosmosDbFactory = new CosmosDbFactory(dbConfig);

        final CosmosMappingContext mappingContext = new CosmosMappingContext();
        personInfo = new CosmosEntityInformation<>(Person.class);
        containerName = personInfo.getContainerName();

        mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));

        final MappingCosmosConverter cosmosConverter = new MappingCosmosConverter(mappingContext,
            null);
        cosmosTemplate = new CosmosTemplate(cosmosDbFactory, cosmosConverter, dbConfig.getDatabase());
        cosmosTemplate.createContainerIfNotExists(personInfo);
        initialized = true;
    }

    insertedPerson = cosmosTemplate.insert(Person.class.getSimpleName(), TEST_PERSON, null);
}
 
Example #6
Source File: ReactiveCosmosTemplateIT.java    From spring-data-cosmosdb with MIT License 6 votes vote down vote up
@Before
public void setUp() throws ClassNotFoundException {
    if (!initialized) {
        cosmosKeyCredential = new CosmosKeyCredential(dbConfig.getKey());
        final CosmosDbFactory dbFactory = new CosmosDbFactory(dbConfig);

        final CosmosMappingContext mappingContext = new CosmosMappingContext();
        personInfo = new CosmosEntityInformation<>(Person.class);
        containerName = personInfo.getContainerName();

        mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));

        final MappingCosmosConverter dbConverter =
            new MappingCosmosConverter(mappingContext, null);
        cosmosTemplate = new ReactiveCosmosTemplate(dbFactory, dbConverter, dbConfig.getDatabase());
        cosmosTemplate.createContainerIfNotExists(personInfo).block().container();
        initialized = true;
    }

    insertedPerson = cosmosTemplate.insert(TEST_PERSON,
        new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON))).block();
}
 
Example #7
Source File: Neo4jDataAutoConfiguration.java    From sdn-rx with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public Neo4jMappingContext neo4jMappingContext(
	ApplicationContext applicationContext, Neo4jConversions neo4jConversions
) throws ClassNotFoundException {

	Set<Class<?>> initialEntityClasses = new EntityScanner(applicationContext).scan(Node.class);
	Neo4jMappingContext context = new Neo4jMappingContext(neo4jConversions);
	context.setInitialEntitySet(initialEntityClasses);

	return context;
}
 
Example #8
Source File: BeihuMongoDataAutoConfiguration.java    From beihu-boot with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
public MongoMappingContext mongoMappingContext(MongoCustomConversions conversions)
		throws ClassNotFoundException {
	MongoMappingContext context = new MongoMappingContext();
	context.setInitialEntitySet(new EntityScanner(this.applicationContext)
			.scan(Document.class, Persistent.class));
	Class<?> strategyClass = this.beihuMongoProperties.getFieldNamingStrategy();
	if (strategyClass != null) {
		context.setFieldNamingStrategy(
				(FieldNamingStrategy) BeanUtils.instantiateClass(strategyClass));
	}
	context.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
	return context;
}