001package org.woehlke.javaee7.petclinic.web;
002
003
004
005import org.richfaces.component.SortOrder;
006
007import javax.faces.bean.ManagedBean;
008import javax.faces.bean.SessionScoped;
009import java.io.Serializable;
010
011/**
012 * Created by tw on 13.03.14.
013 */
014@ManagedBean
015@SessionScoped
016public class VetSortingBean implements Serializable {
017
018    private static final long serialVersionUID = 1L;
019
020    private SortOrder sortOrderFirstName = SortOrder.unsorted;
021    private SortOrder sortOrderLastName = SortOrder.unsorted;
022    private SortOrder sortOrderSpecialties = SortOrder.unsorted;
023
024    public void setSortOrderToFirstName() {
025        if (SortOrder.ascending == sortOrderFirstName) {
026            sortOrderFirstName = SortOrder.descending;
027        } else {
028            sortOrderFirstName = SortOrder.ascending;
029        }
030        sortOrderLastName = SortOrder.unsorted;
031        sortOrderSpecialties = SortOrder.unsorted;
032    }
033
034    public void setSortOrderToLastName() {
035        sortOrderFirstName = SortOrder.unsorted;
036        if (SortOrder.ascending==sortOrderLastName) {
037            sortOrderLastName = SortOrder.descending;
038        } else {
039            sortOrderLastName = SortOrder.ascending;
040        }
041        sortOrderSpecialties = SortOrder.unsorted;
042    }
043
044    public void setSortOrderToSpecialties() {
045        sortOrderFirstName = SortOrder.unsorted;
046        sortOrderLastName = SortOrder.unsorted;
047        if (SortOrder.ascending==sortOrderSpecialties) {
048            sortOrderSpecialties = SortOrder.descending;
049        } else {
050            sortOrderSpecialties = SortOrder.ascending;
051        }
052    }
053
054    public SortOrder getSortOrderFirstName() {
055        return sortOrderFirstName;
056    }
057
058    public void setSortOrderFirstName(SortOrder sortOrderFirstName) {
059        this.sortOrderFirstName = sortOrderFirstName;
060    }
061
062    public SortOrder getSortOrderLastName() {
063        return sortOrderLastName;
064    }
065
066    public void setSortOrderLastName(SortOrder sortOrderLastName) {
067        this.sortOrderLastName = sortOrderLastName;
068    }
069
070    public SortOrder getSortOrderSpecialties() {
071        return sortOrderSpecialties;
072    }
073
074    public void setSortOrderSpecialties(SortOrder sortOrderSpecialties) {
075        this.sortOrderSpecialties = sortOrderSpecialties;
076    }
077}