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

The following examples show how to use org.springframework.transaction.annotation.Propagation#SUPPORTS . 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: DataCarAttributeServiceImpl.java    From mumu with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional(propagation = Propagation.SUPPORTS, readOnly = false)
public boolean updateSystemCarAttr(DataCarAttribute DataCarAttribute) {
	// 对图片的长度进行判断
	String facadeImage = DataCarAttribute.getFacadeImage();
	String centralImage = DataCarAttribute.getCentralImage();
	String seatImage = DataCarAttribute.getSeatImage();
	String detailImage = DataCarAttribute.getDetailImage();
	if (facadeImage!=null && !"".equals(facadeImage)){
		DataCarAttribute.setFacadeImageCount(facadeImage.split(",").length);
	}
	if (centralImage!=null && !"".equals(centralImage)){
		DataCarAttribute.setCentralImageCount(centralImage.split(",").length);
	}
	if (seatImage!=null && !"".equals(seatImage)){
		DataCarAttribute.setSeatImageCount(seatImage.split(",").length);
	}
	if (detailImage!=null && !"".equals(detailImage)){
		DataCarAttribute.setDetailImageCount(detailImage.split(",").length);
	}
	return carAttributeDao.update(DataCarAttribute) > 0;
}
 
Example 2
Source File: AuftragDao.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the highest Auftragsnummer.
 * @param auftrag wird benötigt, damit geschaut werden kann, ob dieser Auftrag ggf. schon existiert. Wenn er schon eine Nummer hatte, so
 *          kann verhindert werden, dass er eine nächst höhere Nummer bekommt. Ein solcher Auftrag bekommt die alte Nummer wieder
 *          zugeordnet.
 */
@SuppressWarnings("unchecked")
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public Integer getNextNumber(final AuftragDO auftrag)
{
  if (auftrag.getId() != null) {
    final AuftragDO orig = internalGetById(auftrag.getId());
    if (orig.getNummer() != null) {
      auftrag.setNummer(orig.getNummer());
      return orig.getNummer();
    }
  }
  final List<Integer> list = getSession().createQuery("select max(t.nummer) from AuftragDO t").list();
  Validate.notNull(list);
  if (list.size() == 0 || list.get(0) == null) {
    log.info("First entry of AuftragDO");
    return START_NUMBER;
  }
  Integer number = list.get(0);
  return ++number;
}
 
Example 3
Source File: HRDao.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns a list of all users which are accessible by the current logged in user and not planned in the given HRViewData object.
 * @return Result list (may be empty but never null).
 */
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<PFUserDO> getUnplannedResources(final HRViewData data)
{
  final List<PFUserDO> users = new ArrayList<PFUserDO>();
  final QueryFilter queryFilter = new QueryFilter(new BaseSearchFilter());
  queryFilter.addOrder(Order.asc("firstname")).addOrder(Order.asc("lastname"));
  final List<PFUserDO> allUsers = userDao.getList(queryFilter);
  if (allUsers != null) {
    for (final PFUserDO user : allUsers) {
      final HRViewUserData userData = data.getUserData(user);
      if (userData == null || NumberHelper.isNotZero(userData.getPlannedDaysSum()) == false) {
        users.add(user);
      }
    }
  }
  return users;
}
 
Example 4
Source File: CustomerServiceImpl.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public Customer getCustomerById(final Integer customerId)
		throws NoSuchCustomerException {

	final Customer customer = getJpaTemplate().find(Customer.class,
			customerId);

	if (customer == null) {
		NoSuchCustomer noSuchCustomer = new NoSuchCustomer();
		noSuchCustomer.setCustomerId(customerId);
		throw new NoSuchCustomerException(
				"Did not find any matching customer for id [" + customerId
						+ "].", noSuchCustomer);

	} else {
		return customer;
	}
}
 
Example 5
Source File: UserService.java    From devicehive-java-server with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.SUPPORTS)
public boolean hasAccessToDevice(UserVO user, String deviceId) {
    if (!user.isAdmin()) {
        long count = userDao.hasAccessToDevice(user, deviceId);
        return count > 0;
    }
    return true;
}
 
