Class SectionTranslationService
java.lang.Object
edu.ucsb.cs156.frontiers.services.SectionTranslationService
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetSectionTranslations(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).booleanisTranslateSectionsEnabled(Long courseId) Returns whether the TRANSLATE_SECTIONS course option is enabled for the given course.static StringtranslateSection(String rawSection, Map<String, String> translations) Translates a raw roster student section value using the given map.
-
Constructor Details
-
SectionTranslationService
public SectionTranslationService()
-
-
Method Details
-
getSectionTranslations
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
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
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
-