Search in sources :

Example 56 with Transactional

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);
}
Also used : InitiativeTransfer(org.collectiveone.modules.tokens.InitiativeTransfer) Timestamp(java.sql.Timestamp) Transactional(javax.transaction.Transactional)

Example 57 with Transactional

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;
}
Also used : User(com.auth0.json.mgmt.users.User) APIException(com.auth0.exception.APIException) Auth0Exception(com.auth0.exception.Auth0Exception) Transactional(javax.transaction.Transactional)

Example 58 with Transactional

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;
}
Also used : User(com.auth0.json.mgmt.users.User) APIException(com.auth0.exception.APIException) Auth0Exception(com.auth0.exception.Auth0Exception) Transactional(javax.transaction.Transactional)

Example 59 with Transactional

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();
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Test(org.junit.Test) AbstractServiceComponentAgentFunctionalIntegrationTest(com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest) Transactional(javax.transaction.Transactional)

Example 60 with Transactional

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();
}
Also used : ObjectMessage(javax.jms.ObjectMessage) Test(org.junit.Test) AbstractServiceComponentAgentFunctionalIntegrationTest(com.hack23.cia.service.component.agent.impl.AbstractServiceComponentAgentFunctionalIntegrationTest) Transactional(javax.transaction.Transactional)

Aggregations

Transactional (javax.transaction.Transactional)299 Test (org.junit.Test)99 PostResult (org.collectiveone.common.dto.PostResult)29 ArrayList (java.util.ArrayList)24 UserDO (org.neusoft.neubbs.entity.UserDO)21 Timestamp (java.sql.Timestamp)18 TopicDO (org.neusoft.neubbs.entity.TopicDO)18 Initiative (org.collectiveone.modules.initiatives.Initiative)16 GetResult (org.collectiveone.common.dto.GetResult)15 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)13 TopicReplyDO (org.neusoft.neubbs.entity.TopicReplyDO)13 HashMap (java.util.HashMap)12 Date (java.util.Date)11 AppUser (org.collectiveone.modules.users.AppUser)11 UUID (java.util.UUID)10 RolesAllowed (javax.annotation.security.RolesAllowed)10 PeerReviewedAssignation (org.collectiveone.modules.assignations.evaluationlogic.PeerReviewedAssignation)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 IOException (java.io.IOException)9 TopicContentDO (org.neusoft.neubbs.entity.TopicContentDO)9