当前位置: 首页>>代码示例>>Java>>正文


Java Persistable类代码示例

本文整理汇总了Java中io.requery.Persistable的典型用法代码示例。如果您正苦于以下问题:Java Persistable类的具体用法?Java Persistable怎么用?Java Persistable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Persistable类属于io.requery包,在下文中一共展示了Persistable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的io.requery.Persistable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。