Search in sources :

Example 1 with SysFormMethodVO

use of com.netsteadfast.greenstep.vo.SysFormMethodVO in project bamboobsc by billchen198318.

the class SystemFormMethodSaveOrUpdateAction method delete.

private void delete() throws ControllerException, AuthorityException, ServiceException, Exception {
    SysFormMethodVO method = new SysFormMethodVO();
    this.transformFields2ValueObject(method, new String[] { "oid" });
    DefaultResult<Boolean> result = this.systemFormLogicService.deleteMethod(method);
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null && result.getValue()) {
        this.success = IS_YES;
    }
}
Also used : SysFormMethodVO(com.netsteadfast.greenstep.vo.SysFormMethodVO)

Example 2 with SysFormMethodVO

use of com.netsteadfast.greenstep.vo.SysFormMethodVO in project bamboobsc by billchen198318.

the class SystemFormLogicServiceImpl method updateMethod.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysFormMethodVO> updateMethod(SysFormMethodVO formMethod, String formOid) throws ServiceException, Exception {
    if (null == formMethod || super.isBlank(formMethod.getOid()) || super.isBlank(formOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<SysFormMethodVO> oldResult = this.sysFormMethodService.findObjectByOid(formMethod);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    SysFormVO form = this.findForm(formOid);
    formMethod.setFormId(form.getFormId());
    // check UK(same "name" and "formId" ) is found. because can update formMethod's UK , so need to check it.
    DefaultResult<SysFormMethodVO> ukResult = this.sysFormMethodService.findByUK(formMethod);
    if (ukResult.getValue() != null) {
        if (!ukResult.getValue().getOid().equals(formMethod.getOid())) {
            // same UK found, but is another data.
            throw new ServiceException("Please change another name!");
        }
    }
    // clear blob expression
    oldResult.getValue().setExpression(null);
    this.sysFormMethodService.updateObject(oldResult.getValue());
    super.setStringValueMaxLength(formMethod, "description", MAX_DESCRIPTION_LENGTH);
    return this.sysFormMethodService.updateObject(formMethod);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormVO(com.netsteadfast.greenstep.vo.SysFormVO) SysFormMethodVO(com.netsteadfast.greenstep.vo.SysFormMethodVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with SysFormMethodVO

use of com.netsteadfast.greenstep.vo.SysFormMethodVO in project bamboobsc by billchen198318.

the class CommonLoadFormAction method execute.

@JSON(serialize = false)
@SystemForm
public String execute() throws Exception {
    String resultName = RESULT_SEARCH_NO_DATA;
    if (StringUtils.isBlank(form_id) || StringUtils.isBlank(form_method)) {
        this.message = "no settings data to init form!";
        this.setErrorMessage(this.message);
        return resultName;
    }
    try {
        SysFormMethodVO formMethod = SystemFormUtils.findFormMethod(this.form_id, this.form_method);
        resultName = formMethod.getResultType();
        this.processExpression(formMethod);
    } catch (ControllerException ce) {
        this.message = ce.getMessage().toString();
        this.setErrorMessage(this.message);
    } catch (AuthorityException ae) {
        this.message = ae.getMessage().toString();
        this.setErrorMessage(this.message);
        if (FormResultType.DEFAULT.equals(resultName)) {
            resultName = RESULT_NO_AUTHORITH;
        }
    } catch (ServiceException se) {
        this.message = se.getMessage().toString();
        this.setErrorMessage(this.message);
    } catch (Exception e) {
        // 因為是 JSON 所以不用拋出 throw e 了
        e.printStackTrace();
        if (e.getMessage() == null) {
            this.message = e.toString();
            this.logger.error(e.toString());
        } else {
            this.message = e.getMessage().toString();
            this.logger.error(e.getMessage());
        }
        this.setErrorMessage(this.message);
        this.success = IS_EXCEPTION;
        if (FormResultType.DEFAULT.equals(resultName)) {
            resultName = ERROR;
        }
    }
    return resultName;
}
Also used : ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormMethodVO(com.netsteadfast.greenstep.vo.SysFormMethodVO) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) ControllerException(com.netsteadfast.greenstep.base.exception.ControllerException) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) AuthorityException(com.netsteadfast.greenstep.base.exception.AuthorityException) JSON(org.apache.struts2.json.annotations.JSON) SystemForm(com.netsteadfast.greenstep.base.model.SystemForm)

Example 4 with SysFormMethodVO

use of com.netsteadfast.greenstep.vo.SysFormMethodVO in project bamboobsc by billchen198318.

the class SystemFormUtils method findFormMethod.

public static SysFormMethodVO findFormMethod(String formId, String methodName) throws ServiceException, Exception {
    SysFormMethodVO formMethod = new SysFormMethodVO();
    formMethod.setFormId(formId);
    formMethod.setName(methodName);
    DefaultResult<SysFormMethodVO> result = sysFormMethodService.findByUK(formMethod);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    formMethod = result.getValue();
    return formMethod;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormMethodVO(com.netsteadfast.greenstep.vo.SysFormMethodVO)

Example 5 with SysFormMethodVO

use of com.netsteadfast.greenstep.vo.SysFormMethodVO in project bamboobsc by billchen198318.

the class SystemFormMethodSaveOrUpdateAction method save.

private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    SysFormMethodVO method = new SysFormMethodVO();
    method.setExpression(this.getFields().get("expression").getBytes());
    this.transformFields2ValueObject(method, new String[] { "name", "resultType", "type", "description" });
    DefaultResult<SysFormMethodVO> result = this.systemFormLogicService.createMethod(method, this.getFields().get("formOid"));
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null) {
        this.success = IS_YES;
    }
}
Also used : SysFormMethodVO(com.netsteadfast.greenstep.vo.SysFormMethodVO)

Aggregations

SysFormMethodVO (com.netsteadfast.greenstep.vo.SysFormMethodVO)8 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)4 AuthorityException (com.netsteadfast.greenstep.base.exception.AuthorityException)1 ControllerException (com.netsteadfast.greenstep.base.exception.ControllerException)1 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 SystemForm (com.netsteadfast.greenstep.base.model.SystemForm)1 SysFormVO (com.netsteadfast.greenstep.vo.SysFormVO)1 JSON (org.apache.struts2.json.annotations.JSON)1 Transactional (org.springframework.transaction.annotation.Transactional)1