Search in sources :

Example 21 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class JpaJaxbNameAdapterTest method fromNameToRecordNameEntityTest.

@Test
public void fromNameToRecordNameEntityTest() throws JAXBException {
    Name name = new Name();
    name.setCreditName(new CreditName("Credit Name"));
    name.setFamilyName(new FamilyName("Family Name"));
    name.setGivenNames(new GivenNames("Given Names"));
    name.setPath("0000-0000-0000-0000");
    name.setVisibility(Visibility.PUBLIC);
    name.setSource(new Source("0000-0000-0000-0000"));
    RecordNameEntity entity = adapter.toRecordNameEntity(name);
    assertNotNull(entity);
    assertEquals("Credit Name", entity.getCreditName());
    assertEquals("Family Name", entity.getFamilyName());
    assertEquals("Given Names", entity.getGivenNames());
    assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC, entity.getVisibility());
    assertNotNull(entity.getProfile());
    assertEquals("0000-0000-0000-0000", entity.getProfile().getId());
}
Also used : FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) GivenNames(org.orcid.jaxb.model.v3.dev1.record.GivenNames) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) Source(org.orcid.jaxb.model.v3.dev1.common.Source) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FamilyName(org.orcid.jaxb.model.v3.dev1.record.FamilyName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Test(org.junit.Test)

Example 22 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest method testMarshallCreditName.

@Test
public void testMarshallCreditName() throws JAXBException, SAXException, URISyntaxException {
    CreditName object = (CreditName) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/credit-name-3.0_dev1.xml", CreditName.class);
    marshall(object, "/record_3.0_dev1/personal-details-3.0_dev1.xsd");
}
Also used : CreditName(org.orcid.jaxb.model.v3.dev1.record.CreditName) Test(org.junit.Test)

Example 23 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class ValidateV3_dev1SamplesTest 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;
        } else if (Education.class.equals(type)) {
            result = (Education) obj;
        } else if (Educations.class.equals(type)) {
            result = (Educations) obj;
        } else if (Employment.class.equals(type)) {
            result = (Employment) obj;
        } else if (Employments.class.equals(type)) {
            result = (Employments) obj;
        } else if (Distinction.class.equals(type)) {
            result = (Distinction) obj;
        } else if (Distinctions.class.equals(type)) {
            result = (Distinctions) obj;
        } else if (InvitedPosition.class.equals(type)) {
            result = (InvitedPosition) obj;
        } else if (InvitedPositions.class.equals(type)) {
            result = (InvitedPositions) obj;
        } else if (Membership.class.equals(type)) {
            result = (Membership) obj;
        } else if (Memberships.class.equals(type)) {
            result = (Memberships) obj;
        } else if (Qualification.class.equals(type)) {
            result = (Qualification) obj;
        } else if (Qualifications.class.equals(type)) {
            result = (Qualifications) obj;
        } else if (Service.class.equals(type)) {
            result = (Service) obj;
        } else if (Services.class.equals(type)) {
            result = (Services) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.v3.dev1.record.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) Address(org.orcid.jaxb.model.v3.dev1.record.Address) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) CreditName(org.orcid.jaxb.model.v3.dev1.record.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Service(org.orcid.jaxb.model.v3.dev1.record.Service) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) History(org.orcid.jaxb.model.v3.dev1.record.History) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) Deprecated(org.orcid.jaxb.model.v3.dev1.record.Deprecated) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction)

Example 24 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorImpl method viewWorkCitation.

@Override
public Response viewWorkCitation(String orcid, Long putCode) {
    Work w = (Work) this.viewWork(orcid, putCode).getEntity();
    ProfileEntity entity = profileEntityManagerReadOnly.findByOrcid(orcid);
    String creditName = null;
    RecordNameEntity recordNameEntity = entity.getRecordNameEntity();
    if (recordNameEntity != null) {
        if (!recordNameEntity.getVisibility().isMoreRestrictiveThan(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC)) {
            creditName = recordNameEntity.getCreditName();
            if (StringUtils.isBlank(creditName)) {
                creditName = recordNameEntity.getGivenNames();
                String familyName = recordNameEntity.getFamilyName();
                if (StringUtils.isNotBlank(familyName)) {
                    creditName += " " + familyName;
                }
            }
        }
    }
    V3WorkToCiteprocTranslator tran = new V3WorkToCiteprocTranslator();
    CSLItemData item = tran.toCiteproc(w, creditName, true);
    return Response.ok(item).build();
}
Also used : CSLItemData(de.undercouch.citeproc.csl.CSLItemData) Work(org.orcid.jaxb.model.v3.dev1.record.Work) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) V3WorkToCiteprocTranslator(org.orcid.api.common.writer.citeproc.V3WorkToCiteprocTranslator) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 25 with CreditName

use of org.orcid.jaxb.model.v3.dev1.record.CreditName in project ORCID-Source by ORCID.

the class ContributorUtilsTest method getWorkContributorWithOrcid.

private WorkContributors getWorkContributorWithOrcid() {
    ContributorOrcid contributorOrcid = new ContributorOrcid();
    contributorOrcid.setPath("0000-0003-4902-6327");
    contributorOrcid.setHost("orcid.org");
    contributorOrcid.setUri("http://orcid.org/0000-0003-4902-6327");
    Contributor contributor = new Contributor();
    contributor.setContributorOrcid(contributorOrcid);
    contributor.setContributorEmail(new ContributorEmail("never@show.this"));
    contributor.setCreditName(new CreditName("original credit name"));
    return new WorkContributors(Arrays.asList(contributor));
}
Also used : WorkContributors(org.orcid.jaxb.model.v3.dev1.record.WorkContributors) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Contributor(org.orcid.jaxb.model.v3.dev1.common.Contributor) ContributorOrcid(org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid) ContributorEmail(org.orcid.jaxb.model.v3.dev1.common.ContributorEmail)

Aggregations

CreditName (org.orcid.jaxb.model.v3.dev1.common.CreditName)18 FundingContributor (org.orcid.jaxb.model.v3.dev1.record.FundingContributor)10 Test (org.junit.Test)8 Name (org.orcid.jaxb.model.v3.dev1.record.Name)8 Contributor (org.orcid.jaxb.model.v3.dev1.common.Contributor)7 FamilyName (org.orcid.jaxb.model.v3.dev1.record.FamilyName)7 GivenNames (org.orcid.jaxb.model.v3.dev1.record.GivenNames)7 Work (org.orcid.jaxb.model.v3.dev1.record.Work)7 ContributorEmail (org.orcid.jaxb.model.v3.dev1.common.ContributorEmail)6 ContributorOrcid (org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid)6 Title (org.orcid.jaxb.model.v3.dev1.common.Title)4 CreditName (org.orcid.jaxb.model.v3.dev1.record.CreditName)4 WorkContributors (org.orcid.jaxb.model.v3.dev1.record.WorkContributors)4 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)4 ArrayList (java.util.ArrayList)3 Country (org.orcid.jaxb.model.v3.dev1.common.Country)3 Day (org.orcid.jaxb.model.v3.dev1.common.Day)3 Iso3166Country (org.orcid.jaxb.model.v3.dev1.common.Iso3166Country)3 PublicationDate (org.orcid.jaxb.model.v3.dev1.common.PublicationDate)3 Subtitle (org.orcid.jaxb.model.v3.dev1.common.Subtitle)3