Class ConceptYamlService

java.lang.Object
edu.ucsb.cs.scaffold.services.ConceptYamlService

@Service public class ConceptYamlService extends Object
Exports and imports a course's entire concept-graph content (concepts, subconcepts, prerequisite edges, and practice problems) as a human-editable YAML document. See docs/yaml-format.md for the format specification.
  • Field Details

  • Constructor Details

    • ConceptYamlService

      public ConceptYamlService()
  • Method Details

    • createYAML

      public String createYAML(long courseId) throws EntityNotFoundException, com.fasterxml.jackson.core.JsonProcessingException
      The complete concept-graph content of the course as a YAML document (see docs/yaml-format.md). Top-level concepts are numbered with consecutive external ids 1..n in database-id order; edges refer to those external ids.
      Throws:
      EntityNotFoundException
      com.fasterxml.jackson.core.JsonProcessingException
    • replaceFromYAML

      @Transactional public Map<String,Object> replaceFromYAML(long courseId, InputStream yamlStream) throws EntityNotFoundException
      Replaces the course's entire concept-graph content with the content of a YAML document in the docs/yaml-format.md format, reporting the outcome as a JSON-shaped map.

      The replacement is all-or-nothing: the document is fully parsed and validated first, and if anything is wrong the course is left untouched and every problem found is reported under errors. Only a valid document deletes the course's concepts, edges, practice problems, and per-user scaffold state (user_state rows, which refer to concepts by ids that no longer exist after a replacement) before creating the new content.

      Throws:
      EntityNotFoundException