Search in sources :

Example 1 with WorkspaceCompomentVO

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

the class BaseWorkspaceCompoment method loadFromId.

@Override
public CompomentsModel loadFromId(String compomentId) throws ServiceException, Exception {
    if (StringUtils.isBlank(compomentId)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    WorkspaceCompomentVO compoment = new WorkspaceCompomentVO();
    compoment.setCompId(compomentId);
    DefaultResult<WorkspaceCompomentVO> result = workspaceCompomentService.findByUK(compoment);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    compoment = result.getValue();
    CompomentsModel model = new CompomentsModel();
    this.setModel(model);
    model.setId(compoment.getCompId());
    model.setName(compoment.getName());
    model.setResource(this.getResource());
    model.setParameters(this.getParameters());
    model.setContent("");
    return model;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) WorkspaceCompomentVO(com.netsteadfast.greenstep.vo.WorkspaceCompomentVO) CompomentsModel(com.netsteadfast.greenstep.compoments.CompomentsModel)

Example 2 with WorkspaceCompomentVO

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

the class WorkspaceUtils method fillTemplateParameters.

private static Map<String, Object> fillTemplateParameters(WorkspaceTemplateVO template, List<BbWorkspaceConfig> configs, boolean defaultMode, Map<String, Object> templateParameters) throws ServiceException, Exception {
    Map<String, Object> parameter = new HashMap<String, Object>();
    for (int position = 0; position < template.getPositionSize(); position++) {
        String content = "";
        for (int c = 0; configs != null && c < configs.size(); c++) {
            BbWorkspaceConfig config = configs.get(c);
            if (config.getPosition() != position) {
                continue;
            }
            WorkspaceCompomentVO compoment = new WorkspaceCompomentVO();
            compoment.setCompId(config.getCompId());
            DefaultResult<WorkspaceCompomentVO> cResult = workspaceCompomentService.findByUK(compoment);
            if (cResult.getValue() == null) {
                throw new ServiceException(cResult.getSystemMessage().getValue());
            }
            compoment = cResult.getValue();
            if (defaultMode) {
                // default mode
                try {
                    setTitle(config, templateParameters);
                    content = getCompomentRenderBody(compoment, templateParameters);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                // view layout mode
                content = getCompomentImage(compoment);
            }
        }
        parameter.put(TEMPLATE_VARIABLE_NAME + position, content);
    }
    return parameter;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) WorkspaceCompomentVO(com.netsteadfast.greenstep.vo.WorkspaceCompomentVO) BbWorkspaceConfig(com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 WorkspaceCompomentVO (com.netsteadfast.greenstep.vo.WorkspaceCompomentVO)2 CompomentsModel (com.netsteadfast.greenstep.compoments.CompomentsModel)1 BbWorkspaceConfig (com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig)1 HashMap (java.util.HashMap)1