Java Code Examples for org.springframework.transaction.annotation.Propagation#REQUIRED

The following examples show how to use org.springframework.transaction.annotation.Propagation#REQUIRED . These examples are extracted from open source projects. 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
@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
@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 3
@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
/**
 * 產生 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 5
Source Project: bamboobsc   File: PdcaLogicServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@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 6
Source Project: disconf   File: ConfigMgrImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 更新 配置项/配置文件 的值
 */
@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 7
@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 8
/**
 * 
 * @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 9
/**
 * 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 10
@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 11
@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 12
@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 13
/**
 * 通过角色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 14
Source Project: OpenCue   File: GroupManagerService.java    License: Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(propagation=Propagation.REQUIRED, readOnly=true)
public GroupDetail getRootGroupDetail(ShowInterface s) {
    return groupDao.getRootGroupDetail(s);
}
 
Example 15
Source Project: java-course-ee   File: RegionFacade.java    License: MIT License 4 votes vote down vote up
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public RegionView getRegion(Long regionId) {
    return Utils.transformEntity(regionDAO.getEntity(regionId));
}
 
Example 16
Source Project: bamboobsc   File: BaseService.java    License: Apache License 2.0 4 votes vote down vote up
@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
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void markOnHasHumanTag(Long documentID){
	documentService.updateHasHumanLabel(documentID, true);
}
 
Example 18
@Transactional (readOnly=true, propagation=Propagation.REQUIRED)
public List<Collection> getCollections (Product product)
{
   return collectionDao.getCollectionsOfProduct(product.getId());
}
 
Example 19
Source Project: OpenCue   File: JobManagerService.java    License: Apache License 2.0 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void optimizeLayer(LayerInterface layer, int cores, long maxRss, int runTime) {
    layerDao.balanceLayerMinMemory(layer, maxRss);
}
 
Example 20
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);