Java Code Examples for org.springframework.transaction.annotation.Propagation#REQUIRED
The following examples show how to use
org.springframework.transaction.annotation.Propagation#REQUIRED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnalyticsConfigLogicServiceImpl.java From bamboobsc with Apache License 2.0 | 6 votes |
@ServiceMethodAuthority(type={ServiceMethodType.UPDATE}) @Transactional( propagation=Propagation.REQUIRED, readOnly=false, rollbackFor={RuntimeException.class, IOException.class, Exception.class} ) @Override public DefaultResult<OlapConfVO> update(OlapConfVO olapConf) throws ServiceException, Exception { if ( null == olapConf || super.isBlank(olapConf.getOid()) ) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } DefaultResult<OlapConfVO> oldResult = this.olapConfService.findObjectByOid(olapConf); if ( oldResult.getValue() == null ) { throw new ServiceException( oldResult.getSystemMessage().getValue() ); } olapConf.setId( oldResult.getValue().getId() ); // ID 不能修改 this.setStringValueMaxLength(olapConf, "description", MAX_DESCRIPTION_LENGTH); return this.olapConfService.updateObject(olapConf); }
Example 2
Source File: SystemProgramLogicServiceImpl.java From bamboobsc with Apache License 2.0 | 6 votes |
/** * 產生 tb_sys_prog_multi_name 資料 * * @param multiName * @return * @throws ServiceException * @throws Exception */ @ServiceMethodAuthority(type={ServiceMethodType.INSERT}) @Transactional( propagation=Propagation.REQUIRED, readOnly=false, rollbackFor={RuntimeException.class, IOException.class, Exception.class} ) @Override public DefaultResult<SysProgMultiNameVO> createMultiName(SysProgMultiNameVO multiName) throws ServiceException, Exception { if (null == multiName || super.isBlank(multiName.getProgId()) || super.isBlank(multiName.getName()) || super.isBlank(multiName.getLocaleCode())) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } if (LocaleLanguageUtils.getMap().get(multiName.getLocaleCode()) == null) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_ERRORS)); } SysProgVO sysProg = new SysProgVO(); sysProg.setProgId(multiName.getProgId()); DefaultResult<SysProgVO> progResult = this.sysProgService.findByUK(sysProg); if (progResult.getValue() == null) { throw new ServiceException(progResult.getSystemMessage().getValue()); } super.setStringValueMaxLength(multiName, "name", 100); return this.sysProgMultiNameService.saveObject(multiName); }
Example 3
Source File: SystemTemplateLogicServiceImpl.java From bamboobsc with Apache License 2.0 | 6 votes |
@ServiceMethodAuthority(type={ServiceMethodType.UPDATE}) @Transactional( propagation=Propagation.REQUIRED, readOnly=false, rollbackFor={RuntimeException.class, IOException.class, Exception.class} ) @Override public DefaultResult<SysTemplateVO> update(SysTemplateVO sysTemplate) throws ServiceException, Exception { if (sysTemplate==null || super.isBlank(sysTemplate.getOid())) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } if (super.defaultString(sysTemplate.getMessage()).length() > MAX_MESSAGE_LENGTH ) { throw new ServiceException("Content max only 4,000 words!"); } DefaultResult<SysTemplateVO> oldResult = this.sysTemplateService.findObjectByOid(sysTemplate); if (oldResult.getValue()==null) { throw new ServiceException(oldResult.getSystemMessage().getValue()); } sysTemplate.setTemplateId( oldResult.getValue().getTemplateId() ); return sysTemplateService.updateObject(sysTemplate); }
Example 4
Source File: AnalyticsConfigLogicServiceImpl.java From bamboobsc with Apache License 2.0 | 6 votes |
@ServiceMethodAuthority(type={ServiceMethodType.DELETE}) @Transactional( propagation=Propagation.REQUIRED, readOnly=false, rollbackFor={RuntimeException.class, IOException.class, Exception.class} ) @Override public DefaultResult<Boolean> delete(OlapConfVO olapConf) throws ServiceException, Exception { if ( null == olapConf || super.isBlank(olapConf.getOid()) ) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("confOid", olapConf.getOid()); if ( this.olapMdxService.countByParams(paramMap) > 0 ) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.DATA_CANNOT_DELETE)); } return this.olapConfService.deleteObject(olapConf); }
Example 5
Source File: SysRoleResourcesServiceImpl.java From OneBlog with GNU General Public License v3.0 | 5 votes |
/** * 通过角色id批量删除 * @param roleId */ @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) public void removeByRoleId(Long roleId) { //删除 Example example = new Example(SysRoleResources.class); Example.Criteria criteria = example.createCriteria(); criteria.andEqualTo("roleId", roleId); resourceMapper.deleteByExample(example); }
Example 6
Source File: PdcaLogicServiceImpl.java From bamboobsc with Apache License 2.0 | 5 votes |
@ServiceMethodAuthority(type={ServiceMethodType.DELETE}) @Transactional( propagation=Propagation.REQUIRED, readOnly=false, rollbackFor={RuntimeException.class, IOException.class, Exception.class} ) @Override public DefaultResult<Boolean> delete(PdcaVO pdca) throws ServiceException, Exception { if (null == pdca || super.isBlank(pdca.getOid())) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } Map<String, Object> paramMap = new HashMap<String, Object>(); paramMap.put("parentOid", pdca.getOid()); if (this.pdcaService.countByParams(paramMap)>0) { throw new ServiceException("The project has child project, cannot delete!"); } List<BusinessProcessManagementTaskVO> tasks = this.queryTaskByVariablePdcaOid(pdca.getOid()); if (tasks!=null && tasks.size()>0) { throw new ServiceException("Audit processing running, project cannot delete!"); } this.deleteMeasureFreq(pdca); this.deleteOwner(pdca); this.deleteOrganization(pdca); this.deleteKpis(pdca); this.deleteDocuments(pdca); this.deleteItems(pdca); return this.pdcaService.deleteObject(pdca); }
Example 7
Source File: SchedulerConfigurationService.java From spring-batch-lightmin with Apache License 2.0 | 5 votes |
@Transactional(transactionManager = "lightminServerSchedulerTransactionManager", propagation = Propagation.REQUIRED) public SchedulerConfiguration save(final SchedulerConfiguration schedulerConfiguration) { if (schedulerConfiguration == null) { throw new SchedulerValidationException("schedulerConfiguration must not be null"); } else { schedulerConfiguration.validate(); return this.schedulerConfigurationRepository.save(schedulerConfiguration); } }
Example 8
Source File: ConsumeSubscriptionServiceImpl.java From DDMQ with Apache License 2.0 | 5 votes |
@Transactional(isolation = Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public ConsoleBaseResponse<?> changeState(Long groupId, Integer state) throws Exception { List<ConsumeSubscription> list = findByGroupId(groupId); if (CollectionUtils.isEmpty(list)) { return ConsoleBaseResponse.error(ConsoleBaseResponse.Status.INVALID_PARAM, "not subscription info found"); } for (ConsumeSubscription sub : list) { updateSubStateById(sub, state); } return ConsoleBaseResponse.success(); }
Example 9
Source File: UserService.java From devicehive-java-server with Apache License 2.0 | 5 votes |
@Transactional(propagation = Propagation.REQUIRED) public UserVO createUser(@NotNull UserVO user, String password) { hiveValidator.validate(user); if (user.getId() != null) { throw new IllegalParametersException(Messages.ID_NOT_ALLOWED); } if (user.getRole() == null ) { throw new IllegalParametersException(Messages.INVALID_USER_ROLE); } if (user.getStatus() == null) { user.setStatus(UserStatus.ACTIVE); } final String userLogin = StringUtils.trim(user.getLogin()); user.setLogin(userLogin); Optional<UserVO> existing = userDao.findByName(user.getLogin()); if (existing.isPresent()) { throw new ActionNotAllowedException(Messages.DUPLICATE_LOGIN); } if (StringUtils.isNotEmpty(password) && password.matches(PASSWORD_REGEXP)) { String salt = passwordService.generateSalt(); String hash = passwordService.hashPassword(password, salt); user.setPasswordSalt(salt); user.setPasswordHash(hash); } else { throw new IllegalParametersException(Messages.PASSWORD_VALIDATION_FAILED); } user.setLoginAttempts(Constants.INITIAL_LOGIN_ATTEMPTS); if (user.getIntroReviewed() == null) { user.setIntroReviewed(false); } if (user.getAllDeviceTypesAvailable() == null) { user.setAllDeviceTypesAvailable(true); } userDao.persist(user); return user; }
Example 10
Source File: UserService.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
/** * THIS METHOD IS NOT SAFE: IT MUST BE REMOVED. * TODO: manage access by page. * @param user_uuid * @return */ @PreAuthorize ("hasRole('ROLE_DATA_MANAGER')") @Transactional (readOnly=true, propagation=Propagation.REQUIRED) public List<Long> getAuthorizedProducts (String user_uuid) { return productDao.getAuthorizedProducts (user_uuid); }
Example 11
Source File: ProductCartService.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
/** * * @param uuid * @return * @throws UserNotExistingException */ @Transactional (readOnly=true, propagation=Propagation.REQUIRED) private User getUser(String uuid) throws UserNotExistingException { User user = userDao.read (uuid); if (user == null) throw new UserNotExistingException(); return user; }
Example 12
Source File: MonitorItemScoreServiceImpl.java From bamboobsc with Apache License 2.0 | 5 votes |
@Transactional( propagation=Propagation.REQUIRED, readOnly=false, rollbackFor={RuntimeException.class, IOException.class, Exception.class} ) @Override public int deleteForOrgId(String orgId) throws ServiceException, Exception { if (StringUtils.isBlank(orgId)) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); } return this.monitorItemScoreDAO.deleteForOrgId(orgId); }
Example 13
Source File: ConfigMgrImpl.java From disconf with Apache License 2.0 | 5 votes |
/** * 更新 配置项/配置文件 的值 */ @Override @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class) public String updateItemValue(Long configId, String value) { Config config = getConfigById(configId); String oldValue = config.getValue(); // // 配置数据库的值 encode to db // configDao.updateValue(configId, CodeUtils.utf8ToUnicode(value)); configHistoryMgr.createOne(configId, oldValue, CodeUtils.utf8ToUnicode(value)); // // 发送邮件通知 // String toEmails = appMgr.getEmails(config.getAppId()); if (applicationPropertyConfig.isEmailMonitorOn()) { boolean isSendSuccess = logMailBean.sendHtmlEmail(toEmails, " config update", DiffUtils.getDiff(CodeUtils.unicodeToUtf8(oldValue), value, config.toString(), getConfigUrlHtml(config))); if (isSendSuccess) { return "修改成功,邮件通知成功"; } else { return "修改成功,邮件发送失败,请检查邮箱配置"; } } return "修改成功"; }
Example 14
Source File: TaskAnswerServiceImpl.java From AIDR with GNU Affero General Public License v3.0 | 4 votes |
@Override @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT) public void markOnHasHumanTag(Long documentID){ documentService.updateHasHumanLabel(documentID, true); }
Example 15
Source File: CollectionService.java From DataHubSystem with GNU Affero General Public License v3.0 | 4 votes |
@Transactional (readOnly=true, propagation=Propagation.REQUIRED) public List<Collection> getCollections (Product product) { return collectionDao.getCollectionsOfProduct(product.getId()); }
Example 16
Source File: BaseService.java From bamboobsc with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @ServiceMethodAuthority(type={ServiceMethodType.UPDATE}) @Transactional( propagation=Propagation.REQUIRED, readOnly=false, rollbackFor={RuntimeException.class, IOException.class, Exception.class} ) public DefaultResult<T> updateObject(T object) throws ServiceException, Exception { if (object==null || !(object instanceof BaseValueObj) ) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL)); } DefaultResult<T> result=new DefaultResult<T>(); Class<T> valueObjectClass=GenericsUtils.getSuperClassGenricType(getClass(), 0); Class<E> entityObjectClass=GenericsUtils.getSuperClassGenricType(getClass(), 1); E entityObject=entityObjectClass.newInstance(); ((BaseEntity)entityObject).setOid(((BaseValueObj)object).getOid()); E findEntity=this.findByOid(entityObject); if (findEntity == null) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)); } this.doMapper(object, findEntity, this.getMapperIdVo2Po()); E updateEntity=null; try { ((BaseEntity)findEntity).setUuserid(this.getAccountId()); ((BaseEntity)findEntity).setUdate(this.generateDate()); updateEntity=this.getBaseDataAccessObject().update(findEntity); } catch (Exception e) { e.printStackTrace(); } if (updateEntity!=null && ((BaseEntity)updateEntity).getOid()!=null ) { T updateValueObj=valueObjectClass.newInstance(); this.doMapper(updateEntity, updateValueObj, this.getMapperIdPo2Vo()); result.setValue(updateValueObj); result.setSystemMessage( new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_SUCCESS))); } else { result.setSystemMessage( new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.UPDATE_FAIL))); } return result; }
Example 17
Source File: JobManagerService.java From OpenCue with Apache License 2.0 | 4 votes |
@Override @Transactional(propagation = Propagation.REQUIRED) public void optimizeLayer(LayerInterface layer, int cores, long maxRss, int runTime) { layerDao.balanceLayerMinMemory(layer, maxRss); }
Example 18
Source File: RegionFacade.java From java-course-ee with MIT License | 4 votes |
@Transactional(readOnly = true, propagation = Propagation.REQUIRED) public RegionView getRegion(Long regionId) { return Utils.transformEntity(regionDAO.getEntity(regionId)); }
Example 19
Source File: GroupManagerService.java From OpenCue with Apache License 2.0 | 4 votes |
@Override @Transactional(propagation=Propagation.REQUIRED, readOnly=true) public GroupDetail getRootGroupDetail(ShowInterface s) { return groupDao.getRootGroupDetail(s); }
Example 20
Source File: PmsProductService.java From BigDataPlatform with GNU General Public License v3.0 | 2 votes |
/** * 创建商品 */ @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED) int create(PmsProductParam productParam);