use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterImpl method getAffiliations.
private Affiliations getAffiliations(ProfileEntity profileEntity) {
LOGGER.debug("About to convert affiliations from entity: " + profileEntity.getId());
Set<OrgAffiliationRelationEntity> orgRelationEntities = profileEntity.getOrgAffiliationRelations();
if (orgRelationEntities != null && !orgRelationEntities.isEmpty()) {
Affiliations affiliations = new Affiliations();
List<Affiliation> affiliationList = affiliations.getAffiliation();
for (OrgAffiliationRelationEntity orgRelationEntity : orgRelationEntities) {
affiliationList.add(getAffiliation(orgRelationEntity));
}
return affiliations;
}
return null;
}
use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getEducationMapperFacade.
public MapperFacade getEducationMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<Education, OrgAffiliationRelationEntity> educationClassMap = mapperFactory.classMap(Education.class, OrgAffiliationRelationEntity.class);
addV2CommonFields(educationClassMap);
registerSourceConverters(mapperFactory, educationClassMap);
educationClassMap.fieldBToA("org.name", "organization.name");
educationClassMap.fieldBToA("org.city", "organization.address.city");
educationClassMap.fieldBToA("org.region", "organization.address.region");
educationClassMap.fieldBToA("org.country", "organization.address.country");
educationClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
educationClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
educationClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
educationClassMap.field("departmentName", "department");
educationClassMap.field("roleTitle", "title");
educationClassMap.register();
ClassMapBuilder<EducationSummary, OrgAffiliationRelationEntity> educationSummaryClassMap = mapperFactory.classMap(EducationSummary.class, OrgAffiliationRelationEntity.class);
addV2CommonFields(educationSummaryClassMap);
registerSourceConverters(mapperFactory, educationSummaryClassMap);
educationSummaryClassMap.fieldBToA("org.name", "organization.name");
educationSummaryClassMap.fieldBToA("org.city", "organization.address.city");
educationSummaryClassMap.fieldBToA("org.region", "organization.address.region");
educationSummaryClassMap.fieldBToA("org.country", "organization.address.country");
educationSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
educationSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
educationSummaryClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
educationSummaryClassMap.field("departmentName", "department");
educationSummaryClassMap.field("roleTitle", "title");
educationSummaryClassMap.register();
mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.
the class Jpa2JaxbAdapterTest method testProfileEntityToOrcidMessage.
@Test
public void testProfileEntityToOrcidMessage() {
String userOrcid = "0000-0000-0000-1234";
String clientId = "APP-5555555555555555";
ProfileEntity profile = new ProfileEntity(userOrcid);
// Set default visibility
profile.setActivitiesVisibilityDefault(org.orcid.jaxb.model.common_v2.Visibility.LIMITED);
// Set name
RecordNameEntity name = new RecordNameEntity();
name.setCreditName("My credit name");
name.setFamilyName("My family name");
name.setGivenNames("My given names");
name.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
profile.setRecordNameEntity(name);
// Set biography
BiographyEntity bio = new BiographyEntity();
bio.setBiography("This is my biography");
bio.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
profile.setBiographyEntity(bio);
// Set other names
TreeSet<OtherNameEntity> otherNames = new TreeSet<OtherNameEntity>();
OtherNameEntity otherName = new OtherNameEntity();
otherName.setDisplayName("My other name");
otherName.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
otherName.setDisplayIndex(20000L);
otherName.setClientSourceId(clientId);
otherName.setId(24816L);
otherNames.add(otherName);
profile.setOtherNames(otherNames);
// Set address
Set<AddressEntity> addresses = new HashSet<AddressEntity>();
AddressEntity address = new AddressEntity();
address.setIso2Country(Iso3166Country.US);
address.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
address.setDisplayIndex(20000L);
address.setClientSourceId(clientId);
address.setId(24816L);
addresses.add(address);
profile.setAddresses(addresses);
// Set keywords
TreeSet<ProfileKeywordEntity> keywords = new TreeSet<ProfileKeywordEntity>();
ProfileKeywordEntity keyword = new ProfileKeywordEntity();
keyword.setKeywordName("My keyword");
keyword.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
keyword.setDisplayIndex(20000L);
keyword.setClientSourceId(clientId);
keyword.setId(24816L);
keywords.add(keyword);
profile.setKeywords(keywords);
// Set researcher urls
TreeSet<ResearcherUrlEntity> rUrls = new TreeSet<ResearcherUrlEntity>();
ResearcherUrlEntity rUrl = new ResearcherUrlEntity();
rUrl.setUrl("http://orcid.org");
rUrl.setUrlName("My rUrl");
rUrl.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
rUrl.setDisplayIndex(20000L);
rUrl.setClientSourceId(clientId);
rUrl.setId(24816L);
rUrls.add(rUrl);
profile.setResearcherUrls(rUrls);
// Set external identifiers
Set<ExternalIdentifierEntity> extIds = new HashSet<ExternalIdentifierEntity>();
ExternalIdentifierEntity extId = new ExternalIdentifierEntity();
extId.setExternalIdCommonName("My common name");
extId.setExternalIdReference("My refrence");
extId.setExternalIdUrl("http://orcid.org");
extId.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
extId.setDisplayIndex(20000L);
extId.setClientSourceId(clientId);
extId.setId(24816L);
extIds.add(extId);
profile.setExternalIdentifiers(extIds);
// Set works
TreeSet<WorkEntity> works = new TreeSet<WorkEntity>();
WorkEntity work = new WorkEntity();
work.setWorkType(WorkType.OTHER);
work.setTitle("My work title");
work.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
work.setDisplayIndex(20000L);
work.setClientSourceId(clientId);
work.setId(24816L);
works.add(work);
profile.setWorks(works);
when(mockWorkEntityCacheManager.retrieveFullWorks(userOrcid, 0)).thenReturn(new ArrayList<>(works));
// Existing org
OrgEntity newOrg = new OrgEntity();
newOrg.setId(1234L);
newOrg.setCity("San Jose");
newOrg.setCountry(org.orcid.jaxb.model.message.Iso3166Country.CR);
newOrg.setName("My org name");
// Set funding
TreeSet<ProfileFundingEntity> fundings = new TreeSet<ProfileFundingEntity>();
ProfileFundingEntity funding = new ProfileFundingEntity();
funding.setOrg(newOrg);
funding.setTitle("My funding title");
funding.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
funding.setDisplayIndex(20000L);
funding.setClientSourceId(clientId);
funding.setId(24816L);
fundings.add(funding);
profile.setProfileFunding(fundings);
// Set affiliations
TreeSet<OrgAffiliationRelationEntity> affiliations = new TreeSet<OrgAffiliationRelationEntity>();
OrgAffiliationRelationEntity affiliation = new OrgAffiliationRelationEntity();
affiliation.setAffiliationType(org.orcid.jaxb.model.record_v2.AffiliationType.EDUCATION);
affiliation.setOrg(newOrg);
affiliation.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
affiliation.setClientSourceId(clientId);
affiliation.setId(24816L);
affiliations.add(affiliation);
profile.setOrgAffiliationRelations(affiliations);
OrcidProfile orcidProfile = adapter.toOrcidProfile(profile);
// Check profile
assertNotNull(orcidProfile);
assertNotNull(orcidProfile.getOrcidIdentifier());
assertEquals("http://orcid.org/" + userOrcid, orcidProfile.getOrcidIdentifier().getUri());
assertEquals("orcid.org", orcidProfile.getOrcidIdentifier().getHost());
assertEquals(userOrcid, orcidProfile.getOrcidIdentifier().getPath());
// Check activities
assertNotNull(orcidProfile.getOrcidActivities());
// Check works
assertNotNull(orcidProfile.getOrcidActivities().getOrcidWorks());
assertNotNull(orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork());
assertEquals(1, orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
assertEquals("My work title", orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkTitle().getTitle().getContent());
assertEquals("24816", orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPutCode());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getVisibility());
checkSource(orcidProfile.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getSource(), clientId);
// Check fundings
assertNotNull(orcidProfile.getOrcidActivities().getFundings());
assertNotNull(orcidProfile.getOrcidActivities().getFundings().getFundings());
assertEquals(1, orcidProfile.getOrcidActivities().getFundings().getFundings().size());
assertEquals("My funding title", orcidProfile.getOrcidActivities().getFundings().getFundings().get(0).getTitle().getTitle().getContent());
assertEquals("24816", orcidProfile.getOrcidActivities().getFundings().getFundings().get(0).getPutCode());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidActivities().getFundings().getFundings().get(0).getVisibility());
checkSource(orcidProfile.getOrcidActivities().getFundings().getFundings().get(0).getSource(), clientId);
// Check affiliations
assertNotNull(orcidProfile.getOrcidActivities().getAffiliations());
assertNotNull(orcidProfile.getOrcidActivities().getAffiliations().getAffiliation());
assertEquals(1, orcidProfile.getOrcidActivities().getAffiliations().getAffiliation().size());
assertEquals(AffiliationType.EDUCATION, orcidProfile.getOrcidActivities().getAffiliations().getAffiliation().get(0).getType());
assertEquals("My org name", orcidProfile.getOrcidActivities().getAffiliations().getAffiliation().get(0).getOrganization().getName());
assertEquals("San Jose", orcidProfile.getOrcidActivities().getAffiliations().getAffiliation().get(0).getOrganization().getAddress().getCity());
assertEquals(org.orcid.jaxb.model.message.Iso3166Country.CR, orcidProfile.getOrcidActivities().getAffiliations().getAffiliation().get(0).getOrganization().getAddress().getCountry());
assertEquals("24816", orcidProfile.getOrcidActivities().getAffiliations().getAffiliation().get(0).getPutCode());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidActivities().getAffiliations().getAffiliation().get(0).getVisibility());
checkSource(orcidProfile.getOrcidActivities().getAffiliations().getAffiliation().get(0).getSource(), clientId);
// Check biography
assertNotNull(orcidProfile.getOrcidBio());
// Check name
assertNotNull(orcidProfile.getOrcidBio().getPersonalDetails());
assertNotNull(orcidProfile.getOrcidBio().getPersonalDetails().getCreditName());
assertEquals("My credit name", orcidProfile.getOrcidBio().getPersonalDetails().getCreditName().getContent());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getPersonalDetails().getCreditName().getVisibility());
assertNotNull(orcidProfile.getOrcidBio().getPersonalDetails().getGivenNames());
assertEquals("My given names", orcidProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getPersonalDetails().getGivenNames().getVisibility());
assertNotNull(orcidProfile.getOrcidBio().getPersonalDetails().getFamilyName());
assertEquals("My family name", orcidProfile.getOrcidBio().getPersonalDetails().getFamilyName().getContent());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getPersonalDetails().getFamilyName().getVisibility());
// Check other names
assertNotNull(orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames());
assertNotNull(orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames().getVisibility());
assertEquals(1, orcidProfile.getOrcidBio().getPersonalDetails().getOtherNames().getOtherName().size());
// Check biography
assertNotNull(orcidProfile.getOrcidBio().getBiography());
assertEquals("This is my biography", orcidProfile.getOrcidBio().getBiography().getContent());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getBiography().getVisibility());
// Check address
assertNotNull(orcidProfile.getOrcidBio().getContactDetails());
assertNotNull(orcidProfile.getOrcidBio().getContactDetails().getAddress());
assertNotNull(orcidProfile.getOrcidBio().getContactDetails().getAddress().getCountry());
assertEquals(org.orcid.jaxb.model.message.Iso3166Country.US, orcidProfile.getOrcidBio().getContactDetails().getAddress().getCountry().getValue());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getContactDetails().getAddress().getCountry().getVisibility());
// Check keywords
assertNotNull(orcidProfile.getOrcidBio().getKeywords());
assertNotNull(orcidProfile.getOrcidBio().getKeywords().getKeyword());
assertEquals(1, orcidProfile.getOrcidBio().getKeywords().getKeyword().size());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getKeywords().getVisibility());
assertEquals("My keyword", orcidProfile.getOrcidBio().getKeywords().getKeyword().get(0).getContent());
// Check researcher urls
assertNotNull(orcidProfile.getOrcidBio().getResearcherUrls());
assertNotNull(orcidProfile.getOrcidBio().getResearcherUrls().getResearcherUrl());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getResearcherUrls().getVisibility());
assertEquals(1, orcidProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().size());
assertEquals("My rUrl", orcidProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrlName().getContent());
assertEquals("http://orcid.org", orcidProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
// Check external identifiers
assertNotNull(orcidProfile.getOrcidBio().getExternalIdentifiers());
assertNotNull(orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier());
assertEquals(1, orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().size());
assertEquals("My common name", orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdCommonName().getContent());
assertEquals("My refrence", orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdReference().getContent());
assertEquals("http://orcid.org", orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getExternalIdUrl().getValue());
assertEquals(org.orcid.jaxb.model.message.Visibility.PUBLIC, orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getVisibility());
checkSource(orcidProfile.getOrcidBio().getExternalIdentifiers().getExternalIdentifier().get(0).getSource(), clientId);
}
use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.
the class JpaJaxbEmploymentAdapterTest method testToOrgAffiliationRelationEntity.
@Test
public void testToOrgAffiliationRelationEntity() throws JAXBException {
Employment e = getEmployment(true);
assertNotNull(e);
OrgAffiliationRelationEntity oar = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity(e);
assertNotNull(oar);
//General info
assertEquals(Long.valueOf(0), oar.getId());
assertEquals(Visibility.PRIVATE.value(), oar.getVisibility().value());
assertEquals("employment:department-name", oar.getDepartment());
assertEquals("employment:role-title", oar.getTitle());
//Dates
assertEquals(Integer.valueOf(2), oar.getStartDate().getDay());
assertEquals(Integer.valueOf(2), oar.getStartDate().getMonth());
assertEquals(Integer.valueOf(1848), oar.getStartDate().getYear());
assertEquals(Integer.valueOf(2), oar.getEndDate().getDay());
assertEquals(Integer.valueOf(2), oar.getEndDate().getMonth());
assertEquals(Integer.valueOf(1848), oar.getEndDate().getYear());
//Source
assertNull(oar.getSourceId());
assertNull(oar.getClientSourceId());
assertNull(oar.getElementSourceId());
}
use of org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity in project ORCID-Source by ORCID.
the class JpaJaxbEducationAdapterTest method fromOrgAffiliationRelationEntityToEducation.
@Test
public void fromOrgAffiliationRelationEntityToEducation() {
OrgAffiliationRelationEntity entity = getEducationEntity();
assertNotNull(entity);
Education education = jpaJaxbEducationAdapter.toEducation(entity);
assertNotNull(education);
assertEquals("education:department", education.getDepartmentName());
assertEquals(Long.valueOf(123456), education.getPutCode());
assertEquals("education:title", education.getRoleTitle());
assertEquals("private", education.getVisibility().value());
assertNotNull(education.getStartDate());
assertEquals("2000", education.getStartDate().getYear().getValue());
assertEquals("01", education.getStartDate().getMonth().getValue());
assertEquals("01", education.getStartDate().getDay().getValue());
assertEquals("2020", education.getEndDate().getYear().getValue());
assertEquals("02", education.getEndDate().getMonth().getValue());
assertEquals("02", education.getEndDate().getDay().getValue());
assertNotNull(education.getOrganization());
assertEquals("org:name", education.getOrganization().getName());
assertNotNull(education.getOrganization().getAddress());
assertEquals("org:city", education.getOrganization().getAddress().getCity());
assertEquals("org:region", education.getOrganization().getAddress().getRegion());
assertEquals(org.orcid.jaxb.model.common_v2.Iso3166Country.US, education.getOrganization().getAddress().getCountry());
assertNotNull(education.getSource());
assertNotNull(education.getSource().retrieveSourcePath());
assertEquals("APP-000000001", education.getSource().retrieveSourcePath());
}
Aggregations