1 /* 2 * Copyright (c) 2002-2021, City of 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.newsletter.business; 35 36 import fr.paris.lutece.portal.service.rbac.RBACResource; 37 import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource; 38 import fr.paris.lutece.portal.service.workgroup.WorkgroupRemovalListenerService; 39 40 /** 41 * This class represents business objects NewsLetterTemplate 42 */ 43 public class NewsLetterTemplate implements AdminWorkgroupResource, RBACResource 44 { 45 /** 46 * The resource type key 47 */ 48 public static final String RESOURCE_TYPE = "NEWSLETTER_TEMPLATE"; 49 private static final String EMPTY_STRING = ""; 50 private static NewsletterTemplateWorkgroupRemovalListener _listenerWorkgroup; 51 private int _nId; 52 private String _strTopicType; 53 private String _strDescription; 54 private String _strFileName; 55 private String _strPicture; 56 private String _strWorkgroup; 57 private int _nSectionNumber; 58 59 /** 60 * Initialisation method 61 */ 62 public static synchronized void init( ) 63 { 64 if ( _listenerWorkgroup == null ) 65 { 66 _listenerWorkgroup = new NewsletterTemplateWorkgroupRemovalListener( ); 67 WorkgroupRemovalListenerService.getService( ).registerListener( _listenerWorkgroup ); 68 } 69 } 70 71 /** 72 * Returns the identifier of the template 73 * 74 * @return the template identifier 75 */ 76 public int getId( ) 77 { 78 return _nId; 79 } 80 81 /** 82 * Sets the identifier of the template 83 * 84 * @param nId 85 * the template identifier 86 */ 87 public void setId( int nId ) 88 { 89 _nId = nId; 90 } 91 92 /** 93 * Returns the topic type of the template 94 * 95 * @return the topic type of the template 96 */ 97 public String getTopicType( ) 98 { 99 return _strTopicType; 100 } 101 102 /** 103 * Sets the topic type of the template 104 * 105 * @param strTopicType 106 * the topic type of the template 107 */ 108 public void setTopicType( String strTopicType ) 109 { 110 _strTopicType = strTopicType; 111 } 112 113 /** 114 * Returns the description of the template 115 * 116 * @return the template description 117 */ 118 public String getDescription( ) 119 { 120 return _strDescription; 121 } 122 123 /** 124 * Sets the description of the template 125 * 126 * @param strDescription 127 * the template description 128 */ 129 public void setDescription( String strDescription ) 130 { 131 _strDescription = ( strDescription == null ) ? EMPTY_STRING : strDescription; 132 } 133 134 /** 135 * Returns the file name of the template 136 * 137 * @return the template file name 138 */ 139 public String getFileName( ) 140 { 141 return _strFileName; 142 } 143 144 /** 145 * Sets the file name of the template 146 * 147 * @param strFileName 148 * the template file name 149 */ 150 public void setFileName( String strFileName ) 151 { 152 _strFileName = ( strFileName == null ) ? EMPTY_STRING : strFileName; 153 } 154 155 /** 156 * Returns the picture of the template 157 * 158 * @return the template picture 159 */ 160 public String getPicture( ) 161 { 162 return _strPicture; 163 } 164 165 /** 166 * Sets the picture of the template 167 * 168 * @param strPicture 169 * the template picture 170 */ 171 public void setPicture( String strPicture ) 172 { 173 _strPicture = ( strPicture == null ) ? EMPTY_STRING : strPicture; 174 } 175 176 /** 177 * Return the workgroup 178 * 179 * @return The workgroup 180 */ 181 public String getWorkgroup( ) 182 { 183 return _strWorkgroup; 184 } 185 186 /** 187 * Set the workgroup 188 * 189 * @param strWorkgroup 190 * The workgroup 191 */ 192 public void setWorkgroup( String strWorkgroup ) 193 { 194 _strWorkgroup = strWorkgroup; 195 } 196 197 /** 198 * Returns the Resource Type Code that identify the resource type 199 * 200 * @return The Resource Type Code 201 */ 202 public String getResourceId( ) 203 { 204 return EMPTY_STRING + getId( ); 205 } 206 207 /** 208 * Returns the resource Id of the current object 209 * 210 * @return The resource Id of the current object 211 */ 212 public String getResourceTypeCode( ) 213 { 214 return RESOURCE_TYPE; 215 } 216 217 /** 218 * Get the number of sections of this template 219 * 220 * @return The number of sections of this template 221 */ 222 public int getSectionNumber( ) 223 { 224 return _nSectionNumber; 225 } 226 227 /** 228 * Set the number of sections of this template 229 * 230 * @param nSectionNumber 231 * The number of sections of this template 232 */ 233 public void setSectionNumber( int nSectionNumber ) 234 { 235 this._nSectionNumber = nSectionNumber; 236 } 237 }