widana

RemoveAllTransactionItemPosByPosId

Oct 26th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.37 KB | None | 0 0
  1. package org.jleaf.pos2.bo.postransaction;
  2.  
  3. import javax.persistence.Query;
  4. import org.jleaf.core.BusinessFunction;
  5. import org.jleaf.core.BusinessTransaction;
  6. import org.jleaf.core.DefaultBusinessTransaction;
  7. import org.jleaf.core.Dto;
  8. import org.jleaf.core.annotation.ErrorList;
  9. import org.jleaf.core.annotation.Info;
  10. import org.jleaf.core.annotation.InfoIn;
  11. import org.jleaf.core.annotation.InfoOut;
  12. import org.jleaf.core.dao.QueryBuilder;
  13. import org.jleaf.pos2.dao.PosDao;
  14. import org.jleaf.pos2.entity.Pos;
  15. import org.jleaf.util.ValidationUtil;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.beans.factory.annotation.Qualifier;
  18. import org.springframework.stereotype.Service;
  19.  
  20. /**
  21.  * Business Transactions: AddPosTransaction
  22.  *
  23.  * @author Widana Nur Azis , 24 oct 2016
  24.  */
  25.  
  26. // @formatter:off
  27. @Service
  28. @InfoIn(value = {
  29.         @Info(name = "userLoginId", description = "user login id", type = Long.class),
  30.         @Info(name = "userLoginName", description = "user login name", type = String.class),
  31.         @Info(name = "roleLoginId", description = "role login id", type = Long.class),
  32.         @Info(name = "roleLoginName", description = "role login name", type = String.class),
  33.         @Info(name = "tenantLoginId", description = "tenantLoginId", type = Long.class),
  34.         @Info(name = "datetime", description = "date time", type = String.class),
  35.  
  36.         @Info(name = "posCashierId", description = "posCashierId", type = Long.class),
  37.         @Info(name = "posId", description = "posId", type = Long.class) })
  38.  
  39. @InfoOut(value = {})
  40. // @formatter:on
  41. @ErrorList(errorKeys = {})
  42. public class RemoveAllTransactionItemPosByPosId extends DefaultBusinessTransaction implements BusinessTransaction {
  43.  
  44.     @Autowired
  45.     PosDao posDao;
  46.  
  47.     @Autowired
  48.     @Qualifier("findPosCashierById")
  49.     BusinessFunction findPosCashierById;
  50.  
  51.      @Autowired
  52.      @Qualifier("findPosById")
  53.      BusinessFunction findPosById;
  54.  
  55.     @Override
  56.     public String getDescription() {
  57.         // TODO Auto-generated method stub
  58.         return "use remove all transaction item pos by pos id";
  59.     }
  60.  
  61.     @Override
  62.     public Dto prepare(Dto inputDto, Dto originalDto) throws Exception {
  63.         // TODO Auto-generated method stub
  64.         ValidationUtil.valBlankOrNull(inputDto, "posCashierId");
  65.         ValidationUtil.valBlankOrNull(inputDto, "posId");
  66.  
  67.         ValidationUtil.valDtoContainsKey(inputDto, "posCashierId");
  68.         ValidationUtil.valBlankOrNull(inputDto, "posId");
  69.  
  70.         findPosById.execute(new Dto().put("id", inputDto.getLong("posId")));
  71.  
  72.         findPosCashierById.execute(new Dto().put("id", inputDto.getLong("posCashierId")));
  73.  
  74.         Dto removeAllTransactionItemPosByPosIdDto = new Dto();
  75.         removeAllTransactionItemPosByPosIdDto.put("posId",inputDto.getLong("posId"));
  76.  
  77.         inputDto.put("removeAllTransactionItemPosByPosIdDto",removeAllTransactionItemPosByPosIdDto);
  78.  
  79.         return null;
  80.     }
  81.  
  82.     @Override
  83.     public Dto process(Dto inputDto, Dto originalDto) throws Exception {
  84.         // TODO Auto-generated method stub
  85.  
  86.         Dto getRemoveAllTransactionItemPosByPosIdDto = inputDto
  87.                 .getDto("removeAllTransactionItemPosByPosIdDto");
  88.  
  89.         QueryBuilder builder = new QueryBuilder();
  90.         builder.add(" DELETE ")
  91.         .add(Pos.TABLE_NAME).add(" A ").add(" FROM ")
  92.         .add(" WHERE A.pos_id = :posId ");
  93.  
  94.         Query query = posDao.createNativeQuery(builder.toString());
  95.         query.setParameter("posId",getRemoveAllTransactionItemPosByPosIdDto.getLong("posId"));
  96.  
  97.         return new Dto();
  98.     }
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment