Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.pos2.bo.postransaction;
- import javax.persistence.Query;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.BusinessTransaction;
- import org.jleaf.core.DefaultBusinessTransaction;
- import org.jleaf.core.Dto;
- import org.jleaf.core.annotation.ErrorList;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.annotation.InfoOut;
- import org.jleaf.core.dao.QueryBuilder;
- import org.jleaf.pos2.dao.PosDao;
- import org.jleaf.pos2.entity.Pos;
- import org.jleaf.util.ValidationUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.stereotype.Service;
- /**
- * Business Transactions: AddPosTransaction
- *
- * @author Widana Nur Azis , 24 oct 2016
- */
- // @formatter:off
- @Service
- @InfoIn(value = {
- @Info(name = "userLoginId", description = "user login id", type = Long.class),
- @Info(name = "userLoginName", description = "user login name", type = String.class),
- @Info(name = "roleLoginId", description = "role login id", type = Long.class),
- @Info(name = "roleLoginName", description = "role login name", type = String.class),
- @Info(name = "tenantLoginId", description = "tenantLoginId", type = Long.class),
- @Info(name = "datetime", description = "date time", type = String.class),
- @Info(name = "posCashierId", description = "posCashierId", type = Long.class),
- @Info(name = "posId", description = "posId", type = Long.class) })
- @InfoOut(value = {})
- // @formatter:on
- @ErrorList(errorKeys = {})
- public class RemoveAllTransactionItemPosByPosId extends DefaultBusinessTransaction implements BusinessTransaction {
- @Autowired
- PosDao posDao;
- @Autowired
- @Qualifier("findPosCashierById")
- BusinessFunction findPosCashierById;
- @Autowired
- @Qualifier("findPosById")
- BusinessFunction findPosById;
- @Override
- public String getDescription() {
- // TODO Auto-generated method stub
- return "use remove all transaction item pos by pos id";
- }
- @Override
- public Dto prepare(Dto inputDto, Dto originalDto) throws Exception {
- // TODO Auto-generated method stub
- ValidationUtil.valBlankOrNull(inputDto, "posCashierId");
- ValidationUtil.valBlankOrNull(inputDto, "posId");
- ValidationUtil.valDtoContainsKey(inputDto, "posCashierId");
- ValidationUtil.valBlankOrNull(inputDto, "posId");
- findPosById.execute(new Dto().put("id", inputDto.getLong("posId")));
- findPosCashierById.execute(new Dto().put("id", inputDto.getLong("posCashierId")));
- Dto removeAllTransactionItemPosByPosIdDto = new Dto();
- removeAllTransactionItemPosByPosIdDto.put("posId",inputDto.getLong("posId"));
- inputDto.put("removeAllTransactionItemPosByPosIdDto",removeAllTransactionItemPosByPosIdDto);
- return null;
- }
- @Override
- public Dto process(Dto inputDto, Dto originalDto) throws Exception {
- // TODO Auto-generated method stub
- Dto getRemoveAllTransactionItemPosByPosIdDto = inputDto
- .getDto("removeAllTransactionItemPosByPosIdDto");
- QueryBuilder builder = new QueryBuilder();
- builder.add(" DELETE ")
- .add(Pos.TABLE_NAME).add(" A ").add(" FROM ")
- .add(" WHERE A.pos_id = :posId ");
- Query query = posDao.createNativeQuery(builder.toString());
- query.setParameter("posId",getRemoveAllTransactionItemPosByPosIdDto.getLong("posId"));
- return new Dto();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment