Пример #1
0
  private void createCategories(final Context context) {
    persistence.runInTransaction(
        em -> {
          Category category;

          category = metadata.create(Category.class);
          category.setName("Housekeeping");
          category.setCatType(CategoryType.EXPENSE);
          em.persist(category);
          context.expenseCategories.add(category);

          category = metadata.create(Category.class);
          category.setName("Hobby");
          category.setCatType(CategoryType.EXPENSE);
          em.persist(category);
          context.expenseCategories.add(category);

          category = metadata.create(Category.class);
          category.setName("Travel");
          category.setCatType(CategoryType.EXPENSE);
          em.persist(category);
          context.expenseCategories.add(category);

          category = metadata.create(Category.class);
          category.setName("Food");
          category.setCatType(CategoryType.EXPENSE);
          em.persist(category);
          context.expenseCategories.add(category);

          category = metadata.create(Category.class);
          category.setName("Clothes");
          category.setCatType(CategoryType.EXPENSE);
          em.persist(category);
          context.expenseCategories.add(category);

          category = metadata.create(Category.class);
          category.setName("Car");
          category.setCatType(CategoryType.EXPENSE);
          em.persist(category);
          context.expenseCategories.add(category);

          category = metadata.create(Category.class);
          category.setName("Salary");
          category.setCatType(CategoryType.INCOME);
          em.persist(category);
          context.salaryCategory = category;

          category = metadata.create(Category.class);
          category.setName("Other");
          category.setCatType(CategoryType.INCOME);
          em.persist(category);
          context.otherIncomeCategory = category;
        });
  }
Пример #2
0
  private void createCurrencies(final Context context) {
    persistence.runInTransaction(
        em -> {
          Currency currency = metadata.create(Currency.class);
          currency.setCode("rub");
          currency.setName("Russian Rubles");
          em.persist(currency);
          context.rubCurrency = currency;

          currency = metadata.create(Currency.class);
          currency.setCode("usd");
          currency.setName("US Dollars");
          em.persist(currency);
          context.usdCurrency = currency;

          currency = metadata.create(Currency.class);
          currency.setCode("eur");
          currency.setName("Euro");
          em.persist(currency);
          context.eurCurrency = currency;
        });
  }