當前位置: 首頁>>代碼示例>>Java>>正文


Java Propagation類代碼示例

本文整理匯總了Java中org.springframework.transaction.annotation.Propagation的典型用法代碼示例。如果您正苦於以下問題:Java Propagation類的具體用法?Java Propagation怎麽用?Java Propagation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Propagation類屬於org.springframework.transaction.annotation包,在下文中一共展示了Propagation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBookmarksForItems

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Override
@Transactional(propagation = Propagation.MANDATORY)
public Map<Item, Bookmark> getBookmarksForItems(Collection<Item> items, String userId)
{
	if( items.isEmpty() )
	{
		return Collections.emptyMap();
	}

	final List<Bookmark> bs = getHibernateTemplate().findByNamedParam(
		"FROM Bookmark b WHERE b.item IN (:items) and b.owner = :ownerId", new String[]{"items", "ownerId"},
		new Object[]{items, userId});

	final Map<Item, Bookmark> rv = new HashMap<Item, Bookmark>();
	for( Bookmark b : bs )
	{
		rv.put(b.getItem(), b);
	}
	return rv;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:22,代碼來源:BookmarkDaoImpl.java

示例2: save

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
/**
 * For REST calls or anything not using some sort of "session"
 * 
 * @param entity
 */
@Transactional(propagation = Propagation.REQUIRED)
@Override
public void save(T entity, @Nullable TargetList targetList, @Nullable Map<Object, TargetList> otherTargetLists,
	@Nullable String stagingUuid, @Nullable String lockId, boolean keepLocked) throws LockedException
{
	if( entity.getId() == 0 )
	{
		final EntityPack<T> pack = new EntityPack<T>(entity, stagingUuid);
		pack.setTargetList(targetList);
		pack.setOtherTargetLists(otherTargetLists);
		doAdd(pack, null, keepLocked);
	}
	else
	{
		doStopEditWithLock(entity, targetList, otherTargetLists, stagingUuid, lockId, !keepLocked);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:AbstractEntityServiceImpl.java

示例3: modifyRelation

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@RequestMapping("/modifyRelation")
@Transactional(propagation = Propagation.REQUIRED)
public Message modifyRelation(@RequestBody List<UserRelation> relations) {
    Message message = new Message();
    if (relations != null && relations.size() > 0) {
        try {
            for (int i = 0; i < relations.size(); i++) {
                if (relations.get(i).getUrid() != null) {
                    this.userRelationService.update(relations.get(i));
                } else {

                    this.userRelationService.insert(relations.get(i));
                }
            }
        } catch (Exception excption) {
            excption.printStackTrace();
            return message;
        }
    }
    message.setStatus(1);
    return message;
}
 
開發者ID:TZClub,項目名稱:OMIPlatform,代碼行數:23,代碼來源:UserRelationController.java

示例4: saveSystemSettings

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@PreAuthorize ("hasRole('ROLE_SYSTEM_MANAGER')")
@Transactional (readOnly=false, propagation=Propagation.REQUIRED)
public Configuration saveSystemSettings (Configuration cfg) throws
      IllegalArgumentException, IllegalAccessException,
      InvocationTargetException, CloneNotSupportedException
{
   Configuration db_cfg = cfgDao.getCurrentConfiguration ();
   cfg = cfg.completeWith (db_cfg);
   db_cfg.setCronConfiguration (cfg.getCronConfiguration ());
   db_cfg.setGuiConfiguration (cfg.getGuiConfiguration ());
   db_cfg.setMessagingConfiguration (cfg.getMessagingConfiguration ());
   db_cfg.setNetworkConfiguration (cfg.getNetworkConfiguration ());
   db_cfg.setProductConfiguration (cfg.getProductConfiguration ());
   db_cfg.setSearchConfiguration (cfg.getSearchConfiguration ());
   db_cfg.setServerConfiguration (cfg.getServerConfiguration ());
   db_cfg.setSystemConfiguration (cfg.getSystemConfiguration ());
   cfgDao.update (db_cfg);
   return cfgDao.getCurrentConfiguration ();
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:20,代碼來源:SystemService.java

示例5: createTempList

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@Transactional(propagation = Propagation.MANDATORY)
public Long createTempList(final Long listId, final Collection<? extends BaseEntity> list) {
    Assert.notNull(listId);
    Assert.isTrue(CollectionUtils.isNotEmpty(list));
    // creates a new local temporary table if it doesn't exists to handle temporary lists
    getJdbcTemplate().update(createTemporaryListQuery);
    // fills in a temporary list by given values
    int i = 0;
    final Iterator<? extends BaseEntity> iterator = list.iterator();
    final MapSqlParameterSource[] batchArgs = new MapSqlParameterSource[list.size()];
    while (iterator.hasNext()) {
        MapSqlParameterSource params = new MapSqlParameterSource();
        params.addValue(HelperParameters.LIST_ID.name(), listId);
        params.addValue(HelperParameters.LIST_VALUE.name(), iterator.next().getId());
        batchArgs[i] = params;
        i++;
    }
    getNamedParameterJdbcTemplate().batchUpdate(insertTemporaryListItemQuery, batchArgs);
    return listId;
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:21,代碼來源:DaoHelper.java

示例6: resetPassword

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@Transactional (readOnly=false, propagation=Propagation.REQUIRED)
@Caching (evict = {
   @CacheEvict(value = "user", allEntries = true),
   @CacheEvict(value = "userByName", allEntries = true)})
public void resetPassword(String code, String new_password)
   throws RootNotModifiableException, RequiredFieldMissingException, 
      EmailNotSentException
{
   User u = userDao.getUserFromUserCode (code);
   if (u == null)
   {
      throw new UserNotExistingException ();
   }
   checkRoot (u);

   u.setPassword (new_password);

   checkRequiredFields (u);
   userDao.update (u);
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:21,代碼來源:UserService.java

示例7: loadSamplesForFilesByReference

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
/**
 * Load sample metadata from the database for all files, corresponding the given reference ID.
 *
 * @param vcfFileId {@code long} reference ID for which files samples were saved.
 * @return {@code Map&lt;Long, List&lt;Sample&gt;&gt;} with file IDs for giver reference ID as keys, and with
 * lists of samples, corresponding this file IDs as values.
 */
@Transactional(propagation = Propagation.MANDATORY)
public Map<Long, List<VcfSample>> loadSamplesForFilesByReference(long vcfFileId) {
    Map<Long, List<VcfSample>> sampleFileMap = new HashMap<>();

    getJdbcTemplate().query(loadSamplesForFilesByReferenceIdQuery, rs -> {
        Long fileId = rs.getLong(SampleParameters.VCF_ID.name());
        if (!sampleFileMap.containsKey(fileId)) {
            sampleFileMap.put(fileId, new ArrayList<>());
        }

        VcfSample sample = new VcfSample();

        sample.setId(rs.getLong(SampleParameters.VCF_SAMPLE_ID.name()));
        sample.setName(rs.getString(SampleParameters.SAMPLE_NAME.name()));
        sample.setIndex(rs.getInt(SampleParameters.ORDER_INDEX.name()));

        sampleFileMap.get(fileId).add(sample);
    }, vcfFileId);

    return sampleFileMap;
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:29,代碼來源:VcfFileDao.java

示例8: getAllEntries

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
@Transactional(propagation = Propagation.MANDATORY)
public List<ACLEntryMapping> getAllEntries(final Collection<String> privileges, Collection<String> targets)
{
	return getHibernateTemplate().executeFind(new CollectionPartitioner<String, ACLEntryMapping>(targets)
	{
		@Override
		public List<ACLEntryMapping> doQuery(Session session, Collection<String> collection)
		{
			Query query = session.getNamedQuery("getAllEntries");
			query.setParameter("institution", CurrentInstitution.get());
			query.setParameterList("targets", collection);
			query.setParameterList("privileges", privileges);
			return query.list();
		}
	});
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:19,代碼來源:AclDaoImpl.java

示例9: specifiedSortedFileShouldBeCreated

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void specifiedSortedFileShouldBeCreated() throws Exception {
    File tempDirectory = getTempDirectory();

    File toBeSorted = context.getResource("classpath:templates/" + UNSORTED_BED_NAME).getFile();
    File copiedToBeSorted = new File(tempDirectory, UNSORTED_BED_NAME);
    Files.copy(toBeSorted.toPath(), copiedToBeSorted.toPath());

    File sortedPath = new File(tempDirectory, SPECIFIED_BED_NAME);

    FeatureFileSortRequest request = new FeatureFileSortRequest();
    request.setOriginalFilePath(copiedToBeSorted.getAbsolutePath());
    request.setSortedFilePath(sortedPath.getAbsolutePath());

    assertSortRequest(request, new Equals(sortedPath.getAbsolutePath()));
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:18,代碼來源:ToolsControllerTest.java

示例10: loadBiologicalDataItemsByIds

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
/**
 * Loads a List of BiologicalDataItem from the database by their IDs
 * @param ids List of IDs of BiologicalDataItem instances
 * @return List of BiologicalDataItem, matching specified IDs
 */
@Transactional(propagation = Propagation.MANDATORY)
public List<BiologicalDataItem> loadBiologicalDataItemsByIds(List<Long> ids) {
    if (ids == null || ids.isEmpty()) {
        return Collections.emptyList();
    }

    Long listId = daoHelper.createTempLongList(ids);

    final MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue(BiologicalDataItemParameters.BIO_DATA_ITEM_ID.name(), listId);

    List<BiologicalDataItem> items = getNamedParameterJdbcTemplate().query(loadBiologicalDataItemsByIdsQuery,
            params, getRowMapper());

    daoHelper.clearTempList(listId);

    return items;
}
 
開發者ID:react-dev26,項目名稱:NGB-master,代碼行數:24,代碼來源:BiologicalDataItemDao.java

示例11: updateResource

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@Transactional(rollbackFor=Exception.class, propagation=Propagation.REQUIRED)
public void updateResource(AdminResource resource) {
	ValidationAssert.notNull(resource, "參數不能為空!");
	ValidationAssert.notNull(resource.getResourceId(), "資源id不能為空!");
	resource.setPermissionExpression(StringUtils.defaultIfEmpty(resource.getPermissionExpression(), null));
	resource.setResourceUrl(StringUtils.defaultIfEmpty(resource.getResourceUrl(), null));
	AdminResource presource = adminResourceMapper.selectThinResourceById(resource.getResourceId(), true);
	ValidationAssert.notNull(presource, "該資源已經不存在了!");
	try {
		adminResourceMapper.updateResource(resource);
	} catch(DuplicateKeyException e) {
		BusinessAssert.isTrue(!e.getCause().getMessage().toUpperCase().contains("RESOURCE_NAME"), "修改資源失敗,該資源名稱已經存在!");
		BusinessAssert.isTrue(!e.getCause().getMessage().toUpperCase().contains("PERMISSION_EXPRESSION"), "修改資源失敗,該權限表達式已經存在!");
		throw e;
	}
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:17,代碼來源:AdminResourceServiceImpl.java

示例12: addKeyResource

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.REQUIRED)
@SecureOnCall(priv = "MODIFY_KEY_RESOURCE")
public void addKeyResource(HierarchyTreeNode node, ItemKey itemId)
{
	final HierarchyTopic topic = getHierarchyTopic(node.getId());
	final Item item = itemService.get(itemId);

	List<Item> list = topic.getKeyResources();
	if( list == null )
	{
		list = new ArrayList<Item>();
		topic.setKeyResources(list);
	}

	if( !list.contains(item) )
	{
		list.add(item);
	}

	dao.saveOrUpdate(topic);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:23,代碼來源:HierarchyServiceImpl.java

示例13: getLock

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.MANDATORY)
public EntityLock getLock(BaseEntity entity, String lockId)
{
	EntityLock lock = entityLockDao.findByCriteria(Restrictions.eq("entity", entity));
	if( lock != null )
	{
		if( lockId == null )
		{
			throw new LockedException("Entity is locked by another user '" + lock.getUserID() + "'",
				lock.getUserID(), lock.getUserSession(), entity.getId());
		}
		if( !lockId.equals(lock.getUserSession()) )
		{
			throw new LockedException("Wrong lock id. Entity is locked by user.", lock.getUserID(),
				lock.getUserSession(), entity.getId());
		}
	}
	else if( lockId != null )
	{
		throw new LockedException("Entity is not locked", null, null, entity.getId());
	}
	return lock;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:25,代碼來源:EntityLockingServiceImpl.java

示例14: markProcessedById

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.MANDATORY)
public int markProcessedById(final String user, final Collection<Long> notifications, final String attemptId)
{
	if( notifications.isEmpty() )
	{
		return 0;
	}
	return (Integer) getHibernateTemplate().execute(new HibernateCallback()
	{
		@Override
		public Object doInHibernate(Session session)
		{
			Query query = session.createQuery("update Notification set processed = true "
					+ "where institution = :inst and userTo = :user and processed = false "
					+ "and id in (:noteid) and attemptId = :attempt");
			query.setParameter(ATTEMPT, attemptId);
			query.setParameterList(NOTEID, notifications);
			query.setParameter(USER, user);
			query.setParameter(INST, CurrentInstitution.get());
			return query.executeUpdate();
		}
	});
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:25,代碼來源:NotificationDaoImpl.java

示例15: removeProducts

import org.springframework.transaction.annotation.Propagation; //導入依賴的package包/類
@PreAuthorize ("hasRole('ROLE_DATA_MANAGER')")
@Transactional (readOnly=false, propagation=Propagation.REQUIRED)
@CacheEvict (value = "products", allEntries = true)
public void removeProducts (String uuid, Long[] pids)
{
   collectionDao.removeProducts (uuid, pids, null);
   long start = new Date ().getTime ();
   for (Long pid: pids)
   {
      try
      {
         searchService.index(productDao.read(pid));
      }
      catch (Exception e)
      {
         throw new RuntimeException("Cannot update Solr index", e);
      }
   }
   long end = new Date ().getTime ();
   LOGGER.info("[SOLR] Remove " + pids.length +
      " product(s) from collection spent " + (end-start) + "ms" );
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:23,代碼來源:CollectionService.java


注:本文中的org.springframework.transaction.annotation.Propagation類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。