下面列出了org.springframework.transaction.annotation.Propagation#REQUIRED 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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);
}
@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);
}
@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);
}
/**
* 產生 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);
}
@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);
}
/**
* 更新 配置项/配置文件 的值
*/
@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 "修改成功";
}
@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);
}
/**
*
* @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;
}
/**
* 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);
}
@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;
}
@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();
}
@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);
}
}
/**
* 通过角色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);
}
@Override
@Transactional(propagation=Propagation.REQUIRED, readOnly=true)
public GroupDetail getRootGroupDetail(ShowInterface s) {
return groupDao.getRootGroupDetail(s);
}
@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public RegionView getRegion(Long regionId) {
return Utils.transformEntity(regionDAO.getEntity(regionId));
}
@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;
}
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void markOnHasHumanTag(Long documentID){
documentService.updateHasHumanLabel(documentID, true);
}
@Transactional (readOnly=true, propagation=Propagation.REQUIRED)
public List<Collection> getCollections (Product product)
{
return collectionDao.getCollectionsOfProduct(product.getId());
}
@Override
@Transactional(propagation = Propagation.REQUIRED)
public void optimizeLayer(LayerInterface layer, int cores, long maxRss, int runTime) {
layerDao.balanceLayerMinMemory(layer, maxRss);
}
/**
* 创建商品
*/
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);