Search in sources :

Example 1 with KeyValue

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;
}
Also used : KeyValue(org.orcid.pojo.KeyValue) WorkType(org.orcid.jaxb.model.record_v2.WorkType) ArrayList(java.util.ArrayList) WorkCategory(org.orcid.jaxb.model.record_v2.WorkCategory) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ArrayList (java.util.ArrayList)1 WorkCategory (org.orcid.jaxb.model.record_v2.WorkCategory)1 WorkType (org.orcid.jaxb.model.record_v2.WorkType)1 KeyValue (org.orcid.pojo.KeyValue)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1