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;
}
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);
}
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;
}
Aggregations