Rev 850 | Rev 916 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
203 | jmachado | 1 | package pt.estgp.estgweb.services.courseunits; |
2 | |||
915 | jmachado | 3 | import jomm.dao.impl.AbstractDao; |
749 | jmachado | 4 | import jomm.utils.PdfUtils; |
915 | jmachado | 5 | import org.apache.commons.net.ftp.FTP; |
6 | import org.apache.commons.net.ftp.FTPClient; |
||
749 | jmachado | 7 | import org.apache.fop.apps.FOPException; |
8 | import org.apache.log4j.Logger; |
||
9 | import org.dom4j.*; |
||
915 | jmachado | 10 | import org.hibernate.Query; |
749 | jmachado | 11 | import pt.estgp.estgweb.Globals; |
204 | jmachado | 12 | import pt.estgp.estgweb.domain.*; |
203 | jmachado | 13 | import pt.estgp.estgweb.domain.dao.DaoFactory; |
915 | jmachado | 14 | import pt.estgp.estgweb.domain.dao.impl.CourseUnitDaoImpl; |
749 | jmachado | 15 | import pt.estgp.estgweb.domain.views.CourseUnitProgramView; |
16 | import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum; |
||
17 | import pt.estgp.estgweb.services.data.RepositoryService; |
||
18 | import pt.estgp.estgweb.services.expceptions.ServiceException; |
||
19 | import pt.estgp.estgweb.utils.DatesUtils; |
||
20 | import pt.estgp.estgweb.utils.Dom4jUtil; |
||
751 | jmachado | 21 | import pt.estgp.estgweb.utils.StringsUtils; |
915 | jmachado | 22 | import pt.estgp.estgweb.web.FtpServer; |
749 | jmachado | 23 | import pt.utl.ist.berserk.logic.serviceManager.IService; |
203 | jmachado | 24 | |
749 | jmachado | 25 | import javax.xml.transform.TransformerException; |
26 | import javax.xml.transform.dom.DOMSource; |
||
27 | import java.io.File; |
||
28 | import java.io.FileInputStream; |
||
29 | import java.io.FileOutputStream; |
||
30 | import java.io.IOException; |
||
31 | import java.text.SimpleDateFormat; |
||
915 | jmachado | 32 | import java.util.*; |
203 | jmachado | 33 | |
34 | /* |
||
35 | * @author Goncalo Luiz gedl [AT] rnl [DOT] ist [DOT] utl [DOT] pt |
||
36 | * |
||
37 | * |
||
38 | * Created at 17/Out/2003 , 23:45:24 |
||
39 | * |
||
40 | */ |
||
749 | jmachado | 41 | |
203 | jmachado | 42 | /** |
43 | * @author Jorge Machado |
||
44 | * |
||
45 | * |
||
46 | * Created at 17/Out/2003 , 23:45:24 |
||
47 | * |
||
48 | */ |
||
749 | jmachado | 49 | public class SaveCourseUnitProgram implements IService |
203 | jmachado | 50 | { |
51 | |||
204 | jmachado | 52 | RepositoryService repositoryService = new RepositoryService(); |
209 | jmachado | 53 | LoadCourseUnitAnnouncements loadCourseUnitAnnouncements = new LoadCourseUnitAnnouncements(); |
204 | jmachado | 54 | |
749 | jmachado | 55 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(SaveCourseUnitProgram.class); |
203 | jmachado | 56 | |
749 | jmachado | 57 | public CourseUnitProgramView run(CourseUnitProgramView cupv, 1.5.0/docs/api/java/lang/Long.html">Long coursUnitId, UserSession usession) throws ServiceException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, 1.5.0/docs/api/java/io/IOException.html">IOException, FOPException { |
757 | jmachado | 58 | |
749 | jmachado | 59 | CourseUnit c = DaoFactory.getCourseUnitDaoImpl().get(coursUnitId); |
206 | jmachado | 60 | |
749 | jmachado | 61 | CourseUnitProgram program = c.getCourseUnitProgram(); |
62 | if(program == null) |
||
63 | { |
||
64 | program = new CourseUnitProgramImpl(); |
||
65 | DaoFactory.getCourseUnitProgramDaoImpl().save(program); |
||
66 | program.setCourseUnitProgramPart2(new CourseUnitProgramPart2Impl()); |
||
67 | DaoFactory.getCourseUnitProgramPart2DaoImpl().save(program.getCourseUnitProgramPart2()); |
||
68 | c.setCourseUnitProgram(program); |
||
69 | } |
||
70 | // |
||
71 | if(usession.getUser().isSuperuserOrAdmin()) |
||
72 | { |
||
73 | cupv.persistViewInObjectAdministrator(program); |
||
74 | cupv.persistViewInObjectCoordinator(program); |
||
75 | cupv.persistViewInObjectTeacher(program); |
||
847 | jmachado | 76 | setResponsableTeacher(cupv, c); |
749 | jmachado | 77 | } |
78 | if(usession.getUser() instanceof Teacher && (((Teacher)(usession.getUser())).isTeacherOfCourseUnit(c.getId(),true))) |
||
79 | { |
||
80 | cupv.persistViewInObjectTeacher(program); |
||
81 | } |
||
82 | if(usession.getUser() instanceof Teacher |
||
83 | && (((usession.getUser())).hasRole(c.getCourse().getValidationRole()) |
||
750 | jmachado | 84 | || |
85 | ((usession.getUser()) == c.getCourse().getCoordinator())) |
||
86 | ) |
||
749 | jmachado | 87 | { |
88 | cupv.persistViewInObjectCoordinator(program); |
||
847 | jmachado | 89 | setResponsableTeacher(cupv, c); |
749 | jmachado | 90 | } |
91 | List<String> errors = new ArrayList<String>(); |
||
751 | jmachado | 92 | createPdf(c,errors,usession); |
93 | |||
94 | if(usession.getUser() instanceof Teacher) |
||
95 | DirectedCoordinatedUnitsService.sendNotificationsEditedInterestedPeople(c,usession); |
||
96 | else |
||
97 | { |
||
98 | logger.info("Nao vai informar docentes"); |
||
99 | } |
||
100 | |||
749 | jmachado | 101 | return cupv; |
102 | } |
||
358 | jmachado | 103 | |
847 | jmachado | 104 | private void setResponsableTeacher(CourseUnitProgramView cupv, CourseUnit c) { |
105 | if(cupv.getResponsableId() > 0) |
||
106 | { |
||
107 | Teacher t = DaoFactory.getTeacherDaoImpl().load(cupv.getResponsableId()); |
||
108 | c.setResponsableTeacher(t); |
||
109 | } |
||
110 | } |
||
206 | jmachado | 111 | |
749 | jmachado | 112 | |
113 | public void createPdf(CourseUnit cu, List<String> errors) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException { |
||
751 | jmachado | 114 | createPdf(cu,errors,null); |
115 | } |
||
915 | jmachado | 116 | |
751 | jmachado | 117 | public void createPdf(CourseUnit cu, List<String> errors,UserSession u) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException { |
749 | jmachado | 118 | |
915 | jmachado | 119 | |
120 | 1.5.0/docs/api/java/lang/String.html">String path = generatePdfFile(cu, errors, u); |
||
121 | |||
122 | |||
123 | |||
124 | RepositoryService repositoryService = new RepositoryService(); |
||
125 | User owner; |
||
126 | if(cu.getTeachers() != null && cu.getTeachers().size() > 0) |
||
127 | owner = cu.getTeachers().iterator().next(); |
||
128 | else |
||
129 | owner = DaoFactory.getUserDaoImpl().load(new 1.5.0/docs/api/java/lang/Long.html">Long(1)); |
||
130 | if(owner.getUsername() == null) |
||
131 | { |
||
132 | errors.add("Docente: " + owner.getName() + " ( " + owner.getId() + " ) don't have username check that situation"); |
||
133 | // owner.setUsername("UKNOWN"); |
||
134 | } |
||
135 | if(cu.getProgramStreamId() == null) |
||
136 | { |
||
137 | 1.5.0/docs/api/java/lang/String.html">String identifier = repositoryService.storeRepositoryFile(new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(path), "application/pdf", "pdf",((int) new 1.5.0/docs/api/java/io/File.html">File(path).length()), cu.getCode() + ".pdf", "courseunit.program.description" + cu.getName(), ResourceAccessControlEnum.publicDomain,owner); |
||
138 | cu.setProgramStreamId(identifier); |
||
139 | } |
||
140 | else |
||
141 | { |
||
142 | repositoryService.updateRepositoryFile(cu.getProgramStreamId(), new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(path), "application/pdf", "pdf", ((int)new 1.5.0/docs/api/java/io/File.html">File(path).length()),cu.getCode() + ".pdf", "courseunit.program.description " + cu.getName(), ResourceAccessControlEnum.publicDomain); |
||
143 | } |
||
144 | cu.setObjectives(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getObjectivos()); |
||
145 | //Obrigar a ser falso |
||
146 | |||
147 | //NOVO |
||
148 | RepositoryFileImpl repoFile = repositoryService.loadView(cu.getProgramStreamId()); |
||
149 | sendPdfFtpIonline(cu,errors,u,path,repoFile.getLastVersion().getSaveDate(),null); |
||
150 | } |
||
151 | |||
152 | |||
153 | public boolean sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u, FTPClient client) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException |
||
154 | { |
||
155 | RepositoryService repositoryService = new RepositoryService(); |
||
156 | if(cu.getProgramStreamId() != null && cu.getProgramStreamId().length()> 0) |
||
157 | { |
||
158 | RepositoryFileImpl repoFile = repositoryService.loadView(cu.getProgramStreamId()); |
||
159 | 1.5.0/docs/api/java/lang/String.html">String path = generatePdfFile(cu, errors, u); |
||
160 | sendPdfFtpIonline(cu,errors,u,path,repoFile.getLastVersion().getSaveDate(),client); |
||
161 | return true; |
||
162 | } |
||
163 | return false; |
||
164 | } |
||
165 | |||
166 | 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat sdf = new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("yyyy_MM_dd.HH_mm_ss"); |
||
167 | private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,1.5.0/docs/api/java/lang/String.html">String pdfPath,5+0%2Fdocs%2Fapi+Date">Date versionDate,FTPClient client) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException { |
||
168 | |||
169 | FtpServer server = null; |
||
170 | if(client == null) |
||
171 | { |
||
172 | server = FtpServer.getNewServer(Globals.FTP_IONLINE_URL,Globals.FTP_IONLINE_USER,Globals.FTP_IONLINE_PASS); |
||
173 | client = server.getClient(); |
||
174 | } |
||
175 | client.setFileType(FTP.BINARY_FILE_TYPE); |
||
176 | |||
177 | 1.5.0/docs/api/java/lang/String.html">String pastaFichaCurricular = Globals.FTP_IONLINE_START_PATH + cu.getPathIntranet() + "/" + Globals.INTRANET_DTP + "/" + Globals.INTRANET_DTP_FichaCurricular; |
||
178 | if(!client.changeWorkingDirectory(pastaFichaCurricular)) |
||
179 | { |
||
180 | logger.error("FTP CANT CHANGE TO PATH: " + pastaFichaCurricular); |
||
181 | } |
||
182 | else |
||
183 | { |
||
184 | client.storeFile(cu.getCode() + "_" + cu.getNormalizedName() + "_v" + sdf.format(versionDate) + ".pdf",new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(pdfPath)); |
||
185 | |||
186 | if(server != null) |
||
187 | { |
||
188 | client.quit(); |
||
189 | client.disconnect(); |
||
190 | } |
||
191 | } |
||
192 | // |
||
193 | } |
||
194 | |||
195 | private 1.5.0/docs/api/java/lang/String.html">String generatePdfFile(CourseUnit cu, List<String> errors, UserSession u) throws 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, 1.5.0/docs/api/java/io/IOException.html">IOException, FOPException { |
||
750 | jmachado | 196 | ((CourseUnitProgramImpl)cu.getCourseUnitProgram()).consistNullValues(); |
749 | jmachado | 197 | 5+0%2Fdocs%2Fapi+Document">Document responseDoc = DocumentHelper.createDocument(); |
198 | Namespace namespace = new Namespace("uc", "http://baco.estgp.pt/schemas/courseunits/program/"); |
||
199 | responseDoc.setXMLEncoding("ISO-8859-1"); |
||
200 | |||
201 | 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat sdf = new 1.5.0/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat("dd-MM-yyyy"); |
||
202 | 5+0%2Fdocs%2Fapi+Element">Element curriculum = responseDoc.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("UnidadeCurricular", namespace)); |
||
203 | curriculum.addAttribute(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("data",namespace),sdf.format(new java.util.5+0%2Fdocs%2Fapi+Date">Date())); |
||
204 | |||
205 | 5+0%2Fdocs%2Fapi+Element">Element curso = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("curso",namespace)); |
||
206 | if(cu.getCourseName() == null) |
||
204 | jmachado | 207 | { |
749 | jmachado | 208 | if(cu.getCourse() == null) |
204 | jmachado | 209 | { |
749 | jmachado | 210 | 1.5.0/docs/api/java/lang/System.html">System.out.println("Unidade nao tem curso"); |
211 | curso.setText("Desactualizado"); |
||
204 | jmachado | 212 | } |
749 | jmachado | 213 | else |
214 | { |
||
215 | 1.5.0/docs/api/java/lang/System.html">System.out.println("Unidade nao tem nome no curso a actualizar com " + cu.getCourse().getName()); |
||
216 | curso.setText(cu.getCourse().getName()); |
||
217 | cu.setCourseName(cu.getCourse().getName()); |
||
218 | } |
||
204 | jmachado | 219 | } |
749 | jmachado | 220 | else |
221 | curso.setText(cu.getCourseName()); |
||
209 | jmachado | 222 | |
749 | jmachado | 223 | 5+0%2Fdocs%2Fapi+Element">Element anoLectivo = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("anoLectivo",namespace)); |
224 | anoLectivo.setText(DatesUtils.getImportYearPrograms(cu.getImportYear())); |
||
225 | |||
226 | 5+0%2Fdocs%2Fapi+Element">Element unidadeCurricular = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("unidadeCurricular",namespace)); |
||
227 | unidadeCurricular.setText(cu.getName()); |
||
228 | |||
229 | if(cu.getResponsableTeacher() != null) |
||
209 | jmachado | 230 | { |
749 | jmachado | 231 | 5+0%2Fdocs%2Fapi+Element">Element responsavel = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("responsavel",namespace)); |
358 | jmachado | 232 | |
754 | jmachado | 233 | if(cu.getResponsableTeacher().getName()==null) |
234 | { |
||
235 | errors.add("Erro a carregar docente responsavel da unidade " + cu.getCode()); |
||
236 | responsavel.setText("erro"); |
||
237 | } |
||
238 | else |
||
239 | responsavel.setText(StringsUtils.getNormalizedName(cu.getResponsableTeacher().getName())); |
||
240 | |||
749 | jmachado | 241 | 5+0%2Fdocs%2Fapi+Element">Element responsavelEmail = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("responsavelEmail",namespace)); |
750 | jmachado | 242 | if(cu.getResponsableTeacher().getEmail()==null) |
243 | { |
||
244 | logger.warn("Teacher don't has email: " + cu.getResponsableTeacher().getSigesCode() + " - " + cu.getResponsableTeacher().getName()); |
||
245 | try { |
||
246 | 1.5.0/docs/api/java/lang/Thread.html">Thread.sleep(3000); |
||
247 | } catch (1.5.0/docs/api/java/lang/InterruptedException.html">InterruptedException e) { |
||
248 | e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. |
||
249 | } |
||
250 | responsavelEmail.setText(""); |
||
251 | } |
||
252 | else |
||
253 | responsavelEmail.setText(cu.getResponsableTeacher().getEmail()); |
||
209 | jmachado | 254 | } |
749 | jmachado | 255 | |
256 | |||
257 | 5+0%2Fdocs%2Fapi+Element">Element apresentacaoObjectivos = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("objetivosDaAprendizagem",namespace)); |
||
258 | apresentacaoObjectivos.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getObjectivos()); |
||
259 | |||
260 | |||
261 | int docenteNumber = 1; |
||
262 | for(Teacher t : cu.getTeachers()) |
||
263 | { |
||
264 | 5+0%2Fdocs%2Fapi+Element">Element codigoSIGESDocente1 = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("codigoSIGESDocente" + docenteNumber,namespace)); |
||
265 | codigoSIGESDocente1.setText(t.getSigesCode()+""); |
||
266 | 5+0%2Fdocs%2Fapi+Element">Element outroDocente1 = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("outroDocente" + docenteNumber,namespace)); |
||
753 | jmachado | 267 | if(t.getName()==null) |
752 | jmachado | 268 | { |
269 | errors.add("Erro a carregar docente da unidade " + cu.getCode()); |
||
270 | outroDocente1.setText("erro"); |
||
271 | } |
||
272 | else |
||
273 | outroDocente1.setText(StringsUtils.getNormalizedName(t.getName())); |
||
749 | jmachado | 274 | 5+0%2Fdocs%2Fapi+Element">Element docenteEmail1 = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("docenteEmail" + docenteNumber,namespace)); |
750 | jmachado | 275 | |
276 | if(t.getEmail()==null) |
||
277 | { |
||
278 | logger.warn("Teacher don't has email: " + t.getSigesCode() + " - " + t.getName()); |
||
279 | try { |
||
280 | 1.5.0/docs/api/java/lang/Thread.html">Thread.sleep(3000); |
||
281 | } catch (1.5.0/docs/api/java/lang/InterruptedException.html">InterruptedException e) { |
||
282 | e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. |
||
283 | } |
||
284 | docenteEmail1.setText(""); |
||
285 | } |
||
286 | else |
||
287 | docenteEmail1.setText(t.getEmail()); |
||
751 | jmachado | 288 | |
289 | docenteNumber++; |
||
749 | jmachado | 290 | } |
291 | |||
292 | |||
293 | 5+0%2Fdocs%2Fapi+Element">Element conteudosProgramaticos = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("conteudosProgramaticos",namespace)); |
||
294 | conteudosProgramaticos.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getConteudos()); |
||
295 | |||
296 | 5+0%2Fdocs%2Fapi+Element">Element demonstracaoCoerenciaConteudosObjectivos = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("demonstracaoCoerenciaConteudosObjectivos",namespace)); |
||
297 | demonstracaoCoerenciaConteudosObjectivos.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getDemonstracaoCoerenciaConteudos()); |
||
298 | |||
299 | 5+0%2Fdocs%2Fapi+Element">Element metodologiasEnsino = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("metodologiasEnsino",namespace)); |
||
300 | metodologiasEnsino.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getMetodologiasEnsino()); |
||
301 | |||
302 | 5+0%2Fdocs%2Fapi+Element">Element alunosOrdinariosPorFrequencia = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("alunosOrdinariosPorFrequencia",namespace)); |
||
303 | alunosOrdinariosPorFrequencia.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getAvaliacaoOrdinariosFrequencia()); |
||
304 | |||
305 | 5+0%2Fdocs%2Fapi+Element">Element alunosOrdinariosPorExame = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("alunosOrdinariosPorExame",namespace)); |
||
306 | alunosOrdinariosPorExame.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getAvaliacaoOrdinariosExame()); |
||
307 | |||
308 | 5+0%2Fdocs%2Fapi+Element">Element alunosMobilidadeAlunosComEstatutoEspecialPorFrequencia = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("alunosMobilidadeAlunosComEstatutoEspecialPorFrequencia",namespace)); |
||
309 | alunosMobilidadeAlunosComEstatutoEspecialPorFrequencia.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getAvaliacaoEspeciaisFrequencia()); |
||
310 | |||
311 | 5+0%2Fdocs%2Fapi+Element">Element alunosMobilidadeAlunosComEstatutoEspecialPorExame = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("alunosMobilidadeAlunosComEstatutoEspecialPorExame",namespace)); |
||
312 | alunosMobilidadeAlunosComEstatutoEspecialPorExame.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getAvaliacaoEspeciaissExame()); |
||
313 | |||
314 | |||
315 | 5+0%2Fdocs%2Fapi+Element">Element demonstracaoDaCoerenciaMetodologiasObjectivos = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("demonstracaoDaCoerenciaMetodologiasObjectivos",namespace)); |
||
316 | demonstracaoDaCoerenciaMetodologiasObjectivos.setText(cu.getCourseUnitProgram().getCourseUnitProgramPart2().getDemonstracaoObjectivosMetodologia()); |
||
317 | |||
318 | |||
319 | 5+0%2Fdocs%2Fapi+Element">Element bibliografiaPrincipal = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("bibliografiaPrincipal",namespace)); |
||
320 | bibliografiaPrincipal.setText(cu.getCourseUnitProgram().getBibliografia()); |
||
321 | |||
322 | 5+0%2Fdocs%2Fapi+Element">Element bibliografiaComplementar = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("bibliografiaComplementar",namespace)); |
||
323 | bibliografiaComplementar.setText(cu.getCourseUnitProgram().getBibliografiaComplementar()); |
||
324 | |||
325 | 5+0%2Fdocs%2Fapi+Element">Element adaptacaoMetodologiasObjectivos = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("adaptacaoMetodologiasObjectivos",namespace)); |
||
326 | adaptacaoMetodologiasObjectivos.setText(cu.getCourseUnitProgram().getAdaptacaoObjectivosMetodologia()); |
||
327 | |||
328 | 5+0%2Fdocs%2Fapi+Element">Element verificacaoCargaECTS = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("verificacaoCargaECTS",namespace)); |
||
329 | verificacaoCargaECTS.setText(cu.getCourseUnitProgram().getDemonstracaoCargaEcts()); |
||
330 | |||
331 | 5+0%2Fdocs%2Fapi+Element">Element avaliacaoFuncaoObjectivos = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("avaliacaoFuncaoObjectivos",namespace)); |
||
332 | avaliacaoFuncaoObjectivos.setText(cu.getCourseUnitProgram().getGarantiaAvaliacaoFuncaObjectivos()); |
||
333 | |||
334 | 5+0%2Fdocs%2Fapi+Element">Element metodologiasFacilitamParticipacaoCientificas = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("metodologiasFacilitamParticipacaoCientificas",namespace)); |
||
335 | metodologiasFacilitamParticipacaoCientificas.setText(cu.getCourseUnitProgram().getMetodologiasActividadeCientifica()); |
||
336 | |||
337 | 5+0%2Fdocs%2Fapi+Element">Element ects = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("ects",namespace)); |
||
338 | ects.setText(cu.getCourseUnitProgram().getEcts()); |
||
339 | |||
340 | |||
341 | 5+0%2Fdocs%2Fapi+Element">Element preRequisitos = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("preRequisitos",namespace)); |
||
342 | preRequisitos.setText(cu.getCourseUnitProgram().getPrerequisitos()); |
||
343 | |||
344 | 5+0%2Fdocs%2Fapi+Element">Element obrigatoria = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("obrigatoria",namespace)); |
||
345 | obrigatoria.setText(cu.getCourseUnitProgram().getObrigatoria()); |
||
346 | |||
347 | 5+0%2Fdocs%2Fapi+Element">Element lingua1 = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("lingua1",namespace)); |
||
348 | lingua1.setText(cu.getCourseUnitProgram().getLingua1()); |
||
349 | |||
350 | 5+0%2Fdocs%2Fapi+Element">Element lingua2 = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("lingua2",namespace)); |
||
763 | jmachado | 351 | lingua2.setText(cu.getCourseUnitProgram().getLingua2()); |
749 | jmachado | 352 | |
353 | 5+0%2Fdocs%2Fapi+Element">Element cargaHorariaT = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("cargaHorariaT",namespace)); |
||
354 | cargaHorariaT.setText(cu.getCourseUnitProgram().getCargaHorariaT()); |
||
355 | 5+0%2Fdocs%2Fapi+Element">Element cargaHorariaTP = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("cargaHorariaTP",namespace)); |
||
356 | cargaHorariaTP.setText(cu.getCourseUnitProgram().getCargaHorariaTP()); |
||
357 | 5+0%2Fdocs%2Fapi+Element">Element cargaHorariaPL = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("cargaHorariaPL",namespace)); |
||
358 | cargaHorariaPL.setText(cu.getCourseUnitProgram().getCargaHorariaPL()); |
||
359 | 5+0%2Fdocs%2Fapi+Element">Element cargaHorariaS = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("cargaHorariaS",namespace)); |
||
360 | cargaHorariaS.setText(cu.getCourseUnitProgram().getCargaHorariaS()); |
||
361 | 5+0%2Fdocs%2Fapi+Element">Element cargaHorariaTC = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("cargaHorariaTC",namespace)); |
||
362 | cargaHorariaTC.setText(cu.getCourseUnitProgram().getCargaHorariaTC()); |
||
363 | 5+0%2Fdocs%2Fapi+Element">Element cargaHorariaO = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("cargaHorariaO",namespace)); |
||
364 | cargaHorariaO.setText(cu.getCourseUnitProgram().getCargaHorariaO()); |
||
365 | 5+0%2Fdocs%2Fapi+Element">Element cargaHorariaOT = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("cargaHorariaOT",namespace)); |
||
366 | cargaHorariaOT.setText(cu.getCourseUnitProgram().getCargaHorariaOT()); |
||
367 | |||
368 | 5+0%2Fdocs%2Fapi+Element">Element cargaHorariaTotal = curriculum.addElement(new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName("cargaHorariaTotal",namespace)); |
||
369 | cargaHorariaTotal.setText(cu.getCourseUnitProgram().getCargaHorariaTotal()); |
||
370 | |||
371 | |||
372 | // Dom4jUtil.writeSout(responseDoc); |
||
373 | |||
780 | jmachado | 374 | |
751 | jmachado | 375 | 1.5.0/docs/api/java/lang/String.html">String path = Globals.TMP_DIR + 1.5.0/docs/api/java/io/File.html">File.separator + cu.getCode() + "-" + cu.getName() + ".pdf"; |
749 | jmachado | 376 | 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream teste = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(path); |
377 | Map<String,Object> params = new HashMap<String,Object>(); |
||
378 | params.put("site", Globals.SITE_URL); |
||
751 | jmachado | 379 | if(cu.isValidProgram()) |
380 | params.put("validadoCC", "true"); |
||
381 | else |
||
382 | params.put("validadoCC", "false"); |
||
383 | if(u != null && u.getUser() != null) |
||
384 | params.put("revisor", u.getUser().getName()); |
||
385 | |||
780 | jmachado | 386 | |
778 | jmachado | 387 | org.w3c.dom.5+0%2Fdocs%2Fapi+Document">Document dd = Dom4jUtil.toW3c(responseDoc); |
780 | jmachado | 388 | |
915 | jmachado | 389 | PdfUtils.createPdfFromXml(new 1.5.0/docs/api/javax/xml/transform/dom/DOMSource.html">DOMSource(dd), "pt/estgp/estgweb/services/courseunits/courseunitprogram.fo.xsl", teste, params); |
749 | jmachado | 390 | teste.flush(); |
391 | teste.close(); |
||
915 | jmachado | 392 | return path; |
393 | } |
||
749 | jmachado | 394 | |
780 | jmachado | 395 | |
915 | jmachado | 396 | public void storeAllPrograms() throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
397 | CourseUnitDaoImpl dao = DaoFactory.getCourseUnitDaoImpl(); |
||
398 | 1.5.0/docs/api/javax/management/Query.html">Query q = AbstractDao.getCurrentSession().createQuery("select c from c in class " + CourseUnit.class.getName() + " where c.importYear = ?"); |
||
399 | q.setString(0,DatesUtils.getImportYear()); |
||
400 | Iterator<CourseUnit> cuIter = q.iterate(); |
||
401 | FtpServer server = FtpServer.getNewServer(Globals.FTP_IONLINE_URL,Globals.FTP_IONLINE_USER,Globals.FTP_IONLINE_PASS); |
||
402 | FTPClient client = server.getClient(); |
||
403 | while (cuIter.hasNext()) { |
||
404 | CourseUnit next = cuIter.next(); |
||
405 | |||
406 | try { |
||
407 | List<String> errors = new ArrayList<String>(); |
||
408 | 1.5.0/docs/api/java/lang/System.html">System.out.print("Sending " + next.getCourse().getName() + " - " + next.getSemestre() + " - " + next.getNormalizedName()); |
||
409 | if(sendPdfFtpIonline(next,errors,null,client)) |
||
410 | 1.5.0/docs/api/java/lang/System.html">System.out.print(" ... OK"); |
||
411 | else |
||
412 | 1.5.0/docs/api/java/lang/System.html">System.out.print(" ... FAIL probably no StreamID"); |
||
413 | 1.5.0/docs/api/java/lang/System.html">System.out.print("\n"); |
||
414 | if(errors.size()>0) |
||
415 | for(1.5.0/docs/api/java/lang/String.html">String error:errors) |
||
416 | logger.warn(error); |
||
417 | } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) { |
||
418 | logger.error(e,e); |
||
419 | } catch (1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException e) { |
||
420 | logger.error(e, e); |
||
421 | } catch (FOPException e) { |
||
422 | e.printStackTrace(); |
||
423 | } |
||
424 | |||
425 | AbstractDao.getCurrentSession().evict(next); |
||
749 | jmachado | 426 | } |
915 | jmachado | 427 | client.quit(); |
428 | client.disconnect(); |
||
429 | |||
430 | } |
||
431 | |||
432 | |||
433 | public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws 1.5.0/docs/api/java/io/IOException.html">IOException { |
||
434 | AbstractDao.getCurrentSession().beginTransaction(); |
||
435 | new SaveCourseUnitProgram().storeAllPrograms(); |
||
436 | AbstractDao.getCurrentSession().flush(); |
||
437 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
749 | jmachado | 438 | } |
439 | |||
203 | jmachado | 440 | } |