Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.common.bo.combo;
- import org.jleaf.common.CommonExceptionConstants;
- import org.jleaf.common.dao.ComboDao;
- import org.jleaf.common.dao.ComboValueDao;
- import org.jleaf.common.entity.Combo;
- import org.jleaf.common.entity.ComboValue;
- import org.jleaf.common.entity.ComboValuePk;
- import org.jleaf.core.AbstractBusinessFunction;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.CoreException;
- import org.jleaf.core.Dto;
- import org.jleaf.core.annotation.Info;
- import org.jleaf.core.annotation.InfoIn;
- import org.jleaf.core.annotation.InfoOut;
- import org.jleaf.util.ValidationUtil;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- /**
- *
- * Validate Combo Value By Code function
- *
- * @author NK
- * @version 1.0
- */
- @Service
- @InfoIn(value={
- @Info(name="comboId",description="combo id",type=String.class),
- @Info(name="code",description="code",type=String.class),
- @Info(name="varName",description="variable name",type=String.class)
- })
- @InfoOut(value = {})
- public class ValComboValueByCode extends AbstractBusinessFunction implements BusinessFunction {
- @Autowired
- ComboValueDao comboValueDao;
- @Autowired
- ComboDao comboDao;
- @Override
- public String getDescription(){
- return "Validate combo value by code and combo id";
- }
- @Override
- public Dto execute(Dto inputDto) throws Exception {
- Dto outputDto = null;
- ValidationUtil.valDtoContainsKey(inputDto, "comboId");
- ValidationUtil.valDtoContainsKey(inputDto, "code");
- Combo combo = comboDao.findByPk(inputDto.getString("comboId"));
- if(combo==null) {
- throw new CoreException(CommonExceptionConstants.COMBO_NOT_FOUND,inputDto.getString("comboId"));
- }
- ComboValuePk comboValuePk = new ComboValuePk(inputDto.getString("comboId"),
- inputDto.getString("code"));
- ComboValue comboValue = comboValueDao.findByPk(comboValuePk);
- if(comboValue==null){
- throw new CoreException(CommonExceptionConstants.COMBO_VALUE_NOT_VALID,
- inputDto.getString("varName"),
- combo.getDescription());
- }
- return outputDto;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement