Search in sources :

Example 6 with SysFormVO

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

the class SystemFormLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<SysFormVO> update(SysFormVO form, String templateOid) throws ServiceException, Exception {
    if (null == form || super.isBlank(templateOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<SysFormVO> oldResult = this.sysFormService.findObjectByOid(form);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    form.setFormId(oldResult.getValue().getFormId());
    super.setStringValueMaxLength(form, "description", MAX_DESCRIPTION_LENGTH);
    SysFormTemplateVO template = this.findTemplate(templateOid);
    form.setTemplateId(template.getTplId());
    return this.sysFormService.updateObject(form);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormVO(com.netsteadfast.greenstep.vo.SysFormVO) SysFormTemplateVO(com.netsteadfast.greenstep.vo.SysFormTemplateVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 with SysFormVO

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

the class SystemFormUtils method processExpression.

public static Map<String, String> processExpression(SysFormMethodVO formMethod, Object actionObj, Map<String, Object> actionDatas, PageOf pageOf, SearchValue searchValue, List<Map<String, String>> items, Map<String, String> fields, List<String> fieldsId, Map<String, String> fieldsMessage, HttpServletRequest request) throws ControllerException, ServiceException, Exception {
    Map<String, String> resultMap = new HashMap<String, String>();
    SysFormVO form = findForm(formMethod.getFormId());
    String expression = new String(formMethod.getExpression(), Constants.BASE_ENCODING);
    Map<String, Object> paramMap = getParameters(formMethod, actionObj, actionDatas, pageOf, searchValue, items, fields, fieldsId, fieldsMessage);
    ScriptExpressionUtils.execute(formMethod.getType(), expression, null, paramMap);
    if (FormResultType.DEFAULT.equals(formMethod.getResultType())) {
        SysFormTemplateVO template = findTemplate(form.getTemplateId());
        setViewPage(resultMap, FORM_PAGE_PATH + template.getFileName());
        String pageFileFullPath = request.getSession().getServletContext().getRealPath("/");
        pageFileFullPath += FORM_PAGE_PATH + template.getFileName();
        File file = new File(pageFileFullPath);
        if (!file.exists() || getEnableTemplateFileReWriteAlways()) {
            if (!file.exists()) {
                logger.warn("no template file: " + pageFileFullPath);
            }
            file = null;
            writePage(template, request);
        }
        file = null;
    }
    if (FormResultType.JSON.equals(formMethod.getResultType())) {
        setJsonValue(resultMap, (String) ((Map<String, Object>) paramMap.get("datas")).get("jsonMessage"), (String) ((Map<String, Object>) paramMap.get("datas")).get("jsonSuccess"));
    }
    if (FormResultType.REDIRECT.equals(formMethod.getResultType())) {
        setRedirectUrl(resultMap, (String) ((Map<String, Object>) paramMap.get("datas")).get("redirectUrl"));
    }
    return resultMap;
}
Also used : HashMap(java.util.HashMap) SysFormVO(com.netsteadfast.greenstep.vo.SysFormVO) SysFormTemplateVO(com.netsteadfast.greenstep.vo.SysFormTemplateVO) File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with SysFormVO

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

the class SystemFormUtils method findForm.

public static SysFormVO findForm(String formId) throws ServiceException, Exception {
    SysFormVO form = new SysFormVO();
    form.setFormId(formId);
    DefaultResult<SysFormVO> result = sysFormService.findByUK(form);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    form = result.getValue();
    return form;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormVO(com.netsteadfast.greenstep.vo.SysFormVO)

Example 9 with SysFormVO

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

the class SystemFormSaveOrUpdateAction method delete.

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

Example 10 with SysFormVO

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

the class SystemFormManagementAction method loadFormData.

private void loadFormData() throws ServiceException, Exception {
    this.transformFields2ValueObject(this.form, new String[] { "oid" });
    DefaultResult<SysFormVO> result = this.sysFormService.findObjectByOid(form);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    this.form = result.getValue();
    SysFormTemplateVO template = new SysFormTemplateVO();
    template.setTplId(this.form.getTemplateId());
    DefaultResult<SysFormTemplateVO> tplResult = this.sysFormTemplateService.findByUK(template);
    if (tplResult.getValue() != null) {
        this.getFields().put("templateOid", tplResult.getValue().getOid());
    }
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormVO(com.netsteadfast.greenstep.vo.SysFormVO) SysFormTemplateVO(com.netsteadfast.greenstep.vo.SysFormTemplateVO)

Aggregations

SysFormVO (com.netsteadfast.greenstep.vo.SysFormVO)10 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)6 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)3 SysFormTemplateVO (com.netsteadfast.greenstep.vo.SysFormTemplateVO)3 Transactional (org.springframework.transaction.annotation.Transactional)3 SysFormMethodVO (com.netsteadfast.greenstep.vo.SysFormMethodVO)1 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1