Package org.gorpipe.querydialogs.factory
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 java.lang.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 Summary
Fields Modifier and Type Field Description protected java.lang.StringinputFileFirstReport -
Constructor Summary
Constructors Constructor Description AbstractDialogFactory(org.gorpipe.gor.model.FileReader fr, org.gorpipe.gor.model.QueryEvaluator queryEval)Constructs a factory with no registered argument builders -
Method Summary
Modifier and Type Method Description protected ArgumentbuildArgument(java.lang.String name, java.util.Map<java.lang.String,? extends java.lang.Object> attributes)protected abstract TbuildDialog(java.lang.String name, java.util.Map<java.lang.String,? extends java.lang.Object> attributes)java.util.List<T>buildDialogs(java.io.Reader reader, java.lang.String cacheDir)Attempts to read and parse the given file as a YAML file and convert the resulting data structure to a list ofDialogsjava.util.List<T>buildDialogs(java.lang.String resource)java.util.List<T>buildDialogs(java.lang.String resource, java.lang.String cacheDir)java.util.List<T>buildDialogs(java.nio.file.Path resource)org.gorpipe.gor.model.FileReadergetFileReader()Get the FileResolver for this factoryjava.lang.StringgetInputFileFirstReport()Get the name of the first report in the input file.org.gorpipe.gor.model.QueryEvaluatorgetQueryEval()ArgumentBuilderregisterArgumentBuilder(ArgumentType type, ArgumentBuilder builder)Registers anArgumentBuilderto use for the givenArgumentType.
-
Field Details
-
inputFileFirstReport
protected java.lang.String inputFileFirstReport
-
-
Constructor Details
-
AbstractDialogFactory
public AbstractDialogFactory(org.gorpipe.gor.model.FileReader fr, org.gorpipe.gor.model.QueryEvaluator queryEval)Constructs a factory with no registered argument builders
-
-
Method Details
-
registerArgumentBuilder
Registers anArgumentBuilderto use for the givenArgumentType.- Parameters:
type- - the type to register builder forbuilder- - 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 java.util.List<T> buildDialogs(java.lang.String resource, java.lang.String cacheDir) throws java.io.IOException, freemarker.template.TemplateException- Parameters:
resource- - the Yaml to read- Returns:
- a
ListofDialogs - Throws:
java.io.IOExceptionfreemarker.template.TemplateException
-
buildDialogs
public java.util.List<T> buildDialogs(java.lang.String resource) throws java.io.IOException, freemarker.template.TemplateException- Parameters:
resource- - the Yaml to read- Returns:
- a
ListofDialogs - Throws:
java.io.IOExceptionfreemarker.template.TemplateException
-
buildDialogs
public java.util.List<T> buildDialogs(java.nio.file.Path resource) throws java.io.IOException, freemarker.template.TemplateException- Parameters:
resource- - the Yaml to read- Returns:
- a
ListofDialogs - Throws:
java.io.IOExceptionfreemarker.template.TemplateException
-
buildDialogs
public java.util.List<T> buildDialogs(java.io.Reader reader, java.lang.String cacheDir) throws freemarker.template.TemplateException, java.io.IOExceptionAttempts to read and parse the given file as a YAML file and convert the resulting data structure to a list ofDialogs- Parameters:
reader- - reader of the yaml content- Returns:
- a
ListofDialogs - Throws:
freemarker.template.TemplateExceptionjava.io.IOException
-
getInputFileFirstReport
public java.lang.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(java.lang.String name, java.util.Map<java.lang.String,? extends java.lang.Object> attributes) throws freemarker.template.TemplateException- Throws:
freemarker.template.TemplateException
-
buildArgument
protected Argument buildArgument(java.lang.String name, java.util.Map<java.lang.String,? extends java.lang.Object> attributes)
-