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.apilocannonces.business;
35  
36  import java.io.Serializable;
37  import java.util.Collections;
38  import java.util.Set;
39  
40  import javax.persistence.Cacheable;
41  import javax.persistence.Column;
42  import javax.persistence.Entity;
43  import javax.persistence.Id;
44  import javax.persistence.JoinColumn;
45  import javax.persistence.JoinTable;
46  import javax.persistence.ManyToMany;
47  import javax.persistence.Table;
48  
49  import org.hibernate.annotations.Cache;
50  import org.hibernate.annotations.CacheConcurrencyStrategy;
51  
52  /**
53   * Class Profil
54   */
55  @Entity
56  @Table( name = "l24t_t_profil" )
57  @Cacheable
58  @Cache( usage = CacheConcurrencyStrategy.READ_ONLY )
59  public class Profil implements Serializable
60  {
61      private static final long serialVersionUID = 1L;
62  
63      @Id
64      @Column( name = "t_profil_id" )
65      private String _id;
66      @Column( name = "description" )
67      private String _description;
68      @ManyToMany
69      @JoinTable( name = "l24t_t_role_x_t_profil", joinColumns = {
70              @JoinColumn( name = "t_profil_id" ) }, inverseJoinColumns = { @JoinColumn( name = "t_role_id" ) } )
71      private Set< Role > _roles;
72  
73      /**
74       * Identifiant du prodil
75       * 
76       * @return identifiant du profil
77       */
78      public String getId( )
79      {
80          return _id;
81      }
82  
83      /**
84       * Identifiant du prodil
85       * 
86       * @param id
87       *            identifiant du profil
88       */
89      public void setId( String id )
90      {
91          _id = id;
92      }
93  
94      /**
95       * Description du profil
96       * 
97       * @return description du profil
98       */
99      public String getDescription( )
100     {
101         return _description;
102     }
103 
104     /**
105      * Description du profil
106      * 
107      * @param description
108      *            description du profil
109      */
110     public void setDescription( String description )
111     {
112         _description = description;
113     }
114 
115     /**
116      * Roles du profil
117      * 
118      * @return roles du profil
119      */
120     public Set< Role > getRoles( )
121     {
122         if ( _roles == null )
123         {
124             return Collections.emptySet( );
125         }
126         return Collections.unmodifiableSet( _roles );
127     }
128 
129     /**
130      * Roles du profil
131      * 
132      * @param roles
133      *            roles du profil
134      */
135     public void setRoles( Set< Role > roles )
136     {
137         _roles = roles;
138     }
139 }