org.springframework.transaction.annotation.Isolation#DEFAULT源码实例Demo

下面列出了org.springframework.transaction.annotation.Isolation#DEFAULT 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: efo   文件: FileServiceImpl.java
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor =
        Exception.class)
public boolean[] updateUrl(int id, String oldLocalUrl, String localUrl, String visitUrl) {
    boolean[] b = new boolean[]{false, false};
    boolean canUpdateLocalUrl = Checker.isExists(oldLocalUrl) && Checker.isNotEmpty(localUrl) && Checker
            .isNotExists(localUrl) && !localUrlExists(localUrl);
    if (canUpdateLocalUrl) {
        FileExecutor.renameTo(oldLocalUrl, localUrl);
        fileDAO.updateLocalUrlById(id, localUrl);
        b[0] = true;
    }
    if (Checker.isNotEmpty(visitUrl) && !visitUrlExists(visitUrl)) {
        fileDAO.updateVisitUrlById(id, visitUrl);
        b[1] = true;
    }
    return b;
}
 
源代码2 项目: efo   文件: FileServiceImpl.java
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor =
        Exception.class)
public boolean shareFiles(String prefix, String files, User user) {
    if (Checker.isNotEmpty(files)) {
        String[] paths = files.split(ValueConsts.COMMA_SIGN);
        for (String path : paths) {
            java.io.File f = new java.io.File(path);
            String name = f.getName();
            String suffix = FileExecutor.getFileSuffix(name);
            String visitUrl = getRegularVisitUrl(prefix, user, name, suffix, null);
            if (f.exists() && f.isFile() && !localUrlExists(path) && !visitUrlExists(visitUrl)) {
                File file = new File(name, suffix, path, visitUrl, ValueConsts.EMPTY_STRING,
                        ValueConsts.EMPTY_STRING, user.getId(),
                        categoryService.getIdByName(DefaultValues.UNCATEGORIZED));
                file.setAuth(ValueConsts.ONE_INT, ValueConsts.ZERO_INT, ValueConsts.ZERO_INT,
                        ValueConsts.ZERO_INT, ValueConsts.ONE_INT);
                fileDAO.insertFile(file);
            }
        }
    }
    return true;
}
 
@Override
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
public boolean saveUserActive(UserActiveDTO userActiveDTO) {
	boolean flag = false;
	// 1.先判断数据库中是否存在当前用户的浏览记录
	int rows = this.userActiveMapper.countUserActive(userActiveDTO);
	int saveRows = 0;
	int updateRows = 0;
	// 2.不存在就添加
	if (rows < 1) { // 不存在
		userActiveDTO.setHits(1L); // 不存在记录的话那肯定是第一次访问,那点击量肯定是1
		saveRows = this.userActiveMapper.saveUserActive(userActiveDTO);
	} else { // 已经存在
		// 3.存在则先把当前用户对当前二级类目的点击量取出来+1
		long hits = this.userActiveMapper.getHitsByUserActiveInfo(userActiveDTO);
		// 4.然后在更新用户的浏览记录
		hits++;
		userActiveDTO.setHits(hits);
		updateRows = this.userActiveMapper.updateUserActive(userActiveDTO);
	}
	if (saveRows > 0 || updateRows > 0) {
		flag = true;
	}
	return flag;
}
 
@Override
@Transactional(isolation=Isolation.DEFAULT, propagation = Propagation.REQUIRED)
public boolean removeMemberBatch(List<Long> memberIds) {
	if (memberIds == null || memberIds.size() == 0) {
		return false;
	}
	// 先检查集合中的memberId是否存在
	int existMemberNums = this.memberMapper.countMemberInList(memberIds);
	if (existMemberNums != memberIds.size()) {
		return false;
	}
	
	// 批量删除
	int removeSuccessNums = this.memberMapper.removeMemberBatch(memberIds);
	
	if (removeSuccessNums == existMemberNums) {
		return true;
	}
	
	return false;
}
 
源代码5 项目: efo   文件: FileServiceImpl.java
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor =
        Exception.class)