Example 6
Source File: FilterManagerService.java    From OpenCue with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.SUPPORTS)
public void runFilterOnJob(FilterEntity filter, String id) {
    JobDetail j = jobDao.getJobDetail(id);
    if (match(filter, j)) {
        applyActions(filter,j);
    }
}
 
Example 7
Source File: TaskDao.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<TaskDO> getList(final BaseSearchFilter filter) throws AccessException
{
  final TaskFilter myFilter;
  if (filter instanceof TaskFilter) {
    myFilter = (TaskFilter) filter;
  } else {
    myFilter = new TaskFilter(filter);
  }
  final QueryFilter queryFilter = new QueryFilter(myFilter);
  final Collection<TaskStatus> col = new ArrayList<TaskStatus>(4);
  if (myFilter.isNotOpened() == true) {
    col.add(TaskStatus.N);
  }
  if (myFilter.isOpened() == true) {
    col.add(TaskStatus.O);
  }
  if (myFilter.isClosed() == true) {
    col.add(TaskStatus.C);
  }
  if (col.size() > 0) {
    queryFilter.add(Restrictions.in("status", col));
  } else {
    // Note: Result set should be empty, because every task should has one of the following status values.
    queryFilter.add(Restrictions.not(Restrictions.in("status", new TaskStatus[] { TaskStatus.N, TaskStatus.O, TaskStatus.C})));
  }
  queryFilter.addOrder(Order.asc("title"));
  if (log.isDebugEnabled() == true) {
    log.debug(myFilter.toString());
  }
  return getList(queryFilter);
}
 
Example 8
Source File: DependManagerService.java    From OpenCue with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(propagation=Propagation.SUPPORTS)
public void createDepend(FrameOnFrame depend) {
    if (frameDao.isFrameComplete(depend.getDependOnFrame())) {
        depend.setActive(false);
    }
    dependDao.insertDepend(depend);
    if (depend.isActive()) {
        updateDependCounts(depend.getDependErFrame());
    }
}
 
Example 9
Source File: DependManagerService.java    From OpenCue with Apache License 2.0 5 votes vote down vote up
/** Layer Depends **/
@Override
@Transactional(propagation=Propagation.SUPPORTS)
public void createDepend(LayerOnJob depend) {
    if (jobDao.isJobComplete(depend.getDependOnJob())) {
        throw new DependException(
                "The job you are depending on is already complete.");
    }
    dependDao.insertDepend(depend);
    updateDependCount(depend.getDependErLayer());
}
 
Example 10
Source File: FilterManagerService.java    From OpenCue with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation = Propagation.SUPPORTS)
public void runFilterOnGroup(FilterEntity filter, GroupInterface group) {
    for (JobDetail job: jobDao.findJobs(group)) {
        if (match(filter,job)) {
            applyActions(filter,job);
        }
    }
}
 
Example 11
Source File: SqlToyCRUDServiceImpl.java    From sagacity-sqltoy with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public <T extends Serializable> List<T> findTopFrom(T entity, double topSize) {
	EntityMeta entityMeta = sqlToyLazyDao.getEntityMeta(entity.getClass());
	if (StringUtil.isBlank(entityMeta.getListSql())) {
		throw new DataAccessException(
				"findTopFromByEntity[" + entity.getClass().getName() + "]沒有在类上用注解@ListSql()定义查询sql!");
	}
	return (List<T>) sqlToyLazyDao.findTopBySql(entityMeta.getListSql(), entity, topSize);
}
 
Example 12
Source File: SqlToyCRUDServiceImpl.java    From sagacity-sqltoy with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public <T extends Serializable> PaginationModel<T> findPageFrom(PaginationModel paginationModel, T entity,
		ReflectPropertyHandler reflectPropertyHandler) {
	EntityMeta entityMeta = sqlToyLazyDao.getEntityMeta(entity.getClass());
	if (StringUtil.isBlank(entityMeta.getPageSql())) {
		throw new DataAccessException(
				"findPageFromByEntity[" + entity.getClass().getName() + "]沒有在类上用注解@PaginationSql() 定义分页sql!");
	}
	return (PaginationModel<T>) sqlToyLazyDao.findPageByQuery(paginationModel,
			new QueryExecutor(entityMeta.getPageSql(), entity).reflectPropertyHandler(reflectPropertyHandler))
			.getPageResult();
}
 
