try {
if(!transaction.isActive()) {
contained = true;
transaction.begin();
}
FoodItem item;
if(system == MeasurementSystem.Imperial) {
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.bacon"));
item.setDescription(BeanUtil.getMessage("foodItem.bacon.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.meats"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.icebergLettuce"));
item.setDescription(BeanUtil.getMessage("foodItem.icebergLettuce.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.vegetables"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.tomato"));
item.setDescription(BeanUtil.getMessage("foodItem.tomato.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.vegetables"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.mayonnaise"));
item.setDescription(BeanUtil.getMessage("foodItem.mayonnaise.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.condiments"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.sandwichBread"));
item.setDescription(BeanUtil.getMessage("foodItem.sandwichBread.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.carbohydrates"));
item.setProject(project);
save(entityManager, item, cache);
} else {
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.potato"));
item.setDescription(BeanUtil.getMessage("foodItem.potato.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.vegetables"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.chives"));
item.setDescription(BeanUtil.getMessage("foodItem.chives.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.vegetables"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.butter"));
item.setDescription(BeanUtil.getMessage("foodItem.butter.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.fatsOils"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.onion"));
item.setDescription(BeanUtil.getMessage("foodItem.onion.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.vegetables"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.egg"));
item.setDescription(BeanUtil.getMessage("foodItem.egg.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.proteins"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.cheddarCheese"));
item.setDescription(BeanUtil.getMessage("foodItem.cheddarCheese.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.dairy"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.salt"));
item.setDescription(BeanUtil.getMessage("foodItem.salt.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.spices"));
item.setProject(project);
save(entityManager, item, cache);
item = new FoodItem();
item.setName(BeanUtil.getMessage("foodItem.pepper"));
item.setDescription(BeanUtil.getMessage("foodItem.pepper.description"));
item.setCategory(BeanUtil.getMessage("foodItem.category.spices"));
item.setProject(project);
save(entityManager, item, cache);
}
if(contained) {
transaction.commit();
}