use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class ActivityValidatorTest method validateEducation_dontChangeVisibilityTest.
@Test(expected = VisibilityMismatchException.class)
public void validateEducation_dontChangeVisibilityTest() {
Education education = getEducation();
education.setVisibility(Visibility.LIMITED);
activityValidator.validateAffiliation(education, null, false, true, Visibility.PUBLIC);
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method createItemList.
private List<Item> createItemList(OrgAffiliationRelationEntity orgAffiliationEntity) {
Item item = new Item();
item.setItemName(orgAffiliationEntity.getOrg().getName());
ItemType itemType = null;
switch(orgAffiliationEntity.getAffiliationType()) {
case DISTINCTION:
itemType = ItemType.DISTINCTION;
break;
case EDUCATION:
itemType = ItemType.EDUCATION;
break;
case EMPLOYMENT:
itemType = ItemType.EMPLOYMENT;
break;
case INVITED_POSITION:
itemType = ItemType.INVITED_POSITION;
break;
case MEMBERSHIP:
itemType = ItemType.MEMBERSHIP;
break;
case QUALIFICATION:
itemType = ItemType.QUALIFICATION;
break;
case SERVICE:
itemType = ItemType.SERVICE;
break;
}
item.setItemType(itemType);
item.setPutCode(String.valueOf(orgAffiliationEntity.getId()));
return Arrays.asList(item);
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class AffiliationsManagerImpl method updateAffiliation.
public Affiliation updateAffiliation(String orcid, Affiliation affiliation, boolean isApiRequest, AffiliationType type) {
OrgAffiliationRelationEntity entity = orgAffiliationRelationDao.getOrgAffiliationRelation(orcid, affiliation.getPutCode());
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
// Save the original source
String existingSourceId = entity.getSourceId();
String existingClientSourceId = entity.getClientSourceId();
org.orcid.jaxb.model.common_v2.Visibility originalVisibility = entity.getVisibility();
orcidSecurityManager.checkSource(entity);
activityValidator.validateAffiliation(affiliation, sourceEntity, false, isApiRequest, org.orcid.jaxb.model.v3.dev1.common.Visibility.fromValue(originalVisibility.value()));
if (isApiRequest) {
checkAffiliationExternalIDsForDuplicates(orcid, affiliation, sourceEntity);
}
switch(type) {
case DISTINCTION:
jpaJaxbDistinctionAdapter.toOrgAffiliationRelationEntity((Distinction) affiliation, entity);
break;
case EDUCATION:
jpaJaxbEducationAdapter.toOrgAffiliationRelationEntity((Education) affiliation, entity);
break;
case EMPLOYMENT:
jpaJaxbEmploymentAdapter.toOrgAffiliationRelationEntity((Employment) affiliation, entity);
break;
case INVITED_POSITION:
jpaJaxbInvitedPositionAdapter.toOrgAffiliationRelationEntity((InvitedPosition) affiliation, entity);
break;
case MEMBERSHIP:
jpaJaxbMembershipAdapter.toOrgAffiliationRelationEntity((Membership) affiliation, entity);
break;
case QUALIFICATION:
jpaJaxbQualificationAdapter.toOrgAffiliationRelationEntity((Qualification) affiliation, entity);
break;
case SERVICE:
jpaJaxbServiceAdapter.toOrgAffiliationRelationEntity((Service) affiliation, entity);
break;
}
entity.setVisibility(originalVisibility);
// Be sure it doesn't overwrite the source
entity.setSourceId(existingSourceId);
entity.setClientSourceId(existingClientSourceId);
// Updates the give organization with the latest organization from
// database, or, create a new one
OrgEntity updatedOrganization = orgManager.getOrgEntity(affiliation);
entity.setOrg(updatedOrganization);
entity.setAffiliationType(type);
entity = orgAffiliationRelationDao.merge(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.Education in project ORCID-Source by ORCID.
the class AffiliationsManagerReadOnlyImpl method getAffiliations.
@Override
public List<Affiliation> getAffiliations(String orcid) {
List<OrgAffiliationRelationEntity> affiliations = orgAffiliationRelationDao.getByUser(orcid);
List<Affiliation> result = new ArrayList<Affiliation>();
if (affiliations != null) {
for (OrgAffiliationRelationEntity affiliation : affiliations) {
switch(affiliation.getAffiliationType()) {
case DISTINCTION:
result.add(jpaJaxbDistinctionAdapter.toDistinction(affiliation));
break;
case EDUCATION:
result.add(jpaJaxbEducationAdapter.toEducation(affiliation));
break;
case EMPLOYMENT:
result.add(jpaJaxbEmploymentAdapter.toEmployment(affiliation));
break;
case INVITED_POSITION:
result.add(jpaJaxbInvitedPositionAdapter.toInvitedPosition(affiliation));
break;
case MEMBERSHIP:
result.add(jpaJaxbMembershipAdapter.toMembership(affiliation));
break;
case QUALIFICATION:
result.add(jpaJaxbQualificationAdapter.toQualification(affiliation));
break;
case SERVICE:
result.add(jpaJaxbServiceAdapter.toService(affiliation));
break;
}
}
}
return result;
}
use of org.orcid.jaxb.model.v3.dev1.record.Education in project ORCID-Source by ORCID.
the class TransientNonEmptyStringTest method testMarshal.
/**
* <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
* <common:external-ids xmlns:internal="http://www.orcid.org/ns/internal" xmlns:address="http://www.orcid.org/ns/address" xmlns:email="http://www.orcid.org/ns/email" xmlns:history="http://www.orcid.org/ns/history" xmlns:employment="http://www.orcid.org/ns/employment" xmlns:person="http://www.orcid.org/ns/person" xmlns:education="http://www.orcid.org/ns/education" xmlns:other-name="http://www.orcid.org/ns/other-name" xmlns:personal-details="http://www.orcid.org/ns/personal-details" xmlns:bulk="http://www.orcid.org/ns/bulk" xmlns:common="http://www.orcid.org/ns/common" xmlns:record="http://www.orcid.org/ns/record" xmlns:keyword="http://www.orcid.org/ns/keyword" xmlns:activities="http://www.orcid.org/ns/activities" xmlns:deprecated="http://www.orcid.org/ns/deprecated" xmlns:external-identifier="http://www.orcid.org/ns/external-identifier" xmlns:funding="http://www.orcid.org/ns/funding" xmlns:error="http://www.orcid.org/ns/error" xmlns:preferences="http://www.orcid.org/ns/preferences" xmlns:work="http://www.orcid.org/ns/work" xmlns:researcher-url="http://www.orcid.org/ns/researcher-url" xmlns:peer-review="http://www.orcid.org/ns/peer-review">
* <common:external-id>
* <common:external-id-type>doi</common:external-id-type>
* <common:external-id-value>value</common:external-id-value>
* <common:external-id-normalized transient="true">normalized-value</common:external-id-normalized>
* </common:external-id>
* </common:external-ids>
* @throws JAXBException
* @throws SAXException
* @throws IOException
*/
@Test
public void testMarshal() throws JAXBException, SAXException, IOException {
ExternalIDs ids = new ExternalIDs();
ExternalID id = new ExternalID();
id.setType("doi");
id.setValue("value");
id.setNormalized(new TransientNonEmptyString("normalized-value"));
ids.getExternalIdentifier().add(id);
JAXBContext context = JAXBContext.newInstance(ExternalIDs.class);
Marshaller marshaller = context.createMarshaller();
StringWriter sw = new StringWriter();
marshaller.marshal(ids, sw);
assertTrue(sw.toString().contains("<common:external-id-normalized transient=\"true\">normalized-value</common:external-id-normalized>"));
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory.newSchema(getClass().getResource("/common_3.0_dev1/common-3.0_dev1.xsd"));
Validator validator = schema.newValidator();
validator.validate(new JAXBSource(context, ids));
}
Aggregations