Search in sources :

Example 1 with MemberType

use of org.orcid.jaxb.model.clientgroup.MemberType in project ORCID-Source by ORCID.

the class ResultContainer method retrieveGroupTypes.

@ModelAttribute("groupTypes")
public Map<String, String> retrieveGroupTypes() {
    MemberType[] groupTypes = MemberType.values();
    Map<String, String> groupTypesMap = new TreeMap<String, String>();
    for (MemberType groupType : groupTypes) {
        if (MemberType.BASIC_INSTITUTION.equals(groupType) || MemberType.PREMIUM_INSTITUTION.equals(groupType)) {
            continue;
        }
        String key = groupType.value();
        String value = key.replace('-', ' ');
        groupTypesMap.put(key, value);
    }
    return groupTypesMap;
}
Also used : MemberType(org.orcid.jaxb.model.clientgroup.MemberType) TreeMap(java.util.TreeMap) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 2 with MemberType

use of org.orcid.jaxb.model.clientgroup.MemberType in project ORCID-Source by ORCID.

the class CustomEmailController method manageDeveloperTools.

@RequestMapping
public ModelAndView manageDeveloperTools(@RequestParam("clientId") String clientId) {
    ModelAndView mav = new ModelAndView("custom_emails");
    boolean haveErrors = false;
    String groupId = getEffectiveUserOrcid();
    MemberType groupType = profileEntityManager.getGroupType(groupId);
    if (!(MemberType.PREMIUM_INSTITUTION.equals(groupType) || MemberType.BASIC_INSTITUTION.equals(groupType))) {
        haveErrors = true;
        mav.addObject("invalid_request", getMessage("manage.developer_tools.group.custom_emails.invalid_group_type"));
    } else if (!clientDetailsManager.exists(clientId)) {
        haveErrors = true;
        mav.addObject("invalid_request", getMessage("manage.developer_tools.group.custom_emails.invalid_client_id"));
    } else if (!clientDetailsManager.belongsTo(clientId, groupId)) {
        haveErrors = true;
        mav.addObject("invalid_request", getMessage("manage.developer_tools.group.custom_emails.not_your_client"));
    }
    if (!haveErrors) {
        mav.addObject("client_id", clientId);
    }
    return mav;
}
Also used : MemberType(org.orcid.jaxb.model.clientgroup.MemberType) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MemberType

use of org.orcid.jaxb.model.clientgroup.MemberType 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);
                Set<Client> clients = clientManagerReadOnly.getClients(orcid);
                List<org.orcid.pojo.ajaxForm.Client> clientsList = new ArrayList<org.orcid.pojo.ajaxForm.Client>();
                clients.forEach(c -> {
                    clientsList.add(org.orcid.pojo.ajaxForm.Client.fromModelObject(c));
                });
                member.setClients(clientsList);
            } 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 : ArrayList(java.util.ArrayList) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) MemberType(org.orcid.jaxb.model.clientgroup.MemberType) Client(org.orcid.jaxb.model.v3.dev1.client.Client) Member(org.orcid.pojo.ajaxForm.Member) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with MemberType

use of org.orcid.jaxb.model.clientgroup.MemberType in project ORCID-Source by ORCID.

the class MembersManagerImpl method updateMemeber.

