View Javadoc
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.mylutece.business.attribute;
35  
36  import fr.paris.lutece.portal.service.plugin.Plugin;
37  
38  import java.util.List;
39  import java.util.Locale;
40  import java.util.Map;
41  
42  /**
43   *
44   * IAttributeDAO
45   *
46   */
47  public interface IAttributeDAO
48  {
49      /**
50       * Load attribute
51       * 
52       * @param nIdAttribute
53       *            ID
54       * @param locale
55       *            Locale
56       * @param plugin
57       *            The plugin
58       * @return Attribute
59       */
60      IAttribute load( int nIdAttribute, Locale locale, Plugin plugin );
61  
62      /**
63       * Insert a new attribute
64       * 
65       * @param attribute
66       *            the attribute
67       * @param plugin
68       *            The plugin
69       * @return new PK
70       */
71      int insert( IAttribute attribute, Plugin plugin );
72  
73      /**
74       * Update an attribute
75       * 
76       * @param attribute
77       *            the attribute
78       * @param plugin
79       *            The plugin
80       */
81      void store( IAttribute attribute, Plugin plugin );
82  
83      /**
84       * Delete an attribute
85       * 
86       * @param nIdAttribute
87       *            the ID of the attribute
88       * @param plugin
89       *            The plugin
90       */
91      void delete( int nIdAttribute, Plugin plugin );
92  
93      /**
94       * Load every attributes
95       * 
96       * @param locale
97       *            locale
98       * @param plugin
99       *            The plugin
100      * @return list of attributes
101      */
102     List<IAttribute> selectAll( Locale locale, Plugin plugin );
103 
104     /**
105      * Load every attributes from plugin name
106      * 
107      * @param strPluginName
108      *            plugin name
109      * @param locale
110      *            locale
111      * @param plugin
112      *            The plugin
113      * @return list of attributes
114      */
115     List<IAttribute> selectPluginAttributes( String strPluginName, Locale locale, Plugin plugin );
116 
117     /**
118      * Load every attributes that do not come from a plugin
119      * 
120      * @param locale
121      *            locale
122      * @param plugin
123      *            The plugin
124      * @return list of attributes
125      */
126     List<IAttribute> selectMyLuteceAttributes( Locale locale, Plugin plugin );
127 
128     /**
129      * Update the anonymization status of the attribute.
130      * 
131      * @param nIdAttribute
132      *            Id of the attribute
133      * @param bAnonymize
134      *            New value of the anonymization status. True means the attribute should be anonymize, false means it doesn't.
135      * @param plugin
136      *            The plugin
137      */
138     void updateAttributeAnonymization( int nIdAttribute, boolean bAnonymize, Plugin plugin );
139 
140     /**
141      * Get the anonymization status of a user field.
142      * 
143      * @param plugin
144      *            The plugin
145      * @return A map containing the associations of user field name and a boolean describing whether the field should be anonymized.
146      */
147     Map<String, Boolean> selectAnonymizationStatusUserStaticField( Plugin plugin );
148 
149     /**
150      * Add an anonymization status to a user field.
151      * 
152      * @param strFieldName
153      *            Name of the field
154      * @param bAnonymizeFiled
155      *            True if the field should be anonymize, false otherwise
156      * @param plugin
157      *            The plugin
158      */
159     void addAnonymizationStatusUserField( String strFieldName, boolean bAnonymizeFiled, Plugin plugin );
160 
161     /**
162      * Remove an anonymization status to a user field.
163      * 
164      * @param strFieldName
165      *            Name of the field
166      * @param plugin
167      *            The plugin
168      */
169     void removeAnonymizationStatusUserField( String strFieldName, Plugin plugin );
170 
171     /**
172      * Update the anonymization status of a user field.
173      * 
174      * @param strFieldName
175      *            Name of the field to update
176      * @param bAnonymizeFiled
177      *            True if the field should be anonymize, false otherwise
178      * @param plugin
179      *            The plugin
180      */
181     void updateAnonymizationStatusUserStaticField( String strFieldName, boolean bAnonymizeFiled, Plugin plugin );
182 }