use of org.orcid.pojo.KeyValue in project ORCID-Source by ORCID.
the class WorksController method retriveWorkTypes.
/**
* Return a list of work types based on the work category provided as a
* parameter
*
* @param workCategoryName
* @return a map containing the list of types associated with that type and
* his localized name
*/
@RequestMapping(value = "/loadWorkTypes.json", method = RequestMethod.GET)
@ResponseBody
public List<KeyValue> retriveWorkTypes(@RequestParam(value = "workCategory") String workCategoryName) {
List<KeyValue> types = new ArrayList<KeyValue>();
WorkCategory workCategory = null;
if (!PojoUtil.isEmpty(workCategoryName))
workCategory = WorkCategory.fromValue(workCategoryName);
// Get work types based on category
if (workCategory != null) {
for (WorkType workType : workCategory.getSubTypes()) {
// Dont put work type UNDEFINED
if (!workType.equals(WorkType.UNDEFINED)) {
types.add(new KeyValue(workType.value(), getMessage(new StringBuffer("org.orcid.jaxb.model.record.WorkType.").append(workType.value()).toString())));
}
}
} else {
// Get all work types
for (WorkType workType : WorkType.values()) {
// Dont put work type UNDEFINED
if (!workType.equals(WorkType.UNDEFINED)) {
types.add(new KeyValue(workType.value(), getMessage(new StringBuffer("org.orcid.jaxb.model.record.WorkType.").append(workType.value()).toString())));
}
}
}
return types;
}
Aggregations