Class ResultMatrix
- Object
-
- ResultMatrix
-
- All Implemented Interfaces:
Serializable
,ComplexCalculationResult
public class ResultMatrix extends Object implements ComplexCalculationResult, Serializable
This class is used to transport a calculated matrix-style result It is basically a list of maps with the addition that the column names are clearly named and can have a format This means: - the UI knows exactly which columns to display (even if some maps do not have those as keys) - the entry maps can have more "columns" (or keys) than those that are displayed; maybe useful for calculation- Author:
- cat
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ResultMatrix.AbstractResultMatrixCell
static class
ResultMatrix.ResultMatrixBackEndCell
Create a link/button that should do some desired action to pricefx backend (unity only) [url:"pricelistmanager.revoke..../...", payload: [...static class
ResultMatrix.ResultMatrixCells
List of other cells (to be shown as dropdown inlinestatic class
ResultMatrix.ResultMatrixDownloadCell
Create a link/button that should do initiate download from pricefx backend (unity only) [url:"pricelistmanager.fetchpdf..../...", payload: [...class
ResultMatrix.ResultMatrixImageCell
class
ResultMatrix.ResultMatrixLinkCell
class
ResultMatrix.ResultMatrixOnRowSelection
class
ResultMatrix.ResultMatrixStyledCell
-
Constructor Summary
Constructors Constructor Description ResultMatrix()
ResultMatrix(String... columns)
Creates a new matrix object with an initial set of columnsResultMatrix(Collection<String> columns)
Creates a new matrix object with an initial set of columnsResultMatrix(Map jsonMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumn(String column)
Adds a column to the existing set of columnsvoid
addColumn(String column, String tooltip)
Adds a column to the existing set of columns including a tooltipvoid
addColumns(Collection<String> columns)
Adds columns to the existing set of columnsvoid
addColumnTranslation(String column, Map<String,String> translations)
Adds translated labels for the given column.void
addRow(Object... values)
Adds a data row.void
addRow(List<Object> row)
Adds a data row.void
addRow(Map<String,Object> row)
Adds a data row.ResultMatrix.ResultMatrixBackEndCell
backEndAction(String label, String url, String payload, String successMessage, String failMessage)
ResultMatrix.ResultMatrixCells
cells(String label, Object... cells)
ResultMatrix.ResultMatrixDownloadCell
downloadButton(String label, String url, String payload)
Map<String,Object>
findRow(String key, Object value)
Retrieves a particular row based on a value checkMap<String,FieldFormatType>
getColumnFormats()
Gets individual column formats (if specified)List<String>
getColumns()
Gets a list of defined columnsMap<String,String>
getColumnTooltips()
Gets the currently assigned column tooltipsMap<String,String>
getColumnTranslations()
Gets current column translations in raw formatFieldFormatType
getDefaultFormat()
Gets the default formatList<Map<String,Object>>
getEntries()
Returns the current list entries as a list (=the rows) of maps (= the row content)Map<String,Map<String,String>>
getOnRowSelectEvents()
String
getPreferenceName()
Gets the preference nameString
getResultType()
String
getTitle()
Gets the current titleResultMatrix.ResultMatrixImageCell
imageCell(Object value)
Creates an image cell that can then be added as row value.boolean
isEnableClientFilter()
boolean
isEscapeHTML()
Is HTML escaping enabled?boolean
isSortingDisabled()
UI sorting of matrix gridResultMatrix.ResultMatrixImageCell
libraryImage(String mainName, String statusName)
ResultMatrix.ResultMatrixLinkCell
linkCell(Object value, String targetPage, String targetPageState)
ResultMatrix.ResultMatrixLinkCell
linkToPriceGrid(Object value, long priceGridID, Filter filter)
ResultMatrix.ResultMatrixLinkCell
linkToPriceList(Object value, long priceListID, Filter filter)
ResultMatrix.ResultMatrixOnRowSelection
onRowSelection()
Configures a client-side UI event.void
setColumnFormat(String column, FieldFormatType fft)
Sets a column format for a specified columnvoid
setColumnTooltip(String column, String tooltip)
Adds a tooltip to a columnvoid
setDefaultFormat(FieldFormatType fft)
Sets a default column formatvoid
setDisableSorting(boolean disableSorting)
Set sorting capability in UI gridvoid
setEnableClientFilter(boolean enableClientFilter)
void
setEscapeHTML(boolean escapeHTML)
Set HTML escaping flag.void
setPreferenceName(String preferenceName)
Sets the so-called preference name.void
setTitle(String title)
Sets the title that will be shown as window title of the result matrix in the clientResultMatrix.ResultMatrixStyledCell
styledCell(Object value)
Creates a styled cell that can then be added as row valueResultMatrix.ResultMatrixStyledCell
styledCell(Object value, String textColor, String bgColor)
Creates a styled cell that can then be added as row valueResultMatrix.ResultMatrixStyledCell
styledCell(Object value, String textColor, String bgColor, String weight)
Creates a styled cell that can then be added as row valueResultMatrix.ResultMatrixStyledCell
styledCell(Object value, String textColor, String bgColor, String weight, String alignment)
Creates a styled cell that can then be added as row valueMatrix2D
toMatrix2D()
String
toString()
ResultMatrix
transpose(String newHeaderColumnName)
Transpose the matrix.ResultMatrix
transpose(String newHeaderColumnName, String oldColLabelsInNewColumnName)
Transpose the matrix.
-
-
-
Constructor Detail
-
ResultMatrix
public ResultMatrix()
-
ResultMatrix
public ResultMatrix(Map jsonMap)
-
ResultMatrix
public ResultMatrix(String... columns)
Creates a new matrix object with an initial set of columns- Parameters:
columns
- The initial set of column names
-
ResultMatrix
public ResultMatrix(Collection<String> columns)
Creates a new matrix object with an initial set of columns- Parameters:
columns
- Collection of column names
-
-
Method Detail
-
getTitle
public String getTitle()
Gets the current title- Returns:
- The current title
-
setTitle
public void setTitle(String title)
Sets the title that will be shown as window title of the result matrix in the client- Parameters:
title
- The title
-
getPreferenceName
public String getPreferenceName()
Gets the preference name- Returns:
- The preference name
-
isSortingDisabled
public boolean isSortingDisabled()
UI sorting of matrix grid- Returns:
- true if sorting is disabled on all columns. Default is false
-
setDisableSorting
public void setDisableSorting(boolean disableSorting)
Set sorting capability in UI grid- Parameters:
disableSorting
- true: sorting is disabled in UI on all columns
-
isEscapeHTML
public boolean isEscapeHTML()
Is HTML escaping enabled?- Returns:
- true if the matrix should display raw text as is (i.e. not try to interpret it as HTML)
-
setEscapeHTML
public void setEscapeHTML(boolean escapeHTML)
Set HTML escaping flag. Default: false (i.e. values will be interpreted as HTML)- Parameters:
escapeHTML
-
-
setPreferenceName
public void setPreferenceName(String preferenceName)
Sets the so-called preference name. I.e. all result matrixes with the same preference name will share the same preference setting. The preference setting can be managed as usual in the client and can be set as global to predefine a good setting- Parameters:
preferenceName
- The preference name
-
addColumnTranslation
public void addColumnTranslation(String column, Map<String,String> translations)
Adds translated labels for the given column.- Parameters:
column
- The column name (as defined e.g. in the constructor)translations
- A map with the translations. The key of the map is the locale, like "de".
-
getColumnTranslations
public Map<String,String> getColumnTranslations()
Gets current column translations in raw format- Returns:
-
addColumn
public void addColumn(String column)
Adds a column to the existing set of columns- Parameters:
column
- The columns name
-
addColumn
public void addColumn(String column, String tooltip)
Adds a column to the existing set of columns including a tooltip- Parameters:
column
- The columns name
-
addColumns
public void addColumns(Collection<String> columns)
Adds columns to the existing set of columns- Parameters:
columns
- Collection of columns names
-
addRow
public void addRow(Map<String,Object> row)
Adds a data row. The keys of the row-map should match the column names defined earlier- Parameters:
row
-
-
addRow
public void addRow(List<Object> row)
Adds a data row. The order of the values is assumed to be the same as the matrix column order.- Parameters:
row
- Row as List
-
addRow
public void addRow(Object... values)
Adds a data row. The order of the values is assumed to be the same as the matrix column order.- Parameters:
values
- Row as Array
-
getEntries
public List<Map<String,Object>> getEntries()
Returns the current list entries as a list (=the rows) of maps (= the row content)- Returns:
- List of maps
-
findRow
public Map<String,Object> findRow(String key, Object value)
Retrieves a particular row based on a value check- Parameters:
key
- The column name to search onvalue
- The value to match the row's column value to- Returns:
- The row
-
transpose
public ResultMatrix transpose(String newHeaderColumnName)
Transpose the matrix.
Example:ProductGroup | AvgPrice | AvgMargin <- header row ----------------------------------- Beef | 4.1€ | 3.6% Pork | 2.2€ | 1.1% Lamb | 4.6€ | 5.2%
Transposed matrix:transpose("ProductGroup") ProductGroup | Beef | Pork | Lamb <- header row --------------------------------- AvgPrice | 4.1€ | 2.2€ | 4.6€ AvgMargin | 3.6% | 1.1% | 5.2%
- Parameters:
newHeaderColumnName
- Name of the column that will become the new header row- Returns:
- The transposed ResultMatrix (new instance)
-
transpose
public ResultMatrix transpose(String newHeaderColumnName, String oldColLabelsInNewColumnName)
Transpose the matrix.
Example:ProductGroup | AvgPrice | AvgMargin <- header row ------------------------------------ Beef | 4.1€ | 3.6% Pork | 2.2€ | 1.1% Lamb | 4.6€ | 5.2%
Transposed matrix:transpose("ProductGroup", "PG Label") Beef | Pork | Lamb | PG Label <- header row ----------------------------------- Beef | Pork | Lamb | ProductGroup 4.1€ | 2.2€ | 4.6€ | AvgPrice 3.6% | 1.1% | 5.2% | AvgMargin
- Parameters:
newHeaderColumnName
- Name of the column that will become the new header rowoldColLabelsInNewColumnName
- Name of the new column that will receive the old column headers as values (optional)- Returns:
- The transposed ResultMatrix (new instance)
-
toMatrix2D
public Matrix2D toMatrix2D()
-
setDefaultFormat
public void setDefaultFormat(FieldFormatType fft)
Sets a default column format- Parameters:
fft
-
-
getDefaultFormat
public FieldFormatType getDefaultFormat()
Gets the default format- Returns:
- Default format
-
getColumnFormats
public Map<String,FieldFormatType> getColumnFormats()
Gets individual column formats (if specified)- Returns:
- A Map with column name and format
-
setColumnFormat
public void setColumnFormat(String column, FieldFormatType fft)
Sets a column format for a specified column- Parameters:
column
- The column namefft
- The format
-
getColumnTooltips
public Map<String,String> getColumnTooltips()
Gets the currently assigned column tooltips- Returns:
-
setColumnTooltip
public void setColumnTooltip(String column, String tooltip)
Adds a tooltip to a column- Parameters:
column
- The column nametooltip
- The tooltip text
-
isEnableClientFilter
public boolean isEnableClientFilter()
-
setEnableClientFilter
public void setEnableClientFilter(boolean enableClientFilter)
-
styledCell
public ResultMatrix.ResultMatrixStyledCell styledCell(Object value)
Creates a styled cell that can then be added as row value- Parameters:
value
- The value of the cell- Returns:
- The styled cell object that can then be further styled with e.g. the flow pattern .withXXX() methods
-
styledCell
public ResultMatrix.ResultMatrixStyledCell styledCell(Object value, String textColor, String bgColor)
Creates a styled cell that can then be added as row value- Parameters:
value
- The value of the celltextColor
- The text color of the cellbgColor
- The background color of the cell (HTML hex value)- Returns:
- The styled cell object
-
styledCell
public ResultMatrix.ResultMatrixStyledCell styledCell(Object value, String textColor, String bgColor, String weight)
Creates a styled cell that can then be added as row value- Parameters:
value
- The value of the celltextColor
- The text color of the cellbgColor
- The background color of the cell (HTML hex value)weight
- The font weight- Returns:
- The styled cell object
-
styledCell
public ResultMatrix.ResultMatrixStyledCell styledCell(Object value, String textColor, String bgColor, String weight, String alignment)
Creates a styled cell that can then be added as row value- Parameters:
value
- The value of the celltextColor
- The text color of the cellbgColor
- The background color of the cell (HTML hex value)weight
- The font weightalignment
- Cell alignement value (valid CSS)- Returns:
- The styled cell object
-
imageCell
public ResultMatrix.ResultMatrixImageCell imageCell(Object value)
Creates an image cell that can then be added as row value. Value should be a valid image URL- Parameters:
value
- The image URL- Returns:
- The image cell object
-
libraryImage
public ResultMatrix.ResultMatrixImageCell libraryImage(String mainName, String statusName)
-
linkToPriceGrid
public ResultMatrix.ResultMatrixLinkCell linkToPriceGrid(Object value, long priceGridID, Filter filter)
-
linkToPriceList
public ResultMatrix.ResultMatrixLinkCell linkToPriceList(Object value, long priceListID, Filter filter)
-
linkCell
public ResultMatrix.ResultMatrixLinkCell linkCell(Object value, String targetPage, String targetPageState)
-
backEndAction
public ResultMatrix.ResultMatrixBackEndCell backEndAction(String label, String url, String payload, String successMessage, String failMessage)
-
downloadButton
public ResultMatrix.ResultMatrixDownloadCell downloadButton(String label, String url, String payload)
-
cells
public ResultMatrix.ResultMatrixCells cells(String label, Object... cells)
-
onRowSelection
public ResultMatrix.ResultMatrixOnRowSelection onRowSelection()
Configures a client-side UI event. Use case is usually a refresh of some sort when a result matrix row is selected Example code:matrix.onRowSelection().triggerEvent(api.dashboardWideEvent("CustomerIdChanged-ED")).withColValueAsEventDataAttr("CustomerID", "customerId")
The embedded dashboard that receives the event could then look like:return api.dashboard("EmbeddedDashboard") // Here the user can assign values to the embedded // dashboard inputs common to all three modes .setParam("Customer Id", api.input("Customer Id")) .setParam("Year", api.input("Year")) // Show the dashboard embedded ... .showEmbedded() // ... and reevaluate it on "CustomerIdChanged-ED" // Note: "dashboardWideEvent()" fce makes the event local // to the containing dashboard instance .andRecalculateOn(api.dashboardWideEvent("CustomerIdChanged-ED")) // Pull the "customerId" attribute out of the event payload and expose it // as the "Customer Id" input to the embedded dashboard .withEventDataAttr("customerId").asParam("Customer Id")
- Returns:
- The selection event to further configure it in a flow pattern
-
getResultType
public String getResultType()
- Specified by:
getResultType
in interfaceComplexCalculationResult
-
-