use of org.orcid.persistence.jpa.entities.FuzzyDateEntity in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterImpl method getAffiliation.
private Affiliation getAffiliation(OrgAffiliationRelationEntity orgAffiliationRelationEntity) {
Affiliation affiliation = new Affiliation();
affiliation.setPutCode(Long.toString(orgAffiliationRelationEntity.getId()));
if (orgAffiliationRelationEntity.getAffiliationType() != null) {
affiliation.setType(AffiliationType.fromValue(orgAffiliationRelationEntity.getAffiliationType().value()));
}
affiliation.setRoleTitle(orgAffiliationRelationEntity.getTitle());
FuzzyDateEntity startDate = orgAffiliationRelationEntity.getStartDate();
FuzzyDateEntity endDate = orgAffiliationRelationEntity.getEndDate();
affiliation.setStartDate(startDate != null ? new FuzzyDate(startDate.getYear(), startDate.getMonth(), startDate.getDay()) : null);
affiliation.setEndDate(endDate != null ? new FuzzyDate(endDate.getYear(), endDate.getMonth(), endDate.getDay()) : null);
affiliation.setVisibility(Visibility.fromValue(orgAffiliationRelationEntity.getVisibility().value()));
affiliation.setDepartmentName(orgAffiliationRelationEntity.getDepartment());
affiliation.setSource(getSource(orgAffiliationRelationEntity));
Organization organization = new Organization();
OrgDisambiguatedEntity orgDisambiguatedEntity = orgAffiliationRelationEntity.getOrg().getOrgDisambiguated();
if (orgDisambiguatedEntity != null) {
organization.setDisambiguatedOrganization(getDisambiguatedOrganization(orgDisambiguatedEntity));
}
organization.setAddress(getAddress(orgAffiliationRelationEntity.getOrg()));
organization.setName(orgAffiliationRelationEntity.getOrg().getName());
affiliation.setOrganization(organization);
affiliation.setCreatedDate(new CreatedDate(toXMLGregorianCalendar(orgAffiliationRelationEntity.getDateCreated())));
affiliation.setLastModifiedDate(new LastModifiedDate(toXMLGregorianCalendar(orgAffiliationRelationEntity.getLastModified())));
return affiliation;
}
use of org.orcid.persistence.jpa.entities.FuzzyDateEntity in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterImpl method getFunding.
/**
* Transforms a profileFundingEntity into a Funding
*
* @param profileFundingEntity
* @return Funding
* */
public Funding getFunding(ProfileFundingEntity profileFundingEntity) {
Funding funding = new Funding();
if (profileFundingEntity.getNumericAmount() != null) {
String stringAmount = profileFundingEntity.getNumericAmount().toString();
Amount orcidAmount = new Amount();
orcidAmount.setContent(stringAmount);
orcidAmount.setCurrencyCode(profileFundingEntity.getCurrencyCode() != null ? profileFundingEntity.getCurrencyCode() : null);
funding.setAmount(orcidAmount);
}
funding.setDescription(StringUtils.isNotEmpty(profileFundingEntity.getDescription()) ? profileFundingEntity.getDescription() : null);
FundingTitle title = new FundingTitle();
title.setTitle(StringUtils.isNotEmpty(profileFundingEntity.getTitle()) ? new Title(profileFundingEntity.getTitle()) : null);
if (StringUtils.isNotEmpty(profileFundingEntity.getTranslatedTitle())) {
String translatedTitleValue = profileFundingEntity.getTranslatedTitle();
String code = profileFundingEntity.getTranslatedTitleLanguageCode();
TranslatedTitle translatedTitle = new TranslatedTitle(translatedTitleValue, code);
title.setTranslatedTitle(translatedTitle);
}
funding.setTitle(title);
if (profileFundingEntity.getType() != null) {
funding.setType(FundingType.fromValue(profileFundingEntity.getType().value()));
}
funding.setOrganizationDefinedFundingType(profileFundingEntity.getOrganizationDefinedType() != null ? new OrganizationDefinedFundingSubType(profileFundingEntity.getOrganizationDefinedType()) : null);
funding.setUrl(StringUtils.isNotEmpty(profileFundingEntity.getUrl()) ? new Url(profileFundingEntity.getUrl()) : new Url(new String()));
if (profileFundingEntity.getVisibility() != null) {
funding.setVisibility(Visibility.fromValue(profileFundingEntity.getVisibility().value()));
} else {
funding.setVisibility(Visibility.PRIVATE);
}
funding.setPutCode(Long.toString(profileFundingEntity.getId()));
funding.setFundingContributors(getFundingContributors(profileFundingEntity));
if (profileFundingEntity.getExternalIdentifiersJson() != null) {
FundingExternalIdentifiers ids = FundingExternalIdentifiers.fromDBJSONString(profileFundingEntity.getExternalIdentifiersJson());
funding.setFundingExternalIdentifiers(ids.toMessagePojo());
}
// Set organization
Organization organization = new Organization();
OrgDisambiguatedEntity orgDisambiguatedEntity = profileFundingEntity.getOrg().getOrgDisambiguated();
if (orgDisambiguatedEntity != null) {
organization.setDisambiguatedOrganization(getDisambiguatedOrganization(orgDisambiguatedEntity));
}
organization.setAddress(getAddress(profileFundingEntity.getOrg()));
organization.setName(profileFundingEntity.getOrg().getName());
funding.setOrganization(organization);
// Set start and end date
FuzzyDateEntity startDate = profileFundingEntity.getStartDate();
FuzzyDateEntity endDate = profileFundingEntity.getEndDate();
funding.setStartDate(startDate != null ? new FuzzyDate(startDate.getYear(), startDate.getMonth(), startDate.getDay()) : null);
funding.setEndDate(endDate != null ? new FuzzyDate(endDate.getYear(), endDate.getMonth(), endDate.getDay()) : null);
// Set source
funding.setSource(getSource(profileFundingEntity));
funding.setCreatedDate(new CreatedDate(toXMLGregorianCalendar(profileFundingEntity.getDateCreated())));
funding.setLastModifiedDate(new LastModifiedDate(toXMLGregorianCalendar(profileFundingEntity.getLastModified())));
return funding;
}
Aggregations