Author: bpoussin Date: 2011-04-01 19:06:22 +0200 (Fri, 01 Apr 2011) New Revision: 55 Url: http://chorem.org/repositories/revision/chorem/55 Log: implantation des requetes pour avoir les informations sur la page d'accueil utilisation de la derniere version de nuiton-utils pour wikitty Modified: trunk/chorem-web/src/main/java/org/chorem/action/HomeAction.java trunk/chorem-web/src/main/webapp/WEB-INF/jsp/home.jsp trunk/pom.xml Modified: trunk/chorem-web/src/main/java/org/chorem/action/HomeAction.java =================================================================== --- trunk/chorem-web/src/main/java/org/chorem/action/HomeAction.java 2011-04-01 15:32:41 UTC (rev 54) +++ trunk/chorem-web/src/main/java/org/chorem/action/HomeAction.java 2011-04-01 17:06:22 UTC (rev 55) @@ -1,11 +1,32 @@ package org.chorem.action; import com.opensymphony.xwork2.ActionContext; +import java.text.ParseException; +import java.util.Date; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; import static org.nuiton.i18n.I18n.n_; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.entities.Company; +import org.chorem.entities.Interval; +import org.chorem.entities.Person; +import org.chorem.entities.PersonImpl; +import org.chorem.entities.Touch; +import org.chorem.entities.TouchImpl; import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyUtil; +import org.nuiton.wikitty.entities.BusinessEntity; +import org.nuiton.wikitty.entities.BusinessEntityImpl; +import org.nuiton.wikitty.entities.Wikitty; +import org.nuiton.wikitty.entities.WikittyUser; +import org.nuiton.wikitty.entities.WikittyUserImpl; +import org.nuiton.wikitty.search.Criteria; +import org.nuiton.wikitty.search.PagedResult; +import org.nuiton.wikitty.search.Search; /** * @@ -36,30 +57,104 @@ return SUCCESS; } + /** nombre d'objet company */ protected int nbCompany = 0; + /** nombre d'objet person */ protected int nbPerson = 0; - protected int nbTouchThisWeek = 0; + /** nombre de contact pour les 7 derniers jours jusqu'à maintenant */ + protected int nbTouchForLast7Days = 0; + protected int nbTouchForLast7DaysForMe = 0; + /** nombre de contact pour les 7 prochains jours depuis maintenant */ protected int nbTouchForNext7Days = 0; - protected int nbTouchThisWeekForMe = 0; protected int nbTouchForNext7DaysForMe = 0; + /** nombre de projet en cours */ protected int nbProjectOrderOpen = 0; + /** nombre de tache a faire ou finir */ protected int nbTaskOpen = 0; protected int nbTaskOpenForMe = 0; + /** nombre de facture a envoyer */ protected int nbInvoiceToSend = 0; + /** montant des factures a envoyer*/ protected int invoiceAmountToSend = 0; + /** cash flow pour les 3 prochains moins */ protected double[] cashFlow = new double[3]; + /** nombre de facture envoyer cette annee jusqu'a maintenant */ protected int nbInvoiceSendThisYear = 0; + /** nombre de facture envoyer l'annee derniere jusqu'a maintenant (meme periode)*/ protected int nbInvoiceSendLastYear = 0; + /** nombre de facture impayer */ protected int nbInvoiceNotPaid = 0; + /** nombre de facture impayer et en retard */ protected int nbInvoiceNotPaidAndLate = 0; + /** CA cette annee jusqu'a maintenant */ protected double salesTurnoverThisYear = 0; + /** CA l'annee derniere jusqu'a maintenant (meme periode)*/ protected double salesTurnoverLastYear = 0; - public void load(WikittyProxy proxy) { -// FIXME write criteria to get information + public void load(WikittyProxy proxy) throws ParseException { + + String now = WikittyUtil.formatDate(new Date()); + + WikittyUser user = proxy.getUser(); + String userId = null; + if (user != null) { + userId = user.getWikittyId(); + } + + Criteria company = Search.query().exteq(Company.EXT_COMPANY).criteria().setEndIndex(0); + Criteria person = Search.query().exteq(Person.EXT_PERSON).criteria().setEndIndex(0); + + Criteria touchLast7days = Search.query() + .exteq(Touch.EXT_TOUCH) + .and() + .le(Touch.FQ_FIELD_INTERVAL_BEGINDATE, now) + .criteria().addFacetField(Touch.FQ_FIELD_TOUCH_PARTICIPANT).setEndIndex(0); + + Criteria touchNext7days = Search.query() + .exteq(Touch.EXT_TOUCH) + .and() + .gt(Touch.FQ_FIELD_INTERVAL_BEGINDATE, now) + .criteria().addFacetField(Touch.FQ_FIELD_TOUCH_PARTICIPANT).setEndIndex(0); + + + PagedResult<Wikitty>[] results = proxy.multiFindAllByCriteria( + company, + person, + touchLast7days, + touchNext7days + ); + + nbCompany = results[0].getNumFound(); + nbPerson = results[1].getNumFound(); + nbTouchForLast7Days = results[2].getNumFound(); + nbTouchForLast7DaysForMe = + results[2].getTopicCount(Touch.FQ_FIELD_TOUCH_PARTICIPANT, userId); + nbTouchForNext7Days = results[3].getNumFound(); + nbTouchForNext7DaysForMe = + results[3].getTopicCount(Touch.FQ_FIELD_TOUCH_PARTICIPANT, userId); + +// nbProjectOrderOpen = results[6].getNumFound(); +// nbTaskOpen = results[7].getNumFound(); +// nbTaskOpenForMe = results[8].getNumFound(); +// nbInvoiceToSend = results[9].getNumFound(); +// invoiceAmountToSend = results[10].getNumFound(); +// +// cashFlow = new double[]{ +// results[11].getNumFound(), +// results[12].getNumFound(), +// results[13].getNumFound() +// }; +// +// nbInvoiceSendThisYear = results[14].getNumFound(); +// nbInvoiceSendLastYear = results[15].getNumFound(); +// nbInvoiceNotPaid = results[16].getNumFound(); +// nbInvoiceNotPaidAndLate = results[17].getNumFound(); +// salesTurnoverThisYear = results[18].getNumFound(); +// salesTurnoverLastYear = results[19].getNumFound(); + } public double[] getCashFlow() { @@ -114,12 +209,12 @@ return nbTouchForNext7DaysForMe; } - public int getNbTouchThisWeek() { - return nbTouchThisWeek; + public int getNbTouchForLast7Days() { + return nbTouchForLast7Days; } - public int getNbTouchThisWeekForMe() { - return nbTouchThisWeekForMe; + public int getNbTouchForLast7DaysForMe() { + return nbTouchForLast7DaysForMe; } public int getInvoiceAmountToSend() { Modified: trunk/chorem-web/src/main/webapp/WEB-INF/jsp/home.jsp =================================================================== --- trunk/chorem-web/src/main/webapp/WEB-INF/jsp/home.jsp 2011-04-01 15:32:41 UTC (rev 54) +++ trunk/chorem-web/src/main/webapp/WEB-INF/jsp/home.jsp 2011-04-01 17:06:22 UTC (rev 55) @@ -14,6 +14,10 @@ <!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> --> +<% +HomeAction action = HomeAction.getAction(); +%> + <html xmlns:s="http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd" xmlns:jsp="http://java.sun.com/JSP/Page"> <head> @@ -24,38 +28,38 @@ <div class="block"> <ul> - <li>Company: <%=HomeAction.getAction().getNbCompany()%></li> - <li>People: <%=HomeAction.getAction().getNbPerson()%></li> + <li>Company: <%=action.getNbCompany()%></li> + <li>People: <%=action.getNbPerson()%></li> <li>Touch - this week <%=HomeAction.getAction().getNbTouchThisWeekForMe()%>/<%=HomeAction.getAction().getNbTouchThisWeek()%> - planned <%=HomeAction.getAction().getNbTouchForNext7DaysForMe()%>/<%=HomeAction.getAction().getNbTouchForNext7Days()%> + last 7 days <%=action.getNbTouchForLast7DaysForMe()%>/<%=action.getNbTouchForLast7Days()%> + planned for next 7 days <%=action.getNbTouchForNext7DaysForMe()%>/<%=action.getNbTouchForNext7Days()%> </li> </ul> </div> <div class="block"> <ul> - <li>Project open: <%=HomeAction.getAction().getNbProjectOrderOpen()%></li> + <li>Project open: <%=action.getNbProjectOrderOpen()%></li> <li>Task: - <%=HomeAction.getAction().getNbTaskOpenForMe()%>/<%=HomeAction.getAction().getNbTaskOpen()%> + <%=action.getNbTaskOpenForMe()%>/<%=action.getNbTaskOpen()%> </li> - <li>Invoice to send <%=HomeAction.getAction().getNbInvoiceToSend()%> - for <%=HomeAction.getAction().getInvoiceAmountToSend()%> + <li>Invoice to send <%=action.getNbInvoiceToSend()%> + for <%=action.getInvoiceAmountToSend()%> </li> </ul> </div> <div class="block"> <ul> - <li>Cash flow <%=Arrays.toString(HomeAction.getAction().getCashFlow())%></li> - <li>Sales turnover <%=HomeAction.getAction().getSalesTurnoverThisYear()%> - (<%=HomeAction.getAction().getSalesTurnoverLastYear()%>) + <li>Cash flow <%=Arrays.toString(action.getCashFlow())%></li> + <li>Sales turnover <%=action.getSalesTurnoverThisYear()%> + (<%=action.getSalesTurnoverLastYear()%>) </li> - <li>Invoice send <%=HomeAction.getAction().getNbInvoiceSendThisYear()%> - (<%=HomeAction.getAction().getNbInvoiceSendLastYear()%>) + <li>Invoice send <%=action.getNbInvoiceSendThisYear()%> + (<%=action.getNbInvoiceSendLastYear()%>) </li> - <li>Unpaid invoice <%=HomeAction.getAction().getNbInvoiceNotPaid()%> - and late <%=HomeAction.getAction().getNbInvoiceNotPaidAndLate()%> + <li>Unpaid invoice <%=action.getNbInvoiceNotPaid()%> + and late <%=action.getNbInvoiceNotPaidAndLate()%> </li> </ul> </div> Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-04-01 15:32:41 UTC (rev 54) +++ trunk/pom.xml 2011-04-01 17:06:22 UTC (rev 55) @@ -51,7 +51,7 @@ <projectId>chorem</projectId> <eugenePluginVersion>2.3.2</eugenePluginVersion> - <nuitonUtilsVersion>2.0</nuitonUtilsVersion> + <nuitonUtilsVersion>2.1-SNAPSHOT</nuitonUtilsVersion> <nuitonI18nVersion>2.3.1</nuitonI18nVersion> <wikittyVersion>3.0.5-SNAPSHOT</wikittyVersion> <slf4jVersion>1.6.1</slf4jVersion>