use of org.orcid.jaxb.model.record_rc3.Work in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method updateWork.
@Override
public Response updateWork(String orcid, Long putCode, Work work) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.ORCID_WORKS_UPDATE);
if (!putCode.equals(work.getPutCode())) {
Map<String, String> params = new HashMap<String, String>();
params.put("urlPutCode", String.valueOf(putCode));
params.put("bodyPutCode", String.valueOf(work.getPutCode()));
throw new MismatchedPutCodeException(params);
}
clearSource(work);
Work w = workManager.updateWork(orcid, work, true);
sourceUtils.setSourceName(w);
return Response.ok(w).build();
}
use of org.orcid.jaxb.model.record_rc3.Work in project ORCID-Source by ORCID.
the class Utils method getWork.
public static Work getWork(String title) {
Work work = new Work();
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title(title));
work.setWorkTitle(workTitle);
work.setWorkType(WorkType.BOOK);
work.setVisibility(Visibility.PUBLIC);
ExternalIDs extIds = new ExternalIDs();
ExternalID extId = new ExternalID();
extId.setRelationship(Relationship.PART_OF);
extId.setType(WorkExternalIdentifierType.AGR.value());
extId.setValue("ext-id-" + System.currentTimeMillis());
extId.setUrl(new Url("http://thisIsANewUrl.com"));
extIds.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIds);
return work;
}
use of org.orcid.jaxb.model.record_rc3.Work in project ORCID-Source by ORCID.
the class WorkForm method toWork.
public Work toWork() {
Work work = new Work();
// Set work id
if (!PojoUtil.isEmpty(this.getPutCode())) {
work.setPutCode(Long.valueOf(this.getPutCode().getValue()));
}
// Set language
if (!PojoUtil.isEmpty(this.getLanguageCode())) {
work.setLanguageCode(this.getLanguageCode().getValue());
}
// Set type
if (!PojoUtil.isEmpty(this.getWorkType())) {
work.setWorkType(WorkType.fromValue(this.getWorkType().getValue()));
}
org.orcid.jaxb.model.record_v2.WorkTitle workTitle = new org.orcid.jaxb.model.record_v2.WorkTitle();
// Set title
if (!PojoUtil.isEmpty(this.getTitle())) {
workTitle.setTitle(new org.orcid.jaxb.model.common_v2.Title(this.getTitle().getValue()));
}
// Set translated title
if (this.getTranslatedTitle() != null && !PojoUtil.isEmpty(this.getTranslatedTitle().getContent())) {
org.orcid.jaxb.model.common_v2.TranslatedTitle translatedTitle = new org.orcid.jaxb.model.common_v2.TranslatedTitle();
translatedTitle.setContent(this.getTranslatedTitle().getContent());
translatedTitle.setLanguageCode(this.getTranslatedTitle().getLanguageCode());
workTitle.setTranslatedTitle(translatedTitle);
}
// Set subtitle
if (!PojoUtil.isEmpty(this.getSubtitle())) {
org.orcid.jaxb.model.common_v2.Subtitle subtitle = new org.orcid.jaxb.model.common_v2.Subtitle();
subtitle.setContent(this.getSubtitle().getValue());
workTitle.setSubtitle(subtitle);
}
work.setWorkTitle(workTitle);
// Set journal title
if (!PojoUtil.isEmpty(this.getJournalTitle())) {
work.setJournalTitle(new org.orcid.jaxb.model.common_v2.Title(this.getJournalTitle().getValue()));
}
// Set description
if (!PojoUtil.isEmpty(this.getShortDescription())) {
work.setShortDescription(this.getShortDescription().getValue());
}
// Set url
if (!PojoUtil.isEmpty(this.getUrl())) {
work.setUrl(new Url(this.getUrl().getValue()));
} else {
work.setUrl(new Url());
}
// Set visibility
if (this.getVisibility() != null) {
work.setVisibility(this.getVisibility());
}
// Set country
if (!PojoUtil.isEmpty(this.getCountryCode())) {
work.setCountry(new org.orcid.jaxb.model.common_v2.Country(org.orcid.jaxb.model.common_v2.Iso3166Country.fromValue(this.getCountryCode().getValue())));
}
// Set publication date
if (this.getPublicationDate() != null) {
Integer yearInteger = PojoUtil.isEmpty(this.getPublicationDate().getYear()) ? null : Integer.valueOf(this.getPublicationDate().getYear());
Integer monthInteger = PojoUtil.isEmpty(this.getPublicationDate().getMonth()) ? null : Integer.valueOf(this.getPublicationDate().getMonth());
Integer dayInteger = PojoUtil.isEmpty(this.getPublicationDate().getDay()) ? null : Integer.valueOf(this.getPublicationDate().getDay());
org.orcid.jaxb.model.common_v2.Year year = null;
org.orcid.jaxb.model.common_v2.Month month = null;
org.orcid.jaxb.model.common_v2.Day day = null;
if (yearInteger != null) {
year = new org.orcid.jaxb.model.common_v2.Year(yearInteger);
}
if (monthInteger != null) {
month = new org.orcid.jaxb.model.common_v2.Month(monthInteger);
}
if (dayInteger != null) {
day = new org.orcid.jaxb.model.common_v2.Day(dayInteger);
}
work.setPublicationDate(new org.orcid.jaxb.model.common_v2.PublicationDate(year, month, day));
}
// Set citation
if (this.getCitation() != null) {
org.orcid.jaxb.model.record_v2.Citation citation = new org.orcid.jaxb.model.record_v2.Citation();
if (!PojoUtil.isEmpty(this.getCitation().getCitation())) {
citation.setCitation(this.getCitation().getCitation().getValue());
}
if (!PojoUtil.isEmpty(this.getCitation().getCitationType())) {
citation.setWorkCitationType(CitationType.fromValue(this.getCitation().getCitationType().getValue()));
}
work.setWorkCitation(citation);
}
// Set contributors
populateContributors(this, work);
// Set external identifiers
populateExternalIdentifiers(this, work);
// Set created date
if (!PojoUtil.isEmpty(this.getCreatedDate())) {
CreatedDate createdDate = new CreatedDate();
createdDate.setValue(DateUtils.convertToXMLGregorianCalendar(this.getCreatedDate().toJavaDate()));
work.setCreatedDate(createdDate);
}
// Set last modified
if (!PojoUtil.isEmpty(this.getLastModified())) {
org.orcid.jaxb.model.common_v2.LastModifiedDate lastModified = new org.orcid.jaxb.model.common_v2.LastModifiedDate();
lastModified.setValue(DateUtils.convertToXMLGregorianCalendar(this.getLastModified().toJavaDate()));
work.setLastModifiedDate(lastModified);
}
if (!PojoUtil.isEmpty(this.getSource())) {
org.orcid.jaxb.model.common_v2.Source source = new org.orcid.jaxb.model.common_v2.Source();
if (OrcidStringUtils.isClientId(this.getSource())) {
source.setSourceClientId(new SourceClientId(this.getSource()));
} else {
source.setSourceOrcid(new SourceOrcid(this.getSource()));
}
work.setSource(source);
}
return work;
}
use of org.orcid.jaxb.model.record_rc3.Work in project ORCID-Source by ORCID.
the class SourceInActivitiesTest method getWork.
private Work getWork(String userOrcid) {
Work work = new Work();
WorkTitle title = new WorkTitle();
title.setTitle(new Title("Work " + System.currentTimeMillis()));
work.setWorkTitle(title);
work.setWorkType(org.orcid.jaxb.model.record_v2.WorkType.BOOK);
ExternalID extId = new ExternalID();
extId.setValue("111");
extId.setType(WorkExternalIdentifierType.DOI.value());
ExternalIDs extIdentifiers = new ExternalIDs();
extIdentifiers.getExternalIdentifier().add(extId);
work.setWorkExternalIdentifiers(extIdentifiers);
work = workManager.createWork(userOrcid, work, false);
return workManager.getWork(userOrcid, work.getPutCode(), 0L);
}
use of org.orcid.jaxb.model.record_rc3.Work in project ORCID-Source by ORCID.
the class OrcidSecurityManager_WorkBulkTest method testMixedPublicAndLimitedWorkBulkReadLimitedToken.
@Test
public void testMixedPublicAndLimitedWorkBulkReadLimitedToken() {
WorkBulk workBulk = new WorkBulk();
workBulk.setBulk(Arrays.asList(createWork(Visibility.PUBLIC, CLIENT_2), createWork(Visibility.LIMITED, CLIENT_2)));
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_LIMITED);
orcidSecurityManager.checkAndFilter(ORCID_1, workBulk, ScopePathType.ORCID_WORKS_READ_LIMITED);
assertNotNull(workBulk);
assertEquals(2, workBulk.getBulk().size());
assertTrue(workBulk.getBulk().get(0) instanceof Work);
assertTrue(workBulk.getBulk().get(1) instanceof Work);
}
Aggregations