return getDao().getStructureTemplateDao().getById(id);
}
@Override
public ServiceResponse save(Map<String, String> vo) {
StructureTemplateEntity entity = null;
if (!StringUtils.isEmpty(vo.get("id"))) {
entity = getDao().getStructureTemplateDao().getById(
Long.valueOf(vo.get("id")));
}
if (entity == null) {
entity = new StructureTemplateEntity();
}
entity.setName(vo.get("name"));
entity.setTitle(vo.get("title"));
entity.setContent(vo.get("content"));
entity.setHeadContent(vo.get("headContent"));
entity.setStructureId(Long.valueOf(vo.get("structureId")));
entity.setType(StructureTemplateType.valueOf(vo.get("type")));
List<String> errors = getBusiness().getStructureTemplateBusiness()
.validateBeforeUpdate(entity);
if (errors.isEmpty()) {
getDao().getStructureTemplateDao().save(entity);
return ServiceResponse.createSuccessResponse(entity.getId()
.toString());
}
else {
return ServiceResponse.createErrorResponse(
Messages.get("errors_occured"), errors);