Search in sources :

Example 1 with BbWorkspaceConfig

use of com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig in project bamboobsc by billchen198318.

the class WorkspaceUtils method getContent.

private static String getContent(String workspaceOid, boolean defaultMode, Map<String, Object> templateParameters) throws ServiceException, Exception {
    if (StringUtils.isBlank(workspaceOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    WorkspaceVO workspace = new WorkspaceVO();
    workspace.setOid(workspaceOid);
    DefaultResult<WorkspaceVO> result = workspaceService.findObjectByOid(workspace);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    workspace = result.getValue();
    if (defaultMode) {
        // for default mode need title
        templateParameters.put("title", workspace.getName());
    }
    WorkspaceTemplateVO template = new WorkspaceTemplateVO();
    template.setTemplateId(workspace.getTemplateId());
    DefaultResult<WorkspaceTemplateVO> wtResult = workspaceTemplateService.findByUK(template);
    if (wtResult.getValue() == null) {
        throw new ServiceException(wtResult.getSystemMessage().getValue());
    }
    template = wtResult.getValue();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("spaceId", workspace.getSpaceId());
    List<BbWorkspaceConfig> configs = workspaceConfigService.findListByParams(params);
    String content = TemplateUtils.processTemplate("resourceTemplate", WorkspaceUtils.class.getClassLoader(), RESOURCE_DIR + template.getResource(), fillTemplateParameters(template, configs, defaultMode, templateParameters));
    if (StringUtils.isBlank(content)) {
        content = "";
    }
    return content;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) WorkspaceTemplateVO(com.netsteadfast.greenstep.vo.WorkspaceTemplateVO) HashMap(java.util.HashMap) WorkspaceVO(com.netsteadfast.greenstep.vo.WorkspaceVO) BbWorkspaceConfig(com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig)

Example 2 with BbWorkspaceConfig

use of com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig in project bamboobsc by billchen198318.

the class WorkspaceLogicServiceImpl method delete.

@ServiceMethodAuthority(type = { ServiceMethodType.DELETE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> delete(String workspaceOid) throws ServiceException, Exception {
    if (super.isBlank(workspaceOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    WorkspaceVO workspace = new WorkspaceVO();
    workspace.setOid(workspaceOid);
    DefaultResult<WorkspaceVO> oldResult = this.workspaceService.findObjectByOid(workspace);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    workspace = oldResult.getValue();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("spaceId", workspace.getSpaceId());
    List<BbWorkspaceConfig> configs = this.workspaceConfigService.findListByParams(params);
    List<BbWorkspaceLabel> labels = this.workspaceLabelService.findListByParams(params);
    for (int i = 0; configs != null && i < configs.size(); i++) {
        BbWorkspaceConfig config = configs.get(i);
        this.workspaceConfigService.delete(config);
    }
    for (int i = 0; labels != null && i < labels.size(); i++) {
        BbWorkspaceLabel label = labels.get(i);
        this.workspaceLabelService.delete(label);
    }
    return workspaceService.deleteObject(workspace);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) BbWorkspaceLabel(com.netsteadfast.greenstep.po.hbm.BbWorkspaceLabel) WorkspaceVO(com.netsteadfast.greenstep.vo.WorkspaceVO) BbWorkspaceConfig(com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with BbWorkspaceConfig

use of com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig 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)3 BbWorkspaceConfig (com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig)3 HashMap (java.util.HashMap)3 WorkspaceVO (com.netsteadfast.greenstep.vo.WorkspaceVO)2 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 BbWorkspaceLabel (com.netsteadfast.greenstep.po.hbm.BbWorkspaceLabel)1 WorkspaceCompomentVO (com.netsteadfast.greenstep.vo.WorkspaceCompomentVO)1 WorkspaceTemplateVO (com.netsteadfast.greenstep.vo.WorkspaceTemplateVO)1 Transactional (org.springframework.transaction.annotation.Transactional)1