01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/presentation/api/src/java/org/theospi/portfolio/presentation/CommentSortBy.java $
03: * $Id: CommentSortBy.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.presentation;
21:
22: import org.theospi.portfolio.shared.model.OspException;
23:
24: /**
25: * Created by IntelliJ IDEA.
26: * User: John Ellis
27: * Date: Jun 1, 2004
28: * Time: 4:17:15 PM
29: * To change this template use File | Settings | File Templates.
30: */
31: public class CommentSortBy {
32:
33: public static final String SORT_BY_DATE = "created";
34: public static final String SORT_BY_CREATOR = "creator_id";
35: public static final String SORT_BY_OWNER = "owner_id";
36: public static final String SORT_BY_PRES_NAME = "name";
37: public static final String SORT_BY_TITLE = "title";
38: public static final String SORT_BY_VISIBILITY = "visibility";
39:
40: private static final String SORT_FIELD_SEARCH = "#" + SORT_BY_DATE
41: + "#" + SORT_BY_CREATOR + "#" + SORT_BY_OWNER + "#"
42: + SORT_BY_PRES_NAME + "#" + SORT_BY_VISIBILITY + "#"
43: + SORT_BY_TITLE + "#";
44:
45: public static final String ASCENDING = "asc";
46: public static final String DESCENDING = "desc";
47:
48: private static final String DIRECTION_SEARCH = "#" + ASCENDING
49: + "#" + DESCENDING + "#";
50:
51: private String sortByColumn = SORT_BY_DATE;
52: private String direction = DESCENDING;
53:
54: public CommentSortBy() {
55: }
56:
57: public CommentSortBy(String sortByColumn) {
58: setSortByColumn(sortByColumn);
59: }
60:
61: public String getSortByColumn() {
62: return sortByColumn;
63: }
64:
65: public void setSortByColumn(String sortByColumn) {
66: if (SORT_FIELD_SEARCH.indexOf("#" + sortByColumn + "#") == -1) {
67: throw new OspException("Invalid sort");
68: }
69:
70: this .sortByColumn = sortByColumn;
71: }
72:
73: public String getDirection() {
74: return direction;
75: }
76:
77: public void setDirection(String direction) {
78: if (DIRECTION_SEARCH.indexOf("#" + direction + "#") == -1) {
79: throw new OspException("Invalid sort");
80: }
81:
82: this.direction = direction;
83: }
84: }
|