use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class ActivityService method newSubinitiativeCreated.
@Transactional
public void newSubinitiativeCreated(Initiative initiative, AppUser triggerUser, Initiative subinitiative, List<InitiativeTransfer> transfers) {
Activity activity = new Activity();
activity.setType(ActivityType.SUBINITIATIVE_CREATED);
activity.setTriggerUser(triggerUser);
activity.setInitiative(initiative);
activity.setTimestamp(new Timestamp(System.currentTimeMillis()));
activity.setSubInitiative(subinitiative);
for (InitiativeTransfer transfer : transfers) {
activity.getInitiativeTransfers().add(transfer);
}
activity = activityRepository.save(activity);
addInitiativeActivityNotifications(activity);
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class AppUserService method updateUserDataInLocalDB.
@Transactional
public Boolean updateUserDataInLocalDB(UUID c1Id) {
AppUser appUser = appUserRepository.findByC1Id(c1Id);
try {
User auth0User = mgmt.users().get(appUser.getAuth0Ids().get(0), null).execute();
appUser.getProfile().setPictureUrl(auth0User.getPicture());
appUserRepository.save(appUser);
return true;
} catch (APIException exception) {
System.out.println(exception.getMessage());
} catch (Auth0Exception exception) {
System.out.println(exception.getMessage());
}
return false;
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class AppUserService method addUserToLocalDB.
@Transactional
private AppUser addUserToLocalDB(String auth0Id) {
/* retrieve from Auth0 */
AppUser appUser = null;
User auth0User = null;
if (auth0Id.equals("anonymousUser")) {
return null;
}
try {
auth0User = mgmt.users().get(auth0Id, null).execute();
/* check if this email is already registered. */
appUser = appUserRepository.findByEmail(auth0User.getEmail());
if (appUser == null) {
// if (auth0User.isEmailVerified()) {
if (true) {
/* create a new user if not */
appUser = new AppUser();
appUser.getAuth0Ids().add((auth0User.getId()));
appUser.setEmail(auth0User.getEmail());
appUser.setEmailNotificationsEnabled(true);
AppUserProfile profile = new AppUserProfile();
if (auth0User.getIdentities().get(0).getProvider().equals("auth0")) {
profile.setNickname(auth0User.getNickname());
} else {
profile.setNickname(auth0User.getName());
}
profile.setUser(appUser);
profile.setPictureUrl(auth0User.getPicture());
profile = appUserProfileRepository.save(profile);
appUser.setProfile(profile);
}
} else {
/* just add the auth0id to the existing user */
appUser.getAuth0Ids().add(auth0Id);
}
appUser = appUserRepository.save(appUser);
} catch (APIException exception) {
System.out.println(exception.getMessage());
} catch (Auth0Exception exception) {
System.out.println(exception.getMessage());
}
return appUser;
}
use of javax.transaction.Transactional in project cia by Hack23.
the class RiksdagenApiAgentWorkConsumerImplITest method onMessageSuccessTest.
/**
* On message success test.
*
* @throws JMSException
* the JMS exception
*/
@Test
@Transactional
public void onMessageSuccessTest() throws JMSException {
final ObjectMessage message = mock(ObjectMessage.class);
when(message.getObject()).thenReturn(RiksdagenDataSources.PERSONS);
messsageListener.onMessage(message);
verify(message, atLeastOnce()).getObject();
}
use of javax.transaction.Transactional in project cia by Hack23.
the class RiksdagenCommitteeProposalComponentDataWorkConsumerImplITest method onMessageSuccessTest.
/**
* On message success test.
*
* @throws JMSException
* the JMS exception
*/
@Test
@Transactional
public void onMessageSuccessTest() throws JMSException {
final ObjectMessage message = mock(ObjectMessage.class);
final Set<String> keySet = riksdagenImportService.getCommitteeProposalComponentDataMap().keySet();
when(message.getObject()).thenReturn(keySet.iterator().next());
messsageListener.onMessage(message);
verify(message, atLeastOnce()).getObject();
}
Aggregations