private String getString(MultiLanguageString mls, Language language) { String value = mls.getContent(language); if (value == null) { value = mls.getContent(); } return value; }
protected Map<JSONObject, String> buildCompetenceCoursesJson() { Map<JSONObject, String> jsons = new HashMap<JSONObject, String>(); RootCourseGroup root = degree.getLastActiveDegreeCurricularPlan().getRoot(); for (CurricularCourse course : root.getAllCurricularCourses(executionSemester)) { CompetenceCourse competence = course.getCompetenceCourse(); if (competence != null) { JSONObject json = new JSONObject(); StringBuilder output = new StringBuilder(); json.put("q-6.2.1.1", competence.getName(executionSemester)); json.put("q-6.2.1.2", getTeachersAndTeachingHours(course, true)); JSONObject q6213 = new JSONObject(); String teachersAndTeachingHours = getTeachersAndTeachingHours(course, false); q6213.put("en", teachersAndTeachingHours); q6213.put("pt", teachersAndTeachingHours); json.put("q-6.2.1.3", q6213); JSONObject q6214 = new JSONObject(); MultiLanguageString objectives = competence.getObjectivesI18N(executionSemester); q6214.put( "en", cut("objectivos em ingles", objectives.getContent(Language.en), output, 1000)); q6214.put( "pt", cut("objectivos em portugues", objectives.getContent(Language.pt), output, 1000)); json.put("q-6.2.1.4", q6214); JSONObject q6215 = new JSONObject(); MultiLanguageString program = competence.getProgramI18N(executionSemester); q6215.put("en", cut("programa em ingles", program.getContent(Language.en), output, 1000)); q6215.put( "pt", cut("programa em portugues", program.getContent(Language.pt), output, 1000)); json.put("q-6.2.1.5", q6215); JSONObject q6216 = new JSONObject(); q6216.put( "en", ResourceBundle.getBundle("resources.GEPResources", Locale.ENGLISH) .getString("label.gep.a3es.q6-2-1-6")); q6216.put( "pt", ResourceBundle.getBundle("resources.GEPResources", new Locale("pt")) .getString("label.gep.a3es.q6-2-1-6")); json.put("q-6.2.1.6", q6216); JSONObject q6217 = new JSONObject(); q6217.put( "en", cut( "avaliação em ingles", competence.getEvaluationMethodEn(executionSemester), output, 1000)); q6217.put( "pt", cut( "avaliação em portugues", competence.getEvaluationMethod(executionSemester), output, 1000)); json.put("q-6.2.1.7", q6217); JSONObject q6218 = new JSONObject(); q6218.put( "en", ResourceBundle.getBundle("resources.GEPResources", Locale.ENGLISH) .getString("label.gep.a3es.q6-2-1-8")); q6218.put( "pt", ResourceBundle.getBundle("resources.GEPResources", new Locale("pt")) .getString("label.gep.a3es.q6-2-1-8")); json.put("q-6.2.1.8", q6218); List<String> references = new ArrayList<String>(); for (BibliographicReference reference : competence .getBibliographicReferences(executionSemester) .getMainBibliographicReferences()) { references.add(extractReference(reference)); } json.put("q-6.2.1.9", StringUtils.join(references, "; ")); jsons.put(json, output.toString()); } } return jsons; }