Search in sources :

Example 1 with SimplifiedUser

use of org.broadinstitute.consent.http.service.UserService.SimplifiedUser in project consent by DataBiosphere.

the class InstitutionWithUsersReducer method accumulate.

@Override
public void accumulate(Map<Integer, Institution> map, RowView rowView) {
    Institution institution = map.computeIfAbsent(rowView.getColumn("institution_id", Integer.class), id -> rowView.getRow(Institution.class));
    User create_user = new User();
    if (Objects.nonNull(rowView.getColumn("u_dacuserid", Integer.class))) {
        create_user = rowView.getRow(User.class);
    }
    User update_user = new User();
    update_user.setDacUserId(rowView.getColumn("u2_dacuserid", Integer.class));
    update_user.setEmail(rowView.getColumn("u2_email", String.class));
    update_user.setDisplayName(rowView.getColumn("u2_displayname", String.class));
    update_user.setCreateDate(rowView.getColumn("u2_createdate", Timestamp.class));
    update_user.setAdditionalEmail(rowView.getColumn("u2_additional_email", String.class));
    update_user.setEmailPreference(rowView.getColumn("u2_email_preference", Boolean.class));
    update_user.setEraCommonsId(rowView.getColumn("u2_era_commons_id", String.class));
    institution.setCreateUser(create_user);
    institution.setUpdateUser(update_user);
    if (Objects.nonNull(rowView.getColumn("so_dacuserid", Integer.class))) {
        SimplifiedUser so_user = new SimplifiedUser();
        so_user = rowView.getRow(SimplifiedUser.class);
        institution.addSigningOfficial(so_user);
    }
}
Also used : SimplifiedUser(org.broadinstitute.consent.http.service.UserService.SimplifiedUser) User(org.broadinstitute.consent.http.models.User) Institution(org.broadinstitute.consent.http.models.Institution) Timestamp(java.sql.Timestamp) SimplifiedUser(org.broadinstitute.consent.http.service.UserService.SimplifiedUser)

Example 2 with SimplifiedUser

use of org.broadinstitute.consent.http.service.UserService.SimplifiedUser in project consent by DataBiosphere.

the class UserServiceTest method testFindSOsByInstitutionId.

@Test
public void testFindSOsByInstitutionId() {
    User u = generateUser();
    Integer institutionId = u.getInstitutionId();
    when(userDAO.getSOsByInstitution(any())).thenReturn(List.of(u, u, u));
    initService();
    List<SimplifiedUser> users = service.findSOsByInstitutionId(institutionId);
    assertEquals(3, users.size());
    assertEquals(u.getDisplayName(), users.get(0).displayName);
    assertEquals(u.getEmail(), users.get(0).email);
}
Also used : AuthUser(org.broadinstitute.consent.http.models.AuthUser) User(org.broadinstitute.consent.http.models.User) SimplifiedUser(org.broadinstitute.consent.http.service.UserService.SimplifiedUser) SimplifiedUser(org.broadinstitute.consent.http.service.UserService.SimplifiedUser) Test(org.junit.Test)

Aggregations

User (org.broadinstitute.consent.http.models.User)2 SimplifiedUser (org.broadinstitute.consent.http.service.UserService.SimplifiedUser)2 Timestamp (java.sql.Timestamp)1 AuthUser (org.broadinstitute.consent.http.models.AuthUser)1 Institution (org.broadinstitute.consent.http.models.Institution)1 Test (org.junit.Test)1