Subversion Repositories bacoAlunos

Rev

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

Rev 1974 Rev 1992
Line 22... Line 22...
22
import pt.estgp.estgweb.services.data.RepositoryFile4JsonView;
22
import pt.estgp.estgweb.services.data.RepositoryFile4JsonView;
23
import pt.estgp.estgweb.services.data.RepositoryService;
23
import pt.estgp.estgweb.services.data.RepositoryService;
24
import pt.estgp.estgweb.services.questionarios.QuestionariosReportsService;
24
import pt.estgp.estgweb.services.questionarios.QuestionariosReportsService;
25
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable;
25
import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable;
26
import pt.estgp.estgweb.utils.Globals;
26
import pt.estgp.estgweb.utils.Globals;
-
 
27
import pt.estgp.estgweb.utils.documentBuilder.Document;
27
import pt.estgp.estgweb.utils.documentBuilder.DocumentSection;
28
import pt.estgp.estgweb.utils.documentBuilder.DocumentSection;
28
import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent;
29
import pt.estgp.estgweb.utils.documentBuilder.QuestionariosDataTableComponent;
29
import pt.estgp.estgweb.web.controllers.utils.FileUploaded;
30
import pt.estgp.estgweb.web.controllers.utils.FileUploaded;
30
import pt.utl.ist.berserk.logic.serviceManager.IService;
31
import pt.utl.ist.berserk.logic.serviceManager.IService;
31
 
32
 
Line 446... Line 447...
446
        chartImg.setImage(view);
447
        chartImg.setImage(view);
447
        //TODO FALTA GUARDAR O JSON NO CURSO
448
        //TODO FALTA GUARDAR O JSON NO CURSO
448
        return view.toJson();
449
        return view.toJson();
449
    }
450
    }
450
 
451
 
-
 
452
    public 1.5.0/docs/api/java/lang/String.html">String generateGlobalLearningResultsChartYearImg(1.5.0/docs/api/java/lang/String.html">String reportDocumentJson,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException {
451
 
453
 
-
 
454
        CourseReportDocument reportDocument =  CourseReportDocument.fromJson(reportDocumentJson);
-
 
455
        LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class);
-
 
456
        LearningGlobalAnalysisSection learningGlobalAnalysisSection = (LearningGlobalAnalysisSection) learningResultsSection.findSection(LearningGlobalAnalysisSection.class);
-
 
457
        GlobalLearningResultsChartYearImg chartImg = (GlobalLearningResultsChartYearImg) learningGlobalAnalysisSection.findDocComponent(GlobalLearningResultsChartYearImg.class);
-
 
458
 
-
 
459
 
-
 
460
        UnitsLearningResultsTable table = (UnitsLearningResultsTable) learningResultsSection.findDocComponent(UnitsLearningResultsTable.class);
-
 
461
 
-
 
462
 
-
 
463
        FileUploaded fileUploaded = chartImg.generateChart2tmp(table,reportDocument);
-
 
464
 
-
 
465
        RepositoryService repositoryService = new RepositoryService();
-
 
466
 
-
 
467
        boolean imageInitialized = chartImg.getImage() != null
-
 
468
                &&
-
 
469
                chartImg.getImage().getIdentifier() != null;
-
 
470
 
-
 
471
        RepositoryFile4JsonView view;
-
 
472
        if(imageInitialized)
-
 
473
        {
-
 
474
            1.5.0/docs/api/java/lang/String.html">String identifier = chartImg.getImage().getIdentifier();
-
 
475
            view = repositoryService.replaceRepositoryFileFromFileUpload(identifier, fileUploaded, ResourceAccessControlEnum.privateDomain, session);
-
 
476
        }
-
 
477
        else
-
 
478
        {
-
 
479
            view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.privateDomain,session);
-
 
480
        }
-
 
481
        chartImg.setImage(view);
-
 
482
        //TODO FALTA GUARDAR O JSON NO CURSO
-
 
483
        return view.toJson();
-
 
484
    }
452
 
485
 
453
 
486
 
454
 
487
 
455
 
488
 
456
    /****************************************************************************/
489
    /****************************************************************************/
Line 517... Line 550...
517
            else
550
            else
518
                return json;
551
                return json;
519
        }
552
        }
520
    }
553
    }
521
 
554
 
-
 
555
 
522
    public 1.5.0/docs/api/java/lang/String.html">String saveCourseReportDocument (1.5.0/docs/api/java/lang/String.html">String reportDocumentJson, UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException
556
    public 1.5.0/docs/api/java/lang/String.html">String saveCourseReportDocument (1.5.0/docs/api/java/lang/String.html">String reportDocumentJson, UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException
