public List<String> getSpecialLessons(String grade, String year) { List<String> lessons = new ArrayList<String>(); lessons.addAll(standardSpecialLessons()); if (StringUtils.equalsIgnoreCase(grade, SIXTH_GRADE) || StringUtils.equalsIgnoreCase(grade, FIFTH_GRADE)) { List<LessonPost> posts = postDAO.getByYearGradeLessonKeyword(year, grade, null); for (LessonPost post : posts) { String uuid = post.getUuid(); if (StringUtils.containsIgnoreCase(uuid, SPECIAL_TAG)) { boolean contains = false; for (String special : standardSpecialLessons()) { if (StringUtils.containsIgnoreCase(uuid, special)) { contains = true; } } if (!contains) { int index = uuid.indexOf(SPECIAL_TAG) + SPECIAL_TAG.length() + 1; String name = uuid.substring(index); lessons.add(name); } } } } return lessons; }
public List<String> getLessons(String grade, String year) { List<String> lessons = new ArrayList<String>(); if (StringUtils.equalsIgnoreCase(grade, SIXTH_GRADE)) { int hi_friends = 2; for (String lesson : sixthGradeLessons()) { lessons.add(HI_FRIENDS_PREFIX + hi_friends + CONJUNCTION + lesson); } } else if (StringUtils.equalsIgnoreCase(grade, FIFTH_GRADE)) { int hi_friends = 1; for (String lesson : fifthGradeLessons()) { lessons.add(HI_FRIENDS_PREFIX + hi_friends + CONJUNCTION + lesson); } } else { List<String> grades = Arrays.asList(StringUtils.split(grade, CONJUNCTION)); List<LessonPost> posts = postDAO.getByYearGradeLessonKeyword(year, grades, null); for (LessonPost post : posts) { String uuid = post.getUuid(); if (StringUtils.containsIgnoreCase(uuid, LESSONS_PREFIX)) { int index = uuid.lastIndexOf(LESSONS_PREFIX) + LESSONS_PREFIX.length(); String name = uuid.substring(index); lessons.add(name); } } } return lessons; }
public LessonPost getPost(String lesson, String grade, String year) { final String hash = year + grade + lesson; if (cachedPosts.containsKey(hash)) { return cachedPosts.get(hash); } List<String> grades = Arrays.asList(StringUtils.split(grade, CONJUNCTION)); List<LessonPost> posts = postDAO.getByYearGradeLessonKeyword(year, grades, lesson); LessonPost post = null; if (!posts.isEmpty()) { post = posts.get(0); } cachedPosts.put(hash, post); return post; }