Example 13
Source File: MonthlyEmployeeReportDao.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public MonthlyEmployeeReport getReport(int year, int month, PFUserDO user)
{
  if (user == null || year <= 0) {
    return null;
  }
  MonthlyEmployeeReport report = new MonthlyEmployeeReport(year, month);
  EmployeeDO employee = employeeDao.getByUserId(user.getId());
  if (employee != null) {
    report.setEmployee(employee);
  } else {
    report.setUser(user);
  }
  report.init();
  TimesheetFilter filter = new TimesheetFilter();
  filter.setDeleted(false);
  filter.setStartTime(report.getFromDate());
  filter.setStopTime(report.getToDate());
  filter.setUserId(user.getId());
  List<TimesheetDO> list = timesheetDao.getList(filter);
  if (CollectionUtils.isNotEmpty(list) == true) {
    for (TimesheetDO sheet : list) {
      report.addTimesheet(sheet);
    }
  }
  report.calculate();
  return report;
}
 
Example 14
Source File: SqlToyCRUDServiceImpl.java    From sagacity-sqltoy with Apache License 2.0 5 votes vote down vote up
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public <T extends Serializable> List<T> findFrom(T entity) {
	EntityMeta entityMeta = sqlToyLazyDao.getEntityMeta(entity.getClass());
	if (StringUtil.isBlank(entityMeta.getListSql())) {
		throw new DataAccessException(
				"findFromByEntity[" + entity.getClass().getName() + "]沒有在类上用注解@ListSql()定义查询sql!");
	}
	return sqlToyLazyDao.findBySql(entityMeta.getListSql(), entity);
}
 
Example 15
Source File: DependManagerService.java    From OpenCue with Apache License 2.0 5 votes vote down vote up
@Transactional(propagation=Propagation.SUPPORTS)
public void satisfyDepend(LightweightDependency depend) {
    /*
     * Before setting the depend to in-active, obtain a list
     * of frames and decrement the depend count on them.
     */
    if (DependType.FRAME_BY_FRAME.equals(depend.type)) {
        List<LightweightDependency> children =
            dependDao.getChildDepends(depend);

        for (LightweightDependency lwd: children) {
            satisfyDepend(lwd);
        }
        return;
    }

    /*
     * Only decrement the depend counts if the depend is
     * actually set to inactive.
     */
    if (dependDao.setInactive(depend)) {
        logger.info("satisfied depend: " + depend.getId());
        for (FrameInterface f: frameDao.getDependentFrames(depend)) {
            if (!dependDao.decrementDependCount(f)) {
                logger.warn("warning, depend count for " +
                        depend.getId() + "was not decremented " +
                        "for frame " + f + "because the count is " +
                        "already 0.");
            }
        }
    }
}
 
Example 16
Source File: AccountService.java    From Spring-Framework-Essentials with MIT License 4 votes vote down vote up
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public BigDecimal getBalance(Long id) {
    return repository.getAccount(id).getBalance();
}
 
Example 17
Source File: User2ServiceImpl.java    From transaction-test with MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public void addSupports(User2 user){
	user2Mapper.insert(user);
}
 
Example 18
Source File: YggdrasilServiceImpl.java    From authlib-agent with MIT License 4 votes vote down vote up
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
@Override
public AuthenticateResponse refresh(String accessToken, String clientToken) throws ForbiddenOperationException {
	return selectProfile(accessToken, clientToken, null);
}
 
Example 19
Source File: RdbmsGenericDao.java    From devicehive-java-server with Apache License 2.0 4 votes vote down vote up
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public <T extends Serializable> T find(Class<T> entityClass, Object primaryKey) {
    return em.find(entityClass, primaryKey);
}
 
Example 20
Source File: User1ServiceImpl.java    From transaction-test with MIT License 4 votes vote down vote up
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public void addSupports(User1 user){
	user1Mapper.insert(user);
}