Search in sources :

Example 46 with Addresses

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

the class PublicV2ApiServiceDelegatorTest method testViewAddresses.

@Test
public void testViewAddresses() {
    Response response = serviceDelegator.viewAddresses(ORCID);
    assertNotNull(response);
    Addresses addresses = (Addresses) response.getEntity();
    assertNotNull(addresses);
    assertNotNull(addresses.getLastModifiedDate());
    assertNotNull(addresses.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/address", addresses.getPath());
    assertEquals(1, addresses.getAddress().size());
    Address address = addresses.getAddress().get(0);
    assertNotNull(address);
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), address.getPutCode());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
    assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Addresses(org.orcid.jaxb.model.record_v2.Addresses) Address(org.orcid.jaxb.model.record_v2.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 47 with Addresses

use of org.orcid.jaxb.model.record_rc2.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 48 with Addresses

use of org.orcid.jaxb.model.record_rc2.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 49 with Addresses

use of org.orcid.jaxb.model.record_rc2.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 50 with Addresses

use of org.orcid.jaxb.model.record_rc2.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)

Aggregations

Test (org.junit.Test)55 Addresses (org.orcid.jaxb.model.record_v2.Addresses)55 Address (org.orcid.jaxb.model.record_v2.Address)42 Keywords (org.orcid.jaxb.model.record_v2.Keywords)35 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)35 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)35 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)35 Biography (org.orcid.jaxb.model.record_v2.Biography)33 Emails (org.orcid.jaxb.model.record_v2.Emails)33 OtherName (org.orcid.jaxb.model.record_v2.OtherName)32 Email (org.orcid.jaxb.model.record_v2.Email)31 Keyword (org.orcid.jaxb.model.record_v2.Keyword)31 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)31 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)31 Name (org.orcid.jaxb.model.record_v2.Name)28 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