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

The following examples show how to use org.springframework.data.mapping.context.MappingContext. These examples are extracted from open source projects. 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 Project: spring-data   Source File: DefaultArangoTypeMapper.java    License: 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 Project: spring-data   Source File: DerivedQueryCreator.java    License: 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 3
Source Project: spring-data   Source File: DefaultArangoConverter.java    License: 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 4
Source Project: spring-data-cosmosdb   Source File: MappingCosmosConverter.java    License: 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 5
Source Project: spring-cloud-gcp   Source File: SpannerQueryMethod.java    License: 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 6
Source Project: spring-vault   Source File: DefaultVaultTypeMapper.java    License: 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 7
/**
 * 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 8
Source Project: POC   Source File: MongoDBListener.java    License: 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 9
Source Project: spring-data-crate   Source File: EntityColumnMapper.java    License: 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 10
Source Project: spring-data-crate   Source File: MappingCrateConverter.java    License: 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 11
Source Project: spring-data-keyvalue   Source File: KeyValueTemplate.java    License: 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 Project: youkefu   Source File: XiaoEUKResultMapper.java    License: Apache License 2.0 4 votes vote down vote up
public XiaoEUKResultMapper(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
	super(new DefaultEntityMapper());
	this.mappingContext = mappingContext;
}
 
Example 13
Source Project: youkefu   Source File: XiaoEUKResultMapper.java    License: 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 14
Source Project: youkefu   Source File: UKResultMapper.java    License: Apache License 2.0 4 votes vote down vote up
public UKResultMapper(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
	super(new DefaultEntityMapper());
	this.mappingContext = mappingContext;
}
 
Example 15
Source Project: youkefu   Source File: UKResultMapper.java    License: 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 16
Source Project: roncoo-education   Source File: ResultMapperExt.java    License: MIT License 4 votes vote down vote up
public ResultMapperExt(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext) {
	super(new DefaultEntityMapper());
	this.mappingContext = mappingContext;
}
 
Example 17
Source Project: roncoo-education   Source File: ResultMapperExt.java    License: MIT License 4 votes vote down vote up
public ResultMapperExt(MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext, EntityMapper entityMapper) {
	super(entityMapper);
	this.mappingContext = mappingContext;
}
 
Example 18
Source Project: spring-data   Source File: ArangoAuditingRegistrar.java    License: Apache License 2.0 4 votes vote down vote up
public ArangoMappingContextLookup(
	final MappingContext<? extends ArangoPersistentEntity<?>, ArangoPersistentProperty> context) {
	super();
	this.context = context;
}
 
Example 19
Source Project: spring-data   Source File: ArangoAuditingRegistrar.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public MappingContext<? extends ArangoPersistentEntity<?>, ArangoPersistentProperty> getObject()
		throws Exception {
	return context;
}
 
Example 20
Source Project: spring-data   Source File: ArangoAuditingRegistrar.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Class<?> getObjectType() {
	return MappingContext.class;
}
 
Example 21
Source Project: spring-data   Source File: DefaultArangoConverter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public MappingContext<? extends ArangoPersistentEntity<?>, ArangoPersistentProperty> getMappingContext() {
	return context;
}
 
Example 22
Source Project: spring-data   Source File: DefaultArangoTypeMapper.java    License: Apache License 2.0 4 votes vote down vote up
public DefaultArangoTypeMapper(final String typeKey,
	final MappingContext<? extends PersistentEntity<?, ?>, ?> mappingContext) {
	this(typeKey, new DefaultTypeAliasAccessor(typeKey), mappingContext,
			Arrays.asList(new SimpleTypeInformationMapper()));
}
 
Example 23
Source Project: dubbox   Source File: SolrQueryCreator.java    License: 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 24
Source Project: dubbox   Source File: SolrEntityInformationCreatorImpl.java    License: Apache License 2.0 4 votes vote down vote up
public SolrEntityInformationCreatorImpl(
		MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> mappingContext) {
	Assert.notNull(mappingContext);
	this.mappingContext = mappingContext;
}
 
Example 25
Source Project: dubbox   Source File: SolrJConverter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> getMappingContext() {
	return mappingContext;
}
 
Example 26
Source Project: dubbox   Source File: MappingSolrConverter.java    License: Apache License 2.0 4 votes vote down vote up
public MappingSolrConverter(
		MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> mappingContext) {
	Assert.notNull(mappingContext);

	this.mappingContext = mappingContext;
}
 
Example 27
Source Project: dubbox   Source File: MappingSolrConverter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> getMappingContext() {
	return mappingContext;
}
 
Example 28
Source Project: dubbox   Source File: SolrTemplate.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * @since 1.3
 * @param mappingContext
 */
public void setMappingContext(
		MappingContext<? extends SolrPersistentEntity<?>, SolrPersistentProperty> mappingContext) {
	this.mappingContext = mappingContext;
}
 
Example 29
Source Project: spring-data-cosmosdb   Source File: CosmosQueryCreator.java    License: MIT License 4 votes vote down vote up
public CosmosQueryCreator(PartTree tree, CosmosParameterAccessor accessor,
                          MappingContext<?, CosmosPersistentProperty> mappingContext) {
    super(tree, accessor);

    this.mappingContext = mappingContext;
}
 
Example 30
Source Project: spring-data-cosmosdb   Source File: ReactiveCosmosQueryCreator.java    License: MIT License 4 votes vote down vote up
public ReactiveCosmosQueryCreator(PartTree tree, ReactiveCosmosParameterAccessor accessor,
                                  MappingContext<?, CosmosPersistentProperty> mappingContext) {
    super(tree, accessor);

    this.mappingContext = mappingContext;
}