Exemplo n.º 1
0
 @Override
 public Amount getAmountOfGoods(Goods goods) {
   EntityManager em = emf.createEntityManager();
   try {
     return em.find(Goods.class, goods.getId()).getWareHouseImpl().getAmount();
   } finally {
     em.close();
   }
 }
Exemplo n.º 2
0
 @Override
 public void exportGoods(Goods goods, Amount amount) {
   EntityManager em = emf.createEntityManager();
   try {
     em.find(Goods.class, goods.getId()).getWareHouseImpl().decrease(amount);
   } finally {
     em.close();
   }
 }
Exemplo n.º 3
0
 @Override
 public boolean canExport(Goods goods, Amount amount) {
   EntityManager em = emf.createEntityManager();
   try {
     return em.find(Goods.class, goods.getId()).getWareHouseImpl().getAmount().compareTo(amount)
             >= 0
         ? true
         : false;
   } finally {
     em.close();
   }
 }