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.helpdesk.business;
35
36 import fr.paris.lutece.portal.service.plugin.Plugin;
37 import fr.paris.lutece.portal.service.role.RoleRemovalListenerService;
38 import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource;
39 import fr.paris.lutece.portal.service.workgroup.WorkgroupRemovalListenerService;
40
41 import java.util.Collection;
42
43
44 /**
45 * This class represents a Faq object.
46 */
47 public class Faq implements AdminWorkgroupResource
48 {
49 private static FaqWorkgroupRemovalListener _listenerWorkgroup;
50 private static FaqRoleRemovalListener _listenerRole;
51 public static final String RESOURCE_TYPE = "HELPDESK_FAQ";
52 public static final String ROLE_NONE = "none";
53 private int _nId;
54 private String _strName;
55 private String _strDescription;
56 private String _strRoleKey;
57 private String _strWorkgroupKey;
58
59 /**
60 * Creates a new Faq object.
61 */
62 public Faq( )
63 {
64 }
65
66 /**
67 * Initialize the Faq
68 */
69 public static void init( )
70 {
71 // Create removal listeners and register them
72 if ( _listenerWorkgroup == null )
73 {
74 _listenerWorkgroup = new FaqWorkgroupRemovalListener( );
75 WorkgroupRemovalListenerService.getService( ).registerListener( _listenerWorkgroup );
76 }
77
78 if ( _listenerRole == null )
79 {
80 _listenerRole = new FaqRoleRemovalListener( );
81 RoleRemovalListenerService.getService( ).registerListener( _listenerRole );
82 }
83 }
84
85 /**
86 * Get the Id
87 *
88 * @return the _nId
89 */
90 public int getId( )
91 {
92 return _nId;
93 }
94
95 /**
96 * Set the Id
97 *
98 * @param nId the _nId to set
99 */
100 public void setId( int nId )
101 {
102 _nId = nId;
103 }
104
105 /**
106 * Get the name
107 *
108 * @return the _strName
109 */
110 public String getName( )
111 {
112 return _strName;
113 }
114
115 /**
116 * Set the name
117 *
118 * @param strName the _strName to set
119 */
120 public void setName( String strName )
121 {
122 _strName = strName;
123 }
124
125 /**
126 * Get the Description
127 *
128 * @return the _strDescription
129 */
130 public String getDescription( )
131 {
132 return _strDescription;
133 }
134
135 /**
136 * Set the Description
137 *
138 * @param strDescription the _strDescription to set
139 */
140 public void setDescription( String strDescription )
141 {
142 _strDescription = strDescription;
143 }
144
145 /**
146 * Get the Lutece role key
147 *
148 * @return the _strRoleKey
149 */
150 public String getRoleKey( )
151 {
152 return _strRoleKey;
153 }
154
155 /**
156 * Set the Lutece role key
157 *
158 * @param strRoleKey the _strRoleKey to set
159 */
160 public void setRoleKey( String strRoleKey )
161 {
162 _strRoleKey = strRoleKey;
163 }
164
165 /**
166 * Get the list of subjects <strong>directly</strong> linked to {@link Faq} (not sub-subjects)
167 * @param plugin The {@link Plugin}
168 * @return The collection of {@link Subject}
169 */
170 public Collection<Subject> getSubjectsList( Plugin plugin )
171 {
172 return (Collection<Subject>) SubjectHome.getInstance( ).findByIdFaq( getId( ), plugin );
173 }
174
175 /**
176 * Get the list of themes <strong>directly</strong> linked to {@link Faq} (not sub-themes)
177 *
178 * @param plugin The {@link Plugin}
179 * @return The collection of {@link Theme}
180 */
181 public Collection<Theme> getThemesList( Plugin plugin )
182 {
183 return (Collection<Theme>) ThemeHome.getInstance( ).findByIdFaq( getId( ), plugin );
184 }
185
186 /**
187 * Set the workgroup key for {@link Faq}
188 *
189 * @param strWorkgroupKey the _strWorkgroupKey to set
190 */
191 public void setWorkgroup( String strWorkgroupKey )
192 {
193 this._strWorkgroupKey = strWorkgroupKey;
194 }
195
196 /**
197 * Get the workgroup key for {@link Faq}
198 *
199 * @return the _strWorkgroupKey
200 */
201 public String getWorkgroup( )
202 {
203 return _strWorkgroupKey;
204 }
205 }