Class SectionTranslationService

java.lang.Object
edu.ucsb.cs156.frontiers.services.SectionTranslationService

@Service public class SectionTranslationService extends Object
Centralizes the logic for checking whether the TRANSLATE_SECTIONS course option is enabled, and for translating a raw roster student section value into its human readable label. This is the single place where this logic lives, so that it behaves consistently everywhere a section value is displayed or exported (e.g. the CATME CSV export, the roster student tables).
  • Constructor Details

    • SectionTranslationService

      public SectionTranslationService()
  • Method Details

    • getSectionTranslations

      public Map<String,String> getSectionTranslations(Long courseId)
      Returns the map from raw section value to label for the course, if the TRANSLATE_SECTIONS course option is enabled; otherwise an empty map (raw values are used as-is).
      Parameters:
      courseId - the id of the course
      Returns:
      map of raw section value to translated label
    • isTranslateSectionsEnabled

      public boolean isTranslateSectionsEnabled(Long courseId)
      Returns whether the TRANSLATE_SECTIONS course option is enabled for the given course.
      Parameters:
      courseId - the id of the course
      Returns:
      true if the TRANSLATE_SECTIONS course option is enabled, false otherwise
    • translateSection

      public static String translateSection(String rawSection, Map<String,String> translations)
      Translates a raw roster student section value using the given map. A null section is treated as blank; a section with no translation is returned unchanged.
      Parameters:
      rawSection - the section value from the roster student row (may be null)
      translations - map of raw section value to label
      Returns:
      the translated section value