Class ViewBuilder
java.lang.Object
fr.inria.rules.integraal.views.builder.ViewBuilder
Creates view wrappers from a view definition file
- Author:
- Florent Tornil
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException for creating datasources with viewsstatic classSub-builder for constructing a view. -
Method Summary
Modifier and TypeMethodDescriptionaddView(Predicate predicate, ViewParameters<String> viewParameters) Adds a view to the current source with the given parameters and predicate.build()Finalizes the configuration and returns the configured source.static ViewBuildercreate()Static factory method to create a new instance of ViewBuilder.createView(Predicate predicate) Initiates the creation of a new view using a sub-builder.static ViewParameters<String> createViewParameters(String query, List<ViewParameterSignature> parameters, String position) Utility method to create a `ViewParameters` instance.static intfindNextFreePort(int startPort) Finds the next available TCP port starting from the supplied value.static Collection<DataSource<String, ?>> loadDataSources(String filename) Creates a collection of view wrappers from the given filestatic Collection<DataSource<String, ?>> loadDataSources(Collection<String> filePaths) Creates a collection of view wrappers from a collection of mapping filessetWrapper(AbstractDataSource<String, ?> source) Sets an already constructed source as the datasource.useHSQLDBSource(String url, String database) Configures the builder to use an HSQLDBSource.useMySQLSource(String url, String database, String user, String password) Configures the builder to use a MySQLSource.usePostgreSQLSource(String url, String database, String user, String password) Configures the builder to use a PostgreSQLSource.useSQLiteSource(String url) Configures the builder to use a SQLiteSource.
-
Method Details
-
create
Static factory method to create a new instance of ViewBuilder.- Returns:
- a new builder instance
-
setWrapper
Sets an already constructed source as the datasource.- Parameters:
source- the source to set- Returns:
- the current builder instance
-
useHSQLDBSource
Configures the builder to use an HSQLDBSource.- Parameters:
url- the database URLdatabase- the database name- Returns:
- the current builder instance
- Throws:
SQLException- if the datasource cannot be initialized
-
useMySQLSource
public ViewBuilder useMySQLSource(String url, String database, String user, String password) throws SQLException Configures the builder to use a MySQLSource.- Parameters:
url- the database URLdatabase- the database nameuser- the database userpassword- the database password- Returns:
- the current builder instance
- Throws:
SQLException- if the datasource cannot be initialized
-
usePostgreSQLSource
public ViewBuilder usePostgreSQLSource(String url, String database, String user, String password) throws SQLException Configures the builder to use a PostgreSQLSource.- Parameters:
url- the database URLdatabase- the database nameuser- the database userpassword- the database password- Returns:
- the current builder instance
- Throws:
SQLException- if the datasource cannot be initialized
-
useSQLiteSource
Configures the builder to use a SQLiteSource.- Parameters:
url- the database URL- Returns:
- the current builder instance
- Throws:
SQLException- if the datasource cannot be initialized
-
addView
Adds a view to the current source with the given parameters and predicate.- Parameters:
predicate- the predicate of the viewviewParameters- the parameters for the view- Returns:
- the current builder instance
-
createViewParameters
public static ViewParameters<String> createViewParameters(String query, List<ViewParameterSignature> parameters, String position) Utility method to create a `ViewParameters` instance.- Parameters:
query- the query stringparameters- the list of parameter signaturesposition- optional positioning- Returns:
- a new ViewParameters instance
-
build
Finalizes the configuration and returns the configured source.- Returns:
- the configured source
-
createView
Initiates the creation of a new view using a sub-builder.- Parameters:
predicate- the predicate of the view- Returns:
- a sub-builder for configuring the view
-
loadDataSources
public static Collection<DataSource<String,?>> loadDataSources(String filename) throws ViewBuilder.ViewBuilderException Creates a collection of view wrappers from the given file- Parameters:
filename- a view configuration file- Returns:
- the wrappers
- Throws:
ViewBuilder.ViewBuilderException- if an exception occurs
-
loadDataSources
public static Collection<DataSource<String,?>> loadDataSources(Collection<String> filePaths) throws ViewBuilder.ViewBuilderException Creates a collection of view wrappers from a collection of mapping files- Parameters:
filePaths- a list of view definition files- Returns:
- the wrappers
- Throws:
ViewBuilder.ViewBuilderException- if an exception occur
-
findNextFreePort
public static int findNextFreePort(int startPort) Finds the next available TCP port starting from the supplied value.- Parameters:
startPort- the first port to test- Returns:
- the first available port
-