r341 - in trunk/chorem-webmotion/src/main: java/org/chorem/webmotion/actions/project webapp/WEB-INF/jsp
Author: meynier Date: 2013-06-14 16:03:04 +0200 (Fri, 14 Jun 2013) New Revision: 341 Url: http://chorem.org/projects/chorem/repository/revisions/341 Log: enhanced the prototype of project dashboard (quotations and tasks) Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java =================================================================== --- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java 2013-06-13 15:33:58 UTC (rev 340) +++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/project/DashboardProjectAction.java 2013-06-14 14:03:04 UTC (rev 341) @@ -1,5 +1,8 @@ package org.chorem.webmotion.actions.project; +import java.util.HashMap; +import java.util.List; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.debux.webmotion.server.WebMotionController; @@ -8,31 +11,80 @@ import org.debux.webmotion.server.render.Render; import org.chorem.entities.Quotation; import org.chorem.entities.Project; +import org.chorem.entities.Task; import org.nuiton.wikitty.query.WikittyQuery; import org.nuiton.wikitty.query.WikittyQueryMaker; import org.nuiton.wikitty.query.WikittyQueryResult; public class DashboardProjectAction extends WebMotionController { - /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(DashboardProjectAction.class); + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(DashboardProjectAction.class); - public Render projectFilter(ChoremClient client, String id) { - - WikittyQuery projectQuery = new WikittyQueryMaker() - .eq(Project.ELEMENT_FIELD_PROJECT_NAME, id) - .end(); + public Render projectFilter(ChoremClient client, String id) { - WikittyQueryResult<Project> result = - client.findAllByQuery(Project.class, projectQuery); - - System.out.println(result); + WikittyQueryResult<Project> projectResult = null; + WikittyQueryResult<Quotation> quotationResult = null; + WikittyQueryResult<Task> taskResult = null; + HashMap<Quotation, List<Task>> taskMap = new HashMap<Quotation, List<Task>>(); + + //Fetch the project form the name (if it has been requested) + if(id != null) { + WikittyQuery projectQuery = new WikittyQueryMaker() + .eq(Project.ELEMENT_FIELD_PROJECT_NAME, id) + .end(); + + projectResult = client.findAllByQuery(Project.class, projectQuery); + + //Fetch the quotations form the project (if there is one) + if(projectResult.size() != 0) { + for(Project project : projectResult.getAll()) { + WikittyQuery quotationQuery = new WikittyQueryMaker() + .eq(Quotation.ELEMENT_FIELD_QUOTATION_PROJECT, project) + .end(); + + quotationResult = client.findAllByQuery(Quotation.class, quotationQuery); + + + } + + } + + //Fetch the tasks form the quotations (if there are some) + if(quotationResult != null) { + for(Quotation quote : quotationResult.getAll()) { + WikittyQuery taskQuery = new WikittyQueryMaker() + .eq(Task.ELEMENT_FIELD_TASK_QUOTATION, quote) + .end(); + + taskResult = client.findAllByQuery(Task.class, taskQuery); + taskMap.put(quote, taskResult.getAll()); + + + } + + } + + } + System.out.println(taskMap); - return renderView("dashboardSingleProject.jsp", - "title", "Tableau de bord projet", "projects", result.getAll()); - } - - public Render requestProject(ChoremClient client, String projectname) { - return projectFilter(client, projectname); - } + if(projectResult == null) { + return renderView("dashboardSingleProject.jsp", + "title", "Tableau de bord projet", "projects", null,"quotations",null); + } + else if(quotationResult == null) { + return renderView("dashboardSingleProject.jsp", + "title", "Tableau de bord projet", "projects", projectResult.getAll(), + "quotations", null); + } + else { + return renderView("dashboardSingleProject.jsp", + "title", "Tableau de bord projet", "projects", projectResult.getAll(), + "quotations", quotationResult.getAll(), "taskMap", taskMap); + } + } + + public Render requestProject(ChoremClient client, String projectname) { + return projectFilter(client, projectname); + } } Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp =================================================================== --- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp 2013-06-13 15:33:58 UTC (rev 340) +++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardSingleProject.jsp 2013-06-14 14:03:04 UTC (rev 341) @@ -21,44 +21,94 @@ #L% --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> -<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %> -<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%> +<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> <%@ taglib uri="/WEB-INF/wikitty.tld" prefix="w"%> <h1>${title}</h1> <form class="well form-inline" method="GET"> -Nom du projet : <input class="input-large" type="text" name="projectname" value="${param.projectname}" placeholder="project name"/> -<input type="submit" class="btn"/> + Nom du projet : <input class="input-large" type="text" + name="projectname" value="${param.projectname}" + placeholder="project name" /> <input type="submit" class="btn" /> </form> <c:choose> -<c:when test="${projects.size() == 1}"> -<%//Project table generation %> -<table class="table table-striped table-bordered table-condensed"> - <thead> - <tr> - <th>Project</th> - <th>Description</th> - </tr> - </thead> - <c:forEach var="p" items="${projects}"> - <tbody> - <tr> - <td>${p.name}</td> - <td>${p.description}</td> - </tr> - </tbody> - </c:forEach> - </table> -</c:when> + <c:when test="${projects.size() >= 1}"> -<c:otherwise> -<c:if test="${param.projectname.length() != 0 }"> + + <c:forEach var="p" items="${projects}"> + <h2>${p.name}</h2> + <p>${p.description}</p> + </c:forEach> + + + + + <c:forEach var="q" items="${quotations}"> + <table class="table table-striped table-bordered table-condensed"> + <thead> + <tr> + <th>Devis</th> + <th>Responsable Code Lutin</th> + <th>Responsable entreprise</th> + <th>Estimated days</th> + <th>Conversion hope</th> + <th>Hoped price day</th> + <th>Amount</th> + </tr> + </thead> + </thead> + + <tbody> + <tr> + <td><w:display wikitty="${q.wikitty}" + fqfield="Quotation.description" label="" /></td> + <td><w:display wikitty="${q.wikitty}" + fqfield="Quotation.supplier" label="" /></td> + <td><w:display wikitty="${q.wikitty}" + fqfield="Quotation.customer" label="" /></td> + <td class="number"><w:display wikitty="${q.wikitty}" + fqfield="Quotation.estimatedDays" label="" /></td> + <td class="percent"><w:display wikitty="${q.wikitty}" + fqfield="Quotation.conversionHope" label="" /></td> + <td class="currency"><f:formatNumber type="currency" + value="${q.amount / q.estimatedDays}" /></td> + <td class="currency"><w:display wikitty="${q.wikitty}" + fqfield="Quotation.amount" label="" /></td> + </td> + </tr> + </tbody> + + + + </table> + Début : ${q.beginDate}<br /> + Fin : <w:display wikitty="${q.wikitty}" fqfield="Interval.endDate" + label="" /> + <p>Liste des tâches :</p> + <c:forEach items="${taskMap}" var="entry"> + + <c:if test="${entry.key.equals(q)}"> + <ul> + <c:forEach items="${entry.value}" var="task"> + <li>${task.name} : ${task.description}</li> + </c:forEach> + </c:if> + </ul> + + + </c:forEach> + </c:forEach> + </c:when> + + <c:otherwise> + <c:if + test="${param.projectname != null && param.projectname.length() != 0 }"> Projet inexistant </c:if> -</c:otherwise> + </c:otherwise> </c:choose>
participants (1)
-
meynier@users.chorem.org