@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 = sourceType.getType(); EntityInformation<Object, ?> entityInformation = repositories.getEntityInformationFor(domainType); return conversionService.convert(entityInformation.getId(source), targetType.getType()); }
public BaseJdbcRepository(EntityInformation<T, ID> entityInformation, RowMapper<T> rowMapper, RowUnmapper<T> rowUnmapper, TableDescription table) { Assert.notNull(rowMapper); Assert.notNull(table); this.entityInfo = entityInformation != null ? entityInformation : createEntityInformation(); this.rowUnmapper = rowUnmapper != null ? rowUnmapper : new UnsupportedRowUnmapper<T>(); this.rowMapper = rowMapper; this.table = table; }
@SuppressWarnings("unchecked") private EntityInformation<T, ID> createEntityInformation() { Class<T> entityType = (Class<T>) GenericTypeResolver.resolveTypeArguments(getClass(), JdbcRepository.class)[0]; return createEntityInformation(entityType); }
@SuppressWarnings({"rawtypes", "unchecked"}) protected static EntityInformation createEntityInformation(Class<?> entityType) { if (Persistable.class.isAssignableFrom(entityType)) { return new PersistableEntityInformation(entityType); } return new ReflectionEntityInformation(entityType); }
public static <T, ID extends Serializable> AbstractRepositoryStrategy chooseStrategy(EntityInformation<T, ID> entityInformation) { switch (EntityUtils.getEntityType(entityInformation)) { case AUTO_INCREMENTAL: return new AutoIncrementRepositoryStrategy(entityInformation); case MANUALLY_ASSIGNED: return new ManuallyAssignedRepositoryStrategy(entityInformation); case READ_ONLY: return new ReadOnlyRepositoryStrategy(entityInformation); default: throw new IllegalArgumentException("Don't know what strategy to instantiate"); } }
@Override public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { TarantoolPersistentEntity<T> entity = ((TarantoolPersistentEntity<T>) keyValueOperations .getMappingContext() .getPersistentEntity(domainClass)); EntityInformation<T, ID> entityInformation = (EntityInformation<T, ID>) new MappingTarantoolEntityInformation<T>(entity); return entityInformation; }
@SuppressWarnings("unchecked") @Override public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { MongoPersistentEntity<T> persistentEntity = (MongoPersistentEntity<T>) mappingContext.getPersistentEntity(domainClass); return new MappingMongoEntityInformation<>(persistentEntity, config); }
public SimpleGcloudDatastoreRepository(EntityInformation<T, ID> entityInformation, DatastoreOptions datastoreOptions) { Assert.notNull(entityInformation, "EntityInformation must not be null!"); this.entityInformation = entityInformation; this.kind = entityInformation.getJavaType().getSimpleName(); this.datastoreOptions = datastoreOptions; }
@Override protected Object getTargetRepository(RepositoryInformation information) { EntityInformation<?, Serializable> entityInformation = getEntityInformation( information.getDomainType()); return getTargetRepositoryViaReflection(information, entityInformation, this.datastoreOptions); }
public SimpleObjectifyRepository(EntityInformation<T, ID> metadata) { this.metadata = metadata; Class<ID> idType = metadata.getIdType(); if ((idType != String.class) && (idType != Long.class)){ throw new RuntimeException("Id Type must be String or Long"); } }
@Override @SuppressWarnings("unchecked") public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { VaultPersistentEntity<T> entity = (VaultPersistentEntity<T>) operations .getMappingContext().getPersistentEntity(domainClass); return new MappingVaultEntityInformation<>(entity); }
/** {@inheritDoc} */ @Override public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { return new AbstractEntityInformation<T, ID>(domainClass) { @Override public ID getId(T entity) { return null; } @Override public Class<ID> getIdType() { return null; } }; }
/** * Creates a new {@link SimpleKeyValueRepository} for the given {@link EntityInformation} and * {@link KeyValueOperations}. * * @param metadata must not be {@literal null}. * @param operations must not be {@literal null}. */ public SimpleKeyValueRepository(EntityInformation<T, ID> metadata, KeyValueOperations operations) { Assert.notNull(metadata, "EntityInformation must not be null!"); Assert.notNull(operations, "KeyValueOperations must not be null!"); this.entityInformation = metadata; this.operations = operations; }
/** * Creates a new {@link QuerydslKeyValueRepository} for the given {@link EntityInformation}, * {@link KeyValueOperations} and {@link EntityPathResolver}. * * @param entityInformation must not be {@literal null}. * @param operations must not be {@literal null}. * @param resolver must not be {@literal null}. */ public QuerydslKeyValueRepository(EntityInformation<T, ID> entityInformation, KeyValueOperations operations, EntityPathResolver resolver) { super(entityInformation, operations); Assert.notNull(resolver, "EntityPathResolver must not be null!"); EntityPath<T> path = resolver.createPath(entityInformation.getJavaType()); this.builder = new PathBuilder<>(path.getType(), path.getMetadata()); }
@Override @SuppressWarnings("unchecked") public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { PersistentEntity<T, ?> entity = (PersistentEntity<T, ?>) context.getRequiredPersistentEntity(domainClass); return new PersistentEntityInformation<>(entity); }
protected EntityInformation<T, ID> getEntityInfo() { return entityInfo; }
public static <T, ID extends Serializable> EntityType getEntityType(EntityInformation<T, ID> information) { if (information instanceof JdbcEntityInformation) { return ((JdbcEntityInformation<T, ID>) information).getEntityType(); } throw new RuntimeException("Don't know how to retrieve entity type"); }
ManuallyAssignedRepositoryStrategy(final EntityInformation entityInformation) { super(entityInformation); }
public AbstractRepositoryStrategy(final EntityInformation entityInformation) { this.entityInformation = entityInformation; }
protected EntityInformation getEntityInformation() { return entityInformation; }
ReadOnlyRepositoryStrategy(final EntityInformation entityInformation) { super(entityInformation); }
public AutoIncrementRepositoryStrategy(final EntityInformation entityInformation) { super(entityInformation); idSetter = getIdSetter(); getNumberValueMethod = GeneratedValueUtil.getNumberConversionMethod(entityInformation.getIdType()); }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { return extractRepositoryField(repository, FIELD_ENTITY_INFO); }
@Override protected Object getTargetRepository(RepositoryInformation information) { final EntityInformation<?, Serializable> entityInformation = getEntityInformation(information.getDomainType()); return getTargetRepositoryViaReflection(information, entityInformation, this.applicationContext); }
@Override public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { return new DocumentDbEntityInformation<T, ID>(domainClass); }
@Test public void useMappingDocumentDBEntityInfoIfMappingContextSet() { final DocumentDbRepositoryFactory factory = new DocumentDbRepositoryFactory(dbTemplate, applicationContext); final EntityInformation<Person, String> entityInfo = factory.getEntityInformation(Person.class); assertTrue(entityInfo instanceof DocumentDbEntityInformation); }
@Override public <U, ID> CrudAdapter<U, ID> createCrudAdapter(EntityInformation<U, ID> ei) { return new TesterCrudAdapter<>(ei); }
public TesterCrudAdapter(EntityInformation<U, ID> entityInformation) { super(entityInformation); }
public GaeCrudAdapter(EntityInformation<T, ID> ei, EntityToModelMapper entityToModelMapper) { this.entityInformation = ei; this.entityToModelMapper = entityToModelMapper; }
public <T, ID> CrudAdapter<T, ID> createCrudAdapter(EntityInformation<T, ID> ei) { return new GaeCrudAdapter<>(ei, entityToModelMapper); }
public <T, ID> CrudAdapter<T, ID> createCrudAdapter(EntityInformation<T, ID> ei) { Cache<ID, T> cache = getCache(ei.getJavaType()); return new InfinispanEmbeddedCrudAdapter<>(ei, cache); }
public InfinispanEmbeddedCrudAdapter(EntityInformation<T, ID> ei, Cache<ID, T> cache) { super(ei, cache); this.cache = cache; }
public InfinispanRemoteCrudAdapter(EntityInformation<T, ID> ei, RemoteCache<ID, T> cache) { super(ei, cache); this.cache = cache; }
public <T, ID> CrudAdapter<T, ID> createCrudAdapter(EntityInformation<T, ID> ei) { RemoteCache<ID, T> cache = getCache(ei.getJavaType()); return new InfinispanRemoteCrudAdapter<T, ID>(ei, cache); }
public MapCrudAdapter(EntityInformation<T, ID> entityInformation, Map<ID, T> map) { super(entityInformation); this.map = map; }
public AbstractCrudAdapter(EntityInformation<T, ID> entityInformation) { this.entityInformation = entityInformation; }
@Override public <T, ID> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { PersistentEntity<?, SnowdropPersistentProperty> persistentEntity = snowdropOperations.getMappingContext().getPersistentEntity(domainClass); return new MappingSnowdropEntityInformation(persistentEntity); }
public <T, ID> CrudAdapter<T, ID> createCrudAdapter(EntityInformation<T, ID> ei) { return new OrmCrudAdapter<>(ei.getJavaType()); }
@Override public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation( Class<T> domainClass) { return new GcloudDatastoreEntityInformation<T, ID>(domainClass); }
@Override public <T, ID extends Serializable> EntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { return new ReflectionEntityInformation<>(domainClass, Id.class); }