Class TemplateLoader


  • public class TemplateLoader
    extends Object
    Copyright 2021 by Michael Schmidt, Hirola Consulting This software us licensed under the AGPL-3.0 or later. Create objects from template files (JSON).
    Since:
    1.1.1
    Author:
    Michael Schmidt (Hirola)
    • Method Detail

      • loadAllFromJSON

        public void loadAllFromJSON()
                             throws SportsLibraryException
        Loads objects of specific types from available templates (JSON) and adds them to the local data store.
        Throws:
        SportsLibraryException - if no templates were found or could not be loaded successfully
      • loadFromJSON

        public void loadFromJSON​(@NotNull
                                 @NotNull Class<? extends de.hirola.kintojava.model.KintoObject> typeOf)
                          throws SportsLibraryException
        Loads objects of a specific type from templates (JSON) and adds them to the local data store.
        Parameters:
        typeOf - objects of this type should be loaded from templates
        Throws:
        SportsLibraryException - if no templates were found or could not be loaded successfully
      • loadRunningPlanTemplateFromJSON

        public RunningPlanTemplate loadRunningPlanTemplateFromJSON​(@NotNull
                                                                   @NotNull InputStream jsonInputStream)
                                                            throws SportsLibraryException
        Load a plan template to create (complex) plan objects from a json file.
        Parameters:
        jsonInputStream - to the template file
        Returns:
        A template object to create a running plan
        Throws:
        SportsLibraryException - if the template was not found or could not be loaded successfully
        See Also:
        RunningPlanTemplate
      • importRunningPlanFromTemplate

        public RunningPlan importRunningPlanFromTemplate​(@NotNull
                                                         @NotNull RunningPlanTemplate template)
                                                  throws SportsLibraryException
        Create a running plan from a plan template object.
        Parameters:
        template - for the running plan
        Returns:
        A running plan, create from a template object
        Throws:
        SportsLibraryException - if the running plan could not create from template object
        See Also:
        RunningPlan
      • exportRunningPlanToJSON

        public void exportRunningPlanToJSON​(RunningPlan runningPlan,
                                            Path exportDirPath)
                                     throws SportsLibraryException
        Exports (saves?) a running plan as a template to a JSON file.
        Parameters:
        runningPlan - to export or save
        exportDirPath - to the JSON file to export the run plan to
        Throws:
        SportsLibraryException - if the file could not be saved or an error occurred during export