Class AbstractDialogFactory<T extends Dialog>

java.lang.Object
org.gorpipe.querydialogs.factory.AbstractDialogFactory<T>
Type Parameters:
T - a Dialog type
Direct Known Subclasses:
PerspectiveDialogFactory

public abstract class AbstractDialogFactory<T extends Dialog> extends Object
A factory responsible for building Dialogs from a supplied YAML file.

Sample usage:

 AbstractDialogFactory<Dialog> f = new SomeDialogFactoryImplementation();
 f.registerArgumentBuilder(ArgumentType.STRING, new StringArgumentBuilder());
 List<Dialog> dialogs = f.buildDialogs(new File("/path/to/yaml/file"));
 
  • Field Details

    • inputFileFirstReport

      protected String inputFileFirstReport
  • Constructor Details

    • AbstractDialogFactory

      public AbstractDialogFactory(org.gorpipe.gor.model.FileReader fr, org.gorpipe.gor.model.QueryEvaluator queryEval, boolean ignoreAllowedMismatch)
      Constructs a factory with no registered argument builders
  • Method Details

    • registerArgumentBuilder

      public ArgumentBuilder registerArgumentBuilder(ArgumentType type, ArgumentBuilder builder)
      Registers an ArgumentBuilder to use for the given ArgumentType.
      Parameters:
      type - - the type to register builder for
      builder - - the builder to use for given type
      Returns:
      the previously registered builder for that type, or null if there was none
    • getFileReader

      public org.gorpipe.gor.model.FileReader getFileReader()
      Get the FileResolver for this factory
      Returns:
      the file resolver for this factory
    • getQueryEval

      public org.gorpipe.gor.model.QueryEvaluator getQueryEval()
    • buildDialogs

      public List<T> buildDialogs(String resource, String cacheDir) throws IOException, freemarker.template.TemplateException
      Parameters:
      resource - - the Yaml to read
      Returns:
      a List of Dialogs
      Throws:
      IOException
      freemarker.template.TemplateException
    • buildDialogs

      public List<T> buildDialogs(String resource) throws IOException, freemarker.template.TemplateException
      Parameters:
      resource - - the Yaml to read
      Returns:
      a List of Dialogs
      Throws:
      IOException
      freemarker.template.TemplateException
    • buildDialogs

      public List<T> buildDialogs(Path resource) throws IOException, freemarker.template.TemplateException
      Parameters:
      resource - - the Yaml to read
      Returns:
      a List of Dialogs
      Throws:
      IOException
      freemarker.template.TemplateException
    • buildDialogs

      public List<T> buildDialogs(Reader reader, String cacheDir) throws freemarker.template.TemplateException, IOException
      Attempts to read and parse the given file as a YAML file and convert the resulting data structure to a list of Dialogs
      Parameters:
      reader - - reader of the yaml content
      Returns:
      a List of Dialogs
      Throws:
      freemarker.template.TemplateException
      IOException
    • getInputFileFirstReport

      public String getInputFileFirstReport()
      Get the name of the first report in the input file.
      Returns:
      the name of the first report in the input file
    • buildDialog

      protected abstract T buildDialog(String name, Map<String,? extends Object> attributes) throws freemarker.template.TemplateException
      Throws:
      freemarker.template.TemplateException
    • buildArgument

      protected Argument buildArgument(String name, Map<String,? extends Object> attributes)