org.springframework.data.mapping.context.MappingContext Java Examples

The following examples show how to use org.springframework.data.mapping.context.MappingContext. 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: DefaultArangoTypeMapper.java    From spring-data with Apache License 2.0 6 votes vote down vote up
private DefaultArangoTypeMapper(final String typeKey, final ArangoTypeAliasAccessor accessor,
	final MappingContext<? extends PersistentEntity<?, ?>, ?> mappingContext,
	final List<? extends TypeInformationMapper> additionalMappers) {

	Assert.notNull(accessor, "Accessor must not be null!");
	Assert.notNull(additionalMappers, "AdditionalMappers must not be null!");

	final List<TypeInformationMapper> mappers = new ArrayList<>(additionalMappers.size() + 1);
	if (mappingContext != null) {
		mappers.add(new MappingContextTypeInformationMapper(mappingContext));
	}
	mappers.addAll(additionalMappers);

	this.mappers = Collections.unmodifiableList(mappers);
	this.accessor = accessor;
	this.typeCache = new ConcurrentHashMap<>(16, 0.75f, 4);
	this.typeKey = typeKey;
}
 
Example #2
Source File: MappingAuditableBeanWrapperFactory.java    From spring-data-mybatis with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new {@link MappingAuditingMetadata} instance from the given
 * {@link PersistentEntity}.
 */
public <P> MappingAuditingMetadata(
		MappingContext<?, ? extends PersistentProperty<?>> context,
		Class<?> type) {

	Assert.notNull(type, "Type must not be null!");

	this.createdByPaths = context.findPersistentPropertyPaths(type,
			withAnnotation(CreatedBy.class,
					org.springframework.data.mybatis.annotation.CreatedBy.class));
	this.createdDatePaths = context.findPersistentPropertyPaths(type,
			withAnnotation(CreatedDate.class,
					org.springframework.data.mybatis.annotation.CreatedDate.class));
	this.lastModifiedByPaths = context.findPersistentPropertyPaths(type,
			withAnnotation(LastModifiedBy.class,
					org.springframework.data.mybatis.annotation.LastModifiedBy.class));
	this.lastModifiedDatePaths = context.findPersistentPropertyPaths(type,
			withAnnotation(LastModifiedDate.class,
					org.springframework.data.mybatis.annotation.LastModifiedDate.class));

	this.isAuditable = Lazy.of( //
			() -> Arrays
					.asList(createdByPaths, createdDatePaths, lastModifiedByPaths,
							lastModifiedDatePaths) //
					.stream() //
					.anyMatch(it -> !it.isEmpty())//
	);
}
 
Example #3
Source File: MappingCosmosConverter.java    From spring-data-cosmosdb with MIT License 5 votes vote down vote up
public MappingCosmosConverter(
    MappingContext<? extends CosmosPersistentEntity<?>, CosmosPersistentProperty> mappingContext,
    @Qualifier(Constants.OBJECTMAPPER_BEAN_NAME) ObjectMapper objectMapper) {
    this.mappingContext = mappingContext;
    this.conversionService = new GenericConversionService();
    this.objectMapper = objectMapper == null ? ObjectMapperFactory.getObjectMapper() :
        objectMapper;
}
 
Example #4
Source File: SpannerQueryMethod.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new {@link QueryMethod} from the given parameters. Looks up the correct
 * query to use for following invocations of the method given.
 *
 * @param method must not be {@literal null}.
 * @param metadata must not be {@literal null}.
 * @param factory must not be {@literal null}.
 * @param mappingContext the mapping context to use.
 */
public SpannerQueryMethod(Method method, RepositoryMetadata metadata,
		ProjectionFactory factory,
		MappingContext<? extends SpannerPersistentEntity<?>,
				SpannerPersistentProperty> mappingContext) {
	super(method, metadata, factory);

	Assert.notNull(mappingContext, "MappingContext must not be null!");

	this.method = method;
	this.mappingContext = mappingContext;
}
 
Example #5
Source File: DefaultVaultTypeMapper.java    From spring-vault with Apache License 2.0 5 votes vote down vote up
private DefaultVaultTypeMapper(@Nullable String typeKey, TypeAliasAccessor<Map<String, Object>> accessor,
		MappingContext<? extends PersistentEntity<?, ?>, ?> mappingContext,
		List<? extends TypeInformationMapper> mappers) {

	super(accessor, mappingContext, mappers);

	this.typeKey = typeKey;
}
 
