use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class Utils method getAffiliation.
public static Affiliation getAffiliation(AffiliationType type) {
Affiliation a = null;
switch(type) {
case DISTINCTION:
a = new Distinction();
break;
case EDUCATION:
a = new Education();
break;
case EMPLOYMENT:
a = new Employment();
break;
case INVITED_POSITION:
a = new InvitedPosition();
break;
case MEMBERSHIP:
a = new Membership();
break;
case QUALIFICATION:
a = new Qualification();
break;
case SERVICE:
a = new Service();
break;
}
a.setDepartmentName("My department name");
a.setRoleTitle("My Role");
a.setOrganization(getOrganization());
a.setStartDate(FuzzyDate.valueOf(2017, 1, 1));
return a;
}
use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class AffiliationsController method createAffiliationsIdList.
/**
* Create an affiliation id list and sorts a map associated with the list in
* in the session
*/
private List<String> createAffiliationsIdList(HttpServletRequest request) {
List<Affiliation> affiliationsList = affiliationsManager.getAffiliations(getCurrentUserOrcid());
HashMap<String, AffiliationForm> affiliationsMap = new HashMap<>();
List<String> affiliationIds = new ArrayList<String>();
if (affiliationsList != null) {
for (Affiliation affiliation : affiliationsList) {
AffiliationForm form = AffiliationForm.valueOf(affiliation);
form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, form.getCountry().getValue())));
if (form.getOrgDisambiguatedId() != null) {
OrgDisambiguated orgDisambiguated = orgDisambiguatedManager.findInDB(Long.parseLong(form.getOrgDisambiguatedId().getValue()));
form.setOrgDisambiguatedName(orgDisambiguated.getValue());
form.setOrgDisambiguatedUrl(orgDisambiguated.getUrl());
form.setOrgDisambiguatedCity(orgDisambiguated.getCity());
form.setOrgDisambiguatedRegion(orgDisambiguated.getRegion());
form.setOrgDisambiguatedCountry(orgDisambiguated.getCountry());
if (orgDisambiguated.getOrgDisambiguatedExternalIdentifiers() != null) {
form.setOrgDisambiguatedExternalIdentifiers(orgDisambiguated.getOrgDisambiguatedExternalIdentifiers());
}
}
affiliationsMap.put(form.getPutCode().getValue(), form);
affiliationIds.add(form.getPutCode().getValue());
}
request.getSession().setAttribute(AFFILIATIONS_MAP, affiliationsMap);
}
return affiliationIds;
}
use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class ActivityValidator method validateAffiliation.
public void validateAffiliation(Affiliation affiliation, SourceEntity sourceEntity, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) {
if (affiliation.getPutCode() != null && createFlag) {
Map<String, String> params = new HashMap<String, String>();
if (sourceEntity != null) {
params.put("clientName", sourceEntity.getSourceName());
}
throw new InvalidPutCodeException(params);
}
// Check that we are not changing the visibility
if (isApiRequest && !createFlag) {
Visibility updatedVisibility = affiliation.getVisibility();
validateVisibilityDoesntChange(updatedVisibility, originalVisibility);
}
if (affiliation.getStartDate() == null) {
throw new OrcidValidationException("Education start date is required");
}
if (isApiRequest) {
validateDisambiguatedOrg(affiliation);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class PojoUtilTest method affiliationsCreateDateSortString_StartDateOnlyTest.
@Test
public void affiliationsCreateDateSortString_StartDateOnlyTest() {
Affiliation aff = new Employment();
FuzzyDate start = new FuzzyDate();
start.setDay(new Day(1));
start.setMonth(new Month(2));
start.setYear(new Year(3));
aff.setStartDate(start);
String dateSortString = PojoUtil.createDateSortString(aff);
assertEquals("Y-3-02-01", dateSortString);
}
use of org.orcid.jaxb.model.v3.dev1.record.Affiliation in project ORCID-Source by ORCID.
the class PojoUtilTest method affiliationsCreateDateSortString_EndDateOnlyTest.
@Test
public void affiliationsCreateDateSortString_EndDateOnlyTest() {
Affiliation aff = new Employment();
FuzzyDate end = new FuzzyDate();
end.setDay(new Day(1));
end.setMonth(new Month(2));
end.setYear(new Year(3));
aff.setEndDate(end);
String dateSortString = PojoUtil.createDateSortString(aff);
assertEquals("X-3-02-01", dateSortString);
}
Aggregations