Subversion Repositories bacoAlunos

Rev

Rev 1968 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1968 Rev 1970
Line 7... Line 7...
7
import org.json.JSONArray;
7
import org.json.JSONArray;
8
import org.json.JSONException;
8
import org.json.JSONException;
9
import org.json.JSONObject;
9
import org.json.JSONObject;
10
import pt.estgp.estgweb.domain.*;
10
import pt.estgp.estgweb.domain.*;
11
import pt.estgp.estgweb.domain.dao.DaoFactory;
11
import pt.estgp.estgweb.domain.dao.DaoFactory;
-
 
12
import pt.estgp.estgweb.domain.dao.DaoUtils;
-
 
13
import pt.estgp.estgweb.domain.dao.impl.CourseDao;
-
 
14
import pt.estgp.estgweb.domain.dao.impl.CourseDaoImpl;
-
 
15
import pt.estgp.estgweb.domain.dao.impl.CourseYearDaoImpl;
12
import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum;
16
import pt.estgp.estgweb.filters.chains.ResourceAccessControlEnum;
13
import pt.estgp.estgweb.services.courses.coursereport.CourseReportUtils;
17
import pt.estgp.estgweb.services.courses.coursereport.CourseReportUtils;
14
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.*;
18
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.*;
15
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.courseunitreport.CourseUnitSection;
19
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.courseunitreport.CourseUnitSection;
16
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.LearningGlobalAnalysisSection;
20
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.learningresults.LearningGlobalAnalysisSection;
Line 27... Line 31...
27
import pt.estgp.estgweb.utils.documentBuilder.DocumentSection;
31
import pt.estgp.estgweb.utils.documentBuilder.DocumentSection;
28
import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent;
32
import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent;
29
import pt.estgp.estgweb.web.controllers.utils.FileUploaded;
33
import pt.estgp.estgweb.web.controllers.utils.FileUploaded;
30
import pt.utl.ist.berserk.logic.serviceManager.IService;
34
import pt.utl.ist.berserk.logic.serviceManager.IService;
31
 
35
 
-
 
36
import javax.swing.text.View;
32
import java.io.IOException;
37
import java.io.IOException;
33
import java.io.InputStream;
38
import java.io.InputStream;
-
 
39
import java.io.Serializable;
34
import java.net.URL;
40
import java.net.URL;
35
import java.net.URLConnection;
41
import java.net.URLConnection;
36
import java.util.*;
42
import java.util.*;
37
 
43
 
38
/**
44
/**
Line 335... Line 341...
335
 
341
 
336
 
342
 
337
        for(CourseUnit cu :units)
343
        for(CourseUnit cu :units)
338
        {
344
        {
339
            CourseUnitDtpStat statFound = CourseReportUtils.findCourseUnitDtpStat(statsLoaded, (CourseUnitImpl) cu);
345
            CourseUnitDtpStat statFound = CourseReportUtils.findCourseUnitDtpStat(statsLoaded, (CourseUnitImpl) cu);
-
 
346
 
-
 
347
 
340
            if(statFound == null)
348
            if(statFound == null)
341
            {
349
            {
342
                statFound = CourseReportUtils.createCourseUnitDtpStat(cu);
350
                statFound = CourseReportUtils.createCourseUnitDtpStat(cu);
343
            }
351
            }
344
 
352
 
Line 448... Line 456...
448
        return view.toJson();
456
        return view.toJson();
449
    }
457
    }
450
 
458
 
451
 
459
 
452
 
460
 
-
 
461
/* Save Method */
-
 
462
 
-
 
463
    public 1.5.0/docs/api/java/lang/String.html">String saveReportDocument (1.5.0/docs/api/java/lang/String.html">String reportDocumentJson,UserSession session){
-
 
464
 
-
 
465
        CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson);
-
 
466
        List<CourseYear> cyList = DaoFactory.getCourseYearDaoImpl().findCourseYear(reportDocument.getCourseCode(),reportDocument.getYear());
-
 
467
 
-
 
468
        if(cyList!= null){
-
 
469
 
-
 
470
 
-
 
471
 
-
 
472
            for (CourseYear courseYear : cyList) {
-
 
473
 
-
 
474
                courseYear.setCourseReportDocument(reportDocument.toJson());
-
 
475
 
-
 
476
 
-
 
477
            }
-
 
478
 
-
 
479
            DaoFactory.getCourseYearDaoImpl().save(cyList);
-
 
480
        }
-
 
481
        else
-
 
482
        {
-
 
483
            CourseYear cy = DomainObjectFactory.createCourseYearImpl();
-
 
484
            cy.setCourseReportDocument(reportDocument.toJson());
-
 
485
            Course course = DaoFactory.getCourseDaoImpl().findCourseByCodeAndYear(reportDocument.getCourseCode(),reportDocument.getYear());
-
 
486
            cy.setImportYear(reportDocument.getYear());
-
 
487
            cy.setSaveDate(session.getSaveDate());
-
 
488
            course.getCourseYears().add(cy);
-
 
489
            cy.setCourse(course);
-
 
490
            DaoFactory.getCourseYearDaoImpl().save(cy);
-
 
491
        }
-
 
492
 
-
 
493
 
-
 
494
        return reportDocumentJson;
-
 
495
    }
-
 
496
 
-
 
497
 
-
 
498
/* LOAD METHOD */
-
 
499
 
-
 
500
 
-
 
501
public 1.5.0/docs/api/java/lang/String.html">String loadReportDocument(1.5.0/docs/api/java/lang/String.html">String courseCode, 1.5.0/docs/api/java/lang/String.html">String year, UserSession session){
-
 
502
 
-
 
503
    CourseYear cy = DaoFactory.getCourseYearDaoImpl().findCourseYear(courseCode,year).get(0);
-
 
504
    CourseReportDocument reportDocument = null;
-
 
505
    1.5.0/docs/api/java/lang/String.html">String reportDocumentJson = null;
-
 
506
 
-
 
507
    if(cy!= null){
-
 
508
        reportDocumentJson = cy.getCourseReportDocument();
-
 
509
 
-
 
510
    }
-
 
511
    else{
-
 
512
        try {
-
 
513
            reportDocument = createNewCourseReportDocument(courseCode,year);
-
 
514
            saveReportDocument(reportDocumentJson,session);
-
 
515
            reportDocumentJson = reportDocument.toJson();
-
 
516
 
-
 
517
 
-
 
518
        } catch (1.5.0/docs/api/java/io/IOException.html">IOException e) {
-
 
519
            e.printStackTrace();
-
 
520
        } catch (JSONException e) {
-
 
521
            e.printStackTrace();
-
 
522
        }
-
 
523
    }
-
 
524
 
-
 
525
 
-
 
526
    return  reportDocumentJson;
-
 
527
 
-
 
528
 
-
 
529
}
453
 
530
 
454
 
531
 
455
 
532
 
456
    /****************************************************************************/
533
    /****************************************************************************/
457
    /*
534
    /*
Line 636... Line 713...
636
 
713
 
637
 
714
 
638
 
715
 
639
 
716
 
640
 
717
 
641
 
-
 
642
 
-
 
643
 
-
 
644
 
-
 
645
 
-
 
646
 
718
 
647
 
719
 
648
 
720
 
649
    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, JSONException {
721
    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, JSONException {
650
        AbstractDao.getCurrentSession().beginTransaction();
722
        AbstractDao.getCurrentSession().beginTransaction();