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