Package de.hirola.sportslibrary.util
Class TemplateLoader
- java.lang.Object
-
- de.hirola.sportslibrary.util.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)
-
-
Constructor Summary
Constructors Constructor Description TemplateLoader(@NotNull DataRepository dataRepository)TemplateLoader(@NotNull DataRepository dataRepository, @Nullable SportsLibraryApplication application)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexportRunningPlanToJSON(RunningPlan runningPlan, Path exportDirPath)Exports (saves?)RunningPlanimportRunningPlanFromTemplate(@NotNull RunningPlanTemplate template)Create a running plan from a plan template object.voidloadAllFromJSON()Loads objects of specific types from available templates (JSON) and adds them to the local data store.voidloadFromJSON(@NotNull Class<? extends de.hirola.kintojava.model.KintoObject> typeOf)Loads objects of a specific type from templates (JSON) and adds them to the local data store.RunningPlanTemplateloadRunningPlanTemplateFromJSON(@NotNull InputStream jsonInputStream)Load a plan template to create (complex) plan objects from a json file.
-
-
-
Constructor Detail
-
TemplateLoader
public TemplateLoader(@NotNull @NotNull DataRepository dataRepository) throws SportsLibraryException- Throws:
SportsLibraryException
-
TemplateLoader
public TemplateLoader(@NotNull @NotNull DataRepository dataRepository, @Nullable @Nullable SportsLibraryApplication application) throws SportsLibraryException- Throws:
SportsLibraryException
-
-
Method Detail
-
loadAllFromJSON
public void loadAllFromJSON() throws SportsLibraryExceptionLoads 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 SportsLibraryExceptionLoads 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 saveexportDirPath- 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
-
-