Search in sources :

Example 11 with Member

use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.

the class ManageMembersControllerTest method editMemberTest.

@Test
public void editMemberTest() throws Exception {
    Member group = new Member();
    group.setEmail(Text.valueOf("group@email.com"));
    group.setGroupName(Text.valueOf("Group Name"));
    group.setType(Text.valueOf("premium-institution"));
    group.setSalesforceId(Text.valueOf("1234567890abcde"));
    group = manageMembers.createMember(group);
    assertEquals(0, group.getErrors().size());
    assertFalse(PojoUtil.isEmpty(group.getGroupOrcid()));
    group.setEmail(Text.valueOf("new_email@user.com"));
    group.setSalesforceId(Text.valueOf(""));
    group.setGroupName(Text.valueOf("Updated Group Name"));
    manageMembers.updateMember(group);
    Member updatedGroup = manageMembers.findMember(group.getGroupOrcid().getValue());
    assertNotNull(updatedGroup);
    assertEquals(group.getGroupOrcid().getValue(), updatedGroup.getGroupOrcid().getValue());
    assertEquals("Updated Group Name", updatedGroup.getGroupName().getValue());
}
Also used : Member(org.orcid.pojo.ajaxForm.Member) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 12 with Member

use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.

the class ManageMembersControllerTest method createMemberProfileTest.

@Test
public void createMemberProfileTest() throws Exception {
    Member group = new Member();
    group.setEmail(Text.valueOf("group@email.com"));
    group.setGroupName(Text.valueOf("Group Name"));
    group.setType(Text.valueOf("premium-institution"));
    group.setSalesforceId(Text.valueOf(""));
    group = manageMembers.createMember(group);
    assertEquals(0, group.getErrors().size());
    assertFalse(PojoUtil.isEmpty(group.getGroupOrcid()));
}
Also used : Member(org.orcid.pojo.ajaxForm.Member) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 13 with Member

use of org.orcid.pojo.ajaxForm.Member in project ORCID-Source by ORCID.

the class MembersManagerImpl method getMember.

@Override
@Transactional
public Member getMember(String memberId) {
    Member member = new Member();
    String orcid = memberId;
    if (!OrcidStringUtils.isValidOrcid(memberId)) {
        Map<String, String> ids = emailManager.findOricdIdsByCommaSeparatedEmails(memberId);
        //Check if it is using the email
        if (ids != null && ids.containsKey(memberId)) {
            orcid = ids.get(memberId);
        } else {
            //Check if can find it by name
            try {
                orcid = profileEntityManager.findByCreditName(memberId);
            } catch (Exception e) {
                member.getErrors().add(getMessage("manage_member.email_not_found"));
                orcid = null;
            }
        }
    }
    if (PojoUtil.isEmpty(orcid)) {
        member.getErrors().add(getMessage("manage_member.email_not_found"));
    } else {
        if (profileEntityManager.orcidExists(orcid)) {
            MemberType groupType = profileEntityManager.getGroupType(orcid);
            if (groupType != null) {
                ProfileEntity memberProfile = profileDao.find(orcid);
                member = Member.fromProfileEntity(memberProfile);
                List<ClientDetailsEntity> clients = clientDetailsManager.findByGroupId(orcid);
                member.setClients(Client.valueOf(clients));
            } else {
                member.getErrors().add(getMessage("manage_members.orcid_is_not_a_member"));
            }
        } else {
            member.getErrors().add(getMessage("manage_members.orcid_doesnt_exists"));
        }
    }
    return member;
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) MemberType(org.orcid.jaxb.model.clientgroup.MemberType) Member(org.orcid.pojo.ajaxForm.Member) OrcidClientGroupManagementException(org.orcid.core.exception.OrcidClientGroupManagementException) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Member (org.orcid.pojo.ajaxForm.Member)13 Test (org.junit.Test)10 DBUnitTest (org.orcid.test.DBUnitTest)10 ArrayList (java.util.ArrayList)6 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)2 OrcidClientGroupManagementException (org.orcid.core.exception.OrcidClientGroupManagementException)1 MemberInfo (org.orcid.internal.util.MemberInfo)1 MemberType (org.orcid.jaxb.model.clientgroup.MemberType)1 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)1 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)1 Text (org.orcid.pojo.ajaxForm.Text)1 Transactional (org.springframework.transaction.annotation.Transactional)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1