First try of progression by me filter page.
This commit is contained in:
parent
de6a42d69a
commit
572a7b2282
|
|
@ -22,6 +22,7 @@ public class AnimalController {
|
||||||
public static final String MODEL_MAP_ANIMAL = "MODEL_MAP_ANIMAL";
|
public static final String MODEL_MAP_ANIMAL = "MODEL_MAP_ANIMAL";
|
||||||
public static final String MODEL_MAP_ANIMAL_CARE_ID = "MODEL_MAP_ANIMAL_CARE_ID";
|
public static final String MODEL_MAP_ANIMAL_CARE_ID = "MODEL_MAP_ANIMAL_CARE_ID";
|
||||||
public static final String MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID = "MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID";
|
public static final String MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID = "MODEL_MAP_ANIMAL_CONSENT_BEHAVIOR_ID";
|
||||||
|
public static final String MODEL_MAP_PROGRESSION = "MODEL_MAP_PROGRESSION";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IServiceAnimal serviceAnimal;
|
IServiceAnimal serviceAnimal;
|
||||||
|
|
@ -269,4 +270,33 @@ public class AnimalController {
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = IndexController.URL_ANIMAL_PROGRESSION_BY_ME, method = RequestMethod.GET)
|
||||||
|
public String doGetAnimalProgressionByMe(final ModelMap pModel, HttpSession httpSession,
|
||||||
|
@PathVariable(value = "animal_id") final int animalId,
|
||||||
|
@PathVariable(value = "progression_value") final String progressionByMeValue) {
|
||||||
|
String ret;
|
||||||
|
|
||||||
|
if (LoginController.isUserAlreadyAuth(httpSession)) {
|
||||||
|
Authentication authentication = (Authentication) httpSession.getAttribute(IndexController.SESSION_ATTRIBUTE_AUTHENTICATION);
|
||||||
|
Object oUserDetails = authentication.getPrincipal();
|
||||||
|
if (oUserDetails instanceof UserDetails) {
|
||||||
|
UserDetails userDetails = (UserDetails) oUserDetails;
|
||||||
|
|
||||||
|
Animal animal = serviceAnimal.getAnimalProgressionByMe(userDetails.getUsername(), animalId, progressionByMeValue);
|
||||||
|
pModel.addAttribute(MODEL_MAP_ANIMAL, animal);
|
||||||
|
|
||||||
|
List<Animal> animals = serviceAnimal.getAnimals(userDetails.getUsername());
|
||||||
|
pModel.addAttribute(MODEL_MAP_ANIMAL_LIST, animals);
|
||||||
|
|
||||||
|
pModel.addAttribute(MODEL_MAP_PROGRESSION, progressionByMeValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = IndexController.PAGE_ANIMAL_PROGRESSION;
|
||||||
|
} else {
|
||||||
|
ret = IndexController.URL_REDIRECT + IndexController.URL_LOGIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ public class IndexController {
|
||||||
public static final String URL_ANIMAL_CARES_AND_BEHAVIORS_LIST = "/animal/{animal_id}/cares_and_behaviors";
|
public static final String URL_ANIMAL_CARES_AND_BEHAVIORS_LIST = "/animal/{animal_id}/cares_and_behaviors";
|
||||||
public static final String URL_ANIMAL_CARE = "/animal/{animal_id}/care/{care_id}";
|
public static final String URL_ANIMAL_CARE = "/animal/{animal_id}/care/{care_id}";
|
||||||
public static final String URL_ANIMAL_BEHAVIOR = "/animal/{animal_id}/consent_behavior/{consent_behavior_id}";
|
public static final String URL_ANIMAL_BEHAVIOR = "/animal/{animal_id}/consent_behavior/{consent_behavior_id}";
|
||||||
|
public static final String URL_ANIMAL_PROGRESSION_BY_ME = "/animal/{animal_id}/progression_by_me/{progression_value}";
|
||||||
public static final String URL_ANIMAL_PROGRESSIONS_LIST = "/animal/{animal_id}/progressions";
|
public static final String URL_ANIMAL_PROGRESSIONS_LIST = "/animal/{animal_id}/progressions";
|
||||||
|
|
||||||
// Add URL
|
// Add URL
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ public interface IProgressionDao extends CommonDao {
|
||||||
public void deleteAllAnimalConsentBehaviorProgression(int animalId, String owner, int consentBehaviorId);
|
public void deleteAllAnimalConsentBehaviorProgression(int animalId, String owner, int consentBehaviorId);
|
||||||
|
|
||||||
public void fillAnimalProgressionByCare(Animal animal, int careId);
|
public void fillAnimalProgressionByCare(Animal animal, int careId);
|
||||||
|
|
||||||
public void fillAnimalProgressionByConsentBehavior(Animal animal, int consentBehaviorId);
|
public void fillAnimalProgressionByConsentBehavior(Animal animal, int consentBehaviorId);
|
||||||
|
public void fillAnimalProgressionByMe(Animal animal, String progressionByMe);
|
||||||
|
public void fillAnimalProgressionBySomeoneElse(Animal animal, String progressionBySomeoneElse);
|
||||||
|
public void fillAnimalProgressionByVeterinary(Animal animal, String progressionByVeterinary);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,98 @@ public class ProgressionDao extends PostgresSqlDao implements IProgressionDao {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillAnimalProgressionByMe(Animal animal, String progressionByMe) {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement statement = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
try {
|
||||||
|
conn = mDataSource.getConnection();
|
||||||
|
statement = conn.prepareStatement("select "
|
||||||
|
+ AnimalDao.TABLE_NAME+".id as animal_id, "+AnimalDao.TABLE_NAME+".name as animal_name, "+AnimalDao.TABLE_NAME+".owner as animal_owner, "
|
||||||
|
+ TABLE_NAME+".id as progression_id, "+TABLE_NAME+".progression_by_me as prog_by_me, "+TABLE_NAME+".progression_by_someone_else as prog_by_someone_else, "+TABLE_NAME+".progression_by_veterinary as prog_by_vet, "
|
||||||
|
+ TABLE_NAME+".care as care_id, "+TABLE_NAME+".consent_behavior as consent_behavior_id, "
|
||||||
|
+ CareDao.TABLE_NAME+".name as care_name, "+CareDao.TABLE_NAME+".description as care_desc, "
|
||||||
|
+ ConsentBehaviorDao.TABLE_NAME+".name as consent_behavior_name, "+ConsentBehaviorDao.TABLE_NAME+".description as consent_behavior_desc "
|
||||||
|
+ "from "+TABLE_NAME+" "
|
||||||
|
+ "left join "+AnimalDao.TABLE_NAME+" on "+TABLE_NAME+".animal = "+AnimalDao.TABLE_NAME+".id "
|
||||||
|
+ "left join "+CareDao.TABLE_NAME+" on "+TABLE_NAME+".care = "+CareDao.TABLE_NAME+".id "
|
||||||
|
+ "left join "+ConsentBehaviorDao.TABLE_NAME+" on "+TABLE_NAME+".consent_behavior = "+ConsentBehaviorDao.TABLE_NAME+".id "
|
||||||
|
+ "where "+AnimalDao.TABLE_NAME+".owner = ? and "+AnimalDao.TABLE_NAME+".id = ? and "+TABLE_NAME+".progression_by_me = ?;");
|
||||||
|
statement.setString(1, animal.getOwner());
|
||||||
|
statement.setInt(2, animal.getId());
|
||||||
|
statement.setString(3, progressionByMe);
|
||||||
|
System.out.println(IndexController.LOG_TAG + " SQL -> " + statement.toString());
|
||||||
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
if (resultSet != null) {
|
||||||
|
while (resultSet.next()) {
|
||||||
|
Progression progression = new Progression();
|
||||||
|
progression.setId(resultSet.getInt("progression_id"));
|
||||||
|
progression.setProgressionByMe(resultSet.getString("prog_by_me"));
|
||||||
|
progression.setProgressionBySomeoneElse(resultSet.getString("prog_by_someone_else"));
|
||||||
|
progression.setProgressionByVeterinary(resultSet.getString("prog_by_vet"));
|
||||||
|
|
||||||
|
int careId = resultSet.getInt("care_id");
|
||||||
|
if (!animal.containsCareKey(careId)) {
|
||||||
|
Care care = new Care();
|
||||||
|
care.setId(careId);
|
||||||
|
care.setName(resultSet.getString("care_name"));
|
||||||
|
care.setDescription(resultSet.getString("care_desc"));
|
||||||
|
animal.addCare(care);
|
||||||
|
}
|
||||||
|
progression.setCare(animal.getCareById(careId));
|
||||||
|
|
||||||
|
int consentBehaviorId = resultSet.getInt("consent_behavior_id");
|
||||||
|
if (!animal.containsConsentBehaviorKey(consentBehaviorId)) {
|
||||||
|
ConsentBehavior consentBehavior = new ConsentBehavior();
|
||||||
|
consentBehavior.setId(consentBehaviorId);
|
||||||
|
consentBehavior.setName(resultSet.getString("consent_behavior_name"));
|
||||||
|
consentBehavior.setDescription(resultSet.getString("consent_behavior_desc"));
|
||||||
|
animal.addConsentBehavior(consentBehavior);
|
||||||
|
}
|
||||||
|
progression.setConsentBehavior(animal.getConsentBehaviorById(consentBehaviorId));
|
||||||
|
|
||||||
|
animal.addProgression(progression);
|
||||||
|
}
|
||||||
|
resultSet.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println(IndexController.LOG_TAG + " SQLException -> fillAnimalProgressionByMe() - " + ex.getMessage());
|
||||||
|
ex.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (resultSet != null) {
|
||||||
|
try {
|
||||||
|
resultSet.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println(IndexController.LOG_TAG + " Failed close ResultSet -> fillAnimalProgressionByMe()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println(IndexController.LOG_TAG + " Failed close statement -> fillAnimalProgressionByMe()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conn != null) {
|
||||||
|
try {
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println(IndexController.LOG_TAG + " Failed close connection -> fillAnimalProgressionByMe()");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillAnimalProgressionBySomeoneElse(Animal animal, String progressionBySomeoneElse) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fillAnimalProgressionByVeterinary(Animal animal, String progressionByVeterinary) {
|
||||||
|
}
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
|
|
||||||
//<editor-fold defaultstate="collapsed" desc="Delete methods">
|
//<editor-fold defaultstate="collapsed" desc="Delete methods">
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ package fr.geoffrey.medical_training_tracker.dao.bean;
|
||||||
*/
|
*/
|
||||||
public class Progression {
|
public class Progression {
|
||||||
|
|
||||||
private static final String PROGRESSION_VALUE_NOT_TRAINED = "NOT_TRAINED";
|
public static final String PROGRESSION_VALUE_NOT_TRAINED = "NOT_TRAINED";
|
||||||
private static final String PROGRESSION_VALUE_CURRENTLY_TRAINING = "CURRENTLY_TRAINING";
|
public static final String PROGRESSION_VALUE_CURRENTLY_TRAINING = "CURRENTLY_TRAINING";
|
||||||
private static final String PROGRESSION_VALUE_TRAINED = "TRAINED";
|
public static final String PROGRESSION_VALUE_TRAINED = "TRAINED";
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private ConsentBehavior consentBehavior;
|
private ConsentBehavior consentBehavior;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ public interface IServiceAnimal {
|
||||||
public Animal getAnimalProgression(String owner, int animalId);
|
public Animal getAnimalProgression(String owner, int animalId);
|
||||||
public Animal getAnimalCareProgression(String owner, int animalId, int careId);
|
public Animal getAnimalCareProgression(String owner, int animalId, int careId);
|
||||||
public Animal getAnimalConsentBehaviorProgression(String owner, int animalId, int consentBehaviorId);
|
public Animal getAnimalConsentBehaviorProgression(String owner, int animalId, int consentBehaviorId);
|
||||||
|
public Animal getAnimalProgressionByMe(String username, int animalId, String progressionValue);
|
||||||
|
|
||||||
public void addAnimal(String name, String owner);
|
public void addAnimal(String name, String owner);
|
||||||
public void addCare(int animalId, String name, String description);
|
public void addCare(int animalId, String name, String description);
|
||||||
|
|
@ -19,4 +20,5 @@ public interface IServiceAnimal {
|
||||||
public void deleteAnimalCare(int animalId, String owner, int careId);
|
public void deleteAnimalCare(int animalId, String owner, int careId);
|
||||||
public void deleteAnimalConsentBehavior(int animalId, String owner, int consentBehaviorId);
|
public void deleteAnimalConsentBehavior(int animalId, String owner, int consentBehaviorId);
|
||||||
public void deleteAnimalProgression(int animalId, String owner, int progressionId);
|
public void deleteAnimalProgression(int animalId, String owner, int progressionId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,4 +106,13 @@ public class ServiceAnimal implements IServiceAnimal {
|
||||||
}
|
}
|
||||||
return animal;
|
return animal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Animal getAnimalProgressionByMe(String username, int animalId, String progressionValue) {
|
||||||
|
Animal animal = animalDao.getAnimal(username, animalId);
|
||||||
|
if (animal != null) {
|
||||||
|
progressionDao.fillAnimalProgressionByMe(animal, progressionValue);
|
||||||
|
}
|
||||||
|
return animal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,11 @@
|
||||||
<c:if test="${progression.getProgressionByMe() == 'TRAINED'}">success</c:if>
|
<c:if test="${progression.getProgressionByMe() == 'TRAINED'}">success</c:if>
|
||||||
<c:if test="${progression.getProgressionByMe() == 'CURRENTLY_TRAINING'}">info</c:if>
|
<c:if test="${progression.getProgressionByMe() == 'CURRENTLY_TRAINING'}">info</c:if>
|
||||||
<c:if test="${progression.getProgressionByMe() == 'NOT_TRAINED'}">active</c:if>
|
<c:if test="${progression.getProgressionByMe() == 'NOT_TRAINED'}">active</c:if>
|
||||||
">${progression.getProgressionByMe()}</td>
|
">
|
||||||
|
<a href="${animalURL}/${MODEL_MAP_ANIMAL.getId()}/progression_by_me/${progression.getProgressionByMe()}">
|
||||||
|
${progression.getProgressionByMe()}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
<td class="
|
<td class="
|
||||||
<c:if test="${progression.getProgressionBySomeoneElse() == 'TRAINED'}">success</c:if>
|
<c:if test="${progression.getProgressionBySomeoneElse() == 'TRAINED'}">success</c:if>
|
||||||
<c:if test="${progression.getProgressionBySomeoneElse() == 'CURRENTLY_TRAINING'}">info</c:if>
|
<c:if test="${progression.getProgressionBySomeoneElse() == 'CURRENTLY_TRAINING'}">info</c:if>
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,18 @@
|
||||||
<h4>List de vos animaux</h4>
|
<h4>List de vos animaux</h4>
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<c:forEach items="${MODEL_MAP_ANIMAL_LIST}" var="animal">
|
<c:forEach items="${MODEL_MAP_ANIMAL_LIST}" var="animal">
|
||||||
<div class="list-group-item">
|
<a class="list-group-item" href="${animalURL}/${animal.getId()}/cares_and_behaviors">
|
||||||
${animal.getName()}
|
${animal.getName()}
|
||||||
<form class="pull-right" action="${animalDeleteURL}/${animal.getId()}" method="POST">
|
<form class="pull-right" action="${animalDeleteURL}/${animal.getId()}" method="POST">
|
||||||
<button class="btn btn-sm btn-danger" type="submit" data-toggle="tooltip" data-placement="bottom" title="Suppression"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
|
<button class="btn btn-sm btn-danger" type="submit" data-toggle="tooltip" data-placement="bottom" title="Suppression"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
|
||||||
</form>
|
</form>
|
||||||
<!--<a class="btn btn-sm btn-danger pull-right" href="${animalDeleteURL}/${animal.getId()}" data-toggle="tooltip" data-placement="bottom" title="Suppression"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>-->
|
</a>
|
||||||
</div>
|
<!-- <div class="list-group-item">
|
||||||
|
${animal.getName()}
|
||||||
|
<form class="pull-right" action="${animalDeleteURL}/${animal.getId()}" method="POST">
|
||||||
|
<button class="btn btn-sm btn-danger" type="submit" data-toggle="tooltip" data-placement="bottom" title="Suppression"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button>
|
||||||
|
</form>
|
||||||
|
</div>-->
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
<%@page import="fr.geoffrey.medical_training_tracker.dao.bean.Animal"%>
|
||||||
|
<%@page import="java.util.List"%>
|
||||||
|
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
|
||||||
|
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
|
||||||
|
<%@ page isELIgnored="false" %>
|
||||||
|
|
||||||
|
<%@ include file="base/language.jsp" %>
|
||||||
|
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<%@ include file="base/header.jsp" %>
|
||||||
|
<style type="text/css">
|
||||||
|
fieldset {
|
||||||
|
margin: auto;
|
||||||
|
width: 600px;
|
||||||
|
margin-top: 30px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: left;
|
||||||
|
border: 2px solid #aaa;
|
||||||
|
}
|
||||||
|
fieldset a {
|
||||||
|
width: 150px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<%@ include file="base/navbar.jsp" %>
|
||||||
|
<center><h1>Feuille de ${MODEL_MAP_ANIMAL.getName()}</h1></center>
|
||||||
|
<h4>Progression par moi ${MODEL_MAP_PROGRESSION}</h4>
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Soin</th>
|
||||||
|
<th>Comportement de consentement</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:forEach items="${MODEL_MAP_ANIMAL.getProgressionList()}" var="progression">
|
||||||
|
<tr>
|
||||||
|
<td><a href="${animalURL}/${MODEL_MAP_ANIMAL.getId()}/care/${progression.getCare().getId()}">${progression.getCare().getName()}</a></td>
|
||||||
|
<td><a href="${animalURL}/${MODEL_MAP_ANIMAL.getId()}/consent_behavior/${progression.getConsentBehavior().getId()}">${progression.getConsentBehavior().getName()}</a></td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<%@ include file="base/footer.jsp" %>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -29,13 +29,14 @@
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<% if (authentication != null) { %>
|
<% if (authentication != null) { %>
|
||||||
<c:forEach items="${MODEL_MAP_ANIMAL_LIST}" var="animal">
|
<c:forEach items="${MODEL_MAP_ANIMAL_LIST}" var="animal">
|
||||||
<li class="dropdown <c:if test="${MODEL_MAP_ANIMAL.getId() == animal.getId()}">active</c:if>" >
|
<li><a href="${animalURL}/${animal.getId()}/cares_and_behaviors">${animal.getName()}</a></li>
|
||||||
|
<!-- <li class="dropdown <c:if test="${MODEL_MAP_ANIMAL.getId() == animal.getId()}">active</c:if>" >
|
||||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">${animal.getName()} <span class="caret"></span></a>
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">${animal.getName()} <span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="${animalURL}/${animal.getId()}/cares_and_behaviors"><fmt:message key="navbar.cares_and_behaviors"></fmt:message></a></li>
|
<li><a href="${animalURL}/${animal.getId()}/cares_and_behaviors"><fmt:message key="navbar.cares_and_behaviors"></fmt:message></a></li>
|
||||||
<li><a href="${animalURL}/${animal.getId()}/progressions">Progressions</a></li>
|
<li><a href="${animalURL}/${animal.getId()}/progressions">Progressions</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>-->
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
<% }%>
|
<% }%>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue