use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class JpaJaxbMembershipAdapterTest method getMembership.
private Membership getMembership() throws JAXBException {
JAXBContext context = JAXBContext.newInstance(new Class[] { Membership.class });
Unmarshaller unmarshaller = context.createUnmarshaller();
String name = "/record_3.0_dev1/samples/read_samples/membership-3.0_dev1.xml";
InputStream inputStream = getClass().getResourceAsStream(name);
return (Membership) unmarshaller.unmarshal(inputStream);
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class JpaJaxbMembershipAdapterTest method fromOrgAffiliationRelationEntityToMembership.
@Test
public void fromOrgAffiliationRelationEntityToMembership() {
OrgAffiliationRelationEntity entity = getEntity();
assertNotNull(entity);
Membership membership = adapter.toMembership(entity);
assertNotNull(membership);
assertEquals("membership:department", membership.getDepartmentName());
assertEquals(Long.valueOf(123456), membership.getPutCode());
assertEquals("membership:title", membership.getRoleTitle());
assertEquals("private", membership.getVisibility().value());
assertNotNull(membership.getStartDate());
assertEquals("2000", membership.getStartDate().getYear().getValue());
assertEquals("01", membership.getStartDate().getMonth().getValue());
assertEquals("01", membership.getStartDate().getDay().getValue());
assertEquals("2020", membership.getEndDate().getYear().getValue());
assertEquals("02", membership.getEndDate().getMonth().getValue());
assertEquals("02", membership.getEndDate().getDay().getValue());
assertNotNull(membership.getOrganization());
assertEquals("org:name", membership.getOrganization().getName());
assertNotNull(membership.getOrganization().getAddress());
assertEquals("org:city", membership.getOrganization().getAddress().getCity());
assertEquals("org:region", membership.getOrganization().getAddress().getRegion());
assertEquals(org.orcid.jaxb.model.v3.dev1.common.Iso3166Country.US, membership.getOrganization().getAddress().getCountry());
assertNotNull(membership.getSource());
assertNotNull(membership.getSource().retrieveSourcePath());
assertEquals("APP-000000001", membership.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method createAffiliation.
private Affiliation createAffiliation(String orcid, Affiliation affiliation, boolean isApiRequest, AffiliationType type) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
activityValidator.validateAffiliation(affiliation, sourceEntity, true, isApiRequest, null);
if (isApiRequest) {
checkAffiliationExternalIDsForDuplicates(orcid, affiliation, sourceEntity);
}
OrgAffiliationRelationEntity entity = null;
switch(type) {
case DISTINCTION:
entity = jpaJaxbDistinctionAdapter.toOrgAffiliationRelationEntity((Distinction) affiliation);
break;
case EDUCATION:
entity = jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity((Education) affiliation);
break;
case EMPLOYMENT:
entity = jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity((Employment) affiliation);
break;
case INVITED_POSITION:
entity = jpaJaxbInvitedPositionAdapter.toOrgAffiliationRelationEntity((InvitedPosition) affiliation);
break;
case MEMBERSHIP:
entity = jpaJaxbMembershipAdapter.toOrgAffiliationRelationEntity((Membership) affiliation);
break;
case QUALIFICATION:
entity = jpaJaxbQualificationAdapter.toOrgAffiliationRelationEntity((Qualification) affiliation);
break;
case SERVICE:
entity = jpaJaxbServiceAdapter.toOrgAffiliationRelationEntity((Service) affiliation);
break;
}
// Updates the give organization with the latest organization from
// database
OrgEntity updatedOrganization = orgManager.getOrgEntity(affiliation);
entity.setOrg(updatedOrganization);
// Set source id
if (sourceEntity.getSourceProfile() != null) {
entity.setSourceId(sourceEntity.getSourceProfile().getId());
}
if (sourceEntity.getSourceClient() != null) {
entity.setClientSourceId(sourceEntity.getSourceClient().getId());
}
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
entity.setProfile(profile);
setIncomingWorkPrivacy(entity, profile);
entity.setAffiliationType(type);
orgAffiliationRelationDao.persist(entity);
orgAffiliationRelationDao.flush();
Affiliation result = null;
switch(type) {
case DISTINCTION:
notificationManager.sendAmendEmail(orcid, AmendedSection.DISTINCTION, createItemList(entity));
result = jpaJaxbDistinctionAdapter.toDistinction(entity);
break;
case EDUCATION:
notificationManager.sendAmendEmail(orcid, AmendedSection.EDUCATION, createItemList(entity));
result = jpaJaxbEducationAdapter.toEducation(entity);
break;
case EMPLOYMENT:
notificationManager.sendAmendEmail(orcid, AmendedSection.EMPLOYMENT, createItemList(entity));
result = jpaJaxbEmploymentAdapter.toEmployment(entity);
break;
case INVITED_POSITION:
notificationManager.sendAmendEmail(orcid, AmendedSection.INVITED_POSITION, createItemList(entity));
result = jpaJaxbInvitedPositionAdapter.toInvitedPosition(entity);
break;
case MEMBERSHIP:
notificationManager.sendAmendEmail(orcid, AmendedSection.MEMBERSHIP, createItemList(entity));
result = jpaJaxbMembershipAdapter.toMembership(entity);
break;
case QUALIFICATION:
notificationManager.sendAmendEmail(orcid, AmendedSection.QUALIFICATION, createItemList(entity));
result = jpaJaxbQualificationAdapter.toQualification(entity);
break;
case SERVICE:
notificationManager.sendAmendEmail(orcid, AmendedSection.SERVICE, createItemList(entity));
result = jpaJaxbServiceAdapter.toService(entity);
break;
}
return result;
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class ValidateV3_dev1SamplesTest method testUnmarshallMembership.
@Test
public void testUnmarshallMembership() throws SAXException, URISyntaxException {
Membership object = (Membership) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/membership-3.0_dev1.xml", Membership.class);
validateAffiliation(object, false);
object = (Membership) unmarshallFromPath("/record_3.0_dev1/samples/write_samples/membership-3.0_dev1.xml", Membership.class);
validateAffiliation(object, true);
}
use of org.orcid.jaxb.model.v3.dev1.record.Membership in project ORCID-Source by ORCID.
the class ValidateV3_dev1SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
} else if (Education.class.equals(type)) {
result = (Education) obj;
} else if (Educations.class.equals(type)) {
result = (Educations) obj;
} else if (Employment.class.equals(type)) {
result = (Employment) obj;
} else if (Employments.class.equals(type)) {
result = (Employments) obj;
} else if (Distinction.class.equals(type)) {
result = (Distinction) obj;
} else if (Distinctions.class.equals(type)) {
result = (Distinctions) obj;
} else if (InvitedPosition.class.equals(type)) {
result = (InvitedPosition) obj;
} else if (InvitedPositions.class.equals(type)) {
result = (InvitedPositions) obj;
} else if (Membership.class.equals(type)) {
result = (Membership) obj;
} else if (Memberships.class.equals(type)) {
result = (Memberships) obj;
} else if (Qualification.class.equals(type)) {
result = (Qualification) obj;
} else if (Qualifications.class.equals(type)) {
result = (Qualifications) obj;
} else if (Service.class.equals(type)) {
result = (Service) obj;
} else if (Services.class.equals(type)) {
result = (Services) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
Aggregations