Subversion Repositories bacoAlunos

Rev

Rev 1216 | Rev 1248 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
995 jmachado 1
package pt.estgp.estgweb.services.sigesimports;
2
 
3
import jomm.dao.impl.AbstractDao;
4
import jomm.utils.FilesUtils;
5
import jomm.utils.PdfUtils;
6
import org.apache.commons.net.ftp.FTP;
7
import org.apache.commons.net.ftp.FTPClient;
8
import org.apache.fop.apps.FOPException;
9
import org.apache.log4j.Logger;
10
import org.dom4j.Document;
11
import org.json.JSONArray;
12
import org.json.JSONException;
13
import org.json.JSONObject;
14
import pt.estgp.estgweb.Globals;
15
import pt.estgp.estgweb.domain.*;
16
import pt.estgp.estgweb.domain.dao.DaoFactory;
17
import pt.estgp.estgweb.domain.enums.LangEnum;
18
import pt.estgp.estgweb.services.courseunits.CreateCourseUnitXML;
19
import pt.estgp.estgweb.services.email.EMAILJob;
20
import pt.estgp.estgweb.services.email.SendEmailService;
21
import pt.estgp.estgweb.services.expceptions.ServiceException;
22
import pt.estgp.estgweb.services.jobs.JobScheduleService;
23
import pt.estgp.estgweb.services.jobs.ServiceJob;
24
import pt.estgp.estgweb.services.logresults.ILogMessages;
25
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
26
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
27
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
1235 jmachado 28
import pt.estgp.estgweb.services.sigesimports.oracle.dao.AulaDao;
995 jmachado 29
import pt.estgp.estgweb.utils.Dom4jUtil;
30
import pt.estgp.estgweb.web.FtpServer;
31
import pt.ipportalegre.siges.web.services.SiGesWEB;
32
import pt.utl.ist.berserk.logic.serviceManager.IService;
33
 
34
import javax.xml.namespace.QName;
35
import javax.xml.transform.TransformerException;
36
import javax.xml.transform.dom.DOMSource;
37
import java.io.File;
38
import java.io.FileInputStream;
39
import java.io.FileOutputStream;
40
import java.io.IOException;
41
import java.net.URL;
42
import java.util.ArrayList;
43
import java.util.HashMap;
44
import java.util.List;
45
import java.util.Map;
46
 
47
/**
48
 * @author Jorge Machado
49
 * @date 11/May/2008
50
 * @time 12:51:32
51
 * @see pt.estgp.estgweb
52
 */
