Search in sources :

Example 51 with OtherNames

use of org.orcid.jaxb.model.record_rc2.OtherNames in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method unmarshallFromPath.

private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type, schemaPath);
        Object result = null;
        if (ResearcherUrls.class.equals(type)) {
            result = (ResearcherUrls) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (PersonExternalIdentifiers.class.equals(type)) {
            result = (PersonExternalIdentifiers) obj;
        } else if (Biography.class.equals(type)) {
            result = (Biography) obj;
        } else if (Name.class.equals(type)) {
            result = (Name) obj;
        } else if (CreditName.class.equals(type)) {
            result = (CreditName) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (OtherNames.class.equals(type)) {
            result = (OtherNames) obj;
        } else if (Keywords.class.equals(type)) {
            result = (Keywords) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Addresses.class.equals(type)) {
            result = (Addresses) obj;
        } else if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Emails.class.equals(type)) {
            result = (Emails) obj;
        } else if (Email.class.equals(type)) {
            result = (Email) obj;
        } else if (Person.class.equals(type)) {
            result = (Person) obj;
        } else if (Deprecated.class.equals(type)) {
            result = (Deprecated) obj;
        } else if (Preferences.class.equals(type)) {
            result = (Preferences) obj;
        } else if (History.class.equals(type)) {
            result = (History) obj;
        } else if (Record.class.equals(type)) {
            result = (Record) obj;
        } else if (ActivitiesSummary.class.equals(type)) {
            result = (ActivitiesSummary) obj;
        } else if (Works.class.equals(type)) {
            result = (Works) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Address(org.orcid.jaxb.model.record_v2.Address) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) CreditName(org.orcid.jaxb.model.record_v2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_v2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_v2.Deprecated) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 52 with OtherNames

use of org.orcid.jaxb.model.record_rc2.OtherNames 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>());
    ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
    Visibility defaultVisibility = Visibility.valueOf(profile.getActivitiesVisibilityDefault());
    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));
            }
            //Set default visibility in case it is null
            if (form.getVisibility() == null || form.getVisibility().getVisibility() == null) {
                form.setVisibility(defaultVisibility);
            }
            copyErrors(form, 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.record_v2.OtherNames) Visibility(org.orcid.pojo.ajaxForm.Visibility) OtherNameForm(org.orcid.pojo.ajaxForm.OtherNameForm) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 53 with OtherNames

use of org.orcid.jaxb.model.record_rc2.OtherNames 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 {
    long lastModifiedTime = getLastModifiedTime(getCurrentUserOrcid());
    OtherNames otherNames = otherNameManager.getOtherNames(getCurrentUserOrcid(), lastModifiedTime);
    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.record_v2.OtherNames) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 54 with OtherNames

use of org.orcid.jaxb.model.record_rc2.OtherNames in project ORCID-Source by ORCID.

the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.

public static XMLGregorianCalendar calculateLatest(OtherNames otherNames) {
    XMLGregorianCalendar latest = null;
    if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
        latest = otherNames.getOtherNames().get(0).getLastModifiedDate().getValue();
        for (OtherName otherName : otherNames.getOtherNames()) {
            if (latest.compare(otherName.getLastModifiedDate().getValue()) == -1) {
                latest = otherName.getLastModifiedDate().getValue();
            }
        }
        otherNames.setLastModifiedDate(new LastModifiedDate(latest));
    }
    return latest;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) LastModifiedDate(org.orcid.jaxb.model.common_rc2.LastModifiedDate) OtherName(org.orcid.jaxb.model.record_rc2.OtherName)

Example 55 with OtherNames

use of org.orcid.jaxb.model.record_rc2.OtherNames in project ORCID-Source by ORCID.

the class OtherNameManagerTest method getAllTest.

@Test
public void getAllTest() {
    String orcid = "0000-0000-0000-0003";
    OtherNames elements = otherNameManager.getOtherNames(orcid, System.currentTimeMillis());
    assertNotNull(elements);
    assertNotNull(elements.getOtherNames());
    assertEquals(5, elements.getOtherNames().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
    for (OtherName element : elements.getOtherNames()) {
        if (13 == element.getPutCode()) {
            found1 = true;
        } else if (14 == element.getPutCode()) {
            found2 = true;
        } else if (15 == element.getPutCode()) {
            found3 = true;
        } else if (16 == element.getPutCode()) {
            found4 = true;
        } else if (17 == element.getPutCode()) {
            found5 = true;
        } else {
            fail("Invalid put code found: " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    assertTrue(found5);
}
Also used : OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)70 Test (org.junit.Test)61 OtherName (org.orcid.jaxb.model.record_v2.OtherName)55 Biography (org.orcid.jaxb.model.record_v2.Biography)47 Name (org.orcid.jaxb.model.record_v2.Name)40 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Keywords (org.orcid.jaxb.model.record_v2.Keywords)35 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)35 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)35 Address (org.orcid.jaxb.model.record_v2.Address)34 Email (org.orcid.jaxb.model.record_v2.Email)33 Emails (org.orcid.jaxb.model.record_v2.Emails)33 Keyword (org.orcid.jaxb.model.record_v2.Keyword)33 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)33 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)33 Person (org.orcid.jaxb.model.record_v2.Person)25 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)15 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)15