From echatellier@users.forge.codelutin.com Mon Jun  2 17:45:55 2014
From: echatellier@users.forge.codelutin.com
To: faxtomail-commits@list.forge.codelutin.com
Subject: [Faxtomail-commits] r121 - in trunk: .
	faxtomail-persistence/src/main/xmi
	faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service
	faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/admin
	faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin
	faxtomail-ui-web/src/main/webapp/js
Date: Mon, 02 Jun 2014 17:45:55 +0200
Message-ID: <20140602154555.B17FC181D77@goh.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============4060269857793846302=="

--===============4060269857793846302==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Author: echatellier
Date: 2014-06-02 17:45:55 +0200 (Mon, 02 Jun 2014)
New Revision: 121

Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/121

Log:
refs #4662: Sauvegarde de la mise en avant des dossiers utilisateur

Modified:
   trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo
   trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/s=
ervice/ConfigurationService.java
   trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/=
admin/UserFolderAction.java
   trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/user-folder-i=
nput.jsp
   trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js
   trunk/pom.xml

Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
(Binary files differ)

Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/ser=
vices/service/ConfigurationService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/=
service/ConfigurationService.java	2014-06-02 11:05:24 UTC (rev 120)
+++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/=
service/ConfigurationService.java	2014-06-02 15:45:55 UTC (rev 121)
@@ -24,6 +24,7 @@
  * #L%
  */
=20
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -45,6 +46,8 @@
 import com.franciaflex.faxtomail.persistence.entities.FaxToMailUserTopiaDao;
 import com.franciaflex.faxtomail.persistence.entities.MailFilter;
 import com.franciaflex.faxtomail.persistence.entities.MailFilterTopiaDao;
+import com.franciaflex.faxtomail.persistence.entities.MailFolder;
+import com.franciaflex.faxtomail.persistence.entities.MailFolderTopiaDao;
 import com.franciaflex.faxtomail.services.FaxToMailServiceSupport;
 import com.google.common.collect.Maps;
=20
@@ -174,6 +177,27 @@
=20
     public List<FaxToMailUser> getAllUsers() {
         FaxToMailUserTopiaDao faxToMailUserDao =3D getPersistenceContext().g=
etFaxToMailUserDao();
-        return faxToMailUserDao.findAll();
+        return faxToMailUserDao.forAll().setOrderByArguments(FaxToMailUser.P=
ROPERTY_FIRST_NAME, FaxToMailUser.PROPERTY_LAST_NAME).findAll();
     }
+
+    public void saveUserFolders(Map<String, Collection<MailFolder>> userFold=
ers) {
+        log.warn("user folders =3D " + userFolders);
+
+        //MailFolderTopiaDao mailFolderTopiaDao =3D getPersistenceContext().=
getMailFolderDao();
+        FaxToMailUserTopiaDao faxToMailUserTopiaDao =3D getPersistenceContex=
t().getFaxToMailUserDao();
+       =20
+        for (Map.Entry<String, Collection<MailFolder>> entry : userFolders.e=
ntrySet()) {
+            String userId =3D entry.getKey();
+            Collection<MailFolder> mailFolders =3D entry.getValue();
+           =20
+            FaxToMailUser user =3D faxToMailUserTopiaDao.findByTopiaId(userI=
d);
+            user.clearAffectedFolders();
+            for (MailFolder mailFolder : mailFolders) {
+                user.addAffectedFolders(mailFolder);
+            }
+            faxToMailUserTopiaDao.update(user);
+        }
+       =20
+        getPersistenceContext().commit();
+    }
 }

Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/=
action/admin/UserFolderAction.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action=
/admin/UserFolderAction.java	2014-06-02 11:05:24 UTC (rev 120)
+++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action=
/admin/UserFolderAction.java	2014-06-02 15:45:55 UTC (rev 121)
@@ -24,9 +24,13 @@
  * #L%
  */
=20
-import java.util.Collections;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
=20
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.struts2.convention.annotation.Result;
@@ -36,6 +40,7 @@
 import com.franciaflex.faxtomail.services.service.ConfigurationService;
 import com.franciaflex.faxtomail.services.service.MailFolderService;
 import com.franciaflex.faxtomail.web.FaxToMailActionSupport;
