use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class OrcidInfo method publicPreview.
@RequestMapping(value = { "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}", "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/print" })
public ModelAndView publicPreview(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "page", defaultValue = "1") int pageNo, @RequestParam(value = "v", defaultValue = "0") int v, @RequestParam(value = "maxResults", defaultValue = "15") int maxResults, @PathVariable("orcid") String orcid) {
ProfileEntity profile = null;
try {
profile = profileEntityCacheManager.retrieve(orcid);
} catch (Exception e) {
response.setStatus(HttpStatus.NOT_FOUND.value());
return new ModelAndView("error-404");
}
try {
// Check if the profile is deprecated, non claimed or locked
orcidSecurityManager.checkProfile(orcid);
} catch (OrcidDeprecatedException | OrcidNotClaimedException | LockedException | DeactivatedException e) {
ModelAndView mav = new ModelAndView("public_profile_unavailable");
mav.addObject("effectiveUserOrcid", orcid);
String displayName = "";
if (e instanceof OrcidDeprecatedException) {
PersonalDetails publicPersonalDetails = personalDetailsManager.getPublicPersonalDetails(orcid);
if (publicPersonalDetails.getName() != null) {
Name name = publicPersonalDetails.getName();
if (name.getVisibility().equals(Visibility.PUBLIC)) {
if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
displayName = name.getCreditName().getContent();
} else {
if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
displayName = name.getGivenNames().getContent() + " ";
}
if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
displayName += name.getFamilyName().getContent();
}
}
}
}
mav.addObject("deprecated", true);
mav.addObject("primaryRecord", profile.getPrimaryRecord().getId());
} else if (e instanceof OrcidNotClaimedException) {
displayName = localeManager.resolveMessage("orcid.reserved_for_claim");
} else if (e instanceof LockedException) {
mav.addObject("locked", true);
mav.addObject("isPublicProfile", true);
displayName = localeManager.resolveMessage("public_profile.deactivated.given_names") + " " + localeManager.resolveMessage("public_profile.deactivated.family_name");
} else {
mav.addObject("deactivated", true);
displayName = localeManager.resolveMessage("public_profile.deactivated.given_names") + " " + localeManager.resolveMessage("public_profile.deactivated.family_name");
}
if (!PojoUtil.isEmpty(displayName)) {
mav.addObject("title", getMessage("layout.public-layout.title", displayName, orcid));
mav.addObject("displayName", displayName);
}
return mav;
}
long lastModifiedTime = getLastModifiedTime(orcid);
ModelAndView mav = null;
if (request.getRequestURI().contains("/print")) {
mav = new ModelAndView("print_public_record");
mav.addObject("hideUserVoiceScript", true);
} else {
mav = new ModelAndView("public_profile_v3");
}
mav.addObject("isPublicProfile", true);
mav.addObject("effectiveUserOrcid", orcid);
mav.addObject("lastModifiedTime", lastModifiedTime);
boolean isProfileEmtpy = true;
PersonalDetails publicPersonalDetails = personalDetailsManager.getPublicPersonalDetails(orcid);
// Fill personal details
if (publicPersonalDetails != null) {
// Get display name
String displayName = "";
if (publicPersonalDetails.getName() != null) {
Name name = publicPersonalDetails.getName();
if (name.getVisibility().equals(Visibility.PUBLIC)) {
if (name.getCreditName() != null && !PojoUtil.isEmpty(name.getCreditName().getContent())) {
displayName = name.getCreditName().getContent();
} else {
if (name.getGivenNames() != null && !PojoUtil.isEmpty(name.getGivenNames().getContent())) {
displayName = name.getGivenNames().getContent() + " ";
}
if (name.getFamilyName() != null && !PojoUtil.isEmpty(name.getFamilyName().getContent())) {
displayName += name.getFamilyName().getContent();
}
}
}
}
if (!PojoUtil.isEmpty(displayName)) {
// <Published Name> (<ORCID iD>) - ORCID | Connecting Research
// and Researchers
mav.addObject("title", getMessage("layout.public-layout.title", displayName.trim(), orcid));
mav.addObject("displayName", displayName);
}
// Get biography
if (publicPersonalDetails.getBiography() != null) {
Biography bio = publicPersonalDetails.getBiography();
if (Visibility.PUBLIC.equals(bio.getVisibility()) && !PojoUtil.isEmpty(bio.getContent())) {
isProfileEmtpy = false;
mav.addObject("biography", bio);
}
}
// Fill other names
OtherNames publicOtherNames = publicPersonalDetails.getOtherNames();
if (publicOtherNames != null && publicOtherNames.getOtherNames() != null) {
Iterator<OtherName> it = publicOtherNames.getOtherNames().iterator();
while (it.hasNext()) {
OtherName otherName = it.next();
if (!Visibility.PUBLIC.equals(otherName.getVisibility())) {
it.remove();
}
}
}
Map<String, List<OtherName>> groupedOtherNames = groupOtherNames(publicOtherNames);
mav.addObject("publicGroupedOtherNames", groupedOtherNames);
}
// Fill biography elements
// Fill country
Addresses publicAddresses = addressManager.getPublicAddresses(orcid);
Map<String, String> countryNames = new HashMap<String, String>();
if (publicAddresses != null && publicAddresses.getAddress() != null) {
Address publicAddress = null;
// The primary address will be the one with the lowest display index
for (Address address : publicAddresses.getAddress()) {
countryNames.put(address.getCountry().getValue().value(), getcountryName(address.getCountry().getValue().value()));
if (publicAddress == null) {
publicAddress = address;
}
}
if (publicAddress != null) {
mav.addObject("publicAddress", publicAddress);
mav.addObject("countryNames", countryNames);
Map<String, List<Address>> groupedAddresses = groupAddresses(publicAddresses);
mav.addObject("publicGroupedAddresses", groupedAddresses);
}
}
// Fill keywords
Keywords publicKeywords = keywordManager.getPublicKeywords(orcid);
Map<String, List<Keyword>> groupedKeywords = groupKeywords(publicKeywords);
mav.addObject("publicGroupedKeywords", groupedKeywords);
// Fill researcher urls
ResearcherUrls publicResearcherUrls = researcherUrlManager.getPublicResearcherUrls(orcid);
Map<String, List<ResearcherUrl>> groupedResearcherUrls = groupResearcherUrls(publicResearcherUrls);
mav.addObject("publicGroupedResearcherUrls", groupedResearcherUrls);
// Fill emails
Emails publicEmails = emailManager.getPublicEmails(orcid);
Map<String, List<Email>> groupedEmails = groupEmails(publicEmails);
mav.addObject("publicGroupedEmails", groupedEmails);
// Fill external identifiers
PersonExternalIdentifiers publicPersonExternalIdentifiers = externalIdentifierManager.getPublicExternalIdentifiers(orcid);
Map<String, List<PersonExternalIdentifier>> groupedExternalIdentifiers = groupExternalIdentifiers(publicPersonExternalIdentifiers);
mav.addObject("publicGroupedPersonExternalIdentifiers", groupedExternalIdentifiers);
LinkedHashMap<Long, Affiliation> affiliationMap = new LinkedHashMap<>();
LinkedHashMap<Long, Funding> fundingMap = new LinkedHashMap<>();
LinkedHashMap<Long, PeerReview> peerReviewMap = new LinkedHashMap<>();
if (worksPaginator.getPublicWorksCount(orcid) > 0) {
isProfileEmtpy = false;
}
affiliationMap = activityManager.affiliationMap(orcid);
if (affiliationMap.size() > 0) {
isProfileEmtpy = false;
} else {
mav.addObject("affiliationsEmpty", true);
}
fundingMap = activityManager.fundingMap(orcid);
if (fundingMap.size() > 0)
isProfileEmtpy = false;
else {
mav.addObject("fundingEmpty", true);
}
peerReviewMap = activityManager.pubPeerReviewsMap(orcid);
if (peerReviewMap.size() > 0) {
isProfileEmtpy = false;
} else {
mav.addObject("peerReviewsEmpty", true);
}
ObjectMapper mapper = new ObjectMapper();
try {
String affiliationIdsJson = mapper.writeValueAsString(affiliationMap.keySet());
String fundingIdsJson = mapper.writeValueAsString(fundingMap.keySet());
String peerReviewIdsJson = mapper.writeValueAsString(peerReviewMap.keySet());
mav.addObject("affiliationIdsJson", StringEscapeUtils.escapeEcmaScript(affiliationIdsJson));
mav.addObject("fundingIdsJson", StringEscapeUtils.escapeEcmaScript(fundingIdsJson));
mav.addObject("peerReviewIdsJson", StringEscapeUtils.escapeEcmaScript(peerReviewIdsJson));
mav.addObject("isProfileEmpty", isProfileEmtpy);
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (!profile.isReviewed()) {
if (isProfileValidForIndex(profile)) {
int countTokens = orcidOauth2TokenService.findCountByUserName(orcid, lastModifiedTime);
if (!profile.isAccountNonLocked() || countTokens == 0 || (!CreationMethod.WEBSITE.value().equals(profile.getCreationMethod()) && !CreationMethod.DIRECT.value().equals(profile.getCreationMethod()))) {
mav.addObject("noIndex", true);
}
} else {
mav.addObject("noIndex", true);
}
}
return mav;
}
use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class AffiliationsController method addAffiliation.
/**
* Adds a new affiliations
*
* @param affiliationForm
*/
private void addAffiliation(AffiliationForm affiliationForm) {
Affiliation affiliation = affiliationForm.toAffiliation();
if (affiliation instanceof Distinction) {
affiliation = affiliationsManager.createDistinctionAffiliation(getCurrentUserOrcid(), (Distinction) affiliation, false);
} else if (affiliation instanceof Education) {
affiliation = affiliationsManager.createEducationAffiliation(getCurrentUserOrcid(), (Education) affiliation, false);
} else if (affiliation instanceof Employment) {
affiliation = affiliationsManager.createEmploymentAffiliation(getCurrentUserOrcid(), (Employment) affiliation, false);
} else if (affiliation instanceof InvitedPosition) {
affiliation = affiliationsManager.createInvitedPositionAffiliation(getCurrentUserOrcid(), (InvitedPosition) affiliation, false);
} else if (affiliation instanceof Membership) {
affiliation = affiliationsManager.createMembershipAffiliation(getCurrentUserOrcid(), (Membership) affiliation, false);
} else if (affiliation instanceof Qualification) {
affiliation = affiliationsManager.createQualificationAffiliation(getCurrentUserOrcid(), (Qualification) affiliation, false);
} else if (affiliation instanceof Service) {
affiliation = affiliationsManager.createServiceAffiliation(getCurrentUserOrcid(), (Service) affiliation, false);
} else {
throw new IllegalArgumentException("Invalid affiliation type: " + affiliation.getClass().getName());
}
affiliationForm.setPutCode(Text.valueOf(affiliation.getPutCode()));
}
use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class AffiliationForm method toAffiliation.
public Affiliation toAffiliation() {
Affiliation affiliation = null;
if (AffiliationType.DISTINCTION.value().equals(affiliationType.getValue())) {
affiliation = new Distinction();
} else if (AffiliationType.EDUCATION.value().equals(affiliationType.getValue())) {
affiliation = new Education();
} else if (AffiliationType.EMPLOYMENT.value().equals(affiliationType.getValue())) {
affiliation = new Employment();
} else if (AffiliationType.INVITED_POSITION.value().equals(affiliationType.getValue())) {
affiliation = new InvitedPosition();
} else if (AffiliationType.MEMBERSHIP.value().equals(affiliationType.getValue())) {
affiliation = new Membership();
} else if (AffiliationType.QUALIFICATION.value().equals(affiliationType.getValue())) {
affiliation = new Qualification();
} else if (AffiliationType.SERVICE.value().equals(affiliationType.getValue())) {
affiliation = new Service();
}
if (!PojoUtil.isEmpty(putCode)) {
affiliation.setPutCode(Long.valueOf(putCode.getValue()));
}
if (visibility != null && visibility.getVisibility() != null) {
affiliation.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(visibility.getVisibility().value()));
}
Organization organization = new Organization();
affiliation.setOrganization(organization);
organization.setName(affiliationName.getValue());
OrganizationAddress organizationAddress = new OrganizationAddress();
organization.setAddress(organizationAddress);
organizationAddress.setCity(city.getValue());
if (!PojoUtil.isEmpty(region)) {
organizationAddress.setRegion(region.getValue());
}
if (!PojoUtil.isEmpty(disambiguatedAffiliationSourceId)) {
organization.setDisambiguatedOrganization(new DisambiguatedOrganization());
organization.getDisambiguatedOrganization().setDisambiguatedOrganizationIdentifier(disambiguatedAffiliationSourceId.getValue());
organization.getDisambiguatedOrganization().setDisambiguationSource(disambiguationSource.getValue());
}
organizationAddress.setCountry(Iso3166Country.fromValue(country.getValue()));
if (!PojoUtil.isEmpty(roleTitle)) {
affiliation.setRoleTitle(roleTitle.getValue());
}
if (!PojoUtil.isEmpty(departmentName)) {
affiliation.setDepartmentName(departmentName.getValue());
}
if (!PojoUtil.isEmpty(startDate)) {
affiliation.setStartDate(startDate.toV3FuzzyDate());
}
if (!PojoUtil.isEmpty(endDate)) {
affiliation.setEndDate(endDate.toV3FuzzyDate());
}
if (!PojoUtil.isEmpty(url)) {
affiliation.setUrl(new Url(url.getValue()));
}
if (affiliationExternalIdentifiers != null) {
ExternalIDs externalIDs = new ExternalIDs();
for (AffiliationExternalIdentifier affiliationExternalIdentifier : affiliationExternalIdentifiers) {
externalIDs.getExternalIdentifier().add(affiliationExternalIdentifier.toExternalID());
}
affiliation.setExternalIDs(externalIDs);
}
return affiliation;
}
use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class AffiliationForm method valueOf.
public static AffiliationForm valueOf(Affiliation affiliation) {
AffiliationForm form = new AffiliationForm();
if (affiliation instanceof Distinction) {
form.setAffiliationType(Text.valueOf(AffiliationType.DISTINCTION.value()));
} else if (affiliation instanceof Education) {
form.setAffiliationType(Text.valueOf(AffiliationType.EDUCATION.value()));
} else if (affiliation instanceof Employment) {
form.setAffiliationType(Text.valueOf(AffiliationType.EMPLOYMENT.value()));
} else if (affiliation instanceof InvitedPosition) {
form.setAffiliationType(Text.valueOf(AffiliationType.INVITED_POSITION.value()));
} else if (affiliation instanceof Membership) {
form.setAffiliationType(Text.valueOf(AffiliationType.MEMBERSHIP.value()));
} else if (affiliation instanceof Qualification) {
form.setAffiliationType(Text.valueOf(AffiliationType.QUALIFICATION.value()));
} else if (affiliation instanceof Service) {
form.setAffiliationType(Text.valueOf(AffiliationType.SERVICE.value()));
}
form.setPutCode(Text.valueOf(affiliation.getPutCode()));
form.setVisibility(Visibility.valueOf(affiliation.getVisibility()));
Organization organization = affiliation.getOrganization();
form.setDateSortString(PojoUtil.createDateSortString(affiliation));
form.setAffiliationName(Text.valueOf(organization.getName()));
OrganizationAddress address = organization.getAddress();
form.setCity(Text.valueOf(address.getCity()));
if (organization.getDisambiguatedOrganization() != null) {
if (organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) {
form.setDisambiguatedAffiliationSourceId(Text.valueOf(organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier()));
form.setDisambiguationSource(Text.valueOf(organization.getDisambiguatedOrganization().getDisambiguationSource()));
form.setOrgDisambiguatedId(Text.valueOf(String.valueOf(organization.getDisambiguatedOrganization().getId())));
}
}
if (address.getRegion() != null) {
form.setRegion(Text.valueOf(address.getRegion()));
} else {
form.setRegion(new Text());
}
if (address.getCountry() != null) {
form.setCountry(Text.valueOf(address.getCountry().value()));
} else {
form.setCountry(new Text());
}
if (affiliation.getDepartmentName() != null) {
form.setDepartmentName(Text.valueOf(affiliation.getDepartmentName()));
} else {
form.setDepartmentName(new Text());
}
if (affiliation.getRoleTitle() != null) {
form.setRoleTitle(Text.valueOf(affiliation.getRoleTitle()));
} else {
form.setRoleTitle(new Text());
}
if (affiliation.getStartDate() != null) {
form.setStartDate(Date.valueOf(affiliation.getStartDate()));
}
if (affiliation.getEndDate() != null) {
form.setEndDate(Date.valueOf(affiliation.getEndDate()));
}
Source source = affiliation.getSource();
if (source != null) {
form.setSource(source.retrieveSourcePath());
if (source.getSourceName() != null) {
form.setSourceName(source.getSourceName().getContent());
}
}
if (affiliation.getUrl() != null) {
form.setUrl(Text.valueOf(affiliation.getUrl().getValue()));
} else {
form.setUrl(new Text());
}
if (affiliation.getExternalIDs() != null) {
List<AffiliationExternalIdentifier> affiliationExternalIdentifiers = new ArrayList<>();
for (ExternalID externalID : affiliation.getExternalIDs().getExternalIdentifier()) {
affiliationExternalIdentifiers.add(AffiliationExternalIdentifier.valueOf(externalID));
}
form.setAffiliationExternalIdentifiers(affiliationExternalIdentifiers);
}
form.setCreatedDate(Date.valueOf(affiliation.getCreatedDate()));
form.setLastModified(Date.valueOf(affiliation.getLastModifiedDate()));
return form;
}
use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class OrcidInfo method getAffiliationsJson.
@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/affiliations.json")
@ResponseBody
public List<AffiliationForm> getAffiliationsJson(HttpServletRequest request, @PathVariable("orcid") String orcid, @RequestParam(value = "affiliationIds") String workIdsStr) {
List<AffiliationForm> affs = new ArrayList<AffiliationForm>();
Map<Long, Affiliation> affMap = activityManager.affiliationMap(orcid);
String[] affIds = workIdsStr.split(",");
for (String id : affIds) {
Affiliation aff = affMap.get(Long.valueOf(id));
validateVisibility(aff.getVisibility());
AffiliationForm form = AffiliationForm.valueOf(aff);
form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, aff.getOrganization().getAddress().getCountry().name())));
if (form.getOrgDisambiguatedId() != null) {
OrgDisambiguated orgDisambiguated = orgDisambiguatedManager.findInDB(Long.parseLong(form.getOrgDisambiguatedId().getValue()));
form.setOrgDisambiguatedName(orgDisambiguated.getValue());
form.setOrgDisambiguatedUrl(orgDisambiguated.getUrl());
form.setOrgDisambiguatedCity(orgDisambiguated.getCity());
form.setOrgDisambiguatedRegion(orgDisambiguated.getRegion());
form.setOrgDisambiguatedCountry(orgDisambiguated.getCountry());
if (orgDisambiguated.getOrgDisambiguatedExternalIdentifiers() != null) {
form.setOrgDisambiguatedExternalIdentifiers(orgDisambiguated.getOrgDisambiguatedExternalIdentifiers());
}
}
affs.add(form);
}
return affs;
}
Aggregations