Java Code Examples for org.springframework.transaction.annotation.Isolation#DEFAULT

The following examples show how to use org.springframework.transaction.annotation.Isolation#DEFAULT . 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: FileServiceImpl.java    From efo with MIT License 6 votes vote down vote up
@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;
}
 
Example 2
Source File: FileServiceImpl.java    From efo with MIT License 6 votes vote down vote up
@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;
}
 
Example 3
Source File: UserActiveServiceImpl.java    From product-recommendation-system with MIT License 6 votes vote down vote up
@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;
}
 
Example 4
Source File: MemberServiceImpl.java    From product-recommendation-system with MIT License 6 votes vote down vote up
@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;
}
 
Example 5
Source File: ProductServiceImpl.java    From product-recommendation-system with MIT License 5 votes vote down vote up
@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;
}
 
Example 6
Source File: TaskAssignmentServiceImpl.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@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());
}
  }
 
Example 7
Source File: InvoiceAddProductImpl.java    From Spring-MVC-Blueprints with MIT License 5 votes vote down vote up
@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);

}
 
Example 8
Source File: FileServiceImpl.java    From efo with MIT License 5 votes vote down vote up
@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;
}
 
Example 9
Source File: DocumentServiceImpl.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@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;  
}
 
Example 10
Source File: StudentServiceImpl.java    From Resource with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT,
    timeout = 36000, rollbackFor = Exception.class)
public Student selectStudentByName(String name)
{
    return studentMapper.selectStudentByName(name);
}
 
Example 11
Source File: TaskAssignmentServiceImpl.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@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());
}
  }
 
Example 12
Source File: DocumentServiceImpl.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void addToOneTaskAssignment(Long documentID, Long userID){
	// addToOneTaskAssignment(documentID, userID);
	taskAssignmentService.addToOneTaskAssignment(documentID, userID);
}
 
Example 13
Source File: TaskAnswerServiceImpl.java    From AIDR with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
@Transactional(readOnly = false, propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void markOnHasHumanTag(Long documentID){
	documentService.updateHasHumanLabel(documentID, true);
}
 
Example 14
Source File: FileServiceImpl.java    From efo with MIT License 4 votes vote down vote up
@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;
}
 
Example 15
Source File: PmsProductService.java    From mall with Apache License 2.0 2 votes vote down vote up
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
Example 16
Source File: PmsProductService.java    From BigDataPlatform with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
Example 17
Source File: PmsProductService.java    From macrozheng-mall with MIT License 2 votes vote down vote up
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
Example 18
Source File: PmsProductService.java    From macrozheng with Apache License 2.0 2 votes vote down vote up
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
Example 19
Source File: PmsProductService.java    From mall-swarm with Apache License 2.0 2 votes vote down vote up
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);
 
Example 20
Source File: PmsProductService.java    From xmall with MIT License 2 votes vote down vote up
/**
 * 创建商品
 */
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
int create(PmsProductParam productParam);