Search in sources :

Example 6 with SysFormTemplateVO

use of com.netsteadfast.greenstep.vo.SysFormTemplateVO 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 SysFormTemplateVO

use of com.netsteadfast.greenstep.vo.SysFormTemplateVO 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 SysFormTemplateVO

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

the class SystemFormTemplateSaveOrUpdateAction method save.

private void save() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    if (StringUtils.isBlank(this.getFields().get("uploadOid"))) {
        super.throwMessage("uploadOid", this.getText("MESSAGE.CORE_PROG001D0012A_uploadOid"));
    }
    SysFormTemplateVO template = new SysFormTemplateVO();
    this.transformFields2ValueObject(template, new String[] { "tplId", "name", "description" });
    DefaultResult<SysFormTemplateVO> result = this.systemFormLogicService.createTmplate(template, this.getFields().get("uploadOid"));
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null) {
        this.success = IS_YES;
    }
}
Also used : SysFormTemplateVO(com.netsteadfast.greenstep.vo.SysFormTemplateVO)

Example 9 with SysFormTemplateVO

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

the class SystemFormTemplateSaveOrUpdateAction method update.

private void update() throws ControllerException, AuthorityException, ServiceException, Exception {
    this.checkFields();
    SysFormTemplateVO template = new SysFormTemplateVO();
    this.transformFields2ValueObject(template, new String[] { "oid", "tplId", "name", "description" });
    DefaultResult<SysFormTemplateVO> result = this.systemFormLogicService.updateTemplate(template, this.getFields().get("uploadOid"));
    this.message = result.getSystemMessage().getValue();
    if (result.getValue() != null) {
        this.success = IS_YES;
    }
}
Also used : SysFormTemplateVO(com.netsteadfast.greenstep.vo.SysFormTemplateVO)

Example 10 with SysFormTemplateVO

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

the class SystemFormTemplateSaveOrUpdateAction method copy2Upload.

private void copy2Upload() throws ControllerException, AuthorityException, ServiceException, Exception {
    SysFormTemplateVO template = new SysFormTemplateVO();
    this.transformFields2ValueObject(template, new String[] { "oid" });
    DefaultResult<SysFormTemplateVO> result = this.sysFormTemplateService.findObjectByOid(template);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    template = result.getValue();
    this.uploadOid = UploadSupportUtils.create(Constants.getSystem(), UploadTypes.IS_TEMP, false, template.getContent(), template.getFileName());
    this.message = SysMessageUtil.get(GreenStepSysMsgConstants.INSERT_SUCCESS);
    this.success = IS_YES;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysFormTemplateVO(com.netsteadfast.greenstep.vo.SysFormTemplateVO)

Aggregations

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