Example usage for org.springframework.transaction.annotation Propagation SUPPORTS

List of usage examples for org.springframework.transaction.annotation Propagation SUPPORTS

Introduction

In this page you can find the example usage for org.springframework.transaction.annotation Propagation SUPPORTS.

Prototype

Propagation SUPPORTS

To view the source code for org.springframework.transaction.annotation Propagation SUPPORTS.

Click Source Link

Document

Support a current transaction, execute non-transactionally if none exists.

Usage

From source file:es.upm.fiware.rss.expenditureLimit.manager.test.ExpenditureLimitManagerTest.java

/**
 * //from  w  ww . java  2s.c  o m
 * @throws RSSException
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void storeGeneralProviderExpLimitsNoAppProvider() throws RSSException {
    ExpenditureLimitManagerTest.logger.debug("Into storeGeneralProviderExpLimits method");
    thrown.expect(RSSException.class);
    thrown.expectMessage("Provider Identifier");
    LimitGroupBean expLimits = ExpenditureLimitBeanConstructor.generateLimitGroupBean();
    elManager.storeGeneralProviderExpLimit(null, null, expLimits);
    ExpenditureLimitManagerTest.logger.debug("Exception expected");
}

From source file:com.oak_yoga_studio.dao.impl.EnrollmentDAOImpl.java

@Transactional(propagation = Propagation.SUPPORTS)
@Override// w  w  w.  j  av a 2s  .  com
public Enrollment getTopWaitingList(int sectionId) {

    Enrollment enrollment = null;
    Query query = sf.getCurrentSession().createQuery("select  e from Enrollment e " + "join e.section s"
            + " where s.id=:sectionId and e.status='WAITINGLIST'");
    query.setParameter("sectionId", sectionId);
    List<Enrollment> en;
    en = query.list();
    if (!en.isEmpty()) {
        enrollment = en.get(0);
    }
    System.out.println("top enrllement waiting is " + en.size());

    return enrollment;

}

From source file:es.upm.fiware.rss.expenditureLimit.server.test.ExpenditureLimitServerTest.java

/**
 * //www.j  av a2s .  c o  m
 * @throws Exception
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void deleteGeneralUserExpLimits() throws Exception {
    ExpenditureLimitServerTest.logger.debug("Into deleteUserAccumulated method");
    Response response = server.deleteUserExpCtrl(aggregator, appProvider, userId, service, currency, type);
    Assert.assertEquals(200, response.getStatus());
}

From source file:org.ext4spring.parameter.DefaultParameterBeanService.java

@Override
@Transactional(readOnly = false, propagation = Propagation.SUPPORTS)
public <T> void writeParameterBean(T parameterBean) {
    LOGGER.debug("Writing parameters for bean:" + parameterBean);
    try {/*from  www.j av a  2 s.  co  m*/
        for (Field field : this.getSupportedFields(parameterBean.getClass())) {
            // find getter for field;
            for (Method method : parameterBean.getClass().getMethods()) {
                if (method.getName().startsWith("set")
                        && method.getName().toLowerCase().endsWith(field.getName().toLowerCase())) {
                    // save value to repository
                    field.setAccessible(true);
                    Metadata metadata = this.parameterResolver.parse(method, null);
                    if (metadata.isQualified()) {
                        //TODO: If the parameter is qualified get the Map and save all values to the repository
                        throw new UnsupportedOperationException(
                                "Saving of parameter beans with @ParameterQualifier annotation is not yet supported");
                    }
                    this.parameterService.write(metadata, field.get(parameterBean));
                    field.setAccessible(false);
                }
            }
        }
    } catch (Exception e) {
        LOGGER.error("Error happened while writing parameter bean:" + parameterBean + "." + e, e);
        throw new ParameterException("Error happened while writing parameter bean:" + parameterBean + "." + e,
                e);
    }
}

From source file:org.jrecruiter.service.impl.UserServiceImpl.java

/** {@inheritDoc} */
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public List<User> getAllUsers() {

    return userDao.getAllUsers();
}

From source file:es.upm.fiware.rss.expenditureLimit.manager.test.ExpenditureLimitDataCheckerTest.java

/**
 * /*from  ww  w .  j a v  a 2  s . c  om*/
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void checkElTypeTest() throws RSSException {
    ExpenditureLimitDataCheckerTest.logger.debug("Into checkElTypeTest mehtod");
    thrown.expect(RSSException.class);
    thrown.expectMessage("eltype Not found.");
    checker.checkElType("monthly");
    ExpenditureLimitDataCheckerTest.logger.debug("No exception expected");
    checker.checkElType("bbb");
}