523
    {
557
    {
-
 
558
        1.5.0/docs/api/java/lang/System.html">System.out.println(reportDocumentJson);
-
 
559
        1.5.0/docs/api/java/lang/System.html">System.out.println("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
-
 
560
        CourseReportDocument courseReportDocument = 5+0%2Fdocs%2Fapi+Document">Document.fromJson(reportDocumentJson);
-
 
561
        1.5.0/docs/api/java/lang/System.html">System.out.println("222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222");
524
        CourseReportDocument courseReportDocument = CourseReportDocument.fromJson(reportDocumentJson);
562
        //CourseReportDocument courseReportDocument = CourseReportDocument.fromJson(reportDocumentJson);
525
 
-
 
526
        Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(courseReportDocument.getCourseCode());
563
        Course course = DaoFactory.getCourseDaoImpl().findCourseByCode(courseReportDocument.getCourseCode());
527
        List<CourseYear> courseYear = DaoFactory.getCourseYearDaoImpl().findCourseYear(courseReportDocument.getCourseCode(), courseReportDocument.getYear());
564
        List<CourseYear> courseYear = DaoFactory.getCourseYearDaoImpl().findCourseYear(courseReportDocument.getCourseCode(), courseReportDocument.getYear());
528
 
565
 
529
        if(courseYear.isEmpty())
566
        if(courseYear.isEmpty())
530
        {
567
        {
Line 538... Line 575...
538
        courseYear.get(0).setCourseReportDocument(reportDocumentJson);
575
        courseYear.get(0).setCourseReportDocument(reportDocumentJson);
539
 
576
 
540
        return courseReportDocument.toJson();
577
        return courseReportDocument.toJson();
541
    }
578
    }
542
 
579
 
-
 
580
    /**
-
 
581
     *
-
 
582
     * @param courseCode
-
 
583
     * @param year
-
 
584
     * @param session
-
 
585
     * @return
-
 
586
     * @throws IOException
-
 
587
     * @throws JSONException
-
 
588
     */
543
    public 1.5.0/docs/api/java/lang/String.html">String loadCourseReportDocument (1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException
589
    public 1.5.0/docs/api/java/lang/String.html">String loadCourseReportDocument(1.5.0/docs/api/java/lang/String.html">String courseCode,1.5.0/docs/api/java/lang/String.html">String year,UserSession session) throws 1.5.0/docs/api/java/io/IOException.html">IOException, JSONException
544
    {
590
    {
545
 
591
 
546
        //Vai buscar (conjunto de anos??) à BaseDados (porquê uma lista)
-
 
547
        List<CourseYear> courseYear = DaoFactory.getCourseYearDaoImpl().findCourseYear(courseCode, year);
592
        List<CourseYear> courseYear = DaoFactory.getCourseYearDaoImpl().findCourseYear(courseCode, year);
548
        1.5.0/docs/api/java/lang/String.html">String courseReport = null;
593
        1.5.0/docs/api/java/lang/String.html">String courseReportJson = null;
549
 
594
 
550
        if(courseYear.isEmpty())
595
        if(courseYear!= null && !courseYear.isEmpty())
-
 
596
        {
-
 
597
            courseReportJson = courseYear.get(0).getCourseReportDocument();
-
 
598
        }
-
 
599
        else
551
        {
600
        {
552
            try {
601
            try {
553
                //System.out.println("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
602
                CourseReportDocument courseReport = createNewCourseReportDocument(courseCode, year);
554
                courseReport = new CourseReportServices().createNewCourseReportDocument(courseCode, year).toJson();
603
                courseReportJson = courseReport.toJson();
555
                //System.out.println(courseReport);
604
                //System.out.println(courseReportJson);
556
                //System.out.println("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU");
605
                //System.out.println("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU");
557
                courseReport = saveCourseReportDocument(courseReport,session);
606
                saveCourseReportDocument(courseReportJson, session);
558
 
607
 
-
 
608
                //System.out.println("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
-
 
609
                //courseReportJson = new CourseReportServices().createNewCourseReportDocument(courseCode, year).toJson();
-
 
610
                //System.out.println(courseReportJson);
-
 
611
                //System.out.println("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU");
-
 
612
                //courseReport = saveCourseReportDocument(courseReport,session);
-
 
613
                //courseReport = loadCourseReportDocument(courseCode, year,session);
559
            } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) {
614
            } catch (1.5.0/docs/api/java/lang/Throwable.html">Throwable e) {
560
                1.5.0/docs/api/java/lang/System.html">System.out.println(e);
615
                1.5.0/docs/api/java/lang/System.html">System.out.println(e);
561
                e.printStackTrace();
616
                e.printStackTrace();
562
            }
617
            }
563
        }
618
        }
564
        else
-
 
565
        {
-
 
566
            courseReport = courseYear.get(0).getCourseReportDocument();
-
 
567
        }
-
 
568
 
-
 
569
        return courseReport;
619
        return courseReportJson;
570
    }
620
    }
571
    /**
621
    /**
572
     *
622
     *
573
     * Para um determinado curso e ano o serviço faz uma listagem de todas as suas unidades curriculares
623
     * Para um determinado curso e ano o serviço faz uma listagem de todas as suas unidades curriculares
574
     * e lista a sua informação básica juntamente com o relatório de avaliação disponivel
624
     * e lista a sua informação básica juntamente com o relatório de avaliação disponivel