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");
         
    • Method Detail

      • getKeyFields

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

        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

        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
      • getRow

        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
      • addDefaultValues

        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(), setDefaultValues(Map)
      • loadRows

        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

        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
      • size

        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
      • deleteCurrentRow

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

        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

        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(Matrix2D, Collection), loadRows(Matrix2D, Map)
      • loadRows

        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(Matrix2D), loadRows(Matrix2D, Map)
      • loadRows

        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:
        loadRows(Matrix2D), loadRows(Matrix2D, Collection)