Example #6
Source File: DefaultArangoConverter.java    From spring-data with Apache License 2.0 5 votes vote down vote up
public DefaultArangoConverter(
	final MappingContext<? extends ArangoPersistentEntity<?>, ArangoPersistentProperty> context,
	final CustomConversions conversions, final ResolverFactory resolverFactory, final ArangoTypeMapper typeMapper) {

	this.context = context;
	this.conversions = conversions;
	this.resolverFactory = resolverFactory;
	this.typeMapper = typeMapper;
	conversionService = new DefaultConversionService();
	conversions.registerConvertersIn(conversionService);
	instantiators = new EntityInstantiators();
}
 
Example #7
Source File: MongoDBListener.java    From POC with Apache License 2.0 5 votes vote down vote up
@EventListener(ContextRefreshedEvent.class)
public void initIndicesAfterStartup() {

	MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext = this.mongoTemplate
			.getConverter().getMappingContext();

	// consider only entities that are annotated with @Document
	mappingContext.getPersistentEntities().stream().filter(it -> it.isAnnotationPresent(Document.class))
			.forEach(it -> {

				IndexOperations indexOps = this.mongoTemplate.indexOps(it.getType());
				IndexResolver.create(mappingContext).resolveIndexFor(it.getType()).forEach(indexOps::ensureIndex);
			});
}
 
Example #8
Source File: DerivedQueryCreator.java    From spring-data with Apache License 2.0 5 votes vote down vote up
public DerivedQueryCreator(
	final MappingContext<? extends ArangoPersistentEntity<?>, ArangoPersistentProperty> context,
	final Class<?> domainClass, final PartTree tree, final ArangoParameterAccessor accessor,
	final BindParameterBinding binder, final List<String> geoFields) {
	super(tree, accessor);
	this.context = context;
	collectionName = AqlUtils.buildCollectionName(context.getPersistentEntity(domainClass).getCollection());
	this.tree = tree;
	this.accessor = accessor;
	this.geoFields = geoFields;
	this.binding = binder;
	withCollections = new HashSet<>();
}
 
Example #9
Source File: MappingCrateConverter.java    From spring-data-crate with Apache License 2.0 5 votes vote down vote up
public MappingCrateConverter(MappingContext<? extends CratePersistentEntity<?>, CratePersistentProperty> mappingContext) {
	super(new DefaultConversionService());
	notNull(mappingContext, "Mapping context is required.");
	this.mappingContext = mappingContext;
	this.spELContext = new SpELContext(INSTANCE);
	this.typeMapper = new DefaultCrateTypeMapper();
}
 
Example #10
Source File: EntityColumnMapper.java    From spring-data-crate with Apache License 2.0 5 votes vote down vote up
public EntityColumnMapper(MappingContext<? extends CratePersistentEntity<?>, CratePersistentProperty> mappingContext) {
	this.mappingContext = mappingContext;
	this.primitiveTypeMapper = new PrimitiveColumnMapper();
	this.primitiveCollectionTypeMapper = new PrimitiveCollectionTypeColumnMapper();
	this.mapTypeMapper = new MapTypeColumnMapper();
	this.mapCollectionTypeMapper = new MapCollectionTypeColumnMapper();
}
 
Example #11
Source File: KeyValueTemplate.java    From spring-data-keyvalue with Apache License 2.0 5 votes vote down vote up
/**
 * Create new {@link KeyValueTemplate} using the given {@link KeyValueAdapter} and {@link MappingContext}.
 *
 * @param adapter must not be {@literal null}.
 * @param mappingContext must not be {@literal null}.
 */
public KeyValueTemplate(KeyValueAdapter adapter,
		MappingContext<? extends KeyValuePersistentEntity<?, ?>, ? extends KeyValuePersistentProperty<?>> mappingContext) {

	Assert.notNull(adapter, "Adapter must not be null!");
	Assert.notNull(mappingContext, "MappingContext must not be null!");

	this.adapter = adapter;
	this.mappingContext = mappingContext;
	this.identifierGenerator = DefaultIdentifierGenerator.INSTANCE;
}
 
Example #12
Source File: MybatisMapperBuildProcessor.java    From spring-data-mybatis with Apache License 2.0 4 votes vote down vote up
public MybatisMapperBuildProcessor(Configuration configuration,
		MappingContext<?, ?> mappingContext) {

	this.configuration = configuration;
	this.mappingContext = mappingContext;
}
 
Example #13
Source File: KeyValueTemplate.java    From spring-data-keyvalue with Apache License 2.0 4 votes vote down vote up
@Override
public MappingContext<?, ?> getMappingContext() {
	return this.mappingContext;
}
 
Example #14
Source File: MappingCosmosConverter.java    From spring-data-cosmosdb with MIT License 4 votes vote down vote up
public MappingContext<? extends CosmosPersistentEntity<?>, CosmosPersistentProperty> getMappingContext() {
    return mappingContext;
}
 
