List of usage examples for org.springframework.transaction.support TransactionCallbackWithoutResult TransactionCallbackWithoutResult
TransactionCallbackWithoutResult
From source file:ro.nextreports.server.security.ExternalAuthenticationProvider.java
protected void createUser(final User user) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Creating new user '%s' for %s", user.getUsername(), realm)); }/* w ww. j a v a2s . co m*/ transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) { try { user.setCreatedBy("synchronizer"); String id = storageDao.addEntity(user); user.setId(id); } catch (DuplicationException e) { // never happening throw new RuntimeException(e); } } }); }
From source file:ro.nextreports.server.security.ExternalAuthenticationProvider.java
protected void updateUser(final User user) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override//w ww . j a v a 2 s . c o m protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) { try { User nextUser = (User) storageDao.getEntity(user.getPath()); user.setId(nextUser.getId()); if (!isEquals(nextUser, user)) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Updating user '%s' for %s", user.getUsername(), realm)); } user.setCreatedBy(nextUser.getCreatedBy()); user.setCreatedDate(nextUser.getCreatedDate()); user.setLastUpdatedBy("synchronizer"); storageDao.modifyEntity(user); } } catch (NotFoundException e) { // never happening throw new RuntimeException(e); } } }); }
From source file:ro.nextreports.server.security.ExternalAuthenticationProvider.java
protected void deleteAsyncUsers(final List<String> realmUserNames) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override//from w w w.j ava2 s . c o m protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) { // TODO improve performance try { Entity[] users = storageDao.getEntityChildren(StorageConstants.USERS_ROOT); for (int i = 0; i < users.length; i++) { User user = (User) users[i]; if (realm.equals(user.getRealm()) && !realmUserNames .contains(StringUtils.removeEnd(user.getUsername(), "@" + realm))) { if (LOG.isDebugEnabled()) { LOG.debug(String.format("Deleting async user '%s' for %s", user.getUsername(), realm)); } storageDao.removeEntityById(user.getId()); } } } catch (NotFoundException e) { // never happening throw new RuntimeException(e); } } }); }
From source file:ro.nextreports.server.security.ExternalAuthenticationProvider.java
protected void updateUserGroups(final String username, final List<String> groupNames) { final String internalUsername = username + "@" + realm; transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override/*from ww w . j av a 2 s. c o m*/ protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) { // TODO improve performance try { for (String groupName : groupNames) { if (!groupExists(groupName)) { // create group and add the user as memeber Group group = new Group(groupName, getGroupNamePath(groupName)); group.setCreatedBy("synchronizer"); LOG.debug("Create group '" + groupName + "'"); group.addMember(internalUsername); LOG.debug("Add '" + internalUsername + "' as member of '" + groupName + "'"); storageDao.addEntity(group); } else { Group group = (Group) storageDao.getEntity(getGroupNamePath(groupName)); if (!group.isMember(internalUsername)) { group.addMember(internalUsername); LOG.debug("Add '" + internalUsername + "' as member of '" + groupName + "'"); group.setLastUpdatedBy("synchronizer"); storageDao.modifyEntity(group); } } } } catch (DuplicationException e) { // never happening throw new RuntimeException(e); } catch (NotFoundException e) { // never happening throw new RuntimeException(e); } } }); }
From source file:ubc.pavlab.aspiredb.server.dao.CNVDaoTest.java
@Before public void createIndividualAndCNVs() { TransactionTemplate tt = new TransactionTemplate(transactionManager); tt.execute(new TransactionCallbackWithoutResult() { @Override/* w w w . j av a2 s. co m*/ public void doInTransactionWithoutResult(TransactionStatus status) { individual = new Subject(); String patientId = "test_patient"; individual.setPatientId(patientId); GenomicLocation genomicLocation1 = new GenomicLocation("40", 5050000, 5450000); cnv1 = new CNV(); cnv1.setLocation(genomicLocation1); cnv1.setCopyNumber(1); cnv1.setType(CnvType.valueOf("LOSS")); cnvDao.create(cnv1); individual.addVariant(cnv1); Phenotype ph = new Phenotype(); ph.setName("Test Phenotype"); ph.setValue("1234"); individual.addPhenotype(ph); individualDao.create(individual); } }); }
From source file:ubc.pavlab.aspiredb.server.dao.CNVDaoTest.java
@Test public void testCreate() { TransactionTemplate tt = new TransactionTemplate(transactionManager); tt.execute(new TransactionCallbackWithoutResult() { @Override/*from ww w. j ava 2s .com*/ public void doInTransactionWithoutResult(TransactionStatus status) { // Just a stub to test the plumbing. CNV cnv = new CNV(); cnvDao.create(cnv); } }); }
From source file:ubc.pavlab.aspiredb.server.dao.IndelDaoTest.java
@Before public void createIndividualAndIndels() { TransactionTemplate tt = new TransactionTemplate(transactionManager); tt.execute(new TransactionCallbackWithoutResult() { @Override//from w ww.ja va 2 s. c o m public void doInTransactionWithoutResult(TransactionStatus status) { individual = new Subject(); String patientId = "test_patient"; individual.setPatientId(patientId); Indel indel = testObjectHelper.createDetachedTestIndelObject(); indelDao.create(indel); individual.addVariant(indel); Phenotype ph = new Phenotype(); ph.setName("Test Phenotype"); ph.setValue("1234"); individual.addPhenotype(ph); individualDao.create(individual); } }); }
From source file:ubc.pavlab.aspiredb.server.dao.IndelDaoTest.java
@Test public void testCreate() { TransactionTemplate tt = new TransactionTemplate(transactionManager); tt.execute(new TransactionCallbackWithoutResult() { @Override//w w w . j ava 2 s. co m public void doInTransactionWithoutResult(TransactionStatus status) { // Just a stub to test the plumbing. Indel indel = new Indel(); indelDao.create(indel); } }); }
From source file:ubc.pavlab.aspiredb.server.dao.SNVDaoTest.java
@Test public void testCreate() { TransactionTemplate tt = new TransactionTemplate(transactionManager); tt.execute(new TransactionCallbackWithoutResult() { @Override/*from ww w . j av a 2 s . co m*/ public void doInTransactionWithoutResult(TransactionStatus status) { // Just a stub to test the plumbing. testObjectHelper.createPersistentTestSNVObject(); } }); }
From source file:ubc.pavlab.aspiredb.server.dao.SubjectDaoTest.java
public void testCreateAndFindByPatientId() throws Exception { TransactionTemplate tt = new TransactionTemplate(transactionManager); tt.execute(new TransactionCallbackWithoutResult() { @Override/*from w w w. ja v a2 s . c o m*/ public void doInTransactionWithoutResult(TransactionStatus status) { Project p1 = new Project(); p1.setName(project1Name); p1 = testObjectHelper.createPersistentProject(p1); assertNull("Subject hasn't been created yet", subjectDao.findByPatientId(p1, patientId)); // List<Project> projects = new ArrayList<>(); // projects.add( p1 ); Subject s = new Subject(); s.setPatientId(patientId); s.setProject(p1); s = subjectDao.create(s); assertNotNull(s); assertNotNull("Subject should have been created", subjectDao.findByPatientId(p1, patientId)); } }); }