--- /dev/null
+<% /**
+*Copyright © Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+*
+*This file is part of the work and learning management system Pentila Nero.
+*
+*Pentila Nero is free software. You can redistribute it and/or modify since
+*you respect the terms of either (at least one of the both license) :
+*- under the terms of the GNU Affero General Public License as
+*published by the Free Software Foundation, either version 3 of the
+*License, or (at your option) any later version.
+*- the CeCILL-C as published by CeCILL-C; either version 1 of the
+*License, or any later version
+*- the GNU Lesser General Public License as published by the
+*Free Software Foundation, either version 3 of the license,
+*or (at your option) any later version.
+*
+*There are special exceptions to the terms and conditions of the
+*licenses as they are applied to this software. View the full text of
+*the exception in file LICENSE-PROJECT.txt in the directory of this software
+*distribution.
+*
+*Pentila Nero is distributed in the hope that it will be useful,
+*but WITHOUT ANY WARRANTY; without even the implied warranty of
+*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+*Licenses for more details.
+*
+*You should have received a copy of the GNU Affero General Public License
+*and the CeCILL-C and the GNU Lesser General Public License along with
+*Pentila Nero. If not, see :
+*<http://www.gnu.org/licenses/> and
+*<http://www.cecill.info/licences.fr.html>.
+*/ %>
+<?xml version="1.0" encoding="UTF-8" ?>
+<%@page import="com.liferay.portal.model.Role"%>
+<%@page import="com.liferay.portal.model.User"%>
+<%@page import="com.liferay.portal.service.RoleLocalServiceUtil"%>
+<%@page import="com.liferay.portal.service.UserLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.service.FicheLocalServiceUtil"%>
+<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.model.Fiche"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.service.ListeLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.model.Liste"%>
+<%@ page import="com.liferay.portal.kernel.servlet.HttpHeaders" %>
+<%@page import="java.util.List"%>
+<%@page import ="java.text.Collator"%>
+<%@page import ="java.util.Locale"%>
+<%@page import="com.liferay.portal.model.Organization"%>
+<%@page import="com.liferay.portal.service.OrganizationLocalServiceUtil"%>
+<%@ include file="/init.jsp" %>
+
+<%
+ renderResponse.setContentType("text/xml");
+ response.setContentType("text/xml");
+ response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
+
+
+
+ List<ProxyFiche> lesFiches = new ArrayList<ProxyFiche>();
+ List<ProxyFiche> construct = new ArrayList<ProxyFiche>();
+ final Long listId = ParamUtil.getLong(renderRequest, "listId", 0);
+ final Long roleId = ParamUtil.getLong(renderRequest, "roleId", 0);
+ final Long orgId = ParamUtil.getLong(renderRequest, "orgId", 0);
+ final String type = ParamUtil.getString(renderRequest, "type", "");
+
+ final int start = ParamUtil.getInteger(renderRequest, "start");
+ final int limit = ParamUtil.getInteger(renderRequest, "limit");
+ int stop = start + limit;
+
+
+ final boolean asc = ParamUtil.getString(renderRequest, "dir", "ASC").equals("ASC")?true:false;
+ final String sort = ParamUtil.getString(renderRequest, "sort", "nom");
+ // Cas par defaut, tri sur les dates
+ OrderByComparator obc = new CANameComparator(asc);
+ // Si tri sur les noms
+ if (sort.equals("nom")) {
+ obc = new CANameComparator(asc);
+ // Sinon si tri sur les prenom
+ } else if (sort.equals("prenom")) {
+ obc = new CAfirstNameComparator(asc);
+ }else if (sort.equals("statut")) {
+ obc = new CAStatusComparator(asc);
+ }
+
+
+ /*Instantiation de l'operateur de comparaison avec Collator*/
+ Collator compareOperator = Collator.getInstance(Locale.FRENCH);
+ compareOperator.setStrength (Collator.PRIMARY);
+
+
+ final String recherche = ParamUtil.getString(renderRequest, "recherche", "").toLowerCase();
+
+ if (type.equals("local")) {
+ Liste userListe = ListeLocalServiceUtil.getListe(listId);
+ construct = ListFicheFactory.createUserListContacts(user, userListe);
+ }
+ else if (type.equals("search")) {
+ /*Gere le cas des listes particulieres provenant des organisations*/
+
+ construct = ListFicheFactory.createSearchContacts(user, orgId, roleId, listId);
+ }
+ else if (type.equals("perso")) {
+ construct = ListFicheFactory.createPersoContacts(user);
+ }
+ else if (type.equals("inst")) {
+ construct = ListFicheFactory.createInstContacts(user);
+ }
+ else if (type.equals("all")) {
+ construct = ListFicheFactory.createAllContacts(user);
+ }
+
+ else if (type.equals("allAmis")) {
+ List<Relationship> listAllRel = RelationshipLocalServiceUtil.getRelationshipByUserIdStateId(user.getUserId(), 2, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
+ List<Long> lesAmis = new ArrayList<Long>();
+ for(Relationship rel : listAllRel){
+ lesAmis.add(rel.getFriendId());
+ }
+ construct = ListFicheFactory.createAmisContacts(user, lesAmis);
+ }
+ else if (type.equals("amis")) {
+ List<Relationship> listRel = RelationshipLocalServiceUtil.getRelationshipByUserIdFriendFolderIdStateId(user.getUserId(), listId, 2, QueryUtil.ALL_POS, QueryUtil.ALL_POS);
+ List<Long> lesAmis = new ArrayList<Long>();
+ for(Relationship rel : listRel){
+ lesAmis.add(rel.getFriendId());
+ }
+ construct = ListFicheFactory.createAmisContacts(user, lesAmis);
+ }
+
+ if (recherche.equals("")) {
+ lesFiches = construct;
+ } else {
+ int sizeRecherche = recherche.length();
+ for (ProxyFiche f : construct) {
+ if (
+ (f.getNom().length()>=sizeRecherche && (compareOperator.compare(f.getNom().substring(0,sizeRecherche),recherche)==0)) ||
+ (f.getPrenom().length()>=sizeRecherche && (compareOperator.compare(f.getPrenom().substring(0,sizeRecherche),recherche)==0))||
+ (f.getStatut().length()>=sizeRecherche && (compareOperator.compare(f.getStatut().substring(0,sizeRecherche),recherche)==0))) {
+ lesFiches.add(f);
+ }
+ }
+ }
+ Collections.sort(lesFiches, obc);
+
+ final int nbRecords = lesFiches.size();
+ if (stop>nbRecords) {
+ stop = nbRecords;
+ }
+ lesFiches = lesFiches.subList(start, stop);
+
+%>
+
+
+
+
+
+
+<%@page import="java.util.ArrayList"%>
+<%@page import="java.util.Collections"%>
+<%@page import="com.liferay.contacts.util.ListFicheFactory"%>
+<%@page import="com.liferay.contacts.util.ProxyFiche"%>
+<%@page import="java.util.Set"%>
+<%@page import="java.util.HashSet"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.CANameComparator"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.CAfirstNameComparator"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.CAStatusComparator"%>
+<%@page import="com.liferay.portal.kernel.util.OrderByComparator"%>
+<%@page import="com.pentila.entSavoie.amis.model.FriendFolder"%>
+<%@page import="com.pentila.entSavoie.amis.service.FriendFolderLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.amis.model.Relationship"%>
+<%@page import="com.pentila.entSavoie.amis.service.RelationshipLocalServiceUtil"%>
+<%@page import="com.liferay.portal.kernel.dao.orm.QueryUtil"%><fiches>
+ <% for (ProxyFiche f : lesFiches) {
+ %>
+ <fiche>
+ <type><%= f.getType() %></type>
+ <id><%= f.getId() %></id>
+ <relUserId><%= f.getRelUserId() %></relUserId>
+ <nom><![CDATA[<%= f.getNom() %>]]></nom>
+ <prenom><![CDATA[<%= f.getPrenom() %>]]></prenom>
+ <statut><![CDATA[<%= f.getStatut() %>]]></statut>
+ <total><%= nbRecords %></total>
+ </fiche>
+ <% } %>
+</fiches>
+
+
+
+