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));
/branches/grupo2/impl/src/java/pt/estgp/estgweb/filters/filters/IsFromCourseCommission.java
7,6 → 7,7
import pt.estgp.estgweb.filters.chains.LoadControlFilter;
import pt.estgp.estgweb.filters.exceptions.AccessDeniedOperationException;
import pt.estgp.estgweb.filters.exceptions.NeedAuthenticationException;
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.CourseReportDocument;
import pt.estgp.estgweb.utils.Globals;
import pt.utl.ist.berserk.ServiceRequest;
import pt.utl.ist.berserk.ServiceResponse;
30,7 → 31,19
if(userSession.getUser().isSuperuser())
return;
 
String courseCode = (String) request.getServiceParameters().getParameter((String) filterParameters.getParameter(0));
Object obj = request.getServiceParameters().getParameter((String) filterParameters.getParameter(0));
String courseCode;
if (obj instanceof String) {
courseCode = (String) obj;
}
else if (obj instanceof CourseReportDocument) {
courseCode = ((CourseReportDocument) obj).getCourseCode();
}
else {
logger.info("Filter: IsFromCourseCommission - Invalid parameter");
throw new AccessDeniedOperationException("fail.owner");
}
 
CourseImpl course = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode);
 
if(!course.isFromCourseCommission(userSession.getUser()))
/branches/grupo2/impl/src/java/pt/estgp/estgweb/web/controllers/courses/CoursesServicesController.java
7,6 → 7,7
import org.json.JSONObject;
import pt.estgp.estgweb.domain.CourseImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.CourseReportDocument;
import pt.estgp.estgweb.web.controllers.utils.AbstractWidgetAjaxController;
import pt.estgp.estgweb.web.exceptions.NoCookiesException;
import pt.estgp.estgweb.web.utils.RequestUtils;
36,42 → 37,50
 
public JSONObject generateGlobalLearningResultsChartImg(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Throwable {
String courseReportDocument = request.getParameter("courseReportDocument");
CourseReportDocument reportDocument = CourseReportDocument.fromJson(courseReportDocument);
 
IServiceManager sm = ServiceManager.getInstance();
String json = (String) sm.execute(RequestUtils.getRequester(request, response),
"CourseReportGenerateGlobalLearningResultsChartImg",
new Object[]{courseReportDocument});
new Object[]{reportDocument},
new String[]{"reportDocument"});
return new JSONObject(json);
}
 
public JSONObject generateGlobalLearningResultsChartYearImg(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Throwable {
String courseReportDocument = request.getParameter("courseReportDocument");
CourseReportDocument reportDocument = CourseReportDocument.fromJson(courseReportDocument);
 
IServiceManager sm = ServiceManager.getInstance();
String json = (String) sm.execute(RequestUtils.getRequester(request, response),
"CourseReportGenerateGlobalLearningResultsChartYearImg",
new Object[]{courseReportDocument});
new Object[]{reportDocument},
new String[]{"reportDocument"});
return new JSONObject(json);
}
 
public JSONObject generateGenerateGlobalLearningResultsChartSem(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Throwable {
String courseReportDocument = request.getParameter("courseReportDocument");
CourseReportDocument reportDocument = CourseReportDocument.fromJson(courseReportDocument);
String semesterCode = request.getParameter("semesterCode");
 
IServiceManager sm = ServiceManager.getInstance();
String json = (String) sm.execute(RequestUtils.getRequester(request, response),
"CourseReportGenerateLearningResultsChartSem",
new Object[]{courseReportDocument, semesterCode});
new Object[]{reportDocument, semesterCode},
new String[]{"reportDocument", "semesterCode"});
return new JSONObject(json);
}
 
public JSONObject saveCourseReportDocument(ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Throwable {
String courseReportDocument = request.getParameter("courseReportDocument");
CourseReportDocument reportDocument = CourseReportDocument.fromJson(courseReportDocument);
 
IServiceManager sm = ServiceManager.getInstance();
String json = (String) sm.execute(RequestUtils.getRequester(request, response),
"SaveCourseReportDocument",
new Object[]{courseReportDocument});
new Object[]{reportDocument},
new String[]{"reportDocument"});
return new JSONObject(json);
}
 
93,4 → 102,23
 
return mapping.findForward("editCourseReport");
}
 
public ActionForward startFormatted(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Throwable {
String courseCode = request.getParameter("courseCode");
String year = request.getParameter("year");
 
IServiceManager sm = ServiceManager.getInstance();
String courseReportJson = (String) sm.execute(RequestUtils.getRequester(request, response),
"LoadCourseReportDocument",
new Object[]{courseCode, year},
new String[]{"courseCode", "year"});
request.setAttribute("courseReportJson", courseReportJson);
 
AbstractDao.getCurrentSession().beginTransaction();
CourseImpl courseImpl = DaoFactory.getCourseDaoImpl().findCourseByCode(courseCode);
request.setAttribute("course", courseImpl);
AbstractDao.getCurrentSession().getTransaction().commit();
 
return mapping.findForward("formatedCourseReport");
}
}