Class DbTable


  • public class DbTable
    extends Object
    Table loaded from the database referred by a MyDBConnectionInfo instance.
    Author:
    mmoquillon
    • Method Detail

      • table

        public static Optional<DbTable> table​(String tableName,
                                              MyDBConnectionInfo dsInfo)
        Gets the table with the specified name from the database referenced by the given connection information. If no such a table doesn't exist, then nothing is returned.
        Parameters:
        tableName - the name of a table in the database.
        dsInfo - the MyDBConnectionInfo instance with information to access the database
        Returns:
        optionally a DbTable instance or nothing if no such a table exist in the database.
      • list

        public static List<String> list​(MyDBConnectionInfo dsInfo)
        Gets a listing of the names of all the business tables in the database. The database is identified by the specified MyDBConnectionInfo instance. (The system and technical tables aren't get.)
        Parameters:
        dsInfo - the MyDBConnectionInfo instance with information to access the database.
        Returns:
        a list with the name of all the business tables in the database.
      • getName

        public String getName()
        Gets this table's name.
        Returns:
        the name of this table.
      • getColumns

        public List<DbColumn> getColumns()
        Gets all the columns that made up this table. If no columns were specified for this table, then an empty list is returned.
        Returns:
        a list of columns.
      • getColumn

        public Optional<DbColumn> getColumn​(String name)
        Gets the column with the specified name.
        Parameters:
        name - the name of the column.
        Returns:
        optionally the asked column. If no such column exists then an empty optional is returned.
      • getRows

        public org.silverpeas.core.util.SilverpeasList<TableRow> getRows​(ColumnValuePredicate filter,
                                                                         String orderBy,
                                                                         org.silverpeas.core.admin.PaginationPage pagination)
        Gets the contents of this table as a list of rows, each of them being a tuple valuing all the columns of this table. If the table is empty, then an empty list is returned.
        Parameters:
        filter - a predicate to use for filtering the table content.
        orderBy - a order by directive already built (without the clause key words).
        pagination - a pagination in order to avoid bad performances.
        Returns:
        a list of table rows. If a filter is set, it is then applied when requesting the content of this table. The number of table rows is limited by the MyDBConnectionInfo.getDataMaxNumber() property.
      • delete

        public long delete​(TableRow row)
        Deletes the specified row.
        Parameters:
        row - the row to delete in this database table.
      • update

        public long update​(TableRow actualRow,
                           TableRow updatedRow)
        Updates the specified row with the specified other row.
        Parameters:
        actualRow - the row currently in this table.
        updatedRow - the row that will replace the actual one in this table.
      • add

        public void add​(TableRow row)
        Adds the specified row into this table. The row will be inserted into the database table.
        Parameters:
        row - the row to add into the database table.