use of org.orcid.pojo.ajaxForm.AffiliationForm in project ORCID-Source by ORCID.
the class OrcidInfo method getAffiliationsJson.
@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/affiliations.json")
@ResponseBody
public List<AffiliationForm> getAffiliationsJson(HttpServletRequest request, @PathVariable("orcid") String orcid, @RequestParam(value = "affiliationIds") String workIdsStr) {
List<AffiliationForm> affs = new ArrayList<AffiliationForm>();
Map<Long, Affiliation> affMap = affiliationMap(orcid, profileEntManager.getLastModified(orcid));
String[] affIds = workIdsStr.split(",");
for (String id : affIds) {
Affiliation aff = affMap.get(Long.valueOf(id));
validateVisibility(aff.getVisibility());
AffiliationForm form = AffiliationForm.valueOf(aff);
form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, aff.getOrganization().getAddress().getCountry().name())));
affs.add(form);
}
return affs;
}
use of org.orcid.pojo.ajaxForm.AffiliationForm in project ORCID-Source by ORCID.
the class AffiliationsController method getAffiliationJson.
/**
* List affiliations associated with a profile
* */
@SuppressWarnings("unchecked")
@RequestMapping(value = "/affiliations.json", method = RequestMethod.GET)
@ResponseBody
public List<AffiliationForm> getAffiliationJson(HttpServletRequest request, @RequestParam(value = "affiliationIds") String affiliationIdsStr) {
List<AffiliationForm> affiliationList = new ArrayList<>();
AffiliationForm affiliation = null;
String[] affiliationIds = affiliationIdsStr.split(",");
if (affiliationIds != null) {
HashMap<String, AffiliationForm> affiliationsMap = (HashMap<String, AffiliationForm>) request.getSession().getAttribute(AFFILIATIONS_MAP);
// this should never happen, but just in case.
if (affiliationsMap == null) {
createAffiliationsIdList(request);
affiliationsMap = (HashMap<String, AffiliationForm>) request.getSession().getAttribute(AFFILIATIONS_MAP);
}
for (String affiliationId : affiliationIds) {
affiliation = affiliationsMap.get(affiliationId);
if (affiliation.getStartDate() == null) {
initializeStartDate(affiliation);
} else {
if (affiliation.getStartDate().getDay() == null) {
affiliation.getStartDate().setDay(new String());
}
if (affiliation.getStartDate().getMonth() == null) {
affiliation.getStartDate().setMonth(new String());
}
if (affiliation.getStartDate().getYear() == null) {
affiliation.getStartDate().setYear(new String());
}
}
if (affiliation.getEndDate() == null) {
initializeEndDate(affiliation);
} else {
if (affiliation.getEndDate().getDay() == null) {
affiliation.getEndDate().setDay(new String());
}
if (affiliation.getEndDate().getMonth() == null) {
affiliation.getEndDate().setMonth(new String());
}
if (affiliation.getEndDate().getYear() == null) {
affiliation.getEndDate().setYear(new String());
}
}
affiliationList.add(affiliation);
}
}
return affiliationList;
}
use of org.orcid.pojo.ajaxForm.AffiliationForm in project ORCID-Source by ORCID.
the class AffiliationsController method getAffiliation.
/**
* Returns a blank affiliation form
* */
@RequestMapping(value = "/affiliation.json", method = RequestMethod.GET)
@ResponseBody
public AffiliationForm getAffiliation(HttpServletRequest request) {
AffiliationForm affiliationForm = new AffiliationForm();
ProfileEntity profile = profileEntityCacheManager.retrieve(getCurrentUserOrcid());
Visibility v = Visibility.valueOf(profile.getActivitiesVisibilityDefault() == null ? org.orcid.jaxb.model.common_v2.Visibility.fromValue(OrcidVisibilityDefaults.FUNDING_DEFAULT.getVisibility().value()) : profile.getActivitiesVisibilityDefault());
affiliationForm.setVisibility(v);
Text affiliationName = new Text();
affiliationForm.setAffiliationName(affiliationName);
affiliationName.setRequired(true);
Text city = new Text();
affiliationForm.setCity(city);
Text region = new Text();
affiliationForm.setRegion(region);
Text country = new Text();
affiliationForm.setCountry(country);
country.setValue("");
country.setRequired(true);
Text department = new Text();
affiliationForm.setDepartmentName(department);
Text roleTitle = new Text();
affiliationForm.setRoleTitle(roleTitle);
Text affiliationType = new Text();
affiliationForm.setAffiliationType(affiliationType);
affiliationType.setValue("");
Date startDate = new Date();
affiliationForm.setStartDate(startDate);
startDate.setDay("");
startDate.setMonth("");
startDate.setYear("");
Date endDate = new Date();
affiliationForm.setEndDate(endDate);
endDate.setDay("");
endDate.setMonth("");
endDate.setYear("");
affiliationForm.setOrgDisambiguatedId(new Text());
return affiliationForm;
}
use of org.orcid.pojo.ajaxForm.AffiliationForm 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())));
affiliationsMap.put(form.getPutCode().getValue(), form);
affiliationIds.add(form.getPutCode().getValue());
}
request.getSession().setAttribute(AFFILIATIONS_MAP, affiliationsMap);
}
return affiliationIds;
}
Aggregations