Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 1928 → Rev 1934

/branches/grupo2/impl/src/java/pt/estgp/estgweb/services/courses/CourseReportServices.java
410,14 → 410,13
* Este servico gera um grafico com a taxa global de aproveitamento e grava-o no repositorio digital
* devolvendo o respectivo RepositoryFile4JsonView em json para poder ser anexado ao objecto imagem do
* widget do grafico
* @param reportDocumentJson
* @param reportDocument
* @param session
* @return
* @throws IOException
*/
public String generateGlobalLearningResultsChartImg(String reportDocumentJson,UserSession session) throws IOException {
public String generateGlobalLearningResultsChartImg(CourseReportDocument reportDocument,UserSession session) throws IOException {
 
CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson);
LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class);
LearningGlobalAnalysisSection learningGlobalAnalysisSection = (LearningGlobalAnalysisSection) learningResultsSection.findSection(LearningGlobalAnalysisSection.class);
GlobalLearningResultsChartImg chartImg = (GlobalLearningResultsChartImg) learningGlobalAnalysisSection.findDocComponent(GlobalLearningResultsChartImg.class);
445,13 → 444,12
view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session);
}
chartImg.setImage(view);
//TODO FALTA GUARDAR O JSON NO CURSO
saveCourseReportDocument(reportDocument, session);
return view.toJson();
}
 
public String generateGenerateGlobalLearningResultsChartYearImg(String reportDocumentJson,UserSession session) throws IOException {
public String generateGenerateGlobalLearningResultsChartYearImg(CourseReportDocument reportDocument,UserSession session) throws IOException {
 
CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson);
LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class);
LearningGlobalAnalysisSection learningGlobalAnalysisSection = (LearningGlobalAnalysisSection) learningResultsSection.findSection(LearningGlobalAnalysisSection.class);
GlobalLearningResultsChartYearImg chartImg = (GlobalLearningResultsChartYearImg) learningGlobalAnalysisSection.findDocComponent(GlobalLearningResultsChartYearImg.class);
478,13 → 476,12
view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session);
}
chartImg.setImage(view);
//TODO FALTA GUARDAR O JSON NO CURSO
saveCourseReportDocument(reportDocument, session);
return view.toJson();
}
 
public String generateGenerateGlobalLearningResultsChartSem(String reportDocumentJson, String semesterCode, UserSession session) throws IOException {
public String generateGenerateGlobalLearningResultsChartSem(CourseReportDocument reportDocument, String semesterCode, UserSession session) throws IOException {
 
CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson);
LearningResultsSection learningResultsSection = (LearningResultsSection) reportDocument.findDocumentSection(LearningResultsSection.class);
LearningAnalysisSection learningAnalysisSection = (LearningAnalysisSection) learningResultsSection.findSection(LearningAnalysisSection.class);
LearningResultsChartSem chartImg = (LearningResultsChartSem) learningAnalysisSection.findDocComponent(LearningResultsChartSem.class, semesterCode);
511,29 → 508,27
view = repositoryService.storeRepositoryFileFromFileUpload(fileUploaded,ResourceAccessControlEnum.publicDomain,session);
}
chartImg.setImage(view);
//TODO FALTA GUARDAR O JSON NO CURSO
saveCourseReportDocument(reportDocument, session);
return view.toJson();
}
 
public String saveCourseReportDocument(String reportDocumentJson,UserSession session) {
CourseReportDocument reportDocument = CourseReportDocument.fromJson(reportDocumentJson);
 
Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(reportDocument.getCourseCode());
public String saveCourseReportDocument(CourseReportDocument reportDocument, UserSession session) {
CourseYear cy = DaoFactory.getCourseYearDaoImpl().findCourseYearU(reportDocument.getCourseCode(), reportDocument.getYear());
 
if (cy == null) {
Course c = DaoFactory.getCourseDaoImpl().findCourseByCode(reportDocument.getCourseCode());
cy = DomainObjectFactory.createCourseYearImpl();
cy.setCourse(c);
c.getCourseYears().add(cy);
cy.setImportYear(reportDocument.getYear());
DaoFactory.getCourseYearDaoImpl().save(cy);
}
cy.setCourseReportDocument(reportDocumentJson);
cy.setCourseReportDocument(reportDocument.toJson());
 
return reportDocument.toJson();
}
 
public String loadCourseReportDocument(String courseCode,String year,UserSession session) {
public String loadCourseReportDocument(String courseCode, String year, UserSession session) {
CourseYear cy = DaoFactory.getCourseYearDaoImpl().findCourseYearU(courseCode, year);
 
String courseReportJson = null;
545,7 → 540,7
try {
CourseReportDocument courseReport = createNewCourseReportDocument(courseCode, year);
courseReportJson = courseReport.toJson();
saveCourseReportDocument(courseReportJson, session);
saveCourseReportDocument(courseReport, session);
} catch (Throwable e) {
System.out.println(e);
e.printStackTrace();
/branches/grupo2/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/learningresults/components/GlobalLearningResultsChartImg.java
23,6 → 23,11
*/
public class GlobalLearningResultsChartImg extends ImageComponent
{
public GlobalLearningResultsChartImg() {
setWidth(200);
setHeight(200);
}
 
/**
*
* @param results
/branches/grupo2/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/learningresults/components/GlobalLearningResultsChartYearImg.java
50,6 → 50,11
*/
public class GlobalLearningResultsChartYearImg extends ImageComponent
{
public GlobalLearningResultsChartYearImg() {
setWidth(200);
setHeight(200);
}
 
public FileUploaded generateChart2tmp(UnitsLearningResultsTable results, CourseReportDocument courseReportDocument) throws IOException {
List<UnitsLearningResultYear> years = results.getYears();
 
/branches/grupo2/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/learningresults/components/LearningResultsChartSem.java
43,6 → 43,8
public LearningResultsChartSem(String semesterCode) {
this.semesterCode = semesterCode;
setInternalCode(semesterCode);
setWidth(300);
setHeight(400);
}
 
public String getSemesterCode() {
113,7 → 115,7
legend.setFrame(BlockBorder.NONE);
 
 
BufferedImage image = chart.createBufferedImage( 300*4, 400*4);
BufferedImage image = chart.createBufferedImage(300*4, 400*4);
String pathGraficoTiposAlunos = Globals.TMP_DIR + java.io.File.separator + tempName;
java.io.File output = new java.io.File(pathGraficoTiposAlunos);
ImageIO.write(image, "png", new FileOutputStream(output));