Rev 1746 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1743 | jmachado | 1 | <%@ page import="jomm.dao.impl.AbstractDao" %> |
2 | <%@ page import="pt.estgp.estgweb.domain.Course" %> |
||
3 | <%@ page import="pt.estgp.estgweb.domain.CourseStudiesPlanImpl" %> |
||
4 | <%@ page import="pt.estgp.estgweb.domain.CourseUnit" %> |
||
5 | <%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
||
6 | <%@ page import="pt.estgp.estgweb.services.courses.CoursesService" %> |
||
7 | <%@ page import="pt.estgp.estgweb.services.courses.xsd.Curso" %> |
||
8 | <%@ page import="pt.estgp.estgweb.services.courses.xsd.UnidadeType" %> |
||
9 | <%@ page import="java.io.InputStream" %> |
||
10 | <%@ page import="java.net.URL" %> |
||
11 | <%@ page import="java.util.List" %> |
||
1744 | jmachado | 12 | <%@ page import="org.apache.commons.httpclient.HttpConnection" %> |
13 | <%@ page import="pt.estgp.estgweb.web.utils.*" %> |
||
1743 | jmachado | 14 | <%@page contentType="text/html"%> |
15 | <%@page pageEncoding="UTF-8"%> |
||
16 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
||
17 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
||
18 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
||
19 | <jsp:useBean id="UserSession" type="pt.estgp.estgweb.domain.UserSessionImpl" scope="request"/> |
||
20 | |||
21 | <table class="tablesorterfiltered"> |
||
22 | <thead> |
||
23 | <tr> |
||
24 | <th>SIGES</th> |
||
25 | <th>Escola</th> |
||
26 | <th>Curso</th> |
||
27 | <th>Tipo</th> |
||
1747 | jmachado | 28 | <th>Perfil</th> |
1743 | jmachado | 29 | <th>SIGES</th> |
30 | <th>Unidade</th> |
||
31 | <th>Ficha</th> |
||
32 | </tr> |
||
33 | </thead> |
||
34 | <tbody> |
||
35 | |||
36 | </tbody> |
||
37 | |||
38 | <% |
||
39 | CoursesService courseService = new CoursesService(); |
||
40 | String importYear = UserSession.getNowConfiguration().getInterfaceImportYear(); |
||
41 | AbstractDao.getCurrentSession().beginTransaction(); |
||
42 | List<Course> courses = DaoFactory.getCourseDaoImpl().findActiveCourses(importYear); |
||
43 | |||
44 | for(Course c : courses) |
||
45 | { |
||
46 | try{ |
||
47 | request.setAttribute("course",c); |
||
48 | boolean studiesPlan = c.getStudiesPlans() != null; |
||
49 | CourseStudiesPlanImpl plan = null; |
||
50 | Curso curso = null; |
||
51 | if(c.getStudiesPlans() != null) |
||
52 | { |
||
53 | plan = (CourseStudiesPlanImpl) c.getStudiesPlans().iterator().next(); |
||
54 | |||
55 | curso = courseService.loadCursoPlanoFromXml(plan.getXml()); |
||
56 | } |
||
57 | %> |
||
58 | |||
59 | |||
60 | |||
61 | <% |
||
62 | if(curso == null) |
||
63 | { |
||
64 | %> |
||
65 | <td colspan="5">Sem Plano Criado</td> |
||
66 | <% |
||
67 | } |
||
68 | else |
||
69 | { |
||
70 | for(Curso.Semestre semestre : curso.getSemestre()) |
||
71 | { |
||
72 | request.setAttribute("semestre",semestre.getId()); |
||
73 | if(semestre.getUnidade() != null) |
||
74 | { |
||
75 | for(UnidadeType unidade : semestre.getUnidade()) |
||
76 | { |
||
77 | request.setAttribute("unidade",unidade); |
||
78 | boolean unidadeSiges = unidade.getSiges() != null && unidade.getSiges().trim().length() > 0; |
||
79 | boolean autoGeneratedSiges = false; |
||
80 | boolean escolaDepartamentoNull = false; |
||
81 | boolean autoGeneratedUrl = false; |
||
82 | boolean urlFail = false; |
||
83 | |||
84 | if(c.getDepartment() == null || c.getDepartment().getCourseSchool() == null || c.getDepartment().getCourseSchool().getInitials() == null) |
||
85 | { |
||
86 | escolaDepartamentoNull = true; |
||
87 | } |
||
88 | |||
89 | if(!unidadeSiges) |
||
90 | { |
||
91 | CourseUnit cu = DaoFactory.getCourseUnitDaoImpl().findUnitByCourseNameYear(c.getId(),unidade.getNome(),importYear); |
||
92 | if(cu != null) |
||
93 | { |
||
94 | unidadeSiges = true; |
||
95 | autoGeneratedSiges = true; |
||
96 | |||
97 | unidade.setSiges(cu.getCode()); |
||
98 | if(escolaDepartamentoNull) |
||
99 | { |
||
100 | //ja foi colocado em cima |
||
101 | } |
||
102 | else if(c.getDepartment().getCourseSchool().getInitials().equals("ESTG")) |
||
103 | { |
||
104 | unidade.setUrlFichaCurricular("http://www.estgp.pt/startLoadCourseUnitProgramSiges.do?unitCode=" + unidade.getSiges() + "&courseCode=" + c.getCode() + "&semestre=" + semestre.getId()); |
||
105 | autoGeneratedUrl = true; |
||
106 | } |
||
107 | } |
||
108 | } |
||
1745 | jmachado | 109 | else if(!escolaDepartamentoNull && |
110 | c.getDepartment().getCourseSchool().getInitials().equals("ESTG") && |
||
111 | (unidade.getUrlFichaCurricular() == null || unidade.getUrlFichaCurricular().length() ==0 )) |
||
1743 | jmachado | 112 | { |
113 | autoGeneratedUrl = true; |
||
114 | unidade.setUrlFichaCurricular("http://www.estgp.pt/startLoadCourseUnitProgramSiges.do?unitCode=" + unidade.getSiges() + "&courseCode=" + c.getCode() + "&semestre=" + semestre.getId()); |
||
115 | } |
||
116 | |||
117 | try{ |
||
1744 | jmachado | 118 | int code = pt.estgp.estgweb.web.utils.HttpUtils.getResponseCode(unidade.getUrlFichaCurricular()); |
119 | if(code != 200) |
||
120 | { |
||
121 | urlFail = true; |
||
122 | System.out.println("Erro a carregar ficha: " + unidade.getUrlFichaCurricular()); |
||
123 | } |
||
1743 | jmachado | 124 | }catch(Throwable f404) |
125 | { |
||
126 | urlFail = true; |
||
127 | System.out.println("Erro a carregar ficha: " + unidade.getUrlFichaCurricular()); |
||
128 | } |
||
129 | |||
130 | request.setAttribute("autoGeneratedSiges",autoGeneratedSiges); |
||
131 | request.setAttribute("unidadeSiges",unidadeSiges); |
||
132 | request.setAttribute("escolaDepartamentoNull",escolaDepartamentoNull); |
||
133 | request.setAttribute("autoGeneratedUrl",autoGeneratedUrl); |
||
134 | request.setAttribute("urlFail",urlFail); |
||
135 | %> |
||
136 | <tr> |
||
1747 | jmachado | 137 | |
1743 | jmachado | 138 | <td><%=c.getCode()%></td> |
139 | <td <logic:equal value="true" name="escolaDepartamentoNull">style="background-color: red"</logic:equal>> |
||
140 | <logic:equal value="true" name="escolaDepartamentoNull"> |
||
141 | S/Esco/Dep/Init |
||
142 | </logic:equal> |
||
143 | <logic:equal value="false" name="escolaDepartamentoNull"> |
||
144 | <%=c.getDepartment().getCourseSchool().getInitials()%></td> |
||
145 | </logic:equal> |
||
146 | |||
147 | <td><%=c.getName()%></td> |
||
148 | <td><bean:message key="course.${course.degree}"/></td> |
||
1747 | jmachado | 149 | <td></td> |
1743 | jmachado | 150 | <td <logic:equal value="false" name="unidadeSiges">style="background-color: red"</logic:equal> <logic:equal value="true" name="autoGeneratedSiges">style="background-color: #ffff00"</logic:equal>> |
151 | <logic:equal value="true" name="unidadeSiges"> |
||
152 | |||
153 | ${unidade.siges} |
||
154 | <logic:equal value="true" name="autoGeneratedSiges"> |
||
155 | (Auto) |
||
156 | </logic:equal> |
||
157 | </logic:equal> |
||
158 | <logic:equal value="false" name="unidadeSiges"> |
||
159 | Nao Tem |
||
160 | </logic:equal> |
||
161 | </td> |
||
162 | <td>${unidade.nome}</td> |
||
163 | <td <logic:equal value="true" name="urlFail">style="background-color: red"</logic:equal>> |
||
164 | <logic:equal value="true" name="autoGeneratedUrl"> |
||
165 | <label <logic:equal value="true" name="autoGeneratedUrl">style="background-color: #ffff00"</logic:equal>>(Auto)</label> |
||
166 | </logic:equal> |
||
167 | <logic:equal value="true" name="urlFail"> |
||
168 | (Falhou) |
||
169 | </logic:equal> |
||
170 | <a href="<%=unidade.getUrlFichaCurricular()%>"><span class="glyphicon glyphicon-download"></span></a> |
||
171 | </td> |
||
172 | </tr> |
||
173 | <% |
||
1746 | jmachado | 174 | if(autoGeneratedSiges || autoGeneratedUrl) |
175 | courseService.savePlanoEstudosEditado(c.getId(),plan.getId(),curso,plan,UserSession); |
||
1743 | jmachado | 176 | } |
177 | } |
||
178 | if(semestre.getPerfil()!=null) |
||
179 | { |
||
180 | for(Curso.Semestre.Perfil perfil : semestre.getPerfil()) |
||
181 | { |
||
182 | for(UnidadeType unidade : semestre.getUnidade()) |
||
183 | { |
||
1747 | jmachado | 184 | request.setAttribute("unidade",unidade); |
185 | boolean unidadeSiges = unidade.getSiges() != null && unidade.getSiges().trim().length() > 0; |
||
186 | boolean autoGeneratedSiges = false; |
||
187 | boolean escolaDepartamentoNull = false; |
||
188 | boolean autoGeneratedUrl = false; |
||
189 | boolean urlFail = false; |
||
1743 | jmachado | 190 | |
1747 | jmachado | 191 | if(c.getDepartment() == null || c.getDepartment().getCourseSchool() == null || c.getDepartment().getCourseSchool().getInitials() == null) |
192 | { |
||
193 | escolaDepartamentoNull = true; |
||
194 | } |
||
195 | |||
196 | if(!unidadeSiges) |
||
197 | { |
||
198 | CourseUnit cu = DaoFactory.getCourseUnitDaoImpl().findUnitByCourseNameYear(c.getId(),unidade.getNome(),importYear); |
||
199 | if(cu != null) |
||
200 | { |
||
201 | unidadeSiges = true; |
||
202 | autoGeneratedSiges = true; |
||
203 | |||
204 | unidade.setSiges(cu.getCode()); |
||
205 | if(escolaDepartamentoNull) |
||
206 | { |
||
207 | //ja foi colocado em cima |
||
208 | } |
||
209 | else if(c.getDepartment().getCourseSchool().getInitials().equals("ESTG")) |
||
210 | { |
||
211 | unidade.setUrlFichaCurricular("http://www.estgp.pt/startLoadCourseUnitProgramSiges.do?unitCode=" + unidade.getSiges() + "&courseCode=" + c.getCode() + "&semestre=" + semestre.getId()); |
||
212 | autoGeneratedUrl = true; |
||
213 | } |
||
214 | } |
||
215 | } |
||
216 | else if(!escolaDepartamentoNull && |
||
217 | c.getDepartment().getCourseSchool().getInitials().equals("ESTG") && |
||
218 | (unidade.getUrlFichaCurricular() == null || unidade.getUrlFichaCurricular().length() ==0 )) |
||
219 | { |
||
220 | autoGeneratedUrl = true; |
||
221 | unidade.setUrlFichaCurricular("http://www.estgp.pt/startLoadCourseUnitProgramSiges.do?unitCode=" + unidade.getSiges() + "&courseCode=" + c.getCode() + "&semestre=" + semestre.getId()); |
||
222 | } |
||
223 | |||
224 | try{ |
||
225 | int code = pt.estgp.estgweb.web.utils.HttpUtils.getResponseCode(unidade.getUrlFichaCurricular()); |
||
226 | if(code != 200) |
||
227 | { |
||
228 | urlFail = true; |
||
229 | System.out.println("Erro a carregar ficha: " + unidade.getUrlFichaCurricular()); |
||
230 | } |
||
231 | }catch(Throwable f404) |
||
232 | { |
||
233 | urlFail = true; |
||
234 | System.out.println("Erro a carregar ficha: " + unidade.getUrlFichaCurricular()); |
||
235 | } |
||
236 | |||
237 | request.setAttribute("autoGeneratedSiges",autoGeneratedSiges); |
||
238 | request.setAttribute("unidadeSiges",unidadeSiges); |
||
239 | request.setAttribute("escolaDepartamentoNull",escolaDepartamentoNull); |
||
240 | request.setAttribute("autoGeneratedUrl",autoGeneratedUrl); |
||
241 | request.setAttribute("urlFail",urlFail); |
||
242 | %> |
||
243 | <tr> |
||
244 | <td><%=c.getCode()%></td> |
||
245 | <td <logic:equal value="true" name="escolaDepartamentoNull">style="background-color: red"</logic:equal>> |
||
246 | <logic:equal value="true" name="escolaDepartamentoNull"> |
||
247 | S/Esco/Dep/Init |
||
248 | </logic:equal> |
||
249 | <logic:equal value="false" name="escolaDepartamentoNull"> |
||
250 | <%=c.getDepartment().getCourseSchool().getInitials()%></td> |
||
251 | </logic:equal> |
||
252 | |||
253 | <td><%=c.getName()%></td> |
||
254 | <td><bean:message key="course.${course.degree}"/></td> |
||
255 | <td><%=perfil.getNome()%></td> |
||
256 | <td <logic:equal value="false" name="unidadeSiges">style="background-color: red"</logic:equal> <logic:equal value="true" name="autoGeneratedSiges">style="background-color: #ffff00"</logic:equal>> |
||
257 | <logic:equal value="true" name="unidadeSiges"> |
||
258 | |||
259 | ${unidade.siges} |
||
260 | <logic:equal value="true" name="autoGeneratedSiges"> |
||
261 | (Auto) |
||
262 | </logic:equal> |
||
263 | </logic:equal> |
||
264 | <logic:equal value="false" name="unidadeSiges"> |
||
265 | Nao Tem |
||
266 | </logic:equal> |
||
267 | </td> |
||
268 | <td>${unidade.nome}</td> |
||
269 | <td <logic:equal value="true" name="urlFail">style="background-color: red"</logic:equal>> |
||
270 | <logic:equal value="true" name="autoGeneratedUrl"> |
||
271 | <label <logic:equal value="true" name="autoGeneratedUrl">style="background-color: #ffff00"</logic:equal>>(Auto)</label> |
||
272 | </logic:equal> |
||
273 | <logic:equal value="true" name="urlFail"> |
||
274 | (Falhou) |
||
275 | </logic:equal> |
||
276 | <a href="<%=unidade.getUrlFichaCurricular()%>"><span class="glyphicon glyphicon-download"></span></a> |
||
277 | </td> |
||
278 | </tr> |
||
279 | <% |
||
280 | if(autoGeneratedSiges || autoGeneratedUrl) |
||
281 | courseService.savePlanoEstudosEditado(c.getId(),plan.getId(),curso,plan,UserSession); |
||
1743 | jmachado | 282 | } |
283 | } |
||
284 | } |
||
285 | } |
||
286 | } |
||
287 | %> |
||
288 | <% |
||
289 | }catch(Throwable t) |
||
290 | { |
||
291 | System.out.println(t.toString()); |
||
292 | t.printStackTrace(); |
||
293 | %> |
||
294 | <tr> |
||
295 | <td colspan="6">Erro no curso (<%=c.getCode()%>) <%=c.getName()%> </td> |
||
296 | </tr> |
||
297 | <% |
||
298 | } |
||
299 | } |
||
300 | |||
301 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
302 | %> |
||
303 | </table> |