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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations