1 /*
2 * Copyright (c) 2002-2014, Mairie de Paris
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice
10 * and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice
13 * and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * License 1.0
33 */
34 package fr.paris.lutece.plugins.digglike.business;
35
36
37 /**
38 *
39 * class DiggFilter
40 *
41 */
42 public class DiggFilter
43 {
44 public static final String ALL_STRING = "all";
45 public static final int ALL_INT = -1;
46 public static final int ID_TRUE = 1;
47 public static final int ID_FALSE = 0;
48 private int _nIdState = ALL_INT;
49 private int _nIdDefaultDigg = ALL_INT;
50 private String _strWorkgroup = ALL_STRING;
51 private String _strRole = Digg.ROLE_NONE;
52
53 /**
54 * @return the _strRole
55 */
56 public String getRole( )
57 {
58 return _strRole;
59 }
60
61 /**
62 * @param strRole the _strRole to set
63 */
64 public void setRole( String strRole )
65 {
66 _strRole = strRole;
67 }
68
69 /**
70 *
71 * @return 1 if the diggs return must be enabled
72 * 0 if the diggss return must be disabled
73 */
74 public int getIdState( )
75 {
76 return _nIdState;
77 }
78
79 /**
80 * Set 1 if the diggs return must be enabled
81 * 0 if the diggs return must be disabled
82 * @param idState 1 if the diggs return must be enabled
83 * 0 if the diggs return must be disabled
84 */
85 public void setIdState( int idState )
86 {
87 _nIdState = idState;
88 }
89
90 /**
91 *
92 * @return true if the filter contain digg state
93 */
94 public boolean containsIdState( )
95 {
96 return ( _nIdState != ALL_INT );
97 }
98
99 /**
100 *
101 * @return the workgroup of the search diggs
102 */
103 public String getWorkgroup( )
104 {
105 return _strWorkgroup;
106 }
107
108 /**
109 * set the workgroup of the search diggs
110 * @param workgroup the workgroup of the search diggs
111 */
112 public void setWorkGroup( String workgroup )
113 {
114 _strWorkgroup = workgroup;
115 }
116
117 /**
118 *
119 * @return true if the filter contain workgroup criteria
120 */
121 public boolean containsWorkgroupCriteria( )
122 {
123 return ( !_strWorkgroup.equals( ALL_STRING ) );
124 }
125
126 /**
127 *
128 * @return true if the filter contain role criteria
129 */
130 public boolean containsRoleCriteria( )
131 {
132 return ( !_strRole.equals( Digg.ROLE_NONE ) );
133 }
134
135 /**
136 *
137 * @return 1 if the diggs return must be a default digg
138 * 0 if the diggs return must no be a default digg
139 */
140 public int getIdDefaultDigg( )
141 {
142 return _nIdDefaultDigg;
143 }
144
145 /**
146 * Set 1 if the diggs return must be a default digg
147 * 0 if the diggs return must no be a default digg
148 * @param idDefaultDigg 1 if the diggs return must be a default digg
149 * 0 if the diggs return must not be a default digg
150 */
151 public void setIdDefaultDigg( int idDefaultDigg )
152 {
153 _nIdDefaultDigg = idDefaultDigg;
154 }
155
156 /**
157 *
158 * @return true if the filter contain digg state
159 */
160 public boolean containsIdDefaultDigg( )
161 {
162 return ( _nIdDefaultDigg != ALL_INT );
163 }
164 }