use of org.orcid.persistence.jpa.entities.PublicationDateEntity in project ORCID-Source by ORCID.
the class JpaJaxbWorkAdapterTest method testToWorkEntity.
@Test
public void testToWorkEntity() throws JAXBException {
Work work = getWork(true);
assertNotNull(work);
WorkEntity workEntity = jpaJaxbWorkAdapter.toWorkEntity(work);
assertNotNull(workEntity);
assertEquals(Visibility.PRIVATE, workEntity.getVisibility());
assertNotNull(workEntity);
assertEquals(123, workEntity.getId().longValue());
assertEquals("common:title", workEntity.getTitle());
assertTrue(PojoUtil.isEmpty(workEntity.getSubtitle()));
assertEquals("common:translated-title", workEntity.getTranslatedTitle());
assertEquals("en", workEntity.getTranslatedTitleLanguageCode());
assertEquals("work:short-description", workEntity.getDescription());
assertEquals(CitationType.FORMATTED_UNSPECIFIED, workEntity.getCitationType());
assertEquals(WorkType.ARTISTIC_PERFORMANCE, workEntity.getWorkType());
PublicationDateEntity publicationDateEntity = workEntity.getPublicationDate();
assertNotNull(publicationDateEntity);
assertEquals(1848, publicationDateEntity.getYear().intValue());
assertEquals(02, publicationDateEntity.getMonth().intValue());
assertEquals(02, publicationDateEntity.getDay().intValue());
assertEquals("{\"workExternalIdentifier\":[{\"relationship\":\"SELF\",\"url\":{\"value\":\"http://orcid.org\"},\"workExternalIdentifierType\":\"AGR\",\"workExternalIdentifierId\":{\"content\":\"work:external-identifier-id\"}}]}", workEntity.getExternalIdentifiersJson());
assertEquals("http://tempuri.org", workEntity.getWorkUrl());
assertEquals("{\"contributor\":[{\"contributorOrcid\":{\"uri\":\"http://orcid.org/8888-8888-8888-8880\",\"path\":\"8888-8888-8888-8880\",\"host\":\"orcid.org\"},\"creditName\":{\"content\":\"work:credit-name\"},\"contributorEmail\":{\"value\":\"work@contributor.email\"},\"contributorAttributes\":{\"contributorSequence\":\"FIRST\",\"contributorRole\":\"AUTHOR\"}}]}", workEntity.getContributorsJson());
assertEquals("en", workEntity.getLanguageCode());
assertEquals(Iso3166Country.AF, workEntity.getIso2Country());
// Source
assertNull(workEntity.getSourceId());
assertNull(workEntity.getClientSourceId());
assertNull(workEntity.getElementSourceId());
}
use of org.orcid.persistence.jpa.entities.PublicationDateEntity in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterImpl method getOrcidWork.
public OrcidWork getOrcidWork(WorkEntity work) {
if (work == null) {
return null;
}
OrcidWork orcidWork = new OrcidWork();
PublicationDateEntity publicationDate = work.getPublicationDate();
orcidWork.setPublicationDate(getPublicationDateFromEntity(publicationDate));
orcidWork.setPutCode(Long.toString(work.getId()));
orcidWork.setShortDescription(work.getDescription());
orcidWork.setUrl(StringUtils.isNotBlank(work.getWorkUrl()) ? new Url(work.getWorkUrl()) : null);
orcidWork.setWorkCitation(getWorkCitation(work));
orcidWork.setWorkContributors(getWorkContributors(work));
if (work.getExternalIdentifiersJson() != null) {
org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIdentifiers extIds = org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIdentifiers.fromDBJSONString(work.getExternalIdentifiersJson());
orcidWork.setWorkExternalIdentifiers(extIds.toMessagePojo());
}
orcidWork.setSource(getSource(work));
orcidWork.setWorkTitle(getWorkTitle(work));
orcidWork.setJournalTitle(StringUtils.isNotBlank(work.getJournalTitle()) ? new Title(work.getJournalTitle()) : null);
orcidWork.setLanguageCode(normalizeLanguageCode(work.getLanguageCode()));
if (work.getIso2Country() != null) {
Country country = new Country(Iso3166Country.fromValue(work.getIso2Country().value()));
country.setVisibility(OrcidVisibilityDefaults.WORKS_COUNTRY_DEFAULT.getVisibility());
orcidWork.setCountry(country);
}
if (work.getWorkType() != null) {
orcidWork.setWorkType(WorkType.fromValue(work.getWorkType().value()));
}
orcidWork.setVisibility(Visibility.fromValue(work.getVisibility().value()));
orcidWork.setCreatedDate(new CreatedDate(toXMLGregorianCalendar(work.getDateCreated())));
orcidWork.setLastModifiedDate(new LastModifiedDate(toXMLGregorianCalendar(work.getLastModified())));
orcidWork.setDisplayIndex(work.getDisplayIndex());
return orcidWork;
}
use of org.orcid.persistence.jpa.entities.PublicationDateEntity in project ORCID-Source by ORCID.
the class JpaJaxbWorkAdapterTest method getWorkEntity.
private WorkEntity getWorkEntity() {
Date date = DateUtils.convertToDate("2015-06-05T10:15:20");
WorkEntity work = new WorkEntity();
work.setDateCreated(date);
work.setLastModified(date);
work.setProfile(new ProfileEntity("0000-0000-0000-0001"));
work.setVisibility(Visibility.LIMITED);
work.setDisplayIndex(1234567890L);
work.setClientSourceId("APP-5555555555555555");
work.setCitation("work:citation");
work.setCitationType(CitationType.BIBTEX);
work.setDateCreated(date);
work.setDescription("work:description");
work.setId(12345L);
work.setIso2Country(Iso3166Country.CR);
work.setJournalTitle("work:journalTitle");
work.setLanguageCode("EN");
work.setLastModified(date);
work.setPublicationDate(new PublicationDateEntity(2000, 1, 1));
work.setSubtitle("work:subtitle");
work.setTitle("work:title");
work.setTranslatedTitle("work:translatedTitle");
work.setTranslatedTitleLanguageCode("ES");
work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
work.setWorkUrl("work:url");
work.setContributorsJson("{\"contributor\":[]}");
work.setExternalIdentifiersJson("{\"workExternalIdentifier\":[{\"workExternalIdentifierType\":\"AGR\",\"workExternalIdentifierId\":{\"content\":\"123\"}}]}");
return work;
}
use of org.orcid.persistence.jpa.entities.PublicationDateEntity in project ORCID-Source by ORCID.
the class Jaxb2JpaAdapterImpl method getWorkPublicationDate.
private PublicationDateEntity getWorkPublicationDate(OrcidWork orcidWork) {
if (orcidWork != null && orcidWork.getPublicationDate() != null) {
PublicationDate publicationDate = orcidWork.getPublicationDate();
Integer year = publicationDate.getYear() != null ? toInteger(publicationDate.getYear().getValue()) : null;
Integer month = publicationDate.getMonth() != null ? toInteger(publicationDate.getMonth().getValue()) : null;
Integer day = publicationDate.getDay() != null ? toInteger(publicationDate.getDay().getValue()) : null;
return new PublicationDateEntity(year, month, day);
}
return null;
}
Aggregations