1 | package org.medias.eccad.persistance; |
---|
2 | |
---|
3 | import java.util.List; |
---|
4 | |
---|
5 | |
---|
6 | import org.medias.eccad.helpers.LoggerPerso; |
---|
7 | import org.medias.eccad.helpers.SpringBeanFactory; |
---|
8 | import org.medias.eccad.modele.*; |
---|
9 | import org.medias.eccad.persistance.dao.GrilleDAO; |
---|
10 | import org.medias.eccad.persistance.dao.MappingDAO; |
---|
11 | import org.medias.eccad.persistance.dao.ParametreDAO; |
---|
12 | import org.medias.eccad.persistance.dao.CatParametreDAO; |
---|
13 | import org.medias.eccad.persistance.dao.ProduitDAO; |
---|
14 | import org.medias.eccad.persistance.exception.PersistanceException; |
---|
15 | import org.medias.eccad.persistance.jdbc.CatParametreDAOjdbc; |
---|
16 | import org.springframework.beans.factory.xml.XmlBeanFactory; |
---|
17 | |
---|
18 | public class ServicePersistance { |
---|
19 | //FactoryDAO factory; |
---|
20 | XmlBeanFactory xmlbean; |
---|
21 | |
---|
22 | public ServicePersistance() { |
---|
23 | LoggerPerso.log(ServicePersistance.class, LoggerPerso.DEBUG, "création du service"); |
---|
24 | xmlbean = SpringBeanFactory.getXmlFactory(); |
---|
25 | } |
---|
26 | |
---|
27 | public List<CatParametre> getListcatParametre() { |
---|
28 | LoggerPerso.log(ServicePersistance.class, LoggerPerso.DEBUG, "load DAOCAT"); |
---|
29 | List<CatParametre> liste_catParam; |
---|
30 | CatParametreDAO catParamdao = (CatParametreDAO) xmlbean.getBean("catParametreDAO"); |
---|
31 | try { |
---|
32 | LoggerPerso.log(ServicePersistance.class, LoggerPerso.DEBUG, "try...!"); |
---|
33 | liste_catParam = catParamdao.getListcatParametre(); |
---|
34 | |
---|
35 | } catch (PersistanceException e) { |
---|
36 | e.printStackTrace(); |
---|
37 | return null; |
---|
38 | } |
---|
39 | |
---|
40 | return liste_catParam; |
---|
41 | } |
---|
42 | |
---|
43 | public List<Parametre> getListParamByCatParam(int id_CatParam) { |
---|
44 | List<Parametre> liste_param; |
---|
45 | ParametreDAO parametre = (ParametreDAO) xmlbean.getBean("parametreDAO"); |
---|
46 | |
---|
47 | try { |
---|
48 | liste_param = parametre.getListParamtByCatParam(id_CatParam); |
---|
49 | } catch (PersistanceException e) { |
---|
50 | e.printStackTrace(); |
---|
51 | return null; |
---|
52 | } |
---|
53 | return liste_param; |
---|
54 | } |
---|
55 | |
---|
56 | public List<Parametre> getListParametre() { |
---|
57 | List<Parametre> liste_param; |
---|
58 | ParametreDAO paramdao = (ParametreDAO) xmlbean.getBean("parametreDAO"); |
---|
59 | try { |
---|
60 | liste_param = paramdao.getListParametre(); |
---|
61 | } catch (PersistanceException e) { |
---|
62 | e.printStackTrace(); |
---|
63 | return null; |
---|
64 | } |
---|
65 | |
---|
66 | return liste_param; |
---|
67 | } |
---|
68 | |
---|
69 | public List<Produit> getListProductByParam(int id_param) { |
---|
70 | List<Produit> liste_param; |
---|
71 | ProduitDAO produit = (ProduitDAO) xmlbean.getBean("produitDAO"); |
---|
72 | |
---|
73 | try { |
---|
74 | liste_param = produit.getListProductByParam(id_param); |
---|
75 | } catch (PersistanceException e) { |
---|
76 | e.printStackTrace(); |
---|
77 | return null; |
---|
78 | } |
---|
79 | return liste_param; |
---|
80 | } |
---|
81 | |
---|
82 | public Produit getProduitByID(long id_produit) { |
---|
83 | Produit produit = null; |
---|
84 | ProduitDAO produitdao = (ProduitDAO) xmlbean.getBean("produitDAO"); |
---|
85 | |
---|
86 | try { |
---|
87 | produit = produitdao.getProduitById(id_produit); |
---|
88 | } catch (PersistanceException e) { |
---|
89 | e.printStackTrace(); |
---|
90 | return null; |
---|
91 | } |
---|
92 | |
---|
93 | LoggerPerso.log(ServicePersistance.class, LoggerPerso.DEBUG, "getProduitById::nom::"+ produit.getNom() + "::date::" + produit.getBeginDate()); |
---|
94 | return produit; |
---|
95 | } |
---|
96 | |
---|
97 | public List<Grille> getListGrille(long id_produit, long id_parametre,String date_debut, String date_fin) { |
---|
98 | List<Grille> grille; |
---|
99 | GrilleDAO grilledao = (GrilleDAO) xmlbean.getBean("grilleDAO"); |
---|
100 | try { |
---|
101 | grille = grilledao.getListGrille(id_produit, id_parametre, date_debut, date_fin); |
---|
102 | } catch (PersistanceException e) { |
---|
103 | e.printStackTrace(); |
---|
104 | return null; |
---|
105 | } |
---|
106 | |
---|
107 | return grille; |
---|
108 | } |
---|
109 | |
---|
110 | public List<Grille> getListGrille(long id_produit,String date_debut, String date_fin) { |
---|
111 | List<Grille> grille; |
---|
112 | GrilleDAO grilledao = (GrilleDAO) xmlbean.getBean("grilleDAO"); |
---|
113 | try { |
---|
114 | grille = grilledao.getListGrille(id_produit, date_debut, date_fin); |
---|
115 | } catch (PersistanceException e) { |
---|
116 | e.printStackTrace(); |
---|
117 | return null; |
---|
118 | } |
---|
119 | |
---|
120 | return grille; |
---|
121 | } |
---|
122 | |
---|
123 | public Parametre getParametreById(int id_param) { |
---|
124 | Parametre param = null; |
---|
125 | ParametreDAO parametredao = (ParametreDAO) xmlbean.getBean("parametreDAO"); |
---|
126 | try { |
---|
127 | param = parametredao.getParametreById(id_param); |
---|
128 | } catch (PersistanceException e) { |
---|
129 | e.printStackTrace(); |
---|
130 | return null; |
---|
131 | } |
---|
132 | |
---|
133 | return param; |
---|
134 | } |
---|
135 | |
---|
136 | public float[][] getDataEccad(int oid) { |
---|
137 | float[][] tableau; |
---|
138 | GrilleDAO grilledao = (GrilleDAO) xmlbean.getBean("grilleDAO"); |
---|
139 | try { |
---|
140 | tableau = grilledao.getGrilleValue(oid); |
---|
141 | } |
---|
142 | catch (PersistanceException e) { |
---|
143 | e.printStackTrace(); |
---|
144 | return null; |
---|
145 | } |
---|
146 | return tableau; |
---|
147 | } |
---|
148 | |
---|
149 | public Visualisation getVisuByProduit(String type_produit) { |
---|
150 | MappingDAO mapping = (MappingDAO) xmlbean.getBean("mappingDAO"); |
---|
151 | return mapping.getVisualisation(type_produit); |
---|
152 | } |
---|
153 | } |
---|