Search in sources :

Example 51 with Addresses

use of org.orcid.jaxb.model.record_v2.Addresses in project ORCID-Source by ORCID.

the class ManageProfileController method getProfileCountryJson.

@RequestMapping(value = "/countryForm.json", method = RequestMethod.GET)
@ResponseBody
public AddressesForm getProfileCountryJson(HttpServletRequest request) throws NoSuchRequestHandlingMethodException {
    long lastModifiedTime = profileEntityManager.getLastModified(getCurrentUserOrcid());
    Addresses addresses = addressManager.getAddresses(getCurrentUserOrcid(), lastModifiedTime);
    AddressesForm form = AddressesForm.valueOf(addresses);
    // Set country name
    if (form != null && form.getAddresses() != null) {
        Map<String, String> countries = retrieveIsoCountries();
        for (AddressForm addressForm : form.getAddresses()) {
            addressForm.setCountryName(countries.get(addressForm.getIso2Country().getValue().name()));
        }
    }
    ProfileEntity profile = profileEntityCacheManager.retrieve(getCurrentUserOrcid());
    // Set the default visibility
    if (profile.getActivitiesVisibilityDefault() != null) {
        form.setVisibility(org.orcid.pojo.ajaxForm.Visibility.valueOf(profile.getActivitiesVisibilityDefault()));
    }
    // Return an empty country in case we dont have any
    if (form.getAddresses() == null) {
        form.setAddresses(new ArrayList<AddressForm>());
    }
    if (form.getAddresses().isEmpty()) {
        AddressForm address = new AddressForm();
        address.setDisplayIndex(1L);
        address.setVisibility(org.orcid.pojo.ajaxForm.Visibility.valueOf(profile.getActivitiesVisibilityDefault()));
        form.getAddresses().add(address);
    }
    return form;
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) AddressesForm(org.orcid.pojo.ajaxForm.AddressesForm) AddressForm(org.orcid.pojo.ajaxForm.AddressForm) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 52 with Addresses

use of org.orcid.jaxb.model.record_v2.Addresses in project ORCID-Source by ORCID.

the class AddressManagerTest method getPublicTest.

@Test
public void getPublicTest() {
    String orcid = "0000-0000-0000-0003";
    Addresses elements = addressManager.getPublicAddresses(orcid, System.currentTimeMillis());
    assertNotNull(elements);
    assertNotNull(elements.getAddress());
    assertEquals(1, elements.getAddress().size());
    assertEquals(Long.valueOf(9), elements.getAddress().get(0).getPutCode());
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 53 with Addresses

use of org.orcid.jaxb.model.record_v2.Addresses in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest method testUnmarshallAddress.

@Test
public void testUnmarshallAddress() throws SAXException, URISyntaxException {
    Addresses addresses = (Addresses) unmarshallFromPath("/record_2.0_rc2/samples/addresses-2.0_rc2.xml", Addresses.class, "/record_2.0_rc2/address-2.0_rc2.xsd");
    assertNotNull(addresses);
    assertNotNull(addresses.getAddress());
    assertEquals(2, addresses.getAddress().size());
    for (Address address : addresses.getAddress()) {
        assertNotNull(address.getPutCode());
        assertNotNull(address.getCreatedDate());
        assertNotNull(address.getLastModifiedDate());
        assertNotNull(address.getCountry());
        if (address.getPutCode().equals(new Long(1))) {
            assertEquals(Iso3166Country.US, address.getCountry().getValue());
            assertEquals(Visibility.PUBLIC, address.getVisibility());
        } else {
            assertEquals(Iso3166Country.CR, address.getCountry().getValue());
            assertEquals(Visibility.LIMITED, address.getVisibility());
        }
    }
    Address address = (Address) unmarshallFromPath("/record_2.0_rc2/samples/address-2.0_rc2.xml", Address.class);
    assertNotNull(address);
    assertNotNull(address.getPutCode());
    assertNotNull(address.getCreatedDate());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Also used : Addresses(org.orcid.jaxb.model.record_rc2.Addresses) Address(org.orcid.jaxb.model.record_rc2.Address) Test(org.junit.Test)

Example 54 with Addresses

use of org.orcid.jaxb.model.record_v2.Addresses in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testUnmarshallAddress.

@Test
public void testUnmarshallAddress() throws SAXException, URISyntaxException {
    Addresses addresses = (Addresses) unmarshallFromPath("/record_2.1/samples/read_samples/addresses-2.1.xml", Addresses.class, "/record_2.1/address-2.1.xsd");
    assertNotNull(addresses);
    assertNotNull(addresses.getAddress());
    assertEquals(2, addresses.getAddress().size());
    for (Address address : addresses.getAddress()) {
        validateSourceInHttps(address.getSource());
        assertNotNull(address.getPutCode());
        assertNotNull(address.getCreatedDate());
        assertNotNull(address.getLastModifiedDate());
        assertNotNull(address.getCountry());
        if (address.getPutCode().equals(new Long(1))) {
            assertEquals(Iso3166Country.US, address.getCountry().getValue());
            assertEquals(Visibility.PUBLIC, address.getVisibility());
        } else {
            assertEquals(Iso3166Country.CR, address.getCountry().getValue());
            assertEquals(Visibility.LIMITED, address.getVisibility());
        }
    }
    Address address = (Address) unmarshallFromPath("/record_2.1/samples/read_samples/address-2.1.xml", Address.class);
    assertNotNull(address);
    assertNotNull(address.getPutCode());
    assertNotNull(address.getCreatedDate());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getCountry());
    validateSourceInHttps(address.getSource());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) Address(org.orcid.jaxb.model.record_v2.Address) Test(org.junit.Test)

Example 55 with Addresses

use of org.orcid.jaxb.model.record_v2.Addresses in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method viewAddresses.

@Override
public Response viewAddresses(String orcid) {
    Addresses addresses = addressManagerReadOnly.getAddresses(orcid, getLastModifiedTime(orcid));
    // Lets copy the list so we don't modify the cached collection
    if (addresses.getAddress() != null) {
        List<Address> filteredAddresses = new ArrayList<Address>(addresses.getAddress());
        addresses = new Addresses();
        addresses.setAddress(filteredAddresses);
    }
    orcidSecurityManager.checkAndFilter(orcid, addresses.getAddress(), ScopePathType.ORCID_BIO_READ_LIMITED);
    ElementUtils.setPathToAddresses(addresses, orcid);
    // Set the latest last modified
    Api2_0_LastModifiedDatesHelper.calculateLastModified(addresses);
    sourceUtils.setSourceName(addresses);
    return Response.ok(addresses).build();
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) Address(org.orcid.jaxb.model.record_v2.Address) ArrayList(java.util.ArrayList)

Aggregations

Test (org.junit.Test)56 Addresses (org.orcid.jaxb.model.record_v2.Addresses)55 Address (org.orcid.jaxb.model.record_v2.Address)48 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)37 Biography (org.orcid.jaxb.model.record_v2.Biography)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 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 OtherName (org.orcid.jaxb.model.record_v2.OtherName)32 Name (org.orcid.jaxb.model.record_v2.Name)29 Person (org.orcid.jaxb.model.record_v2.Person)26 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