/branches/v3/impl/src/java/pt/estgp/estgweb/utils/documentBuilder/ExtensibleDocObject.java |
---|
New file |
0,0 → 1,20 |
package pt.estgp.estgweb.utils.documentBuilder; |
import pt.estgp.estgweb.utils.ClassUtils; |
import java.util.List; |
/** |
* Created by jorgemachado on 07/11/17. |
*/ |
public class ExtensibleDocObject |
{ |
public List<String> getAllSuperClasses() |
{ |
return ClassUtils.getAllSuperClasses(this.getClass()); |
} |
public void setAllSuperClasses(List<String> superclasses) |
{ |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/utils/documentBuilder/DocumentSection.java |
---|
6,10 → 6,10 |
/** |
* Created by jorgemachado on 11/10/17. |
*/ |
public class DocumentSection |
public class DocumentSection extends SectionContainer |
{ |
String title = ""; |
List<DocumentSection> subSections = new ArrayList<DocumentSection>(); |
List<DocComponent> components = new ArrayList<DocComponent>(); |
public DocumentSection() { |
27,14 → 27,7 |
this.title = title; |
} |
public List<DocumentSection> getSubSections() { |
return subSections; |
} |
public void setSubSections(List<DocumentSection> subSections) { |
this.subSections = subSections; |
} |
public List<DocComponent> getComponents() { |
return components; |
} |
43,19 → 36,8 |
this.components = components; |
} |
public DocumentSection findSubSection(Class sectionClass) |
{ |
if(getSubSections() != null) |
for(DocumentSection section: getSubSections()) |
{ |
if(section.getClass().equals(sectionClass)) |
{ |
return section; |
} |
} |
return null; |
} |
public DocComponent findDocComponent(Class compClass) |
{ |
if(getComponents() != null) |
/branches/v3/impl/src/java/pt/estgp/estgweb/utils/documentBuilder/SectionContainer.java |
---|
New file |
0,0 → 1,36 |
package pt.estgp.estgweb.utils.documentBuilder; |
import java.util.ArrayList; |
import java.util.List; |
/** |
* Created by jorgemachado on 07/11/17. |
*/ |
public class SectionContainer extends ExtensibleDocObject |
{ |
List<DocumentSection> sections = new ArrayList<DocumentSection>(); |
public List<DocumentSection> getSections() { |
return sections; |
} |
public void setSections(List<DocumentSection> sections) { |
this.sections = sections; |
} |
public DocumentSection findSection(Class sectionClass) |
{ |
if(getSections() != null) |
for(DocumentSection section: getSections()) |
{ |
if(section.getClass().equals(sectionClass)) |
{ |
return section; |
} |
} |
return null; |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/utils/documentBuilder/DocComponent.java |
---|
3,5 → 3,5 |
/** |
* Created by jorgemachado on 11/10/17. |
*/ |
public class DocComponent { |
public class DocComponent extends ExtensibleDocObject { |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/utils/documentBuilder/Document.java |
---|
5,27 → 5,18 |
import org.json.JSONException; |
import org.json.JSONObject; |
import pt.estgp.estgweb.domain.utils.JsonView; |
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.ReportCourseDocument; |
import pt.estgp.estgweb.services.courses.coursereport.documentmodel.CourseReportDocument; |
import java.util.ArrayList; |
import java.util.Date; |
import java.util.List; |
/** |
* Created by jorgemachado on 31/10/17. |
*/ |
public class Document implements JsonView |
public class Document extends SectionContainer implements JsonView |
{ |
List<DocumentSection> sections = new ArrayList<DocumentSection>(); |
public List<DocumentSection> getSections() { |
return sections; |
} |
public void setSections(List<DocumentSection> sections) { |
this.sections = sections; |
} |
private static Genson gensonGenericLoad; |
static{ |
gensonGenericLoad = new GensonBuilder() |
40,9 → 31,9 |
.create(); |
} |
public static ReportCourseDocument fromJson(String json) |
public static CourseReportDocument fromJson(String json) |
{ |
return gensonGenericLoad.deserialize(json,ReportCourseDocument.class); |
return gensonGenericLoad.deserialize(json,CourseReportDocument.class); |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/utils/Globals.java |
---|
447,8 → 447,8 |
public static final String ROLE_INVITED = "invited"; |
public static final String SYSTEM_WSJSON_SERVICE_COURSE_REPORT_RESULTS = ConfigProperties.getProperty("system.wsjson.service.course.report.quest.result.api"); |
public static final String SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION = ConfigProperties.getProperty("system.wsjson.service.course.units.reports.api"); |
public static final String SYSTEM_WSJSON_SERVICE_COURSE_QUESTIONARIOS_REPORT_RESULTS = ConfigProperties.getProperty("system.wsjson.service.course.report.quest.result.api"); |
public static final String SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT = ConfigProperties.getProperty("system.wsjson.service.course.units.reports.api"); |
public static final String SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS = ConfigProperties.getProperty("system.wsjson.service.course.units.dtp.stats.api"); |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/CourseReportServices.java |
---|
1,6 → 1,7 |
package pt.estgp.estgweb.services.courses; |
import jomm.dao.impl.AbstractDao; |
import jomm.utils.StreamsUtils; |
import org.apache.log4j.Logger; |
import org.json.JSONArray; |
32,6 → 33,7 |
import java.io.IOException; |
import java.io.InputStream; |
import java.net.URL; |
import java.net.URLConnection; |
import java.util.*; |
/** |
52,52 → 54,8 |
/****************************************************************************/ |
/** |
* Gera uma tabela de estatisticas dos DTP recorrendo ao servico WS de |
* load de tabelas DTP, caso o serviço nao devolva unidades são criadas novas |
* com os valores a falso. |
* |
* @param courseCode |
* @param year |
* @return UnitsDtpTable |
* @throws IOException |
* @throws JSONException |
*/ |
public UnitsDtpTable updateDtpStatsTable4Course(ReportCourseDocument reportCourseDocument, String courseCode, String year) throws IOException, JSONException |
{ |
ReportsUcSummarySection reportsUcSummarySection = (ReportsUcSummarySection) reportCourseDocument.findDocumentSection(ReportsUcSummarySection.class); |
UnitsDtpTable unitsDtpTable = (UnitsDtpTable) reportsUcSummarySection.findDocComponent(UnitsDtpTable.class); |
UnitDtpSemester semester1 = new UnitDtpSemester(); |
UnitDtpSemester semester2 = new UnitDtpSemester(); |
unitsDtpTable.setSemester1(semester1); |
unitsDtpTable.setSemester2(semester2); |
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
String json = loadCourseUnitDtpStats(courseCode,year); |
JSONObject response = new JSONObject(json); |
JSONArray stats = (JSONArray) response.get("dtpstats"); |
CourseUnitDtpStat[] statsLoaded = CourseUnitDtpStat.fromJson(stats); |
for(CourseUnit cu :units) |
{ |
CourseUnitDtpStat statFound = CourseReportUtils.findCourseUnitDtpStat(statsLoaded, (CourseUnitImpl) cu); |
if(statFound == null) |
{ |
statFound = CourseReportUtils.createCourseUnitDtpStat(cu); |
} |
if(((CourseUnitImpl) cu).getSemestreAbsolutoS1S2().equals("S1")) |
semester1.getCourseUnitDtpStats().add(statFound); |
else |
semester2.getCourseUnitDtpStats().add(statFound); |
} |
return unitsDtpTable; |
} |
/** |
* |
* @param courseCode |
106,9 → 64,9 |
* @throws IOException |
* @throws JSONException |
*/ |
public ReportCourseDocument createNewCourseReportDocument(String courseCode,String year) throws IOException, JSONException |
public CourseReportDocument createNewCourseReportDocument(String courseCode,String year) throws IOException, JSONException |
{ |
ReportCourseDocument reportCourseDocument = new ReportCourseDocument(); |
CourseReportDocument reportCourseDocument = new CourseReportDocument(); |
reportCourseDocument.init(); |
133,9 → 91,9 |
return reportCourseDocument; |
} |
public SurveysResultsSection updateSurveysDataTables(String courseCode, String year, ReportCourseDocument reportCourseDocument) throws IOException, JSONException { |
public SurveysResultsSection updateSurveysDataTables(String courseCode, String year, CourseReportDocument reportCourseDocument) throws IOException, JSONException { |
SurveysSection surveysSection = (SurveysSection) reportCourseDocument.findDocumentSection(SurveysSection.class); |
SurveysResultsSection surveysResultsSection = (SurveysResultsSection) surveysSection.findSubSection(SurveysResultsSection.class); |
SurveysResultsSection surveysResultsSection = (SurveysResultsSection) surveysSection.findSection(SurveysResultsSection.class); |
QuestionariosDataTableComponent dataTableComponentS1 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(0); |
QuestionariosDataTableComponent dataTableComponentS2 = (QuestionariosDataTableComponent) surveysResultsSection.getComponents().get(1); |
154,7 → 112,7 |
* @param reportCourseDocument |
* @return UnitsLearningResultsTable |
*/ |
public UnitsLearningResultsTable updateCleanLearningResultsFromCourseUnitsSections(ReportCourseDocument reportCourseDocument) |
public UnitsLearningResultsTable updateCleanLearningResultsFromCourseUnitsSections(CourseReportDocument reportCourseDocument) |
{ |
CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
163,7 → 121,7 |
Map<Integer,UnitsLearningResultYear> anosPlano = new HashMap<Integer, UnitsLearningResultYear>(); |
Map<String,UnitsLearningResultSemester> anoSemestre = new HashMap<String, UnitsLearningResultSemester>(); |
for(DocumentSection subSection : unitReportsSection.getSubSections()) |
for(DocumentSection subSection : unitReportsSection.getSections()) |
{ |
CourseUnitSection unitSection = (CourseUnitSection) subSection; |
int anoPlano = unitSection.getAnoPlano(); |
345,6 → 303,62 |
/** |
* Gera uma tabela de estatisticas dos DTP recorrendo ao servico WS de |
* load de tabelas DTP, caso o serviço nao devolva unidades são criadas novas |
* com os valores a falso. |
* |
* @param courseCode |
* @param year |
* @return UnitsDtpTable |
* @throws IOException |
* @throws JSONException |
*/ |
public UnitsDtpTable updateDtpStatsTable4Course(CourseReportDocument reportCourseDocument, String courseCode, String year) throws IOException, JSONException |
{ |
ReportsUcSummarySection reportsUcSummarySection = (ReportsUcSummarySection) reportCourseDocument.findDocumentSection(ReportsUcSummarySection.class); |
UnitsDtpTable unitsDtpTable = (UnitsDtpTable) reportsUcSummarySection.findDocComponent(UnitsDtpTable.class); |
UnitDtpSemester semester1 = new UnitDtpSemester(); |
UnitDtpSemester semester2 = new UnitDtpSemester(); |
unitsDtpTable.setSemester1(semester1); |
unitsDtpTable.setSemester2(semester2); |
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
CourseUnitDtpStat[] statsLoaded; |
try |
{ |
String json = loadCourseUnitDtpStats(courseCode,year); |
JSONObject response = new JSONObject(json); |
JSONArray stats = (JSONArray) response.get("dtpstats"); |
statsLoaded = CourseUnitDtpStat.fromJson(stats); |
} |
catch(Exception e) |
{ |
logger.error(e,e); |
statsLoaded = new CourseUnitDtpStat[0]; |
} |
for(CourseUnit cu :units) |
{ |
CourseUnitDtpStat statFound = CourseReportUtils.findCourseUnitDtpStat(statsLoaded, (CourseUnitImpl) cu); |
if(statFound == null) |
{ |
statFound = CourseReportUtils.createCourseUnitDtpStat(cu); |
} |
if(((CourseUnitImpl) cu).getSemestreAbsolutoS1S2().equals("S1")) |
semester1.getCourseUnitDtpStats().add(statFound); |
else |
semester2.getCourseUnitDtpStats().add(statFound); |
} |
return unitsDtpTable; |
} |
/** |
* Update course unit sections with reports, this method dows not change learning results table |
* values from learning results stays in unit but does not change learning results Table |
* @param courseCode |
354,18 → 368,27 |
* @throws IOException |
* @return a list of CourseUnitSection |
*/ |
public List<DocumentSection> updateCleanCourseUnitSections(String courseCode, String year, ReportCourseDocument reportCourseDocument) throws JSONException, IOException { |
public List<DocumentSection> updateCleanCourseUnitSections(String courseCode, String year, CourseReportDocument reportCourseDocument) throws JSONException, IOException { |
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
String courseUnitSectionsJson = loadCourseEvaluationSections(courseCode,year); |
JSONObject object = new JSONObject(courseUnitSectionsJson); |
JSONArray evaluations = object.getJSONArray("evaluations"); |
CourseUnitSection[] courseUnitSections = CourseUnitSection.fromJsonArray(evaluations.toString()); |
CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
CourseUnitSection[] courseUnitSections = null; |
try{ |
String courseUnitSectionsJson = loadCourseEvaluationSections(courseCode,year); |
JSONObject object = new JSONObject(courseUnitSectionsJson); |
JSONArray evaluations = object.getJSONArray("evaluations"); |
courseUnitSections = CourseUnitSection.fromJsonArray(evaluations.toString()); |
} |
catch(Exception e) |
{ |
logger.error(e,e); |
courseUnitSections = new CourseUnitSection[0]; |
} |
CourseUnitsReportsSection unitReportsSection = (CourseUnitsReportsSection) reportCourseDocument.findDocumentSection(CourseUnitsReportsSection.class); |
List<DocumentSection> subSections = new ArrayList<DocumentSection>(); |
unitReportsSection.setSubSections(subSections); |
unitReportsSection.setSections(subSections); |
for(CourseUnit cu :units) |
{ |
CourseUnitSection sectionFound = CourseReportUtils.findCourseUnitSection(courseUnitSections, (CourseUnitImpl) cu); |
381,7 → 404,7 |
cu.setCourseUnitEvaluation(courseUnitEvaluation); |
sectionFound.setCourseUnitEvaluation(courseUnitEvaluation); |
} |
unitReportsSection.getSubSections().add(sectionFound); |
unitReportsSection.getSections().add(sectionFound); |
} |
return subSections; |
} |
389,20 → 412,20 |
public static void main(String[] args) throws IOException, JSONException { |
/*AbstractDao.getCurrentSession().beginTransaction(); |
AbstractDao.getCurrentSession().beginTransaction(); |
ReportCourseDocument reportCourseDocument = new CourseReportServices().createNewCourseReportDocument("44","201617"); |
CourseReportDocument reportCourseDocument = new CourseReportServices().createNewCourseReportDocument("44","201617"); |
System.out.println(reportCourseDocument.toJson()); |
AbstractDao.getCurrentSession().getTransaction().commit();*/ |
AbstractDao.getCurrentSession().getTransaction().commit(); |
//System.setProperty("javax.net.ssl.trustStore", "/JORGE/COPIAS/.keystore"); |
//System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); |
URL url = new URL("http://pae.ipportalegre.pt/wsjson/api/app/ws-course-pedagogic-results-list?code=44&year=201617&period=S1"); |
/*URL url = new URL("http://pae.ipportalegre.pt/wsjson/api/app/ws-course-pedagogic-results-list?code=44&year=201617&period=S1"); |
System.out.println(StreamsUtils.readString(url.openStream())); |
System.out.println(StreamsUtils.readString(url.openStream()));*/ |
} |
/* |
465,12 → 488,21 |
} |
else |
{ |
URL url = new URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS + "?code=" + courseCode + "&year=" + year); |
InputStream is = url.openStream(); |
String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_DTP_STATS + "?code=" + courseCode + "&year=" + year; |
String json = "{ dtpstats : [] }"; |
try{ |
URL url = new URL(serviceUrl); |
String json = StreamsUtils.readString(is); |
is.close(); |
//TODO temos de extrair o resultado do RESPONSE |
URLConnection conn = url.openConnection(); |
InputStream is = conn.getInputStream(); |
json = StreamsUtils.readString(is); |
is.close(); |
}catch(Throwable e) |
{ |
logger.error("Connecting " + serviceUrl,e); |
return json; |
} |
JSONObject jsonObject = new JSONObject(json); |
return jsonObject.get("response").toString(); |
} |
493,7 → 525,7 |
public String loadCourseEvaluationSections(String courseCode,String year) throws JSONException, IOException { |
if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION.indexOf("localhost")>=0) |
if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT.indexOf("localhost")>=0) |
{ |
JSONArray array = new JSONArray(); |
List<CourseUnit> units = DaoFactory.getCourseUnitDaoImpl().loadByCourseSiges(courseCode, year); |
510,11 → 542,22 |
} |
else |
{ |
URL url = new URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION + "?code=" + courseCode + "&year=" + year); |
InputStream is = url.openStream(); |
String json = "{ evaluations : [] }"; |
String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT + "?code=" + courseCode + "&year=" + year; |
try{ |
URL url = new URL(serviceUrl); |
String json = StreamsUtils.readString(is); |
is.close(); |
URLConnection conn = url.openConnection(); |
InputStream is = conn.getInputStream(); |
json = StreamsUtils.readString(is); |
is.close(); |
}catch(Throwable e) |
{ |
logger.error("Connecting " + serviceUrl,e); |
return json; |
} |
JSONObject jsonObject = new JSONObject(json); |
return jsonObject.get("response").toString(); |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/ReportCourseDocument.java |
---|
File deleted |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/surveys/SurveysAnalysisSection.java |
---|
18,8 → 18,8 |
getComponents().add(new TextComponent()); |
//4.2.1 |
getSubSections().add(new GenericTextSection("Análise das UC's")); |
getSections().add(new GenericTextSection("Análise das UC's")); |
//4.2.2 |
getSubSections().add(new GenericTextSection("Análise das Salas")); |
getSections().add(new GenericTextSection("Análise das Salas")); |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/ConclusionsSection.java |
---|
16,7 → 16,7 |
public void init() |
{ |
super.setTitle("Conclusões"); |
super.getSubSections().add(new GenericTextSection("Identificação de Problemas")); |
super.getSubSections().add(new GenericTextSection("Melhorias")); |
super.getSections().add(new GenericTextSection("Identificação de Problemas")); |
super.getSections().add(new GenericTextSection("Melhorias")); |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/SurveysSection.java |
---|
19,8 → 19,8 |
public void init() { |
super.setTitle("Inquéritos Pedagógicos"); |
//4.1 |
super.getSubSections().add(new SurveysResultsSection("Resultados dos Inquéritos Pedagógicos")); |
super.getSections().add(new SurveysResultsSection("Resultados dos Inquéritos Pedagógicos")); |
//4.2 |
super.getSubSections().add(new SurveysAnalysisSection("Análise dos Inquéritos Pedagógicos")); |
super.getSections().add(new SurveysAnalysisSection("Análise dos Inquéritos Pedagógicos")); |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/LearningResultsSection.java |
---|
28,12 → 28,12 |
super.getComponents().add(new CustomPane()); |
//3.1 Analise Aproveitamento |
super.getSubSections().add(new LearningAnalysisSection("Analise Aproveitamento")); |
super.getSections().add(new LearningAnalysisSection("Analise Aproveitamento")); |
//3.2 Analise Global Aproveitamento |
super.getSubSections().add(new LearningGlobalAnalysisSection("Analise Global Aproveitamento")); |
super.getSections().add(new LearningGlobalAnalysisSection("Analise Global Aproveitamento")); |
//3.3 Analise Funcionamento UCs |
super.getSubSections().add(new GenericTextSection("Analise Funcionamento UCs")); |
super.getSections().add(new GenericTextSection("Analise Funcionamento UCs")); |
//3.4 Cumprimento de Programas |
super.getSubSections().add(new GenericTextSection("Cumprimento de Programas")); |
super.getSections().add(new GenericTextSection("Cumprimento de Programas")); |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/CourseUnitsReportsSection.java |
---|
19,6 → 19,6 |
public void init() { |
setTitle("Relatórios das Unidades Curriculares"); |
setSubSections(new ArrayList<DocumentSection>()); |
setSections(new ArrayList<DocumentSection>()); |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/courses/coursereport/documentmodel/CourseReportDocument.java |
---|
New file |
0,0 → 1,129 |
package pt.estgp.estgweb.services.courses.coursereport.documentmodel; |
import com.owlike.genson.Genson; |
import com.owlike.genson.GensonBuilder; |
import org.apache.log4j.Logger; |
import org.json.JSONException; |
import org.json.JSONObject; |
import pt.estgp.estgweb.domain.utils.JsonView; |
import pt.estgp.estgweb.utils.documentBuilder.Document; |
import pt.estgp.estgweb.utils.documentBuilder.DocumentSection; |
import java.util.Date; |
import java.util.List; |
/** |
* Created by jorgemachado on 14/10/17. |
*/ |
public class CourseReportDocument extends Document implements JsonView |
{ |
private static final Logger logger = Logger.getLogger(CourseReportDocument.class); |
public CourseReportDocument() |
{ |
} |
public void init() |
{ |
//1 - Introducao |
IntroSection introSection = new IntroSection(); |
introSection.init(); |
getSections().add(introSection); |
//2 - Mapa Sintese dos Relatórios dos Responsáveis das UC's |
ReportsUcSummarySection reportsUcSummarySection = new ReportsUcSummarySection(); |
reportsUcSummarySection.init(); |
getSections().add(reportsUcSummarySection); |
//3 - Resultados da Aprendizagem |
LearningResultsSection learningResultsSection = new LearningResultsSection(); |
learningResultsSection.init(); |
getSections().add(learningResultsSection); |
//4 - Inquéritos |
SurveysSection surveysSection = new SurveysSection(); |
surveysSection.init(); |
getSections().add(surveysSection); |
//5 - Conclusões |
ConclusionsSection conclusionsSection = new ConclusionsSection(); |
conclusionsSection.init(); |
getSections().add(conclusionsSection); |
//5 - Unidades Curriculares |
CourseUnitsReportsSection courseUnitsReportsSection = new CourseUnitsReportsSection(); |
courseUnitsReportsSection.init(); |
getSections().add(courseUnitsReportsSection); |
} |
public DocumentSection findDocumentSection(Class sectionClass) |
{ |
if(getSections() != null) |
for(DocumentSection section: getSections()) |
{ |
if(section.getClass().equals(sectionClass)) |
{ |
return section; |
} |
} |
return null; |
} |
private static Genson gensonGenericLoad; |
static{ |
gensonGenericLoad = new GensonBuilder() |
.useMethods(true) |
.useFields(true) |
.useRuntimeType(true) //para ignorar a CGLIB do courseUnitEvaluation |
.useClassMetadata(true) |
.useDateAsTimestamp(true) |
.exclude(Class.class) |
.exclude(Date.class) |
.exclude(java.sql.Timestamp.class) |
.exclude(java.sql.Date.class) |
.create(); |
} |
public static CourseReportDocument fromJson(String json) |
{ |
return gensonGenericLoad.deserialize(json,CourseReportDocument.class); |
} |
public List<String> getJsonExcludedProperties() { |
return null; |
} |
/** |
* Generic Json Object only for local class methods |
* @return |
* @throws org.json.JSONException |
*/ |
public JSONObject toJsonObject() throws JSONException |
{ |
return new JSONObject(toJson()); |
} |
/** |
* * Generic Json Object only for local class methods |
* @return |
* @throws java.io.IOException |
*/ |
public String toJson() |
{ |
return gensonGenericLoad.serialize(this); |
} |
} |
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/QuestionariosReportsService.java |
---|
20,6 → 20,7 |
import java.io.IOException; |
import java.io.InputStream; |
import java.net.URL; |
import java.net.URLConnection; |
import java.util.ArrayList; |
import java.util.HashSet; |
import java.util.List; |
165,7 → 166,7 |
public String loadReportUnidadesSalasJson(String sigesCode, String year, String periodIncluded) throws IOException, JSONException { |
if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_REPORT_RESULTS.indexOf("localhost")>=0) |
if(Globals.SYSTEM_WSJSON_SERVICE_COURSE_QUESTIONARIOS_REPORT_RESULTS.indexOf("localhost")>=0) |
{ |
Criteria c = DaoFactory.getQuestionarioReportCursoFileDaoImpl().createCriteria(); |
c.createAlias("reportGroup","rg"); |
183,11 → 184,22 |
} |
else |
{ |
URL url = new URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_REPORT_RESULTS + "?code=" + sigesCode + "&year=" + year + "&period="+periodIncluded); |
InputStream is = url.openStream(); |
String json = "{ }"; |
String serviceUrl = Globals.SYSTEM_WSJSON_SERVICE_COURSE_QUESTIONARIOS_REPORT_RESULTS + "?code=" + sigesCode + "&year=" + year + "&period="+periodIncluded; |
try{ |
URL url = new URL(serviceUrl); |
String json = StreamsUtils.readString(is); |
is.close(); |
URLConnection conn = url.openConnection(); |
InputStream is = conn.getInputStream(); |
json = StreamsUtils.readString(is); |
is.close(); |
}catch(Throwable e) |
{ |
logger.error("Connecting " + serviceUrl,e); |
return json; |
} |
JSONObject jsonObject = new JSONObject(json); |
return jsonObject.get("response").toString(); |
/branches/v3/impl/src/java/pt/estgp/estgweb/web/controllers/widgetmodel/CoursesServicesWidgetController.java |
---|
134,7 → 134,7 |
public static void main(String[] args) throws Throwable |
{ |
URL url = new URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION + "?code=9119&year=201516&period=S2"); |
URL url = new URL(Globals.SYSTEM_WSJSON_SERVICE_COURSE_UNITS_EVALUATION_REPORT + "?code=9119&year=201516&period=S2"); |
InputStream is = url.openStream(); |
String json = StreamsUtils.readString(is); |