+import com.google.gson.reflect.TypeToken;
=20
 public class UserFolderAction extends FaxToMailActionSupport {
=20
@@ -49,6 +54,8 @@
=20
     protected List<FaxToMailUser> users;
=20
+    protected Map<String, Collection<MailFolder>> userFolders;
+
     public void setConfigurationService(ConfigurationService configurationSe=
rvice) {
         this.configurationService =3D configurationService;
     }
@@ -62,6 +69,11 @@
     public String input() throws Exception {
         mailFolders =3D mailFolderService.getAllMailFolders();
         users =3D configurationService.getAllUsers();
+       =20
+        userFolders =3D new HashMap<>();
+        for (FaxToMailUser user : users) {
+            userFolders.put(user.getTopiaId(), CollectionUtils.emptyIfNull(u=
ser.getAffectedFolders()));
+        }
         return INPUT;
     }
=20
@@ -69,9 +81,9 @@
     @org.apache.struts2.convention.annotation.Action(results =3D {
             @Result(type =3D "redirectAction", params =3D {"actionName", "us=
er-folder-input"})})
     public String execute() throws Exception {
-        String result =3D super.execute();
=20
-        return result;
+        configurationService.saveUserFolders(userFolders);
+        return SUCCESS;
     }
    =20
     public List<MailFolder> getMailFolders() {
@@ -81,4 +93,13 @@
     public List<FaxToMailUser> getUsers() {
         return users;
     }
+   =20
+    public Map<String, Collection<MailFolder>> getUserFolders() {
+        return userFolders;
+    }
+   =20
+    public void setUserFoldersJson(String json) {
+        Type type =3D new TypeToken<Map<String, Collection<MailFolder>>>() {=
}.getType();
+        this.userFolders =3D getGson().fromJson(json, type);
+    }
 }

Modified: trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/user-f=
older-input.jsp
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/user-folder-=
input.jsp	2014-06-02 11:05:24 UTC (rev 120)
+++ trunk/faxtomail-ui-web/src/main/webapp/WEB-INF/content/admin/user-folder-=
input.jsp	2014-06-02 15:45:55 UTC (rev 121)
@@ -28,18 +28,23 @@
 <html>
   <head>
     <title>Import</title>
+    <link rel=3D"stylesheet" type=3D"text/css" href=3D"<s:url value=3D'/webj=
ars/select2/3.4.8/select2.css' />" />
     <link rel=3D"stylesheet" type=3D"text/css" href=3D"<s:url value=3D'/css/=
faxtomail.css' />" />
=20
+    <script type=3D"text/javascript" src=3D"<s:url value=3D'/webjars/select2=
/3.4.8/select2.min.js' />"></script>
+    <script type=3D"text/javascript" src=3D"<s:url value=3D'/webjars/select2=
/3.4.8/select2_locale_fr.js' />"></script>
     <script type=3D"text/javascript" src=3D"<s:url value=3D'/webjars/angular=
js/1.2.16/angular.min.js' />"></script>
+    <script type=3D"text/javascript" src=3D"<s:url value=3D'/js/select2sorta=
ble.js' />"></script>
=20
     <script type=3D"text/javascript" src=3D"<s:url value=3D'/js/faxtomail.js=
' />"></script>
     <script type=3D"text/javascript" src=3D"<s:url value=3D'/js/user-folder.=
js' />"></script>
=20
     <script type=3D"text/javascript">
-      angular.module('UserFolderModule', ['FaxToMail'])
+      angular.module('UserFolderModule', ['FaxToMail', 'ui.select2.sortable'=
])
         .value('UserFolderData', {
           'mailFolders': <s:property value=3D"toJson(mailFolders)" escapeHtm=
l=3D"false"/>,
-          'users': <s:property value=3D"toJson(users)" escapeHtml=3D"false"/>
+          'users': <s:property value=3D"toJson(users)" escapeHtml=3D"false"/=
>,
+          'userFolders': <s:property value=3D"toJson(userFolders)" escapeHtm=
l=3D"false"/>
         });
     </script>
   </head>
@@ -48,12 +53,12 @@
=20
     <div id=3D"main-container" class=3D"container" ng-app=3D"UserFolderModul=
e">
=20
-      <h1 class=3D"page-header">Import</h1>
+      <h1 class=3D"page-header">Dossiers mis en avant par utilisateur</h1>
=20
-      <s:form id=3D"main_form" action=3D"import" method=3D"post" enctype=3D"=
multipart/form-data" ng-controller=3D"UserFolderController">
+      <s:form id=3D"main_form" action=3D"user-folder" method=3D"post" enctyp=
e=3D"multipart/form-data" ng-controller=3D"UserFolderController">
+        <s:hidden name=3D"userFoldersJson" value=3D"{{userFolders}}" />
=20
         <table id=3D'table-snapshot' class=3D"table table-bordered">
-          <caption>Dossiers mis en avant par utilisateur</caption>
           <thead>
             <tr>
               <th>Utilisateur</th>
@@ -62,9 +67,11 @@
           </thead>
           <tbody>
             <tr ng-repeat=3D"user in users">
-              <th>{{user.login}}</th>
+              <th>{{user.firstName}} {{user.lastName}}</th>
               <td>
-                <input type=3D"text" />
+                <div class=3D"controls">
+                  <input type=3D"hidden" ui-select2-sortable ng-model=3D"use=
rFolders[user.topiaId]" simple-query=3D"getObjectsData" multiple sortable>
+                </div>
               </td>
             </tr>
           </tbody>

Modified: trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js	2014-06-02 11:05=
:24 UTC (rev 120)
+++ trunk/faxtomail-ui-web/src/main/webapp/js/user-folder.js	2014-06-02 15:45=
:55 UTC (rev 121)
@@ -31,6 +31,8 @@
     $scope.mailFolders =3D UserFolderData.mailFolders;
     // {Array} Liste des utilisateurs ldap
     $scope.users =3D UserFolderData.users;
+    //{Map} Topia id : mailFolders
+    $scope.userFolders =3D UserFolderData.userFolders;
=20
     // method priv=C3=A9e recursive pour retourner l'ensemble des dossiers
     var recursiveAddMailFolder =3D function(result, mailFolders) {
@@ -48,4 +50,16 @@
       recursiveAddMailFolder(flatMailFolders, $scope.mailFolders);
       return flatMailFolders;
     };
+   =20
+    // fonction retournant l'ensemble des options disponibles
+    $scope.getObjectsData =3D function(term, result) {
+      var resultArray =3D [];
+      angular.forEach($scope.mailFolders, function(mailFolder) {
+        // select 2 require an id field
+        mailFolder.id =3D mailFolder.topiaId;
+        // select 2 can use 'name' for display, so it's ok
+        resultArray.push(mailFolder);
+      });
+      result(resultArray);
+    };
 }]);

Modified: trunk/pom.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/pom.xml	2014-06-02 11:05:24 UTC (rev 120)
+++ trunk/pom.xml	2014-06-02 15:45:55 UTC (rev 121)
@@ -27,7 +27,7 @@
   <parent>
     <groupId>org.nuiton</groupId>
     <artifactId>mavenpom4redmine</artifactId>
-    <version>5.0.7</version>
+    <version>5.0.8</version>
   </parent>
=20
   <groupId>com.franciaflex</groupId>
@@ -97,7 +97,7 @@
=20
     <nuitonI18nVersion>3.1</nuitonI18nVersion>
     <nuitonConfigVersion>3.0-alpha-2</nuitonConfigVersion>
-    <nuitonCsvVersion>3.0-rc-1</nuitonCsvVersion>
+    <nuitonCsvVersion>3.0-rc-2</nuitonCsvVersion>
     <nuitonDecoratorVersion>3.0-alpha-3</nuitonDecoratorVersion>
     <nuitonUpdaterVersion>3.0-alpha-2</nuitonUpdaterVersion>
     <nuitonUtilsVersion>3.0-SNAPSHOT</nuitonUtilsVersion>
@@ -109,7 +109,7 @@
     <hibernateVersion>4.3.5.Final</hibernateVersion>
     <h2Version>1.3.176</h2Version>
=20
-    <jaxxVersion>2.8.6-SNAPSHOT</jaxxVersion>
+    <jaxxVersion>2.8.6</jaxxVersion>
     <!-- do not upgrade to 1.6.5-1 -->
     <swingXVersion>1.6.4</swingXVersion>
     <xworkVersion>2.3.15.1</xworkVersion>
@@ -553,7 +553,7 @@
       <dependency>
         <groupId>org.webjars</groupId>
         <artifactId>select2</artifactId>
-        <version>3.4.8</version>
+        <version>3.4.8-1</version>
         <scope>runtime</scope>
       </dependency>
=20


--===============4060269857793846302==--


