本文整理汇总了Java中io.requery.Persistable类的典型用法代码示例。如果您正苦于以下问题:Java Persistable类的具体用法?Java Persistable怎么用?Java Persistable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Persistable类属于io.requery包,在下文中一共展示了Persistable类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testRunInTransactionFromBlocking
import io.requery.Persistable; //导入依赖的package包/类
@Test
public void testRunInTransactionFromBlocking() {
final BlockingEntityStore<Persistable> blocking = data.toBlocking();
Completable.fromCallable(new Callable<Object>() {
@Override
public Object call() throws Exception {
blocking.runInTransaction(new Callable<Object>() {
@Override
public Object call() throws Exception {
final Person person = randomPerson();
blocking.insert(person);
blocking.update(person);
return null;
}
});
return null;
}
}).subscribe();
assertEquals(1, data.count(Person.class).get().value().intValue());
}
开发者ID:requery,项目名称:requery,代码行数:21,代码来源:ReactiveTest.java
示例2: provideDatabaseSource
import io.requery.Persistable; //导入依赖的package包/类
@Singleton
@Provides
public EntityDataStore<Persistable> provideDatabaseSource() {
Observable.<Void>just(null).observeOn(Schedulers.io()).subscribe(new Action1<Void>() {
@Override
public void call(Void aVoid) {
raw2data(app, DB_NAME, R.raw.books);
}
});
DatabaseSource source = new DatabaseSource(app, Models.DEFAULT, DB_NAME, DB_VERSION);
source.setLoggingEnabled(BuildConfig.DEBUG);
Configuration configuration = source.getConfiguration();
return new EntityDataStore<>(configuration);
}
开发者ID:xdtianyu,项目名称:Kindle,代码行数:17,代码来源:AppModule.java
示例3: shouldSaveNoExistingStripInBatch
import io.requery.Persistable; //导入依赖的package包/类
@Test
public void shouldSaveNoExistingStripInBatch() throws Exception {
StripDto strip = SampleStrip.generateSampleDto();
TestSubscriber testSubscriber = new TestSubscriber<>();
Flowable<StripDto> strips = Flowable.just(strip);
SaveStripBatchTask underTest = new SaveStripBatchTask(getStripRepository());
underTest.execute(strips).blockingSubscribe(testSubscriber);
testSubscriber.assertNoErrors();
testSubscriber.assertComplete();
testSubscriber.assertValueCount(1);
testSubscriber.assertValue(strip);
ReactiveEntityStore<Persistable> database = mRobolectricRepositoryRule.getLocalDatabase();
Integer numberRow = database.count()
.from(StripDaoEntity.class)
.where(StripDaoEntity.ID.eq(1L))
.get().call();
Assert.assertTrue ("Should have one strip saved on database : ", numberRow == 1);
}
开发者ID:DevHugo,项目名称:commitstrip-reader,代码行数:27,代码来源:SaveStripBatchTaskTest.java
示例4: saveInBatchExistingStripShouldReturnZeroStrip
import io.requery.Persistable; //导入依赖的package包/类
@Test
public void saveInBatchExistingStripShouldReturnZeroStrip() throws Exception {
StripDaoEntity strip = SampleStrip.generateSampleDao();
mRobolectricRepositoryRule.getLocalDatabase().insert(strip).blockingGet();
TestSubscriber testSubscriber = new TestSubscriber<>();
Flowable<StripDto> strips = Flowable.just(SampleStrip.generateSampleDto());
SaveStripBatchTask underTest = new SaveStripBatchTask(getStripRepository());
underTest.execute(strips).blockingSubscribe(testSubscriber);
testSubscriber.assertNoErrors();
testSubscriber.assertComplete();
ReactiveEntityStore<Persistable> database = mRobolectricRepositoryRule.getLocalDatabase();
Integer numberRow = database
.count()
.from(StripDaoEntity.class)
.get()
.call();
Assert.assertTrue ("Should have one strip saved on database : ", numberRow == 1);
}
开发者ID:DevHugo,项目名称:commitstrip-reader,代码行数:26,代码来源:SaveStripBatchTaskTest.java
示例5: setup
import io.requery.Persistable; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
Platform platform = new HSQL();
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = io.requery.test.model.Models.DEFAULT;
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setWriteExecutor(Executors.newSingleThreadExecutor())
.setEntityCache(new EntityCacheBuilder(model)
.useReferenceCache(true)
.useSerializableCache(true)
.useCacheManager(cacheManager)
.build())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
data = new ReactorEntityStore<>(new EntityDataStore<Persistable>(configuration));
}
开发者ID:requery,项目名称:requery,代码行数:23,代码来源:ReactorTest.java
示例6: setup
import io.requery.Persistable; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
Platform platform = new HSQL();
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = io.requery.test.model.Models.DEFAULT;
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setWriteExecutor(Executors.newSingleThreadExecutor())
.setEntityCache(new EntityCacheBuilder(model)
.useReferenceCache(true)
.useSerializableCache(true)
.useCacheManager(cacheManager)
.build())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
data = ReactiveSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
开发者ID:requery,项目名称:requery,代码行数:23,代码来源:ReactiveTest.java
示例7: setup
import io.requery.Persistable; //导入依赖的package包/类
@Before
public void setup() throws SQLException {
Platform platform = new HSQL();
CommonDataSource dataSource = DatabaseType.getDataSource(platform);
EntityModel model = io.requery.test.model.Models.DEFAULT;
CachingProvider provider = Caching.getCachingProvider();
CacheManager cacheManager = provider.getCacheManager();
Configuration configuration = new ConfigurationBuilder(dataSource, model)
.useDefaultLogging()
.setWriteExecutor(Executors.newSingleThreadExecutor())
.setEntityCache(new EntityCacheBuilder(model)
.useReferenceCache(true)
.useSerializableCache(true)
.useCacheManager(cacheManager)
.build())
.build();
SchemaModifier tables = new SchemaModifier(configuration);
tables.createTables(TableCreationMode.DROP_CREATE);
data = RxSupport.toReactiveStore(new EntityDataStore<Persistable>(configuration));
}
开发者ID:requery,项目名称:requery,代码行数:23,代码来源:RxTest.java
示例8: getData
import io.requery.Persistable; //导入依赖的package包/类
@NonNull
public ReactiveEntityStore<Persistable> getData() throws RuntimeException {
if (dataStore == null) {
// override onUpgrade to handle migrating to a new version
DatabaseSource source = new DatabaseSource(getReflectedContext(), Models.DEFAULT, 1);
if (BuildConfig.DEBUG) {
// use this in development mode to drop and recreate the tables on every upgrade
source.setTableCreationMode(TableCreationMode.DROP_CREATE);
}
Configuration configuration = source.getConfiguration();
dataStore = ReactiveSupport.toReactiveStore(
new EntityDataStore<Persistable>(configuration));
}
return dataStore;
}
开发者ID:kbiakov,项目名称:newsreader-mvp-android,代码行数:16,代码来源:DbManager.java
示例9: getAll
import io.requery.Persistable; //导入依赖的package包/类
public <T extends Persistable> Observable<T> getAll(Class<T> clazz) {
EntityInfo info = EntityInfos.infoFor(clazz);
if (info.single()) {
//noinspection unchecked
return getObject(info.endpoint(), clazz)
.toObservable();
} else {
return getAll(info.endpoint(), clazz);
}
}
开发者ID:shymmq,项目名称:librus-client,代码行数:11,代码来源:APIClient.java
示例10: getMany
import io.requery.Persistable; //导入依赖的package包/类
private <T extends Persistable> List<T> getMany(Class<T> clazz, int count) {
return database
.getAll(clazz)
.take(count)
.toList()
.blockingGet();
}
开发者ID:shymmq,项目名称:librus-client,代码行数:8,代码来源:NotificationTesterPresenter.java
示例11: sendNotificationClicked
import io.requery.Persistable; //导入依赖的package包/类
public void sendNotificationClicked(Class<? extends Persistable> clazz, int count) {
if (clazz.isAssignableFrom(LuckyNumber.class)) {
notificationService.addLuckyNumber(getMany(LuckyNumber.class, count));
widgetUpdater.updateLuckyNumber();
} else if (clazz.isAssignableFrom(Event.class)) {
notificationService.addEvents(getMany(Event.class, count));
} else if (clazz.isAssignableFrom(Grade.class)) {
notificationService.addGrades(getMany(Grade.class, count));
} else if (clazz.isAssignableFrom(Announcement.class)) {
notificationService.addAnnouncements(getMany(Announcement.class, count));
}
}
开发者ID:shymmq,项目名称:librus-client,代码行数:13,代码来源:NotificationTesterPresenter.java
示例12: getAll
import io.requery.Persistable; //导入依赖的package包/类
public <T extends Persistable> Observable<T> getAll(Class<T> clazz) {
EntityInfo info = EntityInfos.infoFor(clazz);
return getAll(info.endpoint(), clazz)
.onErrorResumeNext(e -> {
if(e instanceof NotActiveException){
return Observable.empty();
} else {
return Observable.error(e);
}
});
}
开发者ID:shymmq,项目名称:librus-client,代码行数:12,代码来源:DefaultAPIClient.java
示例13: getById
import io.requery.Persistable; //导入依赖的package包/类
@Override
public <T extends Persistable & Identifiable> Single<T> getById(Class<T> clazz, String id) {
EntityInfo info = EntityInfos.infoFor(clazz);
return makeRequest(info.endpoint(id))
.map(s -> EntityParser.parseObject(s, clazz))
.map(o -> {
if (o.isPresent()) {
return o.get();
} else {
throw new EntityMissingException("server", clazz, id);
}
});
}
开发者ID:shymmq,项目名称:librus-client,代码行数:15,代码来源:DefaultAPIClient.java
示例14: getAll
import io.requery.Persistable; //导入依赖的package包/类
@Override
public <T extends Persistable> Observable<T> getAll(Class<T> clazz) {
return dataStore.select(clazz)
.get()
.observable()
.subscribeOn(Schedulers.io());
}
开发者ID:shymmq,项目名称:librus-client,代码行数:8,代码来源:DatabaseManager.java
示例15: getById
import io.requery.Persistable; //导入依赖的package包/类
@Override
public <T extends Persistable & Identifiable> Single<T> getById(Class<T> clazz, String id) {
return dataStore.findByKey(clazz, id)
.toSingle()
.onErrorResumeNext(Single.error(new EntityMissingException("database", clazz, id)))
.subscribeOn(Schedulers.io());
}
开发者ID:shymmq,项目名称:librus-client,代码行数:8,代码来源:DatabaseManager.java
示例16: setLastUpdate
import io.requery.Persistable; //导入依赖的package包/类
private Completable setLastUpdate(List<? extends Persistable> elements) {
if (elements.isEmpty()) {
return Completable.complete();
} else {
Class<? extends Persistable> clazz = elements.get(0).getClass();
LastUpdate lastUpdate = LastUpdate.of(clazz, LocalDate.now());
return dataStore.upsert(lastUpdate)
.subscribeOn(Schedulers.io())
.toCompletable();
}
}
开发者ID:shymmq,项目名称:librus-client,代码行数:13,代码来源:DatabaseManager.java
示例17: getDataStore
import io.requery.Persistable; //导入依赖的package包/类
public static EntityDataStore<Persistable> getDataStore(DatabaseSource source) {
Configuration configuration = new ConfigurationBuilder(source, Models.DEFAULT)
.setMapping(new MainMapping())
.setStatementCacheSize(100)
.setEntityCache(new EntityCacheBuilder(Models.DEFAULT)
.useReferenceCache(true)
.build())
.build();
return new EntityDataStore<>(configuration);
}
开发者ID:shymmq,项目名称:librus-client,代码行数:11,代码来源:SqlHelper.java
示例18: updateAll
import io.requery.Persistable; //导入依赖的package包/类
public Completable updateAll(ProgressReporter progressReporter) {
ImmutableList.Builder<Completable> builder = ImmutableList.builder();
for (Class<? extends Persistable> entityClass : entitiesToUpdate) {
builder.add(update(entityClass, progressReporter));
}
builder.addAll(updateNearestTimetables(progressReporter));
List<Completable> tasks = builder.build();
progressReporter.setTotal(tasks.size());
return Completable.merge(tasks);
}
开发者ID:shymmq,项目名称:librus-client,代码行数:12,代码来源:UpdateHelper.java
示例19: update
import io.requery.Persistable; //导入依赖的package包/类
private <T extends Persistable> Completable update(Class<T> clazz, ProgressReporter progressReporter) {
return serverStrategy.getAll(clazz)
.toList()
.doOnSuccess(list -> LibrusUtils.log("Loaded %s %s", list.size(), clazz.getSimpleName()))
.doOnSuccess(progressReporter::report)
.flatMapCompletable(databaseStrategy::upsert);
}
开发者ID:shymmq,项目名称:librus-client,代码行数:8,代码来源:UpdateHelper.java
示例20: shouldUpdate
import io.requery.Persistable; //导入依赖的package包/类
@VisibleForTesting
public Maybe<?> shouldUpdate(Class<? extends Persistable> clazz) {
return databaseStrategy.findLastUpdate(clazz)
.observeOn(Schedulers.computation())
.map(LastUpdate::date)
.map(date -> Days.daysBetween(date, LocalDate.now()).getDays())
.map(diff -> diff > EntityInfos.infoFor(clazz).refreshDays())
.toSingle(true)
.filter(should -> should);
}
开发者ID:shymmq,项目名称:librus-client,代码行数:11,代码来源:UpdateHelper.java
注:本文中的io.requery.Persistable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论