1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.portal.business.user.attribute;
35
36 import fr.paris.lutece.portal.business.user.AdminUser;
37 import fr.paris.lutece.portal.service.plugin.Plugin;
38 import fr.paris.lutece.portal.service.user.attribute.AttributeService;
39
40 import org.apache.commons.lang3.StringUtils;
41
42 import java.util.ArrayList;
43 import java.util.List;
44 import java.util.Locale;
45
46 import javax.servlet.http.HttpServletRequest;
47
48
49
50
51 public abstract class SimpleAdminUserFieldListener implements AdminUserFieldListener
52 {
53
54
55
56
57
58 public abstract Plugin getPlugin( );
59
60
61
62
63
64
65
66
67
68
69
70 public abstract void doCreateUserFields( AdminUser user, List<AdminUserField> listUserFields, Locale locale );
71
72
73
74
75
76
77
78
79
80
81
82
83
84 public abstract void doModifyUserFields( AdminUser/AdminUser.html#AdminUser">AdminUser user, List<AdminUserField> listUserFields, Locale locale, AdminUser currentUser );
85
86
87
88
89
90
91
92
93
94 public abstract void doRemoveUserFields( AdminUser user, Locale locale );
95
96
97
98
99 @Override
100 public void doCreateUserFields( AdminUser user, HttpServletRequest request, Locale locale )
101 {
102 List<IAttribute> listAttributes = AttributeService.getInstance( ).getPluginAttributesWithoutFields( getPlugin( ).getName( ), locale );
103 List<AdminUserField> listUserFields = new ArrayList<>( );
104
105 for ( IAttribute attribute : listAttributes )
106 {
107 List<AdminUserField> userFields = attribute.getUserFieldsData( request, user );
108
109 for ( AdminUserField userField : userFields )
110 {
111 if ( ( userField != null ) && StringUtils.isNotBlank( userField.getValue( ) ) )
112 {
113
114
115
116 userField.setValue( userField.getAttributeField( ).getTitle( ) );
117 AdminUserFieldHome.create( userField );
118 listUserFields.add( userField );
119 }
120 }
121 }
122
123 doCreateUserFields( user, listUserFields, locale );
124 }
125
126
127
128
129 @Override
130 public void doModifyUserFields( AdminUserl/business/user/AdminUser.html#AdminUser">AdminUser user, HttpServletRequest request, Locale locale, AdminUser currentUser )
131 {
132 List<IAttribute> listAttributes = AttributeService.getInstance( ).getPluginAttributesWithoutFields( getPlugin( ).getName( ), locale );
133 List<AdminUserField> listUserFields = new ArrayList<>( );
134
135 for ( IAttribute attribute : listAttributes )
136 {
137 List<AdminUserField> userFields = attribute.getUserFieldsData( request, user );
138
139 for ( AdminUserField userField : userFields )
140 {
141 if ( ( userField != null ) && StringUtils.isNotBlank( userField.getValue( ) ) )
142 {
143
144
145
146 userField.setValue( userField.getAttributeField( ).getTitle( ) );
147 AdminUserFieldHome.create( userField );
148 listUserFields.add( userField );
149 }
150 }
151 }
152
153 doModifyUserFields( user, listUserFields, locale, currentUser );
154 }
155
156
157
158
159
160
161
162
163
164
165
166 public void doRemoveUserFields( AdminUser user, HttpServletRequest request, Locale locale )
167 {
168 doRemoveUserFields( user, locale );
169 }
170 }