use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class PeerReviewForm method valueOf.
public static PeerReviewForm valueOf(PeerReview peerReview) {
PeerReviewForm form = new PeerReviewForm();
// Put code
if (peerReview.getPutCode() != null) {
form.setPutCode(Text.valueOf(peerReview.getPutCode()));
}
// Visibility
if (peerReview.getVisibility() != null) {
form.setVisibility(Visibility.valueOf(peerReview.getVisibility()));
}
// Completion date
if (!PojoUtil.isEmpty(peerReview.getCompletionDate())) {
form.setCompletionDate(Date.valueOf(peerReview.getCompletionDate()));
}
// Role
if (peerReview.getRole() != null) {
form.setRole(Text.valueOf(peerReview.getRole().value()));
}
// Type
if (peerReview.getType() != null) {
form.setType(Text.valueOf(peerReview.getType().value()));
}
// Url
if (!PojoUtil.isEmpty(peerReview.getUrl())) {
form.setUrl(Text.valueOf(peerReview.getUrl().getValue()));
}
// Org info
if (peerReview.getOrganization() != null) {
if (!PojoUtil.isEmpty(peerReview.getOrganization().getName())) {
form.setOrgName(Text.valueOf(peerReview.getOrganization().getName()));
}
if (peerReview.getOrganization().getAddress() != null) {
if (!PojoUtil.isEmpty(peerReview.getOrganization().getAddress().getCity())) {
form.setCity(Text.valueOf(peerReview.getOrganization().getAddress().getCity()));
}
if (peerReview.getOrganization().getAddress().getCountry() != null) {
form.setCountry(Text.valueOf(peerReview.getOrganization().getAddress().getCountry().value()));
}
if (!PojoUtil.isEmpty(peerReview.getOrganization().getAddress().getRegion())) {
form.setRegion(Text.valueOf(peerReview.getOrganization().getAddress().getRegion()));
}
}
if (peerReview.getOrganization().getDisambiguatedOrganization() != null) {
if (!PojoUtil.isEmpty(peerReview.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier())) {
form.setDisambiguatedOrganizationSourceId(Text.valueOf(peerReview.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier()));
}
if (!PojoUtil.isEmpty(peerReview.getOrganization().getDisambiguatedOrganization().getDisambiguationSource())) {
form.setDisambiguationSource(Text.valueOf(peerReview.getOrganization().getDisambiguatedOrganization().getDisambiguationSource()));
}
}
}
// External ids
if (peerReview.getExternalIdentifiers() != null) {
List<ExternalID> externalIdentifiers = peerReview.getExternalIdentifiers().getExternalIdentifier();
form.setExternalIdentifiers(new ArrayList<WorkExternalIdentifier>());
for (ExternalID extId : externalIdentifiers) {
form.getExternalIdentifiers().add(WorkExternalIdentifier.valueOf(extId));
}
}
// Group Id
if (!PojoUtil.isEmpty(peerReview.getGroupId())) {
form.setGroupId(Text.valueOf(peerReview.getGroupId()));
}
// Subject ext Id
if (peerReview.getSubjectExternalIdentifier() != null) {
WorkExternalIdentifier wExtId = new WorkExternalIdentifier();
if (peerReview.getSubjectExternalIdentifier().getRelationship() != null) {
wExtId.setRelationship(Text.valueOf(peerReview.getSubjectExternalIdentifier().getRelationship().value()));
}
if (peerReview.getSubjectExternalIdentifier().getUrl() != null) {
wExtId.setUrl(Text.valueOf(peerReview.getSubjectExternalIdentifier().getUrl().getValue()));
}
if (peerReview.getSubjectExternalIdentifier().getValue() != null) {
wExtId.setWorkExternalIdentifierId(Text.valueOf(peerReview.getSubjectExternalIdentifier().getValue()));
}
if (peerReview.getSubjectExternalIdentifier().getType() != null) {
wExtId.setWorkExternalIdentifierType(Text.valueOf(peerReview.getSubjectExternalIdentifier().getType()));
}
form.setSubjectExternalIdentifier(wExtId);
}
// Subject Container name
if (peerReview.getSubjectContainerName() != null) {
form.setSubjectContainerName(Text.valueOf(peerReview.getSubjectContainerName().getContent()));
}
// Subject type
if (peerReview.getSubjectType() != null) {
form.setSubjectType(Text.valueOf(peerReview.getSubjectType().value()));
}
// Subject name
if (peerReview.getSubjectName() != null) {
if (peerReview.getSubjectName().getTitle() != null) {
form.setSubjectName(Text.valueOf(peerReview.getSubjectName().getTitle().getContent()));
}
TranslatedTitleForm tTitle = new TranslatedTitleForm();
if (peerReview.getSubjectName().getTranslatedTitle() != null) {
tTitle.setContent(peerReview.getSubjectName().getTranslatedTitle().getContent());
tTitle.setLanguageCode(peerReview.getSubjectName().getTranslatedTitle().getLanguageCode());
}
form.setTranslatedSubjectName(tTitle);
}
// Subject url
if (peerReview.getSubjectUrl() != null) {
form.setSubjectUrl(Text.valueOf(peerReview.getSubjectUrl().getValue()));
}
// Source
if (peerReview.getSource() != null) {
form.setSource(peerReview.getSource().retrieveSourcePath());
if (peerReview.getSource().getSourceName() != null)
form.setSourceName(peerReview.getSource().getSourceName().getContent());
}
// Created Date
if (peerReview.getCreatedDate() != null) {
form.setCreatedDate(Date.valueOf(peerReview.getCreatedDate()));
}
// Last modified
if (peerReview.getLastModifiedDate() != null) {
form.setLastModified(Date.valueOf(peerReview.getLastModifiedDate()));
}
return form;
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class PeerReviewForm method toPeerReview.
public PeerReview toPeerReview() {
PeerReview peerReview = new PeerReview();
// Put Code
if (!PojoUtil.isEmpty(putCode)) {
peerReview.setPutCode(Long.valueOf(putCode.getValue()));
}
// Visibility
if (visibility != null && visibility.getVisibility() != null) {
peerReview.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(visibility.getVisibility().value()));
}
// Completion date
if (completionDate != null) {
peerReview.setCompletionDate(new FuzzyDate(completionDate.toFuzzyDate()));
}
// External identifiers
if (externalIdentifiers != null && !externalIdentifiers.isEmpty()) {
peerReview.setExternalIdentifiers(new ExternalIDs());
for (WorkExternalIdentifier extId : externalIdentifiers) {
peerReview.getExternalIdentifiers().getExternalIdentifier().add(extId.toRecordWorkExternalIdentifier());
}
}
// Set Organization
Organization organization = new Organization();
OrganizationAddress organizationAddress = new OrganizationAddress();
organization.setAddress(organizationAddress);
if (!PojoUtil.isEmpty(orgName)) {
organization.setName(orgName.getValue());
}
if (!PojoUtil.isEmpty(city)) {
organizationAddress.setCity(city.getValue());
}
if (!PojoUtil.isEmpty(region)) {
organizationAddress.setRegion(region.getValue());
}
if (!PojoUtil.isEmpty(country)) {
organizationAddress.setCountry(Iso3166Country.fromValue(country.getValue()));
}
if (!PojoUtil.isEmpty(disambiguatedOrganizationSourceId)) {
organization.setDisambiguatedOrganization(new DisambiguatedOrganization());
organization.getDisambiguatedOrganization().setDisambiguatedOrganizationIdentifier(disambiguatedOrganizationSourceId.getValue());
organization.getDisambiguatedOrganization().setDisambiguationSource(disambiguationSource.getValue());
}
peerReview.setOrganization(organization);
// Role
if (!PojoUtil.isEmpty(role)) {
peerReview.setRole(Role.fromValue(role.getValue()));
}
// Type
if (!PojoUtil.isEmpty(type)) {
peerReview.setType(PeerReviewType.fromValue(type.getValue()));
}
// Url
if (!PojoUtil.isEmpty(url)) {
peerReview.setUrl(new Url(url.getValue()));
}
// Group id
if (!PojoUtil.isEmpty(groupId)) {
peerReview.setGroupId(groupId.getValue());
}
// Subject external id
if (!PojoUtil.isEmpty(subjectExternalIdentifier)) {
ExternalID subjectExtId = new ExternalID();
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getRelationship())) {
subjectExtId.setRelationship(Relationship.fromValue(subjectExternalIdentifier.getRelationship().getValue()));
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getUrl())) {
subjectExtId.setUrl(new Url(subjectExternalIdentifier.getUrl().getValue()));
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getWorkExternalIdentifierId())) {
subjectExtId.setValue(subjectExternalIdentifier.getWorkExternalIdentifierId().getValue());
}
if (!PojoUtil.isEmpty(subjectExternalIdentifier.getWorkExternalIdentifierType())) {
subjectExtId.setType(subjectExternalIdentifier.getWorkExternalIdentifierType().getValue());
}
peerReview.setSubjectExternalIdentifier(subjectExtId);
}
// Subject container name
if (!PojoUtil.isEmpty(subjectContainerName)) {
Title containerName = new Title(subjectContainerName.getValue());
peerReview.setSubjectContainerName(containerName);
}
// Subject type
if (!PojoUtil.isEmpty(subjectType)) {
peerReview.setSubjectType(WorkType.fromValue(subjectType.getValue()));
}
// Subject name and subject translated name
if (!PojoUtil.isEmpty(subjectName) || !PojoUtil.isEmpty(translatedSubjectName)) {
WorkTitle workTitle = new WorkTitle();
if (!PojoUtil.isEmpty(subjectName)) {
workTitle.setTitle(new Title(subjectName.getValue()));
}
if (translatedSubjectName != null) {
org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle tTitle = new org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle();
if (!PojoUtil.isEmpty(translatedSubjectName.getContent())) {
tTitle.setContent(translatedSubjectName.getContent());
}
if (!PojoUtil.isEmpty(translatedSubjectName.getLanguageCode())) {
tTitle.setLanguageCode(translatedSubjectName.getLanguageCode());
}
workTitle.setTranslatedTitle(tTitle);
}
peerReview.setSubjectName(workTitle);
}
// Subject url
if (!PojoUtil.isEmpty(subjectUrl)) {
peerReview.setSubjectUrl(new Url(subjectUrl.getValue()));
}
return peerReview;
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class AffiliationForm method valueOf.
public static AffiliationForm valueOf(Affiliation affiliation) {
AffiliationForm form = new AffiliationForm();
if (affiliation instanceof Distinction) {
form.setAffiliationType(Text.valueOf(AffiliationType.DISTINCTION.value()));
} else if (affiliation instanceof Education) {
form.setAffiliationType(Text.valueOf(AffiliationType.EDUCATION.value()));
} else if (affiliation instanceof Employment) {
form.setAffiliationType(Text.valueOf(AffiliationType.EMPLOYMENT.value()));
} else if (affiliation instanceof InvitedPosition) {
form.setAffiliationType(Text.valueOf(AffiliationType.INVITED_POSITION.value()));
} else if (affiliation instanceof Membership) {
form.setAffiliationType(Text.valueOf(AffiliationType.MEMBERSHIP.value()));
} else if (affiliation instanceof Qualification) {
form.setAffiliationType(Text.valueOf(AffiliationType.QUALIFICATION.value()));
} else if (affiliation instanceof Service) {
form.setAffiliationType(Text.valueOf(AffiliationType.SERVICE.value()));
}
form.setPutCode(Text.valueOf(affiliation.getPutCode()));
form.setVisibility(Visibility.valueOf(affiliation.getVisibility()));
Organization organization = affiliation.getOrganization();
form.setDateSortString(PojoUtil.createDateSortString(affiliation));
form.setAffiliationName(Text.valueOf(organization.getName()));
OrganizationAddress address = organization.getAddress();
form.setCity(Text.valueOf(address.getCity()));
if (organization.getDisambiguatedOrganization() != null) {
if (organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) {
form.setDisambiguatedAffiliationSourceId(Text.valueOf(organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier()));
form.setDisambiguationSource(Text.valueOf(organization.getDisambiguatedOrganization().getDisambiguationSource()));
form.setOrgDisambiguatedId(Text.valueOf(String.valueOf(organization.getDisambiguatedOrganization().getId())));
}
}
if (address.getRegion() != null) {
form.setRegion(Text.valueOf(address.getRegion()));
} else {
form.setRegion(new Text());
}
if (address.getCountry() != null) {
form.setCountry(Text.valueOf(address.getCountry().value()));
} else {
form.setCountry(new Text());
}
if (affiliation.getDepartmentName() != null) {
form.setDepartmentName(Text.valueOf(affiliation.getDepartmentName()));
} else {
form.setDepartmentName(new Text());
}
if (affiliation.getRoleTitle() != null) {
form.setRoleTitle(Text.valueOf(affiliation.getRoleTitle()));
} else {
form.setRoleTitle(new Text());
}
if (affiliation.getStartDate() != null) {
form.setStartDate(Date.valueOf(affiliation.getStartDate()));
}
if (affiliation.getEndDate() != null) {
form.setEndDate(Date.valueOf(affiliation.getEndDate()));
}
Source source = affiliation.getSource();
if (source != null) {
form.setSource(source.retrieveSourcePath());
if (source.getSourceName() != null) {
form.setSourceName(source.getSourceName().getContent());
}
}
if (affiliation.getUrl() != null) {
form.setUrl(Text.valueOf(affiliation.getUrl().getValue()));
} else {
form.setUrl(new Text());
}
if (affiliation.getExternalIDs() != null) {
List<AffiliationExternalIdentifier> affiliationExternalIdentifiers = new ArrayList<>();
for (ExternalID externalID : affiliation.getExternalIDs().getExternalIdentifier()) {
affiliationExternalIdentifiers.add(AffiliationExternalIdentifier.valueOf(externalID));
}
form.setAffiliationExternalIdentifiers(affiliationExternalIdentifiers);
}
form.setCreatedDate(Date.valueOf(affiliation.getCreatedDate()));
form.setLastModified(Date.valueOf(affiliation.getLastModifiedDate()));
return form;
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class WorkFormTest method getWork.
public static Work getWork() {
Work work = new Work();
work.setCountry(new Country(Iso3166Country.US));
Date date = new Date();
work.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(date)));
work.setJournalTitle(new Title("Journal Title"));
work.setLanguageCode("EN");
work.setPublicationDate(new PublicationDate(new Year(2015), new Month(1), new Day(1)));
work.setPutCode(Long.valueOf("12345"));
work.setShortDescription("Short description");
work.setUrl(new Url("http://test.com"));
work.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED);
work.setWorkCitation(new org.orcid.jaxb.model.v3.dev1.record.Citation("Citation", CitationType.BIBTEX));
WorkContributors contributors = new WorkContributors();
org.orcid.jaxb.model.v3.dev1.common.Contributor contributor = new org.orcid.jaxb.model.v3.dev1.common.Contributor();
contributor.setCreditName(new CreditName("Credit name"));
contributor.setContributorOrcid(new ContributorOrcid("0000-0000-0000-0000"));
ContributorAttributes att = new ContributorAttributes();
att.setContributorRole(ContributorRole.ASSIGNEE);
att.setContributorSequence(SequenceType.FIRST);
contributor.setContributorAttributes(att);
contributors.getContributor().add(contributor);
work.setWorkContributors(contributors);
ExternalIDs weis = new ExternalIDs();
ExternalID wei = new ExternalID();
wei.setRelationship(Relationship.SELF);
wei.setUrl(new Url("http://test.com"));
wei.setValue("ID");
wei.setType(WorkExternalIdentifierType.AGR.value());
weis.getExternalIdentifier().add(wei);
work.setWorkExternalIdentifiers(weis);
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Work Title"));
workTitle.setSubtitle(new Subtitle("Subtitle"));
TranslatedTitle translated = new TranslatedTitle("Translated", "US");
workTitle.setTranslatedTitle(translated);
work.setWorkTitle(workTitle);
work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
return work;
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class JSONExternalIdentifiersConverterV3 method convertTo.
@Override
public String convertTo(ExternalIDs source, Type<String> destinationType) {
JSONExternalIdentifiers jsonExternalIdentifiers = new JSONExternalIdentifiers();
for (ExternalID externalID : source.getExternalIdentifier()) {
JSONExternalIdentifier jsonExternalIdentifier = new JSONExternalIdentifier();
if (externalID.getType() != null) {
jsonExternalIdentifier.setType(conv.convertTo(externalID.getType(), null));
}
if (externalID.getUrl() != null) {
jsonExternalIdentifier.setUrl(new JSONUrl(externalID.getUrl().getValue()));
}
if (!PojoUtil.isEmpty(externalID.getValue())) {
jsonExternalIdentifier.setValue(externalID.getValue());
}
if (externalID.getRelationship() != null) {
jsonExternalIdentifier.setRelationship(conv.convertTo(externalID.getRelationship().value(), null));
}
jsonExternalIdentifiers.getExternalIdentifier().add(jsonExternalIdentifier);
}
return JsonUtils.convertToJsonString(jsonExternalIdentifiers);
}
Aggregations