public boolean updateFileInfo(long id, User user, String name, String category, String tag, String description) {
    File file = fileDAO.getById(id);
    if (Checker.isNotNull(file) && file.getIsUpdatable() == 1) {
        AuthRecord authRecord = authService.getByFileIdAndUserId(id, user.getId());
        String suffix = FileExecutor.getFileSuffix(name);
        boolean canUpdate = (Checker.isNull(authRecord) ? user.getIsUpdatable() == 1 :
                authRecord.getIsUpdatable() == 1) && Checker.isNotEmpty(name) && Pattern.compile(EfoApplication.settings.getStringUseEval(ConfigConsts.FILE_SUFFIX_MATCH_OF_SETTING)).matcher(suffix).matches();
        if (canUpdate) {
            String localUrl = file.getLocalUrl();
            java.io.File newFile = new java.io.File(localUrl);
            String visitUrl = file.getVisitUrl();
            String newLocalUrl = localUrl.substring(0, localUrl.lastIndexOf(ValueConsts.SEPARATOR) + 1) + name;
            String newVisitUrl = visitUrl.substring(0, visitUrl.lastIndexOf(ValueConsts.SPLASH_STRING) + 1) + name;
            file.setName(name);
            file.setSuffix(suffix);
            file.setLocalUrl(newLocalUrl);
            file.setVisitUrl(newVisitUrl);
            file.setCategoryId(categoryService.getIdByName(category));
            file.setTag(tag);
            file.setDescription(description);
            boolean isValid = (localUrl.endsWith(ValueConsts.SEPARATOR + name) || (!Checker.isExists(newLocalUrl)
                    && !localUrlExists(newLocalUrl) && !visitUrlExists(newVisitUrl)));
            if (isValid && fileDAO.updateFileInfo(file)) {
                return newFile.renameTo(new java.io.File(newLocalUrl));
            }
        }
    }
    return false;
}
 
源代码6 项目: Resource   文件: StudentServiceImpl.java
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT,
    timeout = 36000, rollbackFor = Exception.class)
public Student selectStudentByName(String name)
{
    return studentMapper.selectStudentByName(name);
}
 
源代码7 项目: AIDR   文件: TaskAssignmentServiceImpl.java
@Override
  @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
  public void addToTaskAssignment(List<DocumentDTO> documents, Long userID){
      //taskAssignmentDao.insertTaskAssignment(documents, userID);
 
  	//List<qa.qcri.aidr.task.entities.Document> docList = mapper.deSerializeList(jsonString, new TypeReference<List<qa.qcri.aidr.task.entities.Document>>() {});
  	try {
  		//System.out.println("[addToTaskAssignment] Going to insert task list of size = " + documents.size() + ", for userID: " + userID);
  		taskManager.assignNewTaskToUser(documents, userID);
} catch (Exception e) {
	logger.error("Error while adding Task Assignment for userID="+userID+"\t"+e.getStackTrace());
}
  }
 
源代码8 项目: AIDR   文件: DocumentServiceImpl.java
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public List<DocumentDTO> getDocumentForTask(Long crisisID, int count, String userName) {

	if(count>CodeLookUp.DOCUMENT_MAX_FETCH_COUNT){
		count = CodeLookUp.DOCUMENT_MAX_FETCH_COUNT;
	}
	
	List<DocumentDTO> documents = taskManager.getDocumentsForTagging(crisisID, count, userName, CodeLookUp.DOCUMENT_REMAINING_COUNT);
	logger.info("For crisisID = " + crisisID + ", user = " + userName + ", documents available for tagging: " + (documents != null ? documents.size() : "empty list"));
	return documents;  
}
 
@Transactional(
		propagation = Propagation.REQUIRED,
		isolation = Isolation.DEFAULT
		)
@Override
public void addProduct(InventoryForm invForm) {
	Catalog catalog = new Catalog();
	catalog.setName(invForm.getName());
	catalog.setDescription(invForm.getDescription());
	catalog.setCostPrice(invForm.getCostPrice());
	catalog.setRetailPrice(invForm.getRetailPrice());
	catalog.setWholesalePrice(invForm.getWholeSalePrice());
	catalog.setStock(invForm.getStock());
	catalog.setTags(invForm.getTags());
	catalog.setSupplierId(invForm.getVendor());
	
	Uom uom = new Uom();
	uom.setId(invForm.getUomId());
	
	MaterialType type = new MaterialType();
	type.setId(invForm.getTypeId());
	
	catalog.setUom(uom);
	catalog.setMaterialType(type);
	
	inventoryDao.setProduct(catalog);

}
 
源代码10 项目: AIDR   文件: TaskAssignmentServiceImpl.java
@Override
  @Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
  public void revertTaskAssignment(Long documentID, Long userID) {
      //taskAssignmentDao.undoTaskAssignment(documentID,userID);
  	try {
	taskManager.undoTaskAssignment(documentID, userID);
	//logger.info("Removed from taskAssignment table: documentID = " + documentID + ", userID = " + userID);
} catch (Exception e) {
	logger.error(" Error while reverting Task Assignment for userID: "+userID+"\t"+e.getStackTrace());
}
  }
 
@Override
   @Transactional(isolation=Isolation.DEFAULT,propagation=Propagation.REQUIRED)
public boolean updateProductHitsByProductId(Long productId) {
	// 1.获取当前商品的点击量
   	long hits = this.productMapper.getProductHitsByPId(productId);
   	// 2.点击量+1再存进去
   	Product product = new Product();
   	product.setProductId(productId);
   	product.setHits(++hits);
   	int rows = this.productMapper.updateProduct(product);
   	
	return rows > 0 ? true : false;
}
 
