List<ResultPublication> books = new ArrayList<ResultPublication>(); List<ResultPublication> bookParts = new ArrayList<ResultPublication>(); List<ResultPublication> articles = new ArrayList<ResultPublication>(); List<ResultPublication> inproceedings = new ArrayList<ResultPublication>(); List<ResultPublication> proceedings = new ArrayList<ResultPublication>(); List<ResultPublication> theses = new ArrayList<ResultPublication>(); List<ResultPublication> manuals = new ArrayList<ResultPublication>(); List<ResultPublication> technicalReports = new ArrayList<ResultPublication>(); List<ResultPublication> booklets = new ArrayList<ResultPublication>(); List<ResultPublication> miscs = new ArrayList<ResultPublication>(); List<ResultPublication> unpublisheds = new ArrayList<ResultPublication>(); List<ResultPublication> unstructureds = new ArrayList<ResultPublication>();
setRequestAttributesToList(request);
    public ActionForward listPublications(ActionMapping mapping, ActionForm form,            HttpServletRequest request, HttpServletResponse response) {        final IUserView userView = getUserView(request);        List<ResultPublication> books = new ArrayList<ResultPublication>();        List<ResultPublication> bookParts = new ArrayList<ResultPublication>();        List<ResultPublication> articles = new ArrayList<ResultPublication>();        List<ResultPublication> inproceedings = new ArrayList<ResultPublication>();        List<ResultPublication> proceedings = new ArrayList<ResultPublication>();        List<ResultPublication> theses = new ArrayList<ResultPublication>();        List<ResultPublication> manuals = new ArrayList<ResultPublication>();        List<ResultPublication> technicalReports = new ArrayList<ResultPublication>();        List<ResultPublication> booklets = new ArrayList<ResultPublication>();        List<ResultPublication> miscs = new ArrayList<ResultPublication>();        List<ResultPublication> unpublisheds = new ArrayList<ResultPublication>();        List<ResultPublication> unstructureds = new ArrayList<ResultPublication>();        for (ResultPublication resultPublication : userView.getPerson().getResultPublications()) {            if (resultPublication instanceof Book)                books.add(resultPublication);            else if (resultPublication instanceof BookPart)                bookParts.add(resultPublication);            else if (resultPublication instanceof Article)                articles.add(resultPublication);            else if (resultPublication instanceof Inproceedings)                inproceedings.add(resultPublication);            else if (resultPublication instanceof Proceedings)                proceedings.add(resultPublication);            else if (resultPublication instanceof Thesis)                theses.add(resultPublication);            else if (resultPublication instanceof Manual)                manuals.add(resultPublication);            else if (resultPublication instanceof TechnicalReport)                technicalReports.add(resultPublication);            else if (resultPublication instanceof Booklet)                booklets.add(resultPublication);            else if (resultPublication instanceof Misc)                miscs.add(resultPublication);            else if (resultPublication instanceof Unpublished)                unpublisheds.add(resultPublication);            else if (resultPublication instanceof Unstructured)                unstructureds.add(resultPublication);        }        // comparator by year in descendent order        Comparator YearComparator = new Comparator() {            public int compare(Object o1, Object o2) {                Integer publication1Year = ((ResultPublication) o1).getYear();                Integer publication2Year = ((ResultPublication) o2).getYear();                if (publication1Year == null) {                    return 1;                } else if (publication2Year == null) {                    return -1;                }                return (-1) * publication1Year.compareTo(publication2Year);            }        };        // order publications        Collections.sort(books, YearComparator);        Collections.sort(bookParts, YearComparator);        Collections.sort(articles, YearComparator);        Collections.sort(inproceedings, YearComparator);        Collections.sort(proceedings, YearComparator);        Collections.sort(theses, YearComparator);        Collections.sort(manuals, YearComparator);        Collections.sort(technicalReports, YearComparator);        Collections.sort(booklets, YearComparator);        Collections.sort(miscs, YearComparator);        Collections.sort(unpublisheds, YearComparator);        request.setAttribute("books", books);        request.setAttribute("bookParts", bookParts);        request.setAttribute("articles", articles);        request.setAttribute("inproceedings", inproceedings);        request.setAttribute("proceedings", proceedings);        request.setAttribute("theses", theses);        request.setAttribute("manuals", manuals);        request.setAttribute("technicalReports", technicalReports);        request.setAttribute("booklets", booklets);        request.setAttribute("miscs", miscs);        request.setAttribute("unpublisheds", unpublisheds);        request.setAttribute("unstructureds", unstructureds);        return mapping.findForward("ListPublications");    }