use of org.orcid.jaxb.model.v3.dev1.common.Visibility 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.common.Visibility in project ORCID-Source by ORCID.
the class KeywordForm method toKeyword.
public Keyword toKeyword() {
Keyword keyword = new Keyword();
if (!PojoUtil.isEmpty(putCode)) {
keyword.setPutCode(Long.valueOf(putCode));
}
if (!PojoUtil.isEmpty(content)) {
keyword.setContent(content);
}
if (visibility != null && visibility.getVisibility() != null) {
keyword.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(visibility.getVisibility().value()));
} else {
keyword.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(OrcidVisibilityDefaults.KEYWORD_DEFAULT.getVisibility().value()));
}
if (createdDate != null) {
keyword.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(createdDate.toCalendar())));
}
if (lastModified != null) {
keyword.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(lastModified.toCalendar())));
}
if (displayIndex != null) {
keyword.setDisplayIndex(displayIndex);
} else {
keyword.setDisplayIndex(0L);
}
keyword.setSource(new Source(source));
return keyword;
}
use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.
the class WorksController method getWorkInfo.
/**
* Returns a blank work
*/
@RequestMapping(value = "/getWorkInfo.json", method = RequestMethod.GET)
@ResponseBody
public WorkForm getWorkInfo(@RequestParam(value = "workId") Long workId) {
Map<String, String> countries = retrieveIsoCountries();
Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
if (workId == null)
return null;
Work work = workManager.getWork(this.getEffectiveUserOrcid(), workId);
if (work != null) {
WorkForm workForm = WorkForm.valueOf(work);
if (workForm.getPublicationDate() == null) {
initializePublicationDate(workForm);
} else {
if (workForm.getPublicationDate().getDay() == null) {
workForm.getPublicationDate().setDay(new String());
}
if (workForm.getPublicationDate().getMonth() == null) {
workForm.getPublicationDate().setMonth(new String());
}
if (workForm.getPublicationDate().getYear() == null) {
workForm.getPublicationDate().setYear(new String());
}
}
// Set country name
if (!PojoUtil.isEmpty(workForm.getCountryCode())) {
Text countryName = Text.valueOf(countries.get(workForm.getCountryCode().getValue()));
workForm.setCountryName(countryName);
}
// Set language name
if (!PojoUtil.isEmpty(workForm.getLanguageCode())) {
Text languageName = Text.valueOf(languages.get(workForm.getLanguageCode().getValue()));
workForm.setLanguageName(languageName);
}
// Set translated title language name
if (!(workForm.getTranslatedTitle() == null) && !StringUtils.isEmpty(workForm.getTranslatedTitle().getLanguageCode())) {
String languageName = languages.get(workForm.getTranslatedTitle().getLanguageCode());
workForm.getTranslatedTitle().setLanguageName(languageName);
}
if (workForm.getContributors() != null) {
for (Contributor contributor : workForm.getContributors()) {
if (!PojoUtil.isEmpty(contributor.getOrcid())) {
String contributorOrcid = contributor.getOrcid().getValue();
if (profileEntityManager.orcidExists(contributorOrcid)) {
// contributor is an ORCID user - visibility of user's name in record must be taken into account
ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
String publicContributorCreditName = activityManager.getPublicCreditName(profileEntity);
contributor.setCreditName(Text.valueOf(publicContributorCreditName));
}
}
}
}
return workForm;
}
return null;
}
use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.
the class WorkspaceController method setOtherNamesFormJson.
@RequestMapping(value = "/my-orcid/otherNamesForms.json", method = RequestMethod.POST)
@ResponseBody
public OtherNamesForm setOtherNamesFormJson(@RequestBody OtherNamesForm onf) throws NoSuchRequestHandlingMethodException {
onf.setErrors(new ArrayList<String>());
if (onf != null) {
Iterator<OtherNameForm> it = onf.getOtherNames().iterator();
while (it.hasNext()) {
OtherNameForm form = it.next();
if (PojoUtil.isEmpty(form.getContent())) {
it.remove();
continue;
}
if (form.getContent().length() > SiteConstants.MAX_LENGTH_255) {
form.setContent(form.getContent().substring(0, SiteConstants.MAX_LENGTH_255));
}
// Validate visibility is not null
validateVisibility(form);
copyErrors(form, onf);
copyErrors(form.getVisibility(), onf);
}
if (onf.getErrors().size() > 0) {
return onf;
}
OtherNames otherNames = onf.toOtherNames();
otherNameManager.updateOtherNames(getEffectiveUserOrcid(), otherNames);
}
return onf;
}
use of org.orcid.jaxb.model.v3.dev1.common.Visibility in project ORCID-Source by ORCID.
the class WorkspaceController method getOtherNamesFormJson.
@RequestMapping(value = "/my-orcid/otherNamesForms.json", method = RequestMethod.GET)
@ResponseBody
public OtherNamesForm getOtherNamesFormJson(HttpServletRequest request) throws NoSuchRequestHandlingMethodException {
OtherNames otherNames = otherNameManager.getOtherNames(getCurrentUserOrcid());
OtherNamesForm form = OtherNamesForm.valueOf(otherNames);
// Set the default visibility
ProfileEntity profile = profileEntityCacheManager.retrieve(getCurrentUserOrcid());
if (profile != null && profile.getActivitiesVisibilityDefault() != null) {
form.setVisibility(Visibility.valueOf(profile.getActivitiesVisibilityDefault()));
}
return form;
}
Aggregations