Interface DatamartRowSet


public interface DatamartRowSet
Represents the data of a PA field collection (Data Feed, Data Source, Datamart, etc.) and provides methods to work with it. Available in a PA DataLoad context only. If you need an alternative, see DatamartContext.DataLoader. In order to get a valid instance of DatamartRowSet, use api.getDatamartRowSet(). Typically only changes to the target DatamartRowSet will actually be stored. And which field collection is actually the source or the target depends on the Dataload configuration.

Example:


         def sourceRows = api.getDatamartRowSet("source");
         def targetRows = api.getDatamartRowSet("target");
     
  • Field Details Link icon

  • Method Details Link icon

    • getKeyFields Link icon

      List<String> getKeyFields()
      Provides the list of the key fields.
      Returns:
      key field names represented as a List of String
    • getAllFields Link icon

      Collection<String> getAllFields()
      Provides the list of all the fields.
      Returns:
      field names represented as a Collection of String
    • addRow Link icon

      boolean addRow(Map<String,Object> map)
      Adds a row.
      
            target.addRow([
                       sku: obj.sku,              // key field
                       salesOrg: obj.attribute1,  // key field
                       quantity: 0
               ])
       
      Parameters:
      map - represented as Map
      Returns:
      true if the row was added
    • updateRow Link icon

      boolean updateRow(Map<String,Object> map)
      Updates row values, only if a row already exists for the provided keys.
      
            target.updateRow([
                       sku: obj.sku,              // key field
                       salesOrg: obj.attribute1,  // key field
                       quantity: 0
               ])
       
      Parameters:
      map - row represented as Map
      Returns:
      true if the row was updated
    • deleteRow Link icon

      boolean deleteRow(Map<String,Object> map)
      Deletes a row. Note that only the key field values are relevant, the method does not verify that every single value matches.
      
            target.deleteRow([
                       txid: obj.txid
               ])
       
      Parameters:
      map - key fields represented as Map
      Returns:
      true if the row was deleted
      Since:
      6.0 - Vesper
      See Also:
    • getRow Link icon

      Map<String,Object> getRow(Map<String,Object> map)
      Get the row with the given key values. Always returns a copy.
      
           def rowKey = [
               "SHIP_TO": obj.ship_to,
               "SALES_MANAGER": obj.sales_manager,
               "MATERIAL": obj.sku,
               "REPORT_MONTH": prPeriod]
           def rRow = target.getRow(rowKey)
       
      Parameters:
      map - key fields represented as Map
      Returns:
      row represented as Map
    • setDefaultValues Link icon

      void setDefaultValues(Map<String,Object> defaultValues)
      Set default values to be used when creating new rows. This method will drop all previously set defaults. To add to the existing defaults, use addDefaultValues(Map)
      See Also:
    • addDefaultValues Link icon

      void addDefaultValues(Map<String,Object> defaultValues)
      Add default values to be used when creating new rows. There can be only one default value per field, so previously set defaults may be replaced.
      See Also:
    • newRow Link icon

      Map<String,Object> newRow()
      Creates a representation of a new row, potentially populated with default values. Note that the row is not yet added to the DatamartRowSet. Use addRow(Map) to add the row.
      Returns:
      new row represented as Map
      See Also:
    • loadRows Link icon

      void loadRows(DatamartRowSet otherRowset) throws IllegalFieldValuesException
      Adds rows from another DatamartRowSet. Note that there is no check whether the fields of the rowsets are compatible, not even regarding the key fields.
      Parameters:
      otherRowset - DatamartRowSet containing the rows
      Throws:
      IllegalFieldValuesException - if the key fields are not the same
    • getRows Link icon

      Collection<? extends Map<String,Object>> getRows()
      Provides a Collection of Map representing every row in this DatamartRowSet.
      Returns:
      a Collection of all rows, each row represented as a #Map
    • isEmpty Link icon

      boolean isEmpty()
      Returns true if this DatamartRowSet contains no rows.
      Returns:
      true if this DatamartRowSet contains no rows
    • size Link icon

      int size()
      Returns the number of rows in this DatamartRowSet. If this DatamartRowSet contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
      Returns:
      the number of rows in this DatamartRowSet
    • reset Link icon

      void reset()
      Resets the current row index of this DatamartRowSet.
      See Also:
    • first Link icon

      boolean first() throws SQLException
      Sets the current row index of this DatamartRowSet to the first row.
      Throws:
      SQLException
      See Also:
    • last Link icon

      boolean last() throws SQLException
      Sets the current row index of this DatamartRowSet to the last row.
      Throws:
      SQLException
      See Also:
    • previous Link icon

      boolean previous() throws SQLException
      Sets the current row index of this DatamartRowSet to the previous row.
      Throws:
      SQLException
      See Also:
    • next Link icon

      boolean next() throws SQLException
      Sets the current row index of this DatamartRowSet to the next row.
      Throws:
      SQLException
      See Also:
    • getCurrentRow Link icon

      Map<String,Object> getCurrentRow()
      Returns the current row.
      Returns:
      current row represented as Map
      See Also:
    • deleteCurrentRow Link icon

      boolean deleteCurrentRow()
      Deletes the current row.
      Returns:
      true if successful (row existed)
    • merge Link icon

      void merge(DatamartRowSet otherSet)
      Updates rows in this set, for which a row with the same key exists in the other set. Does not add any rows to this set!
      Parameters:
      otherSet - other DatamartRowSet
    • loadRows Link icon

      void loadRows(Matrix2D data)
      Add rows from a #Matrix2D. If the #Matrix2D data does not contain all DatamartRowSet key fields, then we assume auto-increment of the missing key fields is desired. If on the other hand, the fields are there, but the values are missing (for some rows), then we assume inserting empty #String ("").
      Parameters:
      data - the #Matrix2D holding the data to add
      See Also:
    • loadRows Link icon

      void loadRows(Matrix2D data, Collection<String> columns)
      Add rows from a #Matrix2D, possibly only a subset of the matrix columns. If the #Matrix2D data does not contain all DatamartRowSet key fields, then we assume auto-increment of the missing key fields is desired. If on the other hand, the fields are there, but the values are missing (for some rows), then we assume inserting empty #String ("").
      Parameters:
      data - the #Matrix2D holding the data to add
      columns - name of the #Matrix2D columns to import
      See Also:
    • loadRows Link icon

      void loadRows(Matrix2D data, Map<String,String> fieldMapping)
      Add rows from a #Matrix2D, possibly only a subset of the matrix columns. If the #Matrix2D data does not contain all DatamartRowSet key fields, then we assume auto-increment of the missing key fields is desired. If on the other hand, the fields are there, but the values are missing (for some rows), then we assume inserting empty #String ("").
      Parameters:
      data - the #Matrix2D holding the data to add
      fieldMapping - key is the DatamartRowSet field name, and value is the Matrix column name
      See Also:
    • toResultMatrix Link icon

      ResultMatrix toResultMatrix()
      Converts the data to ResultMatrix Limited to RESULTMATRIX_MAXROWS rows.
      Returns:
      converted to ResultMatrix
    • toResultMatrix Link icon

      ResultMatrix toResultMatrix(int maxRows)
      Converts the data to ResultMatrix Limited to user defined number of rows which cannot exceed RESULTMATRIX_MAXROWS.
      Parameters:
      maxRows - maximum number of rows to be converted, capped to RESULTMATRIX_MAXROWS
      Returns:
      converted to ResultMatrix