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


Java MotechDataService.doInTransaction方法代码示例

本文整理汇总了Java中org.motechproject.mds.service.MotechDataService.doInTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java MotechDataService.doInTransaction方法的具体用法?Java MotechDataService.doInTransaction怎么用?Java MotechDataService.doInTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.motechproject.mds.service.MotechDataService的用法示例。


在下文中一共展示了MotechDataService.doInTransaction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpTestData

import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
private void setUpTestData() throws Exception {
    MotechDataService service = getService();

    final Object instance1 = objectInstance("one", asList("one", "two"));
    final Object instance2 = objectInstance("two", asList("two", "one", "four"));
    final Object instance3 = objectInstance("four", asList("four", "four", "four"));
    final Object instance4 = objectInstance("five", singletonList("five"));
    final Object instance5 = objectInstance("one", asList("one", "two", "four", "three"));
    final Object instance6 = objectInstance(null, null);
    final Object instance7 = objectInstance(null, singletonList(null));
    final Object instance8 = objectInstance("", singletonList(""));

    service.doInTransaction(new TransactionCallbackWithoutResult() {
        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            service.create(instance1);
            service.create(instance2);
            service.create(instance3);
            service.create(instance4);
            service.create(instance5);
            service.create(instance6);
            service.create(instance7);
            service.create(instance8);
        }
    });

    assertEquals("There were issues creating test data", 8, service.count());
}
 
开发者ID:motech,项目名称:motech,代码行数:29,代码来源:ComboboxValueRepositoryContextIT.java

示例2: setUpTestData

import org.motechproject.mds.service.MotechDataService; //导入方法依赖的package包/类
private void setUpTestData() throws Exception {
    Class<?> clazz = getEntityClass();

    DateTime threeDaysAgo = NOW.minusDays(3);
    DateTime eightDaysAgo = NOW.minusDays(8);
    DateTime notThisMonth = NOW.minusMonths(2);
    DateTime notThisYear = NOW.minusYears(2);

    MotechDataService service = getService();

    final Object instance1 = objectInstance(clazz, true, NOW.toDate(), NOW, "now");
    final Object instance2 = objectInstance(clazz, true, threeDaysAgo.toDate(), threeDaysAgo, "threeDaysAgo");
    final Object instance3 = objectInstance(clazz, false, eightDaysAgo.toDate(), eightDaysAgo, "eightDaysAgo");
    final Object instance4 = objectInstance(clazz, false, notThisMonth.toDate(), notThisMonth, "notThisMonth");
    final Object instance5 = objectInstance(clazz, false, notThisYear.toDate(), notThisYear, "notThisYear");

    service.doInTransaction(new TransactionCallbackWithoutResult() {
        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            service.create(instance1);
            service.create(instance2);
            service.create(instance3);
            service.create(instance4);
            service.create(instance5);
        }
    });

    assertEquals("There were issues creating test data", 5, service.count());
}
 
开发者ID:motech,项目名称:motech,代码行数:30,代码来源:FilterContextIT.java


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