Search in sources :

Example 1 with WorkspaceTemplateVO

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

the class WorkspaceUtils method getTemplateConfResource.

public static String getTemplateConfResource(String templateOid) throws ServiceException, Exception {
    if (StringUtils.isBlank(templateOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    WorkspaceTemplateVO template = new WorkspaceTemplateVO();
    template.setOid(templateOid);
    DefaultResult<WorkspaceTemplateVO> result = workspaceTemplateService.findObjectByOid(template);
    if (result.getValue() == null) {
        throw new ServiceException(result.getSystemMessage().getValue());
    }
    template = result.getValue();
    String content = TemplateUtils.getResourceSrc(WorkspaceUtils.class.getClassLoader(), RESOURCE_DIR + template.getResourceConf());
    if (StringUtils.isBlank(content)) {
        content = "";
    }
    return content;
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) WorkspaceTemplateVO(com.netsteadfast.greenstep.vo.WorkspaceTemplateVO)

Example 2 with WorkspaceTemplateVO

use of com.netsteadfast.greenstep.vo.WorkspaceTemplateVO 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 3 with WorkspaceTemplateVO

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