View Javadoc
1   /*
2    * Copyright (c) 2002-2017, 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.myapps.business;
35  
36  import java.io.Serializable;
37  
38  import fr.paris.lutece.plugins.myapps.service.MyAppsProvider;
39  import fr.paris.lutece.portal.service.rbac.RBACResource;
40  
41  
42  /**
43   *
44   * MyApps
45   *
46   */
47  public abstract class MyApps implements RBACResource,Serializable
48  {
49      /**
50  	 * 
51  	 */
52  	private static final long serialVersionUID = -6980039470136434474L;
53  
54  	public static final String RESOURCE_TYPE = "MYAPPS";
55  
56      // Variables declarations
57      private int _nIdApplication;
58      private String _strName;
59      private String _strDescription;
60      private String _strUrl;
61  
62      /**
63       * Check if the myApp has an icon or not
64       *
65       * @return true if it has an icon, false otherwise
66       */
67      public abstract boolean hasIcon(  );
68  
69      /**
70       * Get the provider that provides this MyApp
71       *
72       * @return a {@link MyAppsProvider}
73       */
74      public abstract MyAppsProvider getProvider(  );
75  
76      /**
77       * Returns the IdApplication
78       *
79       * @return The IdApplication
80       */
81      public int getIdApplication(  )
82      {
83          return _nIdApplication;
84      }
85  
86      /**
87       * Sets the IdApplication
88       *
89       * @param nIdApplication The IdApplication
90       */
91      public void setIdApplication( int nIdApplication )
92      {
93          _nIdApplication = nIdApplication;
94      }
95  
96      /**
97       * Returns the Name
98       *
99       * @return The Name
100      */
101     public String getName(  )
102     {
103         return _strName;
104     }
105 
106     /**
107      * Sets the Name
108      *
109      * @param strName The Name
110      */
111     public void setName( String strName )
112     {
113         _strName = strName;
114     }
115 
116     /**
117      * Returns the Description
118      *
119      * @return The Description
120      */
121     public String getDescription(  )
122     {
123         return _strDescription;
124     }
125 
126     /**
127      * Sets the Description
128      *
129      * @param strDescription The Description
130      */
131     public void setDescription( String strDescription )
132     {
133         _strDescription = strDescription;
134     }
135 
136     /**
137      * Returns the Url
138      *
139      * @return The Url
140      */
141     public String getUrl(  )
142     {
143         return _strUrl;
144     }
145 
146     /**
147      * Sets the Url
148      *
149      * @param strUrl The Url
150      */
151     public void setUrl( String strUrl )
152     {
153         _strUrl = strUrl;
154     }
155 
156     /**
157      * Get the resource ID
158      *
159      * @return the resource ID
160      */
161     public String getResourceId(  )
162     {
163         return String.valueOf( _nIdApplication );
164     }
165 
166     /**
167      * Get the resource type code
168      *
169      * @return the resource type code
170      */
171     public String getResourceTypeCode(  )
172     {
173         return RESOURCE_TYPE;
174     }
175 
176     /**
177      * Override the method equals
178      * @param o Object
179      * @return true if it is equals to the object o
180      */
181     @Override
182     public boolean equals( Object o )
183     {
184         boolean bIsEqual = false;
185 
186         if ( o instanceof fr.paris.lutece.plugins.myapps.business.MyApps )
187         {
188             MyApps myApp = (MyApps) o;
189 
190             if ( myApp != null )
191             {
192                 bIsEqual = _nIdApplication == myApp.getIdApplication(  );
193             }
194         }
195 
196         return bIsEqual;
197     }
198 
199     /**
200      * Override the method hashCode
201      * @return the hashCode
202      */
203     @Override
204     public int hashCode(  )
205     {
206         return _nIdApplication;
207     }
208 }