Search in sources :

Example 41 with Address

use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.

the class AddressManagerReadOnlyImpl method getPrimaryAddress.

@Override
@Cacheable(value = "primary-address", key = "#orcid.concat('-').concat(#lastModified)")
public Address getPrimaryAddress(String orcid, long lastModified) {
    List<AddressEntity> addresses = addressDao.getAddresses(orcid, getLastModified(orcid));
    Address address = null;
    if (addresses != null) {
        //Look for the address with the largest display index
        for (AddressEntity entity : addresses) {
            if (address == null || address.getDisplayIndex() < entity.getDisplayIndex()) {
                address = adapter.toAddress(entity);
            }
        }
    }
    return address;
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) AddressEntity(org.orcid.persistence.jpa.entities.AddressEntity) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 42 with Address

use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.

the class AddressManagerTest method displayIndexIsSetTo_1_FromUI.

@Test
public void displayIndexIsSetTo_1_FromUI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Address address = getAddress(Iso3166Country.MX);
    address = addressManager.createAddress(claimedOrcid, address, false);
    address = addressManager.getAddress(claimedOrcid, address.getPutCode());
    assertNotNull(address);
    assertEquals(Long.valueOf(1), address.getDisplayIndex());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Address(org.orcid.jaxb.model.record_v2.Address) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 43 with Address

use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.

the class AddressManagerTest method getAddress.

private Address getAddress(Iso3166Country country) {
    Address address = new Address();
    address.setCountry(new Country(country));
    address.setVisibility(Visibility.PUBLIC);
    return address;
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) Country(org.orcid.jaxb.model.common_v2.Country)

Example 44 with Address

use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.

the class OrcidSecurityManagerTestBase method createAddress.

protected Address createAddress(Visibility v, String sourceId) {
    Address a = new Address();
    a.setVisibility(v);
    Iso3166Country[] all = Iso3166Country.values();
    Random r = new Random();
    int index = r.nextInt(all.length);
    if (index < 0 || index >= all.length) {
        index = 0;
    }
    a.setCountry(new Country(all[index]));
    setSource(a, sourceId);
    return a;
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) Random(java.util.Random) Country(org.orcid.jaxb.model.common_v2.Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country)

Example 45 with Address

use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.

the class ValidateV2RC2SamplesTest 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;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_rc2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_rc2.Keyword) Address(org.orcid.jaxb.model.record_rc2.Address) OtherNames(org.orcid.jaxb.model.record_rc2.OtherNames) CreditName(org.orcid.jaxb.model.record_rc2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_rc2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_rc2.Deprecated) Biography(org.orcid.jaxb.model.record_rc2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_rc2.ResearcherUrl)

Aggregations

Test (org.junit.Test)85 Address (org.orcid.jaxb.model.record_v2.Address)82 Addresses (org.orcid.jaxb.model.record_v2.Addresses)43 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)43 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 OtherName (org.orcid.jaxb.model.record_v2.OtherName)42 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)42 Email (org.orcid.jaxb.model.record_v2.Email)41 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)35 Biography (org.orcid.jaxb.model.record_v2.Biography)34 Emails (org.orcid.jaxb.model.record_v2.Emails)34 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)33 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)32 Name (org.orcid.jaxb.model.record_v2.Name)31 Person (org.orcid.jaxb.model.record_v2.Person)31 Record (org.orcid.jaxb.model.record_v2.Record)19 Response (javax.ws.rs.core.Response)18 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18