public int anonymizeHelperAddresses() { SessionHolder sessionHolder = SessionManager.getInstance().registerSession(this, null); try { sessionHolder.beginTransaction(); Query qry = sessionHolder.createQuery( "UPDATE " + Helper.class.getSimpleName() + " SET " + Helper.ATTR_MAIL_ADDRESS + " = :address WHERE " + Helper.ATTR_MAIL_ADDRESS + " IS NOT NULL AND " + Helper.ATTR_MAIL_ADDRESS + " <> ''"); qry.setParameter( "address", AppConfiguration.getInstance() .getConfigurationValue(AppConfigurationValues.PROCESS_TEST_MAIL)); int rows = qry.executeUpdate(); sessionHolder.commitTransaction(); return rows; } catch (Exception e) { sessionHolder.rollbackTransaction(); ; throw new ResourcePlanningException( "helper addresses could not be anonymized : " + e.getMessage()); } finally { SessionManager.getInstance().unregisterSession(sessionHolder); } }
private void createSomePersonAndSimpleEvents() { SessionHolder sessionHolder = SessionManager.getInstance().registerSession(this, null); try { sessionHolder.beginTransaction(); createSimpleEvent(sessionHolder, "some simple event", new Date(), "sse-123"); createPerson(sessionHolder, "Hanke", "Jan", "*****@*****.**", new Date()); sessionHolder.commitTransaction(); } catch (Exception e) { sessionHolder.rollbackTransaction(); throw new ResourcePlanningException( "helper addresses could not be anonymized : " + e.getMessage()); } finally { SessionManager.getInstance().unregisterSession(sessionHolder); } }
private void createSimpleEvent( SessionHolder sessionHolder, String description, Date eventDate, String eventKey) { SimpleEvent simpleEvent = new SimpleEvent(); simpleEvent.setDescription(description); simpleEvent.setEventDate(eventDate); simpleEvent.setEventKey(eventKey); sessionHolder.saveOrUpdate(simpleEvent); }
private void createPerson( SessionHolder sessionHolder, String lastName, String firstName, String email, Date dateOfBirth) { Person person = new Person(); person.setFirstName(firstName); person.setLastName(lastName); person.setEmail(email); person.setDateOfBirth(dateOfBirth); sessionHolder.saveOrUpdate(person); }