Search in sources :

Example 1 with WorkspaceVO

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

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

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

the class WorkspaceLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@SuppressWarnings("unchecked")
@Override
public DefaultResult<WorkspaceVO> create(String spaceId, String name, String description, String workspaceTemplateOid, Map<String, Object> jsonData) throws ServiceException, Exception {
    if (super.isBlank(spaceId) || super.isBlank(name) || super.isNoSelectId(workspaceTemplateOid) || jsonData == null || jsonData.size() < 1) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    if (jsonData.get("nodes") == null || !(jsonData.get("nodes") instanceof List)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    if (jsonData.get("labels") == null || !(jsonData.get("labels") instanceof List)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    WorkspaceTemplateVO template = new WorkspaceTemplateVO();
    template.setOid(workspaceTemplateOid);
    DefaultResult<WorkspaceTemplateVO> wtResult = this.workspaceTemplateService.findObjectByOid(template);
    if (wtResult.getValue() == null) {
        throw new ServiceException(wtResult.getSystemMessage().getValue());
    }
    template = wtResult.getValue();
    WorkspaceVO workspace = new WorkspaceVO();
    workspace.setSpaceId(spaceId);
    workspace.setTemplateId(template.getTemplateId());
    workspace.setName(name);
    workspace.setDescription(super.defaultString(description));
    this.setStringValueMaxLength(workspace, "description", MAX_DESCRIPTION_LENGTH);
    DefaultResult<WorkspaceVO> result = this.workspaceService.saveObject(workspace);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    workspace = result.getValue();
    List<Map<String, Object>> nodes = (List<Map<String, Object>>) jsonData.get("nodes");
    List<Map<String, Object>> labels = (List<Map<String, Object>>) jsonData.get("labels");
    for (int i = 0; nodes != null && i < nodes.size(); i++) {
        Map<String, Object> data = nodes.get(i);
        String id = (String) data.get("id");
        int position = Integer.parseInt(String.valueOf(data.get("position")));
        BbWorkspaceCompoment compoment = new BbWorkspaceCompoment();
        compoment.setCompId(id);
        if (this.workspaceCompomentService.countByEntityUK(compoment) < 1) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        WorkspaceConfigVO configObj = new WorkspaceConfigVO();
        configObj.setSpaceId(workspace.getSpaceId());
        configObj.setCompId(id);
        configObj.setPosition(position);
        this.workspaceConfigService.saveObject(configObj);
    }
    for (int i = 0; labels != null && i < labels.size(); i++) {
        Map<String, Object> data = labels.get(i);
        String label = (String) data.get("label");
        int position = Integer.parseInt(String.valueOf(data.get("position")));
        if (StringUtils.isBlank(label)) {
            label = "   ";
        }
        WorkspaceLabelVO labelObj = new WorkspaceLabelVO();
        labelObj.setSpaceId(workspace.getSpaceId());
        labelObj.setLabel(label);
        labelObj.setPosition(position);
        this.workspaceLabelService.saveIgnoreUK(labelObj);
    }
    return result;
}
Also used : BbWorkspaceCompoment(com.netsteadfast.greenstep.po.hbm.BbWorkspaceCompoment) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) WorkspaceTemplateVO(com.netsteadfast.greenstep.vo.WorkspaceTemplateVO) WorkspaceVO(com.netsteadfast.greenstep.vo.WorkspaceVO) WorkspaceLabelVO(com.netsteadfast.greenstep.vo.WorkspaceLabelVO) List(java.util.List) WorkspaceConfigVO(com.netsteadfast.greenstep.vo.WorkspaceConfigVO) HashMap(java.util.HashMap) Map(java.util.Map) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)3 WorkspaceVO (com.netsteadfast.greenstep.vo.WorkspaceVO)3 HashMap (java.util.HashMap)3 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)2 BbWorkspaceConfig (com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig)2 WorkspaceTemplateVO (com.netsteadfast.greenstep.vo.WorkspaceTemplateVO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 BbWorkspaceCompoment (com.netsteadfast.greenstep.po.hbm.BbWorkspaceCompoment)1 BbWorkspaceLabel (com.netsteadfast.greenstep.po.hbm.BbWorkspaceLabel)1 WorkspaceConfigVO (com.netsteadfast.greenstep.vo.WorkspaceConfigVO)1 WorkspaceLabelVO (com.netsteadfast.greenstep.vo.WorkspaceLabelVO)1 List (java.util.List)1 Map (java.util.Map)1