Search in sources :

Example 21 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority 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);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) HashMap(java.util.HashMap) BbWorkspaceLabel(com.netsteadfast.greenstep.po.hbm.BbWorkspaceLabel) WorkspaceVO(com.netsteadfast.greenstep.vo.WorkspaceVO) BbWorkspaceConfig(com.netsteadfast.greenstep.po.hbm.BbWorkspaceConfig) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class StrategyMapLogicServiceImpl 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, Map<String, Object> jsonData) throws ServiceException, Exception {
    this.delete(visionOid);
    VisionVO vision = new VisionVO();
    vision.setOid(visionOid);
    DefaultResult<VisionVO> vResult = this.visionService.findObjectByOid(vision);
    if (vResult.getValue() == null) {
        // 沒 TB_VISION 資料, 不用清 STRATEGY MAP 			
        throw new ServiceException(vResult.getSystemMessage().getValue());
    }
    vision = vResult.getValue();
    StrategyMapVO strategyMap = new StrategyMapVO();
    strategyMap.setVisId(vision.getVisId());
    DefaultResult<StrategyMapVO> smResult = strategyMapService.saveObject(strategyMap);
    if (smResult.getValue() == null) {
        throw new ServiceException(smResult.getSystemMessage().getValue());
    }
    strategyMap = smResult.getValue();
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(Boolean.TRUE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    this.saveNodesAndConnections(strategyMap, jsonData);
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) StrategyMapVO(com.netsteadfast.greenstep.vo.StrategyMapVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 23 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class StrategyMapLogicServiceImpl 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 visionOid) throws ServiceException, Exception {
    if (super.isBlank(visionOid) || super.isNoSelectId(visionOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(Boolean.TRUE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.DELETE_SUCCESS)));
    VisionVO vision = new VisionVO();
    vision.setOid(visionOid);
    DefaultResult<VisionVO> vResult = this.visionService.findObjectByOid(vision);
    if (vResult.getValue() == null) {
        // 沒 TB_VISION 資料, 不用清 STRATEGY MAP 			
        return result;
    }
    vision = vResult.getValue();
    StrategyMapVO strategyMap = new StrategyMapVO();
    strategyMap.setVisId(vision.getVisId());
    DefaultResult<StrategyMapVO> smResult = this.strategyMapService.findByUK(strategyMap);
    if (smResult.getValue() == null) {
        // 沒有 BB_STRATEGY_MAP 資料
        return result;
    }
    strategyMap = smResult.getValue();
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("masterOid", strategyMap.getOid());
    List<BbStrategyMapNodes> nodes = this.strategyMapNodesService.findListByParams(params);
    List<BbStrategyMapConns> conns = this.strategyMapConnsService.findListByParams(params);
    for (int i = 0; nodes != null && i < nodes.size(); i++) {
        strategyMapNodesService.delete(nodes.get(i));
    }
    for (int i = 0; conns != null && i < conns.size(); i++) {
        strategyMapConnsService.delete(conns.get(i));
    }
    return strategyMapService.deleteObject(strategyMap);
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) BbStrategyMapConns(com.netsteadfast.greenstep.po.hbm.BbStrategyMapConns) HashMap(java.util.HashMap) StrategyMapVO(com.netsteadfast.greenstep.vo.StrategyMapVO) VisionVO(com.netsteadfast.greenstep.vo.VisionVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) BbStrategyMapNodes(com.netsteadfast.greenstep.po.hbm.BbStrategyMapNodes) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 24 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class ObjectiveLogicServiceImpl method update.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<ObjectiveVO> update(ObjectiveVO objective, String perspectiveOid) throws ServiceException, Exception {
    if (null == objective || super.isBlank(objective.getOid()) || super.isBlank(perspectiveOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<ObjectiveVO> oldResult = this.objectiveService.findObjectByOid(objective);
    if (oldResult.getValue() == null) {
        throw new ServiceException(oldResult.getSystemMessage().getValue());
    }
    PerspectiveVO perspective = new PerspectiveVO();
    perspective.setOid(perspectiveOid);
    DefaultResult<PerspectiveVO> pResult = this.perspectiveService.findObjectByOid(perspective);
    if (pResult.getValue() == null) {
        throw new ServiceException(pResult.getSystemMessage().getValue());
    }
    perspective = pResult.getValue();
    objective.setObjId(oldResult.getValue().getObjId());
    objective.setPerId(perspective.getPerId());
    this.setStringValueMaxLength(objective, "description", MAX_DESCRIPTION_LENGTH);
    return this.objectiveService.updateObject(objective);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ObjectiveVO(com.netsteadfast.greenstep.vo.ObjectiveVO) PerspectiveVO(com.netsteadfast.greenstep.vo.PerspectiveVO) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Example 25 with ServiceMethodAuthority

use of com.netsteadfast.greenstep.base.model.ServiceMethodAuthority in project bamboobsc by billchen198318.

the class OrganizationLogicServiceImpl method updateParent.

@ServiceMethodAuthority(type = { ServiceMethodType.UPDATE })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = { RuntimeException.class, IOException.class, Exception.class })
@Override
public DefaultResult<Boolean> updateParent(OrganizationVO organization, String parentOid) throws ServiceException, Exception {
    if (organization == null || super.isBlank(organization.getOid()) || super.isBlank(parentOid)) {
        throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK));
    }
    DefaultResult<Boolean> result = new DefaultResult<Boolean>();
    result.setValue(Boolean.FALSE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL)));
    organization = this.findOrganizationData(organization.getOid());
    this.deleteParent(organization);
    if ("root".equals(parentOid) || "r".equals(parentOid)) {
        this.createParent(organization, BscConstants.ORGANIZATION_ZERO_ID);
    } else {
        OrganizationVO newParOrganization = this.findOrganizationData(parentOid);
        // 找當前部門的子部門中的資料, 不因該存在要update的新父部門
        if (this.foundChild(organization.getOrgId(), newParOrganization.getOrgId())) {
            throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS));
        }
        this.createParent(organization, newParOrganization.getOrgId());
    }
    result.setValue(Boolean.TRUE);
    result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS)));
    return result;
}
Also used : SystemMessage(com.netsteadfast.greenstep.base.model.SystemMessage) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) OrganizationVO(com.netsteadfast.greenstep.vo.OrganizationVO) DefaultResult(com.netsteadfast.greenstep.base.model.DefaultResult) ServiceMethodAuthority(com.netsteadfast.greenstep.base.model.ServiceMethodAuthority) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ServiceMethodAuthority (com.netsteadfast.greenstep.base.model.ServiceMethodAuthority)95 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)91 Transactional (org.springframework.transaction.annotation.Transactional)84 HashMap (java.util.HashMap)32 SystemMessage (com.netsteadfast.greenstep.base.model.SystemMessage)31 DefaultResult (com.netsteadfast.greenstep.base.model.DefaultResult)29 SysVO (com.netsteadfast.greenstep.vo.SysVO)13 LinkedHashMap (java.util.LinkedHashMap)13 Map (java.util.Map)12 AccountVO (com.netsteadfast.greenstep.vo.AccountVO)7 VisionVO (com.netsteadfast.greenstep.vo.VisionVO)7 BaseEntity (com.netsteadfast.greenstep.base.model.BaseEntity)6 EmployeeVO (com.netsteadfast.greenstep.vo.EmployeeVO)6 PerspectiveVO (com.netsteadfast.greenstep.vo.PerspectiveVO)6 IOException (java.io.IOException)6 BaseValueObj (com.netsteadfast.greenstep.base.model.BaseValueObj)5 RoleVO (com.netsteadfast.greenstep.vo.RoleVO)5 SysProgVO (com.netsteadfast.greenstep.vo.SysProgVO)5 UserRoleVO (com.netsteadfast.greenstep.vo.UserRoleVO)5 BbReportRoleView (com.netsteadfast.greenstep.po.hbm.BbReportRoleView)4