use of org.orcid.persistence.jpa.entities.WorkEntity 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(org.orcid.jaxb.model.common_v2.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(org.orcid.jaxb.model.record_v2.CitationType.FORMATTED_UNSPECIFIED, workEntity.getCitationType());
assertEquals(org.orcid.jaxb.model.record_v2.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(org.orcid.jaxb.model.common_v2.Iso3166Country.AF, workEntity.getIso2Country());
// Source
assertNull(workEntity.getSourceId());
assertNull(workEntity.getClientSourceId());
assertNull(workEntity.getElementSourceId());
}
use of org.orcid.persistence.jpa.entities.WorkEntity in project ORCID-Source by ORCID.
the class JpaJaxbWorkAdapterTest method fromProfileWorkEntityToWorkSummaryTest.
@Test
public void fromProfileWorkEntityToWorkSummaryTest() {
WorkEntity work = getWorkEntity();
assertNotNull(work);
WorkSummary ws = jpaJaxbWorkAdapter.toWorkSummary(work);
assertNotNull(ws);
assertEquals(Long.valueOf(12345), ws.getPutCode());
assertEquals(Visibility.LIMITED.value(), ws.getVisibility().value());
assertEquals("1234567890", ws.getDisplayIndex());
assertNotNull(ws.getExternalIdentifiers());
assertNotNull(ws.getExternalIdentifiers().getExternalIdentifier());
assertEquals(1, ws.getExternalIdentifiers().getExternalIdentifier().size());
ExternalID workExtId = ws.getExternalIdentifiers().getExternalIdentifier().get(0);
assertNotNull(workExtId.getValue());
assertEquals("123", workExtId.getValue());
assertNotNull(workExtId.getType());
assertEquals(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value(), workExtId.getType());
assertEquals("work:journalTitle", ws.getJournalTitle().getContent());
}
use of org.orcid.persistence.jpa.entities.WorkEntity 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.setOrcid("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.WorkEntity in project ORCID-Source by ORCID.
the class JSONWorkExternalIdentifiersConverterV2Test method testConvertFrom.
@Test
public void testConvertFrom() {
WorkEntity workEntity = getWorkEntity();
ExternalIDs entityIDs = converter.convertFrom(workEntity.getExternalIdentifiersJson(), null);
assertEquals(1, entityIDs.getExternalIdentifier().size());
ExternalID externalID = entityIDs.getExternalIdentifier().get(0);
assertEquals("123", externalID.getValue());
assertNotNull(externalID.getType());
assertEquals(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value(), externalID.getType());
}
use of org.orcid.persistence.jpa.entities.WorkEntity in project ORCID-Source by ORCID.
the class WorkManagerReadOnlyImpl method findWorkBulk.
@Override
public WorkBulk findWorkBulk(String orcid, String putCodesAsString) {
List<BulkElement> works = new ArrayList<>();
String[] putCodes = getPutCodeArray(putCodesAsString);
for (String putCode : putCodes) {
try {
Long id = Long.valueOf(putCode);
WorkEntity workEntity = workEntityCacheManager.retrieveFullWork(orcid, id, getLastModified(orcid));
works.add(jpaJaxbWorkAdapter.toWork(workEntity));
} catch (Exception e) {
works.add(orcidCoreExceptionMapper.getOrcidError(new PutCodeFormatException("'" + putCode + "' is not a valid put code")));
}
}
WorkBulk bulk = new WorkBulk();
bulk.setBulk(works);
return bulk;
}
Aggregations