@Override
public Member updateMemeber(Member member) throws IllegalArgumentException {
    String memberId = member.getGroupOrcid().getValue();
    String name = member.getGroupName().getValue();
    String email = member.getEmail().getValue();
    String salesForceId = member.getSalesforceId() == null ? null : member.getSalesforceId().getValue();
    MemberType memberType = MemberType.fromValue(member.getType().getValue());
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {

        protected void doInTransactionWithoutResult(TransactionStatus status) {
            boolean memberChangedType = false;
            ProfileEntity memberEntity = profileDao.find(member.getGroupOrcid().getValue());
            memberEntity.setLastModified(new Date());
            memberEntity.setIndexingStatus(IndexingStatus.PENDING);
            memberEntity.getRecordNameEntity().setCreditName(name);
            memberEntity.setSalesforeId(salesForceId);
            if (!memberType.equals(memberEntity.getGroupType())) {
                memberEntity.setGroupType(memberType);
                memberChangedType = true;
            }
            EmailEntity primaryEmail = memberEntity.getPrimaryEmail();
            if (!email.equals(primaryEmail.getId())) {
                if (emailManager.emailExists(email)) {
                    throw new IllegalArgumentException("Email already exists");
                }
                Date now = new Date();
                EmailEntity newPrimaryEmail = new EmailEntity();
                newPrimaryEmail.setLastModified(now);
                newPrimaryEmail.setDateCreated(now);
                newPrimaryEmail.setCurrent(true);
                newPrimaryEmail.setId(email);
                newPrimaryEmail.setPrimary(true);
                newPrimaryEmail.setVerified(true);
                newPrimaryEmail.setVisibility(Visibility.PRIVATE);
                memberEntity.setPrimaryEmail(newPrimaryEmail);
            }
            profileDao.merge(memberEntity);
            if (memberChangedType) {
                updateClientTypeDueMemberTypeUpdate(memberId, memberType);
            }
        }
    });
    clearCache();
    return member;
}
Also used : MemberType(org.orcid.jaxb.model.clientgroup.MemberType) TransactionStatus(org.springframework.transaction.TransactionStatus) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Date(java.util.Date)

Example 5 with MemberType

use of org.orcid.jaxb.model.clientgroup.MemberType in project ORCID-Source by ORCID.

the class CustomEmailController method getCustomEmails.

@RequestMapping(value = "/get.json", method = RequestMethod.GET)
@ResponseBody
public List<CustomEmailForm> getCustomEmails(@RequestParam("clientId") String clientId) throws IllegalArgumentException {
    List<CustomEmailForm> result = new ArrayList<CustomEmailForm>();
    boolean haveErrors = false;
    String groupId = getEffectiveUserOrcid();
    MemberType groupType = profileEntityManager.getGroupType(groupId);
    if (!(MemberType.PREMIUM_INSTITUTION.equals(groupType) || MemberType.BASIC_INSTITUTION.equals(groupType))) {
        haveErrors = true;
    } else if (!clientDetailsManager.exists(clientId)) {
        haveErrors = true;
    } else if (!clientDetailsManager.belongsTo(clientId, groupId)) {
        haveErrors = true;
    }
    if (!haveErrors) {
        List<CustomEmailEntity> customEmails = customEmailManager.getCustomEmails(clientId);
        for (CustomEmailEntity entity : customEmails) {
            CustomEmailForm form = CustomEmailForm.valueOf(entity);
            result.add(form);
        }
    }
    return result;
}
Also used : MemberType(org.orcid.jaxb.model.clientgroup.MemberType) CustomEmailEntity(org.orcid.persistence.jpa.entities.CustomEmailEntity) ArrayList(java.util.ArrayList) CustomEmailForm(org.orcid.pojo.ajaxForm.CustomEmailForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

MemberType (org.orcid.jaxb.model.clientgroup.MemberType)8 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)5 ArrayList (java.util.ArrayList)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 Date (java.util.Date)2 EmailEntity (org.orcid.persistence.jpa.entities.EmailEntity)2 Member (org.orcid.pojo.ajaxForm.Member)2 TransactionStatus (org.springframework.transaction.TransactionStatus)2 Transactional (org.springframework.transaction.annotation.Transactional)2 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 TreeMap (java.util.TreeMap)1 Client (org.orcid.jaxb.model.client_v2.Client)1 Client (org.orcid.jaxb.model.v3.dev1.client.Client)1 CustomEmailEntity (org.orcid.persistence.jpa.entities.CustomEmailEntity)1 Client (org.orcid.pojo.ajaxForm.Client)1 CustomEmailForm (org.orcid.pojo.ajaxForm.CustomEmailForm)1 ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1