源代码12 项目: AIDR   文件: TaskAnswerServiceImpl.java
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void markOnHasHumanTag(Long documentID){
	documentService.updateHasHumanLabel(documentID, true);
}
 
源代码13 项目: efo   文件: FileServiceImpl.java
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, timeout = 36000, rollbackFor =
        Exception.class)
public boolean upload(int categoryId, String tag, String description, String prefix, MultipartFile multipartFile,
                      User user) {
    if (user.getIsUploadable() == 1) {
        String name = multipartFile.getOriginalFilename();
        String suffix = FileExecutor.getFileSuffix(name);
        String localUrl = SettingConfig.getUploadStoragePath() + ValueConsts.SEPARATOR + name;
        Category category = categoryService.getById(categoryId);
        long maxSize = Formatter.sizeToLong(EfoApplication.settings.getStringUseEval(ConfigConsts
                .FILE_MAX_SIZE_OF_SETTING));
        long size = multipartFile.getSize();
        boolean fileExists = localUrlExists(localUrl);
        //检测标签是否合法
        if (EfoApplication.settings.getBooleanUseEval(ConfigConsts.TAG_REQUIRE_OF_SETTING)) {
            String[] tags = Checker.checkNull(tag).split(ValueConsts.SPACE);
            if (tags.length <= EfoApplication.settings.getIntegerUseEval(ConfigConsts.TAG_SIZE_OF_SETTING)) {
                int maxLength = EfoApplication.settings.getIntegerUseEval(ConfigConsts.TAG_LENGTH_OF_SETTING);
                for (String t : tags) {
                    if (t.length() > maxLength) {
                        return false;
                    }
                }
            } else {
                return false;
            }
        }
        //是否可以上传
        boolean canUpload = !multipartFile.isEmpty() && size <= maxSize && Pattern.compile(EfoApplication
                .settings.getStringUseEval(ConfigConsts.FILE_SUFFIX_MATCH_OF_SETTING)).matcher(suffix).matches()
                && (Checker.isNotExists(localUrl) || !fileExists || EfoApplication.settings.getBooleanUseEval
                (ConfigConsts.FILE_COVER_OF_SETTING));
        logger.info("is empty [" + multipartFile.isEmpty() + "], file size [" + size + "], max file size [" +
                maxSize + "]");
        if (canUpload) {
            String visitUrl = getRegularVisitUrl(Checker.isNotEmpty(prefix) && user.getPermission() > 1 ? prefix
                    : EfoApplication.settings.getStringUseEval(ConfigConsts.CUSTOM_LINK_RULE_OF_SETTING), user,
                    name, suffix, category);
            if (fileExists) {
                removeByLocalUrl(localUrl);
            }
            if (visitUrlExists(visitUrl)) {
                removeByVisitUrl(visitUrl);
            }
            try {
                multipartFile.transferTo(new java.io.File(localUrl));
                logger.info("local url of upload file: " + localUrl);
                File file = new File(name, suffix, localUrl, visitUrl, WebUtils.scriptFilter(description),
                        WebUtils.scriptFilter(tag), user.getId(), categoryId);
                int[] auth = SettingConfig.getAuth(ConfigConsts.FILE_DEFAULT_AUTH_OF_SETTING);
                file.setAuth(auth[0], auth[1], auth[2], auth[3], auth[4]);
                boolean isSuccess = fileDAO.insertFile(file);
                if (isSuccess) {
                    long fileId = fileDAO.getIdByLocalUrl(localUrl);
                    if (fileId > 0) {
                        authService.insertDefaultAuth(user.getId(), fileId);
                    }
                } else {
                    FileExecutor.deleteFile(localUrl);
                }
                return isSuccess;
            } catch (Exception e) {
                FileExecutor.deleteFile(localUrl);
                logger.error("save file error: " + e.getMessage());
            }
        }
    }
    return false;
}
 
源代码14 项目: AIDR   文件: DocumentServiceImpl.java
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void addToOneTaskAssignment(Long documentID, Long userID){
	// addToOneTaskAssignment(documentID, userID);
	taskAssignmentService.addToOneTaskAssignment(documentID, userID);
}
 
源代码15 项目: BigDataPlatform   文件: PmsProductService.java
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
源代码16 项目: xmall   文件: PmsProductService.java
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
源代码17 项目: mall-swarm   文件: PmsProductService.java
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
源代码18 项目: macrozheng   文件: PmsProductService.java
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
源代码19 项目: macrozheng-mall   文件: PmsProductService.java
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
源代码20 项目: mall   文件: PmsProductService.java
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);