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 38 import java.util.Date; 39 40 41 /** 42 * This class represents question and answers on the help desk 43 */ 44 public class QuestionAnswer 45 { 46 public static final int STATUS_PUBLISHED = 1; 47 public static final int STATUS_UNPUBLISHED = 0; 48 private int _nIdQuestionAnswer; 49 private String _strQuestion; 50 private String _strAnswer; 51 private int _nIdSubject; 52 private int _nIdOrder; 53 private boolean _bIsEnabled; 54 private Date _dateCreation; 55 56 /** 57 * Creates a new QuestionAnswer object. 58 */ 59 public QuestionAnswer( ) 60 { 61 } 62 63 /** 64 * Returns the identifier of the object 65 * @return The identifier 66 */ 67 public int getIdQuestionAnswer( ) 68 { 69 return _nIdQuestionAnswer; 70 } 71 72 /** 73 * Sets the identifier of the object to the specified value 74 * @param nIdQuestionAnswer The new value 75 */ 76 public void setIdQuestionAnswer( int nIdQuestionAnswer ) 77 { 78 _nIdQuestionAnswer = nIdQuestionAnswer; 79 } 80 81 /** 82 * Returns the question associated with this object 83 * @return A string literal containing the question 84 */ 85 public String getQuestion( ) 86 { 87 return _strQuestion; 88 } 89 90 /** 91 * Associates a new question with this object 92 * @param strQuestion The new value 93 */ 94 public void setQuestion( String strQuestion ) 95 { 96 _strQuestion = strQuestion; 97 } 98 99 /** 100 * Returns the answer associated with this object 101 * @return A string literal containing the answer 102 */ 103 public String getAnswer( ) 104 { 105 return _strAnswer; 106 } 107 108 /** 109 * Associates a new answer with this object 110 * @param strAnswer The new value 111 */ 112 public void setAnswer( String strAnswer ) 113 { 114 _strAnswer = strAnswer; 115 } 116 117 /** 118 * Returns the identifier of the subject 119 * @return The identifier 120 */ 121 public int getIdSubject( ) 122 { 123 return _nIdSubject; 124 } 125 126 /** 127 * Return the {@link Subject} 128 * @param plugin The plugin 129 * @return The {@link Subject} 130 */ 131 public Subject getSubject( Plugin plugin ) 132 { 133 return (Subject) SubjectHome.getInstance( ).findByPrimaryKey( getIdSubject( ), plugin ); 134 } 135 136 /** 137 * Assigns this QuestionAnswer to a subject 138 * @param nIdSubject The identifier of the subject 139 */ 140 public void setIdSubject( int nIdSubject ) 141 { 142 _nIdSubject = nIdSubject; 143 } 144 145 /** 146 * Returns the status of the object 147 * @return true if the object is enabled 148 */ 149 public boolean isEnabled( ) 150 { 151 return _bIsEnabled; 152 } 153 154 /** 155 * Sets the status of the object 156 * @param status 1 to enable the object, any other value to disable it 157 */ 158 public void setStatus( int status ) 159 { 160 if ( status == 1 ) 161 { 162 _bIsEnabled = true; 163 } 164 else 165 { 166 _bIsEnabled = false; 167 } 168 } 169 170 /** 171 * @return the _dateCreation 172 */ 173 public Date getCreationDate( ) 174 { 175 return _dateCreation; 176 } 177 178 /** 179 * @param dateCreationDate the _dateCreation to set 180 */ 181 public void setCreationDate( Date dateCreationDate ) 182 { 183 _dateCreation = dateCreationDate; 184 } 185 186 /** 187 * @return the _nIdOrder 188 */ 189 public int getIdOrder( ) 190 { 191 return _nIdOrder; 192 } 193 194 /** 195 * @param nIdOrder the _nIdOrder to set 196 */ 197 public void setIdOrder( int nIdOrder ) 198 { 199 _nIdOrder = nIdOrder; 200 } 201 }