Example #15
Source File: XiaoEUKResultMapper.java    From youkefu with Apache License 2.0 4 votes vote down vote up
public XiaoEUKResultMapper(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
	super(new DefaultEntityMapper());
	this.mappingContext = mappingContext;
}
 
Example #16
Source File: EbeanRepositoryFactoryBean.java    From spring-data-ebean with Apache License 2.0 4 votes vote down vote up
@Override
public void setMappingContext(MappingContext<?, ?> mappingContext) {
    super.setMappingContext(mappingContext);
}
 
Example #17
Source File: VaultPartTreeQuery.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
public VaultQueryCreatorFactory(
		MappingContext<VaultPersistentEntity<?>, VaultPersistentProperty> mappingContext) {
	this.mappingContext = mappingContext;
}
 
Example #18
Source File: MappingVaultConverter.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
@Override
public MappingContext<? extends VaultPersistentEntity<?>, VaultPersistentProperty> getMappingContext() {
	return this.mappingContext;
}
 
Example #19
Source File: VaultKeyValueAdapter.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
MappingContext<? extends VaultPersistentEntity<?>, VaultPersistentProperty> getMappingContext() {
	return this.vaultConverter.getMappingContext();
}
 
Example #20
Source File: MybatisQueryCreationListener.java    From spring-data-mybatis with Apache License 2.0 4 votes vote down vote up
public MybatisQueryCreationListener(Configuration configuration,
		MappingContext<?, ?> mappingContext) {

	this.configuration = configuration;
	this.mappingContext = mappingContext;
}
 
Example #21
Source File: KeyValueRepositoryFactoryBean.java    From spring-data-keyvalue with Apache License 2.0 4 votes vote down vote up
@Override
public void setMappingContext(MappingContext<?, ?> mappingContext) {
	super.setMappingContext(mappingContext);
}
 
Example #22
Source File: MybatisRepositoryFactoryBean.java    From spring-data-mybatis with Apache License 2.0 4 votes vote down vote up
@Override
public void setMappingContext(MappingContext<?, ?> mappingContext) {
	super.setMappingContext(mappingContext);
	this.mappingContext = mappingContext;
}
 
Example #23
Source File: MappingCrateConverter.java    From spring-data-crate with Apache License 2.0 4 votes vote down vote up
@Override
public MappingContext<? extends CratePersistentEntity<?>, CratePersistentProperty> getMappingContext() {
	return mappingContext;
}
 
Example #24
Source File: CrateEntityInformationCreatorImpl.java    From spring-data-crate with Apache License 2.0 4 votes vote down vote up
public CrateEntityInformationCreatorImpl(
           MappingContext<? extends CratePersistentEntity<?>, CratePersistentProperty> mappingContext) {
	Assert.notNull(mappingContext);
	this.mappingContext = mappingContext;
}
 
Example #25
Source File: CratePersistentEntityTableManager.java    From spring-data-crate with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new {@link CratePersistentEntityTableManager} for the given {@link CrateMappingContext}
 * 
 * @param mappingContext must not be {@literal null}.
 */
public CratePersistentEntityTableManager(MappingContext<? extends CratePersistentEntity<?>, CratePersistentProperty> mappingContext) {
	super();
	notNull(mappingContext);
	this.entityColumnMapper = new EntityColumnMapper(mappingContext);
}
 
Example #26
Source File: SolrQueryCreator.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public SolrQueryCreator(PartTree tree, SolrParameterAccessor parameters,
		MappingContext<?, SolrPersistentProperty> context) {
	super(tree, parameters);
	this.context = context;
}
 
Example #27
Source File: XiaoEUKResultMapper.java    From youkefu with Apache License 2.0 4 votes vote down vote up
public XiaoEUKResultMapper(
		MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext,
		EntityMapper entityMapper) {
	super(entityMapper);
	this.mappingContext = mappingContext;
}
 
Example #28
Source File: UKResultMapper.java    From youkefu with Apache License 2.0 4 votes vote down vote up
public UKResultMapper(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
	super(new DefaultEntityMapper());
	this.mappingContext = mappingContext;
}
 
Example #29
Source File: UKResultMapper.java    From youkefu with Apache License 2.0 4 votes vote down vote up
public UKResultMapper(
		MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext,
		EntityMapper entityMapper) {
	super(entityMapper);
	this.mappingContext = mappingContext;
}
 
Example #30
Source File: ResultMapperExt.java    From roncoo-education with MIT License 4 votes vote down vote up
public ResultMapperExt(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
	super(new DefaultEntityMapper());
	this.mappingContext = mappingContext;
}