Search in sources :

Example 31 with Visibility

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;
}
Also used : Organization(org.orcid.jaxb.model.v3.dev1.common.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) OrganizationAddress(org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress) Service(org.orcid.jaxb.model.v3.dev1.record.Service) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 32 with Visibility

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;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) Source(org.orcid.jaxb.model.v3.dev1.common.Source)

Example 33 with Visibility

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;
}
Also used : WorkForm(org.orcid.pojo.ajaxForm.WorkForm) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Contributor(org.orcid.pojo.ajaxForm.Contributor) Text(org.orcid.pojo.ajaxForm.Text) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 34 with Visibility

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;
}
Also used : OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) OtherNameForm(org.orcid.pojo.ajaxForm.OtherNameForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 35 with Visibility

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;
}
Also used : OtherNamesForm(org.orcid.pojo.ajaxForm.OtherNamesForm) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Visibility (org.orcid.jaxb.model.v3.dev1.common.Visibility)44 ClientResponse (com.sun.jersey.api.client.ClientResponse)17 Test (org.junit.Test)17 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 Url (org.orcid.jaxb.model.v3.dev1.common.Url)11 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)11 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)11 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)11 HashMap (java.util.HashMap)10 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)10 Name (org.orcid.jaxb.model.v3.dev1.record.Name)7 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)7 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)6 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)6 Work (org.orcid.jaxb.model.v3.dev1.record.Work)6 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)6 Date (java.util.Date)5 OrcidDuplicatedElementException (org.orcid.core.exception.OrcidDuplicatedElementException)5