diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..838458f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/dist/ \ No newline at end of file diff --git a/build/web/WEB-INF/classes/DAO/MagasinHelper.class b/build/web/WEB-INF/classes/DAO/MagasinHelper.class index 8ef5d0d..2a62d1d 100644 Binary files a/build/web/WEB-INF/classes/DAO/MagasinHelper.class and b/build/web/WEB-INF/classes/DAO/MagasinHelper.class differ diff --git a/build/web/WEB-INF/classes/controller/BddController.class b/build/web/WEB-INF/classes/controller/BddController.class index 646e32c..9839cf8 100644 Binary files a/build/web/WEB-INF/classes/controller/BddController.class and b/build/web/WEB-INF/classes/controller/BddController.class differ diff --git a/build/web/WEB-INF/classes/jsp/header.jsp b/build/web/WEB-INF/classes/jsp/header.jsp index b2d31f2..585d2f9 100644 --- a/build/web/WEB-INF/classes/jsp/header.jsp +++ b/build/web/WEB-INF/classes/jsp/header.jsp @@ -7,14 +7,15 @@
diff --git a/build/web/WEB-INF/jsp/header.jsp b/build/web/WEB-INF/jsp/header.jsp index b2d31f2..585d2f9 100644 --- a/build/web/WEB-INF/jsp/header.jsp +++ b/build/web/WEB-INF/jsp/header.jsp @@ -7,14 +7,15 @@
diff --git a/build/web/WEB-INF/lib/spring-web-3.2.18.RELEASE.jar b/build/web/WEB-INF/lib/spring-web-3.2.18.RELEASE.jar deleted file mode 100644 index ff7664d..0000000 Binary files a/build/web/WEB-INF/lib/spring-web-3.2.18.RELEASE.jar and /dev/null differ diff --git a/src/java/DAO/MagasinHelper.java b/src/java/DAO/MagasinHelper.java index 4e5e905..2f84eb4 100644 --- a/src/java/DAO/MagasinHelper.java +++ b/src/java/DAO/MagasinHelper.java @@ -136,7 +136,7 @@ public class MagasinHelper { return resultat; } - public List getClients(String name){ + public List getClientsColums(String name){ List resultat=null; Transaction tx=null; try{ @@ -159,6 +159,28 @@ public class MagasinHelper { return resultat; } + public List getClientsColums(int _id){ + List resultat=null; + Transaction tx=null; + try{ + if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + session.flush(); + + tx=session.beginTransaction(); + Query q=session.createQuery("select a.customerId, a.name, a.addressline1,a.addressline2,a.zip from Customer a where a.customerId = :_id"); + q.setInteger("_id", _id); + resultat=q.list(); + } + catch (Exception e) { + e.printStackTrace(); + } + finally{ + if (session.isOpen())session.close(); + } + + return resultat; +} + public List getManufacturers(){ List resultat=null; Transaction tx=null; diff --git a/src/java/controller/BddController.java b/src/java/controller/BddController.java index 6d7116f..ebf3461 100644 --- a/src/java/controller/BddController.java +++ b/src/java/controller/BddController.java @@ -148,22 +148,32 @@ public class BddController extends MultiActionController { } public ModelAndView find(HttpServletRequest request, HttpServletResponse response) throws Exception { - sessionInit(request); - - ModelAndView mv ; - MagasinHelper requeteur = new MagasinHelper(); - if (requeteur.getClients(request.getParameter("nom")).isEmpty() || request.getParameter("nom").equals("%") ){ - mv= new ModelAndView("error"); - mv.addObject("erreur", "0 enregistrement"); - - } - else{ - mv= new ModelAndView("resultat"); - mv.addObject("liste",requeteur.getClients(request.getParameter("nom"))); - - } + sessionInit(request); + String type = request.getParameter("type"); + ModelAndView mv = new ModelAndView("resultat"); + mv.addObject("user",session.getAttribute("user")); + mv.addObject("type", type); - mv.addObject("user",session.getAttribute("user")); + String query = request.getParameter("query"); + if (query == null || query.isEmpty()) + mv.addObject("error", "No query"); + else { + List customers = new ArrayList(); + try { + customers.addAll(new MagasinHelper().getClientsColums(Integer.parseInt(query))); + } catch (NumberFormatException exception) { + + } + + query = "%".concat(query.concat("%")); + customers.addAll(new MagasinHelper().getClientsColums(query)); + + if (customers.size() == 0) + mv.addObject("error", "No user found :/"); + else + mv.addObject("results", customers); + } + MagasinHelper helper = new MagasinHelper(); return mv; } public ModelAndView formfind(HttpServletRequest request, diff --git a/web/WEB-INF/jsp/header.jsp b/web/WEB-INF/jsp/header.jsp index b2d31f2..585d2f9 100644 --- a/web/WEB-INF/jsp/header.jsp +++ b/web/WEB-INF/jsp/header.jsp @@ -7,14 +7,15 @@