Search in sources :

Example 1 with SwotVO

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

the class SwotLogicServiceImpl method create.

@ServiceMethodAuthority(type = { ServiceMethodType.INSERT, ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> create(String visionOid, String organizationOid, List<SwotVO> datas) throws ServiceException, Exception {
    if (super.isBlank(visionOid) || super.isBlank(organizationOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    VisionVO vision = new VisionVO();
    vision.setOid(visionOid);
    DefaultResult<VisionVO> vResult = this.visionService.findObjectByOid(vision);
    if (vResult.getValue() == null) {
        throw new ServiceException(vResult.getSystemMessage().getValue());
    }
    vision = vResult.getValue();
    OrganizationVO organization = this.findOrganizationData(organizationOid);
    //因為 dojo 的 dijit.InlineEditBox 元件特性是, 沒有修改過, 就不會產生editor , 所以修改模式下用全部刪除後->再全部新增會有問題
    //this.delete(vision.getVisId());
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(Boolean.TRUE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    Map<String, Object> params = new HashMap<String, Object>();
    for (SwotVO swot : datas) {
        if (!vision.getVisId().equals(swot.getVisId()) || !organization.getOrgId().equals(swot.getOrgId())) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        this.setStringValueMaxLength(swot, "issues", MAX_ISSUES_LENGTH);
        params.clear();
        params.put("perId", swot.getPerId());
        if (this.perspectiveService.countByParams(params) < 1) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        if (this.swotService.countByUK(swot) > 0) {
            // 修改 ISSUES
            this.updateIssues(swot);
        } else {
            // 新增
            this.swotService.saveObject(swot);
        }
    }
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) SwotVO(com.netsteadfast.greenstep.vo.SwotVO) HashMap(java.util.HashMap) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with SwotVO

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

the class SwotSaveOrUpdateAction method fillDatas.

private List<SwotVO> fillDatas() throws Exception {
    String headParam = "BSC_PROG002D0008Q" + BscConstants.SWOT_TEXT_INPUT_ID_SEPARATE;
    List<SwotVO> datas = new ArrayList<SwotVO>();
    Enumeration<String> names = this.getHttpServletRequest().getParameterNames();
    while (names.hasMoreElements()) {
        String paramName = names.nextElement();
        if (!paramName.startsWith(headParam)) {
            continue;
        }
        // BSC_PROG002D0008Q:TYPE:VIS_ID:PER_ID:ORG_ID
        String[] tmpId = paramName.split(BscConstants.SWOT_TEXT_INPUT_ID_SEPARATE);
        if (tmpId.length != 5) {
            continue;
        }
        SwotVO obj = new SwotVO();
        obj.setType(tmpId[1]);
        obj.setVisId(tmpId[2]);
        obj.setPerId(tmpId[3]);
        obj.setOrgId(tmpId[4]);
        obj.setIssues(StringUtils.defaultString(this.getHttpServletRequest().getParameter(paramName)));
        datas.add(obj);
    }
    return datas;
}
Also used : SwotVO(com.netsteadfast.greenstep.vo.SwotVO) ArrayList(java.util.ArrayList)

Aggregations

SwotVO (com.netsteadfast.greenstep.vo.SwotVO)2 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)1 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)1 ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)1 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)1 OrganizationVO (com.netsteadfast.greenstep.vo.OrganizationVO)1 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Transactional (org.springframework.transaction.annotation.Transactional)1