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