Package net.pricefx.formulaengine
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefaultValues(Map<String, Object> defaultValues) Add default values to be used when creating new rows.booleanAdds a row.booleanDeletes the current row.booleanDeletes a row.booleanfirst()Sets the current row index of thisDatamartRowSetto the first row.Provides the list of all the fields.Returns the current row.Provides the list of the key fields.Get the row with the given key values.Collection<? extends Map<String, Object>> getRows()booleanisEmpty()Returnstrueif thisDatamartRowSetcontains no rows.booleanlast()Sets the current row index of thisDatamartRowSetto the last row.voidloadRows(DatamartRowSet otherRowset) Adds rows from anotherDatamartRowSet.voidAdd rows from a #Matrix2D.voidloadRows(Matrix2D data, Collection<String> columns) Add rows from a #Matrix2D, possibly only a subset of the matrix columns.voidAdd rows from a #Matrix2D, possibly only a subset of the matrix columns.voidmerge(DatamartRowSet otherSet) Updates rows in this set, for which a row with the same key exists in the other set.newRow()Creates a representation of a new row, potentially populated with default values.booleannext()Sets the current row index of thisDatamartRowSetto the next row.booleanprevious()Sets the current row index of thisDatamartRowSetto the previous row.voidreset()Resets the current row index of thisDatamartRowSet.voidsetDefaultValues(Map<String, Object> defaultValues) Set default values to be used when creating new rows.intsize()Returns the number of rows in thisDatamartRowSet.Converts the data toResultMatrixLimited toRESULTMATRIX_MAXROWSrows.toResultMatrix(int maxRows) Converts the data toResultMatrixLimited to user defined number of rows which cannot exceedRESULTMATRIX_MAXROWS.booleanUpdates row values, only if a row already exists for the provided keys.
-
Field Details
-
RESULTMATRIX_MAXROWS
static final int RESULTMATRIX_MAXROWS- See Also:
-
-
Method Details
-
getKeyFields
Provides the list of the key fields. -
getAllFields
Collection<String> getAllFields()Provides the list of all the fields.- Returns:
- field names represented as a
CollectionofString
-
addRow
Adds a row.target.addRow([ sku: obj.sku, // key field salesOrg: obj.attribute1, // key field quantity: 0 ])- Parameters:
map- represented asMap- Returns:
- true if the row was added
-
updateRow
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 asMap- Returns:
- true if the row was updated
-
deleteRow
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 asMap- Returns:
- true if the row was deleted
- Since:
- 6.0 - Vesper
- See Also:
-
getRow
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) -
setDefaultValues
Set default values to be used when creating new rows. This method will drop all previously set defaults. To add to the existing defaults, useaddDefaultValues(Map)- See Also:
-
addDefaultValues
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
Creates a representation of a new row, potentially populated with default values. Note that the row is not yet added to theDatamartRowSet. UseaddRow(Map)to add the row.- Returns:
- new row represented as
Map - See Also:
-
loadRows
Adds rows from anotherDatamartRowSet. Note that there is no check whether the fields of the rowsets are compatible, not even regarding the key fields.- Parameters:
otherRowset-DatamartRowSetcontaining the rows- Throws:
IllegalFieldValuesException- if the key fields are not the same
-
getRows
Collection<? extends Map<String,Object>> getRows()- Returns:
- a
Collectionof all rows, each row represented as a #Map
-
isEmpty
boolean isEmpty()Returnstrueif thisDatamartRowSetcontains no rows.- Returns:
trueif thisDatamartRowSetcontains no rows
-
size
int size()Returns the number of rows in thisDatamartRowSet. If thisDatamartRowSetcontains more thanInteger.MAX_VALUEelements, returnsInteger.MAX_VALUE.- Returns:
- the number of rows in this
DatamartRowSet
-
reset
void reset()Resets the current row index of thisDatamartRowSet.- See Also:
-
first
Sets the current row index of thisDatamartRowSetto the first row.- Throws:
SQLException- See Also:
-
last
Sets the current row index of thisDatamartRowSetto the last row.- Throws:
SQLException- See Also:
-
previous
Sets the current row index of thisDatamartRowSetto the previous row.- Throws:
SQLException- See Also:
-
next
Sets the current row index of thisDatamartRowSetto the next row.- Throws:
SQLException- See Also:
-
getCurrentRow
Returns the current row.- Returns:
- current row represented as
Map - See Also:
-
deleteCurrentRow
boolean deleteCurrentRow()Deletes the current row.- Returns:
- true if successful (row existed)
-
merge
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- otherDatamartRowSet
-
loadRows
Add rows from a #Matrix2D. If the #Matrix2D data does not contain allDatamartRowSetkey 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
Add rows from a #Matrix2D, possibly only a subset of the matrix columns. If the #Matrix2D data does not contain allDatamartRowSetkey 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 addcolumns- name of the #Matrix2D columns to import- See Also:
-
loadRows
Add rows from a #Matrix2D, possibly only a subset of the matrix columns. If the #Matrix2D data does not contain allDatamartRowSetkey 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 addfieldMapping- key is theDatamartRowSetfield name, and value is the Matrix column name- See Also:
-
toResultMatrix
ResultMatrix toResultMatrix()Converts the data toResultMatrixLimited toRESULTMATRIX_MAXROWSrows.- Returns:
- converted to
ResultMatrix
-
toResultMatrix
Converts the data toResultMatrixLimited to user defined number of rows which cannot exceedRESULTMATRIX_MAXROWS.- Parameters:
maxRows- maximum number of rows to be converted, capped toRESULTMATRIX_MAXROWS- Returns:
- converted to
ResultMatrix
-