Class ViewBuilder

java.lang.Object
fr.inria.rules.integraal.views.builder.ViewBuilder

public class ViewBuilder extends Object
Creates view wrappers from a view definition file
Author:
Florent Tornil
  • Method Details

    • create

      public static ViewBuilder create()
      Static factory method to create a new instance of ViewBuilder.
      Returns:
      a new builder instance
    • setWrapper

      public ViewBuilder setWrapper(AbstractDataSource<String,?> source)
      Sets an already constructed source as the datasource.
      Parameters:
      source - the source to set
      Returns:
      the current builder instance
    • useHSQLDBSource

      public ViewBuilder useHSQLDBSource(String url, String database) throws SQLException
      Configures the builder to use an HSQLDBSource.
      Parameters:
      url - the database URL
      database - 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 URL
      database - the database name
      user - the database user
      password - 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 URL
      database - the database name
      user - the database user
      password - the database password
      Returns:
      the current builder instance
      Throws:
      SQLException - if the datasource cannot be initialized
    • useSQLiteSource

      public ViewBuilder useSQLiteSource(String url) throws SQLException
      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

      public ViewBuilder addView(Predicate predicate, ViewParameters<String> viewParameters)
      Adds a view to the current source with the given parameters and predicate.
      Parameters:
      predicate - the predicate of the view
      viewParameters - 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 string
      parameters - the list of parameter signatures
      position - optional positioning
      Returns:
      a new ViewParameters instance
    • build

      public AbstractDataSource<String,?> build()
      Finalizes the configuration and returns the configured source.
      Returns:
      the configured source
    • createView

      public ViewBuilder.ViewSubBuilder createView(Predicate predicate)
      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