53
public class ImportSumariesJson extends ServiceJob implements IService
54
{
55
 
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(ImportSumariesJson.class);
57
 
1030 jmachado 58
    private static final int MAX_COMMIT = 10;
995 jmachado 59
 
60
 
61
    public ILogMessages run(1.5.0/docs/api/java/lang/String.html">String year,1.5.0/docs/api/java/lang/String.html">String semestre) throws ServiceException
62
    {
63
        return run(year,semestre,true,true);
64
    }
65
 
66
    public ILogMessages run(1.5.0/docs/api/java/lang/String.html">String year,1.5.0/docs/api/java/lang/String.html">String semestre,boolean sendIONLINE,boolean sendEMAIL) throws ServiceException
67
    {
68
        1.5.0/docs/api/java/lang/String.html">String msgS = "STARTING SUMARIES IMPORT SERVICE FOR year: " + year + " semestre: " + semestre + " sendIONLINE: " + sendIONLINE + " sendEMAIL: " + sendEMAIL;
69
        serviceLogInfo(msgS);
70
        logger.info(msgS);
71
 
72
        DefaultLogMessages logMessages = new DefaultLogMessages();
1017 jmachado 73
        logMessages.addMessage(new DefaultLogMessage("import.summaries", LogMessageTypeEnum.INFO, "instituicao " + DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()));
995 jmachado 74
        serviceLogInfo(logMessages.getLastMessage());
75
 
76
 
77
        int countUnits = 0;
78
        int countUnitsOk = 0;
79
        int countUnitsZeroSummaries = 0;
1081 jmachado 80
        int countUnitsZeroValidSummaries = 0;
995 jmachado 81
 
82
        List<String> unitsZeroSummaries = new ArrayList<String>();
83
        List<String> unitsFailed = new ArrayList<String>();
84
        try
85
        {
86
 
87
            SiGesWEB service;
1017 jmachado 88
            1.5.0/docs/api/java/lang/String.html">String WSDL = DaoFactory.getConfigurationDaoImpl().getSigesWebServicesWsdl();
995 jmachado 89
            try
90
            {
1017 jmachado 91
                serviceLogInfo("STARTING WEB SERVICE AT " + WSDL);
92
                service = new SiGesWEB(new 1.5.0/docs/api/java/net/URL.html">URL(WSDL), new 1.5.0/docs/api/javax/xml/namespace/QName.html">QName(Globals.SIGES_WEBSERVICE_TARGET_NAMESPACE, "SiGesWEB"));
995 jmachado 93
            }
94
            catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
95
            {
96
                logMessages.addMessage(new DefaultLogMessage("import.error",e.toString(),"erro na configuracao do WEB Service", LogMessageTypeEnum.INFO));
97
                serviceLogInfo(logMessages.getLastMessage());
98
                logger.fatal(e, e);
99
                serviceLogError(e.toString(), e);
100
                return logMessages;
101
            }
102
 
103
            int i = 0;
104
            //List<Long> cUs = DaoFactory.getCourseUnitDaoImpl().loadIds(year,DatesUtils.getSemestre());
105
            List<Long> cUs = DaoFactory.getCourseUnitDaoImpl().loadIds(year,semestre);
106
            1.5.0/docs/api/java/lang/String.html">String nowCode = "";
107
            for(1.5.0/docs/api/java/lang/Long.html">Long cId: cUs)
108
            {
1144 jmachado 109
                nowCode = "" + cId;
995 jmachado 110
                countUnits++;
111
                try
112
                {
113
                    if (i++ > MAX_COMMIT)
114
                    {
115
                        i = 0;
996 jmachado 116
                        setProgress((int) (((float)countUnits)/((float)cUs.size())*100.0f));
1076 jmachado 117
                        commitPartially();
995 jmachado 118
                    }
119
                    CourseUnit c = DaoFactory.getCourseUnitDaoImpl().load(cId);
120
                    nowCode = c.getCode();
121
                    logMessages.addMessage(new DefaultLogMessage("import.info","Importing Summaries to CourseUnit: " + c.getCode() + ": course: " + c.getCourse().getCode(),"", LogMessageTypeEnum.INFO));
122
                    logger.info("Importing Summaries to CourseUnit: " + c.getName() + " (" + c.getCode() + ") course " + c.getCourse().getName() + " (" + c.getCourse().getCode() + ")");
123
                    serviceLogInfo(logMessages.getLastMessage());
124
 
125
                    int tries = 3;
1235 jmachado 126
                    //ArrayOfAula arrayOfAulas = null;
127
                    ArrayList<pt.estgp.estgweb.services.sigesimports.oracle.domain.Aula> arrayOfAulas = null;
995 jmachado 128
                    while(tries > 0)
129
                    {
130
                    //comentario de teste
131
                        try
132
                        {
1235 jmachado 133
                            //arrayOfAulas = service.getSiGesWEBSoap().getAulas(new BigDecimal(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode()), year,c.getCode(),semestre,c.getCourse().getCode());
134
                            arrayOfAulas = AulaDao.getInstance().loadAulas(DaoFactory.getConfigurationDaoImpl().getSigesInstitutionCode(),year,c.getCode(),semestre,c.getCourse().getCode());
995 jmachado 135
                            break;
136
                        }
137
                        catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable t)
138
                        {
139
                            if(tries-- == 0)
140
                            {
141
                                logger.error("Giving up of courseUnit:" + cId + " ( " + c.getName() + " ) ",t);
142
                                serviceLogError("Giving up of courseUnit:" + cId + " ( " + c.getName() + " ) ",t);
143
                                break;
144
                            }
145
 
1144 jmachado 146
 
995 jmachado 147
                            logger.error("WebService Fail, trying " + tries + " times sleeping a while");
1144 jmachado 148
                            serviceLogError("WebService Fail, trying " + tries + " times sleeping a while " + t.toString());
149
                            serviceLogError("WebService Fail, trying " + tries + " times sleeping a while " + t.getCause());
995 jmachado 150
                            1.5.0/docs/api/java/lang/Thread.html">Thread.sleep(5000);
151
                        }
152
                    }
153
 
1235 jmachado 154
                    if(arrayOfAulas != null && arrayOfAulas.size() > 0)
995 jmachado 155
                    {
156
                        List<CourseUnitSummary> courseUnitSummaries = new ArrayList<CourseUnitSummary>();
157
 
158
                        //HashMap<String, CourseUnitSummary> map = new HashMap<String, CourseUnitSummary>();
159
                        /*if(c.getSummaries() != null && c.getSummaries().size() > 0)
160
                            for(CourseUnitSummary s: c.getSummaries())
161
                                map.put(s.getCodigoAula() + ":" + s.getCodigoSumario(),s);
162
                        else
163
                            c.setSummaries(new HashSet<CourseUnitSummary>());*/
164
                        JSONObject summariesJson = new JSONObject();
165
                        JSONArray summaries = new JSONArray();
166
                        summariesJson.put("summary",summaries);
1081 jmachado 167
                        int summariesValid = 0;
1235 jmachado 168
                        for(pt.estgp.estgweb.services.sigesimports.oracle.domain.Aula aula: arrayOfAulas)
995 jmachado 169
                        {
170
 
1235 jmachado 171
                            //todo cdTurma Rollback aqui não retirar o sumário
172
                            //Mas pensar em separar os sumários na página, podemos
173
                            //separar tendo em conta quem entra, se for aluno só vê os
174
                            //seus sumários, se for prof vê os sumários das suas turmas
175
 
176
                            if(c.getCdTurma() != null && aula.getAula_codigoTurma()!=null
1133 jmachado 177
                                    && c.getCdTurma().trim().length() > 0
1235 jmachado 178
                                    && aula.getAula_codigoTurma().trim().length() > 0
179
                                    && !aula.getAula_codigoTurma().equals(c.getCdTurma()))
1133 jmachado 180
                            {
181
                                //Código de Turma diferente
1235 jmachado 182
                                1.5.0/docs/api/java/lang/System.html">System.out.println("Ignoring summary code: " + aula.getAula_codigoTurma() + " for unit " + c.getName() + "/" + c.getCode() + " T:" + c.getCdTurma());
1133 jmachado 183
                                continue;
184
                            }
185
 
995 jmachado 186
                            //CourseUnitSummary s = map.get(aula.getSumNumeroAula() + ":" + aula.getCodigoSumario());
187
                            //if(s == null)
188
                            //{
189
                            CourseUnitSummaryImpl s = DomainObjectFactory.createCourseUnitSummaryImpl();
190
                            s.setCourseUnit(c);
191
                                //c.getSummaries().add(s);
192
                                //DaoFactory.getCourseUnitSummaryDaoImpl().save(s);
193
                            //summaries.add();
194
                            //}
1235 jmachado 195
                            s.setCdTipoOcupacao(aula.getTipoOcupacao().intValue());
196
                            s.setNrAula(aula.getNumeroAula().intValue());
995 jmachado 197
                            s.setCodigoSumario(""+aula.getCodigoSumario().intValue());
1235 jmachado 198
                            s.setCodigoAula("" + aula.getSum_numeroAula().intValue());
199
                            s.setNumeroAula(aula.getSum_numeroAula().intValue());
200
                            s.setDataAula(aula.getData());
201
                            s.setTipoAula(aula.getSum_tipoAula());
202
                            s.setCodigoSalaAula("" + aula.getAula_codigoSalaAula().intValue());
203
                            s.setAlunosPresentes(aula.getSum_numeroPresencas().intValue());
204
                            s.setTitulo(aula.getSum_titulo());
205
                            s.setCodigoDocente(aula.getAula_codigoDocente()+ "");
206
                            s.setDescricao(aula.getSum_descricao());
207
                            s.setcEstado(""+aula.getSum_cdEstado().intValue());
995 jmachado 208
                            s.setNumeroHoras("" + aula.getNumeroCelulas().intValue());
209
                            summaries.put(s.getJson());
210
                            courseUnitSummaries.add(s);
1081 jmachado 211
                            if(s.getNumeroAula() > 0)
212
                                summariesValid++;
995 jmachado 213
                        }
214
                        if(courseUnitSummaries.size() == 0)
215
                        {
216
                            countUnitsZeroSummaries++;
217
                            unitsZeroSummaries.add(c.getCode());
1081 jmachado 218
                            logger.info("ZERO SUMARIES unit:" + c.getCode() + " course: " + c.getCourseCode());
219
                            serviceLogInfo("ZERO SUMARIES unit:" + c.getCode() + " course: " + c.getCourseCode());
995 jmachado 220
                        }
1081 jmachado 221
                        else if(summariesValid == 0)
222
                        {
1144 jmachado 223
                            //NAO METE OK NEM ZERO
1081 jmachado 224
                            countUnitsZeroValidSummaries++;
225
                            unitsZeroSummaries.add(c.getCode());
226
                            logger.info("ZERO VALID SUMARIES unit:" + c.getCode() + " course: " + c.getCourseCode());
227
                            serviceLogInfo("ZERO VALID SUMARIES unit:" + c.getCode() + " course: " + c.getCourseCode());
228
                        }
995 jmachado 229
                        else
230
                        {
231
                            countUnitsOk++;
232
                        }
233
                        c.setSummariesJson(summariesJson.toString());
234
 
235
                        if(sendIONLINE)
236
                        {
237
                            1.5.0/docs/api/java/lang/String.html">String path = generatePdf(c);
238
                            sendPdfFtpIonline(c,new ArrayList<String>(),null,path,null);
239
                            FilesUtils.delete(path);
240
                        }
241
                        if(sendEMAIL)
242
                        {
243
                            sendEmail(null, courseUnitSummaries,true);
244
                        }
245
                    }
246
                    else
247
                    {
1144 jmachado 248
                        //NAO METE OK MAS METE ZERO
995 jmachado 249
                        countUnitsZeroSummaries++;
250
                        unitsZeroSummaries.add(c.getCode());
251
                        logger.error("Summaries come null in unit:" + c.getCode());
252
                        serviceLogError("Summaries come null in unit:" + c.getCode());
253
                    }
254
                }
255
                catch(1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
256
                {
1144 jmachado 257
                    //NAO METE OK
995 jmachado 258
                    unitsFailed.add(nowCode);
259
                    logger.error(e,e);
260
                    serviceLogError(e.toString(),e);
261
                }
262
            }
263
 
264
            setProgress(100);
265
            serviceLogError("Finish commiting");
266
 
267
        }
268
        catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e)
269
        {
270
            logger.error(e, e);
271
            logMessages.addMessage(new DefaultLogMessage("import.error", e.toString(), "see log for details", LogMessageTypeEnum.ERROR));
272
            serviceLogError(logMessages.getLastMessage(),e);
273
            throw new ServiceException(e.toString(), e);
274
        }
275
 
276
        logMessages.addMessage(new DefaultLogMessage("import.summaries.terminating", LogMessageTypeEnum.INFO));
277
        logger.info("terminating summaries import");
278
        serviceLogInfo(logMessages.getLastMessage());
279
 
1144 jmachado 280
        1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder failedUnitsExc = new 1.5.0/docs/api/java/lang/StringBuilder.html">StringBuilder();
281
        for(1.5.0/docs/api/java/lang/String.html">String cId: unitsFailed)
282
            failedUnitsExc.append(cId).append(";");
1145 jmachado 283
 
995 jmachado 284
        serviceLogInfo("#######################################");
285
        serviceLogInfo("#######################################");
286
        serviceLogInfo("UNITS PROCESSED: " + countUnits);
1144 jmachado 287
        serviceLogInfo("UNITS FAILED: " + (countUnits - countUnitsZeroSummaries - countUnitsOk - countUnitsZeroValidSummaries));
288
        serviceLogInfo("UNITS FAILED EXCEPTION PARSING XML WEB SERVICE: " + unitsFailed.size());
995 jmachado 289
        serviceLogInfo("UNITS IMPORT OK: " + countUnitsOk);
290
        serviceLogInfo("UNITS ZERO SUMARIES: " + countUnitsZeroSummaries);
1081 jmachado 291
        serviceLogInfo("UNITS ZERO VALID SUMARIES: " + countUnitsZeroValidSummaries);
995 jmachado 292
        serviceLogInfo("#######################################");
1144 jmachado 293
        serviceLogWarn("####FAILED Exception (Check exceptions in log): Units Baco Id Code : " + failedUnitsExc.toString());
1025 jmachado 294
 
295
        logger.info("#######################################");
296
        logger.info("#######################################");
297
        logger.info("UNITS PROCESSED: " + countUnits);
1144 jmachado 298
        logger.info("UNITS FAILED: " + (countUnits - countUnitsZeroSummaries - countUnitsOk - countUnitsZeroValidSummaries));
299
        logger.info("UNITS FAILED EXCEPTION PARSING XML WEB SERVICE: " + unitsFailed.size());
1025 jmachado 300
        logger.info("UNITS IMPORT OK: " + countUnitsOk);
301
        logger.info("UNITS ZERO SUMARIES: " + countUnitsZeroSummaries);
1081 jmachado 302
        logger.info("UNITS ZERO VALID SUMARIES: " + countUnitsZeroValidSummaries);
1025 jmachado 303
        logger.info("#######################################");
1144 jmachado 304
        logger.warn("####FAILED Exception (Check exceptions in log): Units Baco Id Code : " + failedUnitsExc.toString());
305
 
306
 
995 jmachado 307
        return logMessages;
308
    }
309
 
310
 
311
    public static SendEmailService sendEmailService = new SendEmailService();
312
 
313
    private void sendEmail(UserSession userSession,List<CourseUnitSummary> summaries,boolean sendEmail)
314
    {
315
        if(Globals.EMAIL_SUMMARIES && summaries.size() > 0 && sendEmail)
316
        {
317
           // for(CourseUnitSummary summary: summaries)
318
           // {
319
 
320
                List<String> emails = DaoFactory.getCourseUnitSummaryDaoImpl().getStudentsEmails(summaries.get(0).getId());
321
                if(emails == null)
322
                    logger.warn("No students emails in unit: code:" + summaries.get(0).getCourseUnit().getCode() + " " + summaries.get(0).getCourseUnit().getName());
323
                EMAILJob emailJob = new EMAILJob(sendEmailService.getSummariesEmail(emails, summaries, summaries.get(0).getCourseUnit(), LangEnum.PORTUGUESE));
324
                JobScheduleService.getInstance().scheduleNow(emailJob,"New Summary EMAIL from: " + summaries.get(0).getCourseUnit().getName() + " aula: " +summaries.get(summaries.size()-1).getNumeroAula() ,userSession);
325
           // }
326
        }
327
    }
328
 
329
 
330
 
331
 
332
 
333
 
334
    public static 1.5.0/docs/api/java/lang/String.html">String generatePdf(CourseUnit c) throws 1.5.0/docs/api/java/io/IOException.html">IOException, 1.5.0/docs/api/javax/xml/transform/TransformerException.html">TransformerException, FOPException {
335
        5+0%2Fdocs%2Fapi+Document">Document dom = new CreateCourseUnitXML().run(c,null);
336
        org.w3c.dom.5+0%2Fdocs%2Fapi+Document">Document dd = Dom4jUtil.toW3c(dom);
337
        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 + c.getCode() + "-" + c.getNormalizedName() + "-sumarios.pdf";
338
        1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream out = new 1.5.0/docs/api/java/io/FileOutputStream.html">FileOutputStream(path);
339
        Map<String,Object> params = new HashMap<String,Object>();
340
        params.put("site", Globals.SITE_URL);
341
        PdfUtils.createPdfFromXml(new 1.5.0/docs/api/javax/xml/transform/dom/DOMSource.html">DOMSource(dd), "pt/estgp/estgweb/services/courseunits/courseunitsummaries.fo.xsl", out, params);
342
        out.flush();
343
        out.close();
344
        return path;
345
    }
346
 
1006 jmachado 347
    private void sendPdfFtpIonline(CourseUnit cu, List<String> errors, UserSession u,1.5.0/docs/api/java/lang/String.html">String pdfPath,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 {
995 jmachado 348
 
349
        FtpServer server = null;
350
        if(client == null)
351
        {
352
            server = FtpServer.getNewServer(Globals.FTP_IONLINE_URL,Globals.FTP_IONLINE_USER,Globals.FTP_IONLINE_PASS);
353
            client = server.getClient();
1005 jmachado 354
            if(client == null)
355
            {
356
                logger.warn("###################");
1009 jmachado 357
                logger.warn("################### > CANT CONNECT FTP - could be FTPTimeout: " + Globals.FTP_TIMEOUT_SECONDS);
358
                errors.add("################### > CANT CONNECT FTP to send summaries " + ((CourseUnitImpl)cu).getSummariosPathIntranet());
1005 jmachado 359
                return;
360
            }
361
 
995 jmachado 362
        }
363
        client.setFileType(FTP.BINARY_FILE_TYPE);
364
 
365
 
366
        1.5.0/docs/api/java/lang/String.html">String pastaFichaCurricular = ((CourseUnitImpl)cu).getSummariosPathIntranet();
367
        if(!client.changeWorkingDirectory(pastaFichaCurricular))
368
        {
369
            logger.error("FTP CANT CHANGE TO PATH: " + pastaFichaCurricular);
370
        }
371
        else
372
        {
1009 jmachado 373
            if(!client.storeFile(((CourseUnitImpl)cu).getSummariosFileNameIntranet(),new 1.5.0/docs/api/java/io/FileInputStream.html">FileInputStream(pdfPath)))
374
            {
1010 jmachado 375
                1.5.0/docs/api/java/lang/String.html">String msgS = "CANT store file in given time, probably timeout at " + Globals.FTP_DATA_STORE_TIMEOUT_SECONDS;
376
                logger.error(msgS);
377
                serviceLogError(msgS);
1009 jmachado 378
            }
995 jmachado 379
            if(server != null)
380
            {
381
                client.quit();
382
                client.disconnect();
383
            }
384
        }
385
        //
386
    }
387
    /**
388
     * Testar por aqui poi requer Super Role e assim e' autmatico
389
     *
390
     *
391
     * @param args of main
392
     * @throws pt.estgp.estgweb.services.expceptions.ServiceException on error
393
     */
394
    public static void main(1.5.0/docs/api/java/lang/String.html">String[] args) throws ServiceException, JSONException {
395
 
997 jmachado 396
        1.5.0/docs/api/java/lang/System.html">System.out.println("Syntax:");
397
        1.5.0/docs/api/java/lang/System.html">System.out.println("year, semestre, sendIonline, sendEmail");
398
        1.5.0/docs/api/java/lang/System.html">System.out.println("If no arguments wil user actual year import config in all semestres and true in email and ionline");
399
 
995 jmachado 400
        1.5.0/docs/api/java/lang/String.html">String year = DaoFactory.getConfigurationDaoImpl().getImportsDefaultImportYearCreateTransaction();
401
        1.5.0/docs/api/java/lang/String.html">String semestre = null;
1133 jmachado 402
        boolean sendIonline = false;
403
        boolean sendEmail = false;
995 jmachado 404
        if(args != null && args.length > 0)
405
            year = args[0];
997 jmachado 406
 
995 jmachado 407
        if(args != null && args.length > 1)
408
            semestre = args[1];
997 jmachado 409
 
995 jmachado 410
        if(args != null && args.length > 2)
411
            sendIonline = 1.5.0/docs/api/java/lang/Boolean.html">Boolean.parseBoolean(args[2]);
997 jmachado 412
 
995 jmachado 413
        if(args != null && args.length > 3)
414
            sendEmail = 1.5.0/docs/api/java/lang/Boolean.html">Boolean.parseBoolean(args[3]);
997 jmachado 415
 
995 jmachado 416
        AbstractDao.getCurrentSession().beginTransaction();
417
        if(semestre != null)
418
            new ImportSumariesJson().run(year,semestre,sendIonline,sendEmail);
419
        else
420
        {
421
            new ImportSumariesJson().run(year,"S1",sendIonline,sendEmail);
422
            new ImportSumariesJson().run(year,"S2",sendIonline,sendEmail);
423
            new ImportSumariesJson().run(year,"A",sendIonline,sendEmail);
424
        }
425
        AbstractDao.getCurrentSession().getTransaction().commit();
426
    }
427
 
428
 
429
    @1.5.0/docs/api/java/lang/Override.html">Override
1070 jmachado 430
    protected ILogMessages runJobServiceTask() throws 1.5.0/docs/api/java/lang/Throwable.html">Throwable {
995 jmachado 431
 
1070 jmachado 432
        1.5.0/docs/api/java/lang/String.html">String importYear =  getParametersMap().get(JOB_importYear_KEY).getObject();
433
        1.5.0/docs/api/java/lang/String.html">String semestre =  getParametersMap().get(JOB_semestre_KEY).getObject();
434
        1.5.0/docs/api/java/lang/String.html">String sendIonlineStr = getParametersMap().get(JOB_sendIonline_KEY).getObject();
435
        1.5.0/docs/api/java/lang/String.html">String sendEmailStr =  getParametersMap().get(JOB_sendEmail_KEY).getObject();
436
        boolean sendIonline = sendIonlineStr != null && 1.5.0/docs/api/java/lang/Boolean.html">Boolean.parseBoolean(sendIonlineStr);
437
        boolean sendEmail = sendEmailStr != null && 1.5.0/docs/api/java/lang/Boolean.html">Boolean.parseBoolean(sendEmailStr);
438
        return run(importYear,semestre,sendIonline,sendEmail);
995 jmachado 439
    }
440
 
441
}