From source file:es.upm.fiware.rss.expenditureLimit.dao.impl.tests.DbeExpendControlDaoTest.java

@Transactional(propagation = Propagation.SUPPORTS)
public void testNewExpendLimitDataForaUser() {

    BmCurrency bmCurrency = new BmCurrency();
    bmCurrency.setNuCurrencyId(1);/*  ww w  .j a  v  a 2 s.c o m*/

    List<DbeExpendControl> l = expLimitDao.getExpendDataForUserAppProvCurrency("userId01", "agg123",
            "app123456", bmCurrency);

    Assert.assertTrue("Elements found before " + l.toString(), l != null && l.size() == 3);
    Iterator<DbeExpendControl> it = l.iterator();

    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(Propagation.REQUIRES_NEW.value());
    TransactionStatus status = transactionManager.getTransaction(def);

    while (it.hasNext()) {
        DbeExpendControl el = it.next();
        DbeExpendControl neoEc = new DbeExpendControl();
        neoEc.setId(new DbeExpendLimitPK());
        neoEc.getId().setTxAppProviderId("123456");
        neoEc.getId().setTxElType(el.getId().getTxElType());
        neoEc.getId().setTxEndUserId("userId101");
        neoEc.setDtNextPeriodStart(el.getDtNextPeriodStart());
        neoEc.setTxNotifications(el.getTxNotifications());
        neoEc.setFtExpensedAmount(el.getFtExpensedAmount());
        expLimitDao.saveDbeExpendControl(neoEc);
    }

    transactionManager.commit(status);

    List<DbeExpendControl> l1 = expLimitDao.getExpendDataForUserAppProvCurrency("userId101", "agg123", "123456",
            bmCurrency);

    Assert.assertTrue("Elements found after " + l.toString() + " " + l1.toString(), l != null && l.size() == 3);
    it = l1.iterator();
    while (it.hasNext()) {
        DbeExpendControl el = it.next();
        if (!el.getId().getTxAppProviderId().equalsIgnoreCase("123456")) {
            Assert.fail("Application provider invalid: " + el.getId().getTxAppProviderId());
        }
        if (!el.getId().getTxEndUserId().equalsIgnoreCase("userId101")) {
            Assert.fail("User invalid: " + el.getId().getTxEndUserId());
        }
    }
}

From source file:com.brienwheeler.svc.usergroups.impl.UserGroupService.java

@Override
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
@MonitoredWork//from  w w  w.  ja  v  a 2 s  .  c  o m
@GracefulShutdown
public List<User> getUsersForGroup(UserGroup userGroup) {
    DbValidationUtils.assertPersisted(userGroup);

    List<UserGroupMember> groupMemberList = userGroupMemberDao.findForGroup(userGroup);
    ArrayList<User> userList = new ArrayList<User>(groupMemberList.size());
    for (UserGroupMember groupMember : groupMemberList)
        userList.add(groupMember.getUser());
    return userList;
}

From source file:es.upm.fiware.rss.expenditureLimit.manager.test.ExpenditureLimitManagerTest.java

/**
 * //www  .j  a v  a  2 s.co m
 */
@Transactional(propagation = Propagation.SUPPORTS)
public void deleteGeneralProviderExpLimits() throws RSSException {
    ExpenditureLimitManagerTest.logger.debug("Into deleteGeneralProviderExpLimits method");
    elManager.deleteProviderLimits(aggregator, appProvider, service, currency, type);
    ExpenditureLimitManagerTest.logger.debug("No exception produced");
}

From source file:org.brekka.phalanx.core.services.impl.AsymmetricCryptoServiceImpl.java

@Override
@Transactional(propagation = Propagation.SUPPORTS)
public PrivateKeyToken decrypt(AsymmetricKeyPair keyPair, final String password) {
    // Resolve the key pair from persistent storage (could just be id)
    keyPair = this.asymetricKeyPairDAO.retrieveById(keyPair.getId());

    CryptoData privateKey = keyPair.getPrivateKey();
    if (privateKey instanceof PasswordedCryptoData == false) {
        throw new PhalanxException(PhalanxErrorCode.CP209,
                "Key pair '%s' private key is not password protected", keyPair.getId());
    }//from w  w w  . j  a v  a  2s . c o m
    PasswordedCryptoData passwordedCryptoData = (PasswordedCryptoData) privateKey;
    InternalSecretKeyToken secretKeyToken = this.passwordBasedCryptoService.decrypt(passwordedCryptoData,
            password, InternalSecretKeyToken.class);
    return symDecryptForPrivateKey(secretKeyToken, keyPair);
}