Interface AttributeColumnsController
-
public interface AttributeColumnsController
This interface defines part of the Data Laboratory API basic actions.
It contains methods for manipulating the attributes and properties of nodes and edges.
- Author:
- Eduardo Ramos
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Column
addAttributeColumn(Table table, String title, Class type)
Adds a new column to the specified table with the given title and type of column.Map<Object,Integer>
calculateColumnValuesFrequencies(Table table, Column column)
Calculates the absolute frequency of appearance of each value of the given column and returns a Map containing each different value mapped to its frequency of appearance.boolean
canChangeColumnData(Column column)
Indicates if the Data Laboratory API behaviour allows to change a value of the given column of a table.boolean
canClearColumnData(Column column)
Indicates if the Data Laboratory API behaviour allows to set as null a value of the given column of a table.boolean
canConvertColumnToDynamic(Column column)
Indicates if the Data Laboratory API behaviour allows to convert an existing column into its dynamic equivalent.boolean
canDeleteColumn(Column column)
Indicates if the Data Laboratory API behaviour allows to delete the given column of a table.void
clearColumnData(Table table, Column column)
Clears all rows data for a given column of a table (nodes table or edges table)void
clearEdgeData(Edge edge, Column[] columnsToClear)
Clears all edge attributes except computed attributes and id.void
clearEdgesData(Edge[] edges, Column[] columnsToClear)
Clears all the edges attributes except computed attributes and id, checking first that the edges are in the graph.void
clearNodeData(Node node, Column[] columnsToClear)
Clears all node attributes except computed attributes and id, checking first that the node is in the graph.void
clearNodesData(Node[] nodes, Column[] columnsToClear)
Clears all the nodes attributes except computed attributes and id.void
clearRowData(Element row, Column[] columnsToClear)
Clears row attributes except computed attributes and id if node/edge row.Column
convertAttributeColumnToDynamic(Table table, Column column, double low, double high)
Converts and replaces a table column with a dynamic column preserving original column values.Column
convertAttributeColumnToNewDynamicColumn(Table table, Column column, double low, double high, String newColumnTitle)
Converts a table column into a new dynamic column preserving original column values.void
copyColumnDataToOtherColumn(Table table, Column sourceColumn, Column targetColumn)
Copies all row values of a column to another column.void
copyEdgeDataToOtherEdges(Edge edge, Edge[] otherEdges, Column[] columnsToCopy)
Copies attributes data of the given edge to the other rows except computed attributes and id.void
copyNodeDataToOtherNodes(Node node, Node[] otherNodes, Column[] columnsToCopy)
Copies attributes data of the given node to the other rows except computed attributes and id.void
copyRowDataToOtherRows(Element row, Element[] otherRows, Column[] columnsToCopy)
Copies attributes data of the given row to the other rows except computed attributes and id if node/edge.Column
createBooleanMatchesColumn(Table table, Column column, String newColumnTitle, Pattern pattern)
Creates a newBOOLEAN
column from the given column and regular expression filling it with boolean values that indicate if each of the old column values match the regular expression.Column
createFoundGroupsListColumn(Table table, Column column, String newColumnTitle, Pattern pattern)
Creates a newLIST_STRING
column from the given column and regular expression with values that are the list of matching groups for the given regular expression for each row.void
deleteAttributeColumn(Table table, Column column)
Deletes the specified column from a table if the table has the column and data laboratory behaviour allows to delete it (seecanDeleteColumn
method).List<List<Node>>
detectNodeDuplicatesByColumn(Column column, boolean caseSensitive)
Finds and returns nodes duplicates based on the values of a given column of nodes tableColumn
duplicateColumn(Table table, Column column, String title, Class type)
Duplicates a given column of a table and copies al row values.void
fillColumnWithValue(Table table, Column column, String value)
Fills the data values of a given column of a table with a value as a String, parsing it for theClass
of the column.void
fillEdgesColumnWithValue(Edge[] edges, Column column, String value)
Fills the data values of a given column of the indicated edges with a value as a String, parsing it for theClass
of the column.void
fillNodesColumnWithValue(Node[] nodes, Column column, String value)
Fills the data values of a given column of the indicated nodes with a value as a String, parsing it for theClass
of the column.Number[]
getColumnNumbers(Table table, Column column)
Prepares an array with all not null numbers of all the rows of a given column.BigDecimal[]
getNumberOrNumberListColumnStatistics(Table table, Column column)
Calculates all statistics at once from a number/number list column usingMathUtils
class.Number[]
getRowNumbers(Element row, Column[] columns)
Prepares an array with all not null numbers of a row using only the given columns.Number[]
getRowsColumnNumbers(Element[] rows, Column column)
Prepares an array only with all not null numbers the indicated rows of a given column.Element[]
getTableAttributeRows(Table table)
Returns all rows of a given table (node or edges table).int
getTableRowsCount(Table table)
Counts the number of rows of a table (nodes or edges table) and returns the result.boolean
isEdgeColumn(Column column)
boolean
isEdgeTable(Table table)
Checks if the given table is edges table.boolean
isNodeColumn(Column column)
boolean
isNodeTable(Table table)
Checks if the given table is nodes table.boolean
isTableColumn(Table table, Column column)
void
mergeRowsValues(Column[] columns, AttributeRowsMergeStrategy[] mergeStrategies, Element[] rows, Element selectedRow, Element resultRow)
Merges the given rows values to the given result row using one merge strategy for each column of the table.void
negateBooleanColumn(Table table, Column column)
Negates not null values of a givenBOOLEAN
orLIST_BOOLEAN
column.boolean
setAttributeValue(Object value, Element row, Column column)
Sets a value to the given row,column pair (cell).
-
-
-
Method Detail
-
setAttributeValue
boolean setAttributeValue(Object value, Element row, Column column)
Sets a value to the given row,column pair (cell). If the class of the value is not the column type class, it will try to parse the
toString
representation of the value.Takes care to avoid parsing exceptions of the target column type.
Also, this will not set a null value to a column that can't have null values (see
canClearColumnData
method) if the given object is null or the parsing fails.- Parameters:
value
- Value to set, can be nullrow
- Rowcolumn
- Column- Returns:
- True if the value was set, false otherwise
-
addAttributeColumn
Column addAttributeColumn(Table table, String title, Class type)
Adds a new column to the specified table with the given title and type of column.
The title for the new column can't be repeated in the table, null or an empty string.
.The id of the column will be set to the same as the title, but if the first TimeInterval column of the table is created it will be given the default dynamic time interval id to be able to use dynamic filters.
The
AttributeOrigin
of the column will be set toDATA
.Default column value will be set to null.
- Parameters:
table
- Table to add the columntitle
- Title for the new column, can't be repeated in the table, null or empty stringtype
- Type for the new column- Returns:
- The created column or null if the column could not be created
-
duplicateColumn
Column duplicateColumn(Table table, Column column, String title, Class type)
Duplicates a given column of a table and copies al row values.
If the
Class
for the new column is different from the old column type, it will try to parse each value. If it is not possible, the value will be set to null.The title for the new column can't be repeated in the table, null or an empty string.
.The id of the column will be set to the title.
The
AttributeOrigin
of the column will be set toDATA
.Default column value will be set to null.
- Parameters:
table
- Table of the column to duplicatecolumn
- Column to duplicatetitle
- Title for the new columntype
- Class for the new column- Returns:
- The created column or null if the column could not be created
-
copyColumnDataToOtherColumn
void copyColumnDataToOtherColumn(Table table, Column sourceColumn, Column targetColumn)
Copies all row values of a column to another column.
If the
Class
for the target is different from the source column type, it will try to parse each value. If it is not possible, the value will be set to null.Source and target columns must be different.
- Parameters:
table
- Table of the columnssourceColumn
- Source columntargetColumn
- Target column
-
deleteAttributeColumn
void deleteAttributeColumn(Table table, Column column)
Deletes the specified column from a table if the table has the column and data laboratory behaviour allows to delete it (see
canDeleteColumn
method).- Parameters:
table
- Table to delete the columncolumn
- Column to delete
-
convertAttributeColumnToDynamic
Column convertAttributeColumnToDynamic(Table table, Column column, double low, double high)
Converts and replaces a table column with a dynamic column preserving original column values.
This should be used only in columns where the
canConvertColumnToDynamic
returns trueFor graphs with
INTERVAL
TimeRepresentation
, the new values have a default interval that uses thelow
andhigh
parameters.For graphs with
TIMESTAMP
TimeRepresentation
, the new values have a default timestamp that uses thelow
parameter,high
parameter is ignored.- Parameters:
table
- Table of the columncolumn
- Column to convert and replacelow
- Low bound for default interval or default timestamphigh
- High bound for default interval or ignored for timestamps- Returns:
- The new column
-
convertAttributeColumnToNewDynamicColumn
Column convertAttributeColumnToNewDynamicColumn(Table table, Column column, double low, double high, String newColumnTitle)
Converts a table column into a new dynamic column preserving original column values. The original column is kept intact
For graphs with
INTERVAL
TimeRepresentation
, the new values have a default interval that uses thelow
andhigh
parameters.For graphs with
TIMESTAMP
TimeRepresentation
, the new values have a default timestamp that uses thelow
parameter,high
parameter is ignored.- Parameters:
table
- Table of the columncolumn
- Column to convert to dynamiclow
- Low bound for default interval or default timestamphigh
- High bound for default interval or ignored for timestampsnewColumnTitle
- Title for the new dynamic column- Returns:
- The new column
-
fillColumnWithValue
void fillColumnWithValue(Table table, Column column, String value)
Fills the data values of a given column of a table with a value as a String, parsing it for the
Class
of the column. If it is not possible to parse, the value will be set to null.- Parameters:
table
- Table of the columncolumn
- Column to fillvalue
- String representation of the value for each row of the column
-
fillNodesColumnWithValue
void fillNodesColumnWithValue(Node[] nodes, Column column, String value)
Fills the data values of a given column of the indicated nodes with a value as a String, parsing it for the
Class
of the column. If it is not possible to parse, the value will be set to null.- Parameters:
nodes
- Nodes to fillcolumn
- Column to fillvalue
- String representation of the value for the column for each node
-
fillEdgesColumnWithValue
void fillEdgesColumnWithValue(Edge[] edges, Column column, String value)
Fills the data values of a given column of the indicated edges with a value as a String, parsing it for the
Class
of the column. If it is not possible to parse, the value will be set to null.- Parameters:
edges
- Edges to fillcolumn
- Column to fillvalue
- String representation of the value for the column for each edge
-
clearColumnData
void clearColumnData(Table table, Column column)
Clears all rows data for a given column of a table (nodes table or edges table)
- Parameters:
table
- Table to clear column datacolumn
- Column to clear data
-
calculateColumnValuesFrequencies
Map<Object,Integer> calculateColumnValuesFrequencies(Table table, Column column)
Calculates the absolute frequency of appearance of each value of the given column and returns a Map containing each different value mapped to its frequency of appearance.
- Parameters:
table
- Table of the columncolumn
- Column to calculate values frequencies- Returns:
- Map containing each different value mapped to its frequency of appearance
-
createBooleanMatchesColumn
Column createBooleanMatchesColumn(Table table, Column column, String newColumnTitle, Pattern pattern)
Creates a new
BOOLEAN
column from the given column and regular expression filling it with boolean values that indicate if each of the old column values match the regular expression.Title for the new column can't be repeated in the table, null or empty.
- Parameters:
table
- Table of the column to matchcolumn
- Column to matchnewColumnTitle
- Title for the new boolean columnpattern
- Regular expression to match- Returns:
- New created column or null if title is not correct
-
negateBooleanColumn
void negateBooleanColumn(Table table, Column column)
Negates not null values of a given
BOOLEAN
orLIST_BOOLEAN
column.Throws IllegalArgumentException if the column does not have
BOOLEAN
orLIST_BOOLEAN
Class
.- Parameters:
table
- Table of the column to negatecolumn
- Boolean column to negate
-
createFoundGroupsListColumn
Column createFoundGroupsListColumn(Table table, Column column, String newColumnTitle, Pattern pattern)
Creates a new
LIST_STRING
column from the given column and regular expression with values that are the list of matching groups for the given regular expression for each row.The title for the new column can't be repeated in the table, null or an empty string.
.- Parameters:
table
- Table of the column to matchcolumn
- Column to matchnewColumnTitle
- Title for the new boolean columnpattern
- Regular expression to match- Returns:
- New created column or null if title is not correct
-
clearNodeData
void clearNodeData(Node node, Column[] columnsToClear)
Clears all node attributes except computed attributes and id, checking first that the node is in the graph.
Columns to clear can be specified, but id and computed columns will not be cleared.
- Parameters:
node
- Node to clear datacolumnsToClear
- Columns of the node to clear. All columns will be cleared if it is null
-
clearNodesData
void clearNodesData(Node[] nodes, Column[] columnsToClear)
Clears all the nodes attributes except computed attributes and id.
Columns to clear can be specified, but id and computed columns will not be cleared.
- Parameters:
nodes
- Array of nodes to clear datacolumnsToClear
- Columns of the nodes to clear. All columns will be cleared if it is null
-
clearEdgeData
void clearEdgeData(Edge edge, Column[] columnsToClear)
Clears all edge attributes except computed attributes and id.
Columns to clear can be specified, but id and computed columns will not be cleared.
- Parameters:
edge
- Edge to clear datacolumnsToClear
- Columns of the edge to clear. All columns will be cleared if it is null
-
clearEdgesData
void clearEdgesData(Edge[] edges, Column[] columnsToClear)
Clears all the edges attributes except computed attributes and id, checking first that the edges are in the graph.
Columns to clear can be specified, but id and computed columns will not be cleared.
- Parameters:
edges
- Array of edges to clear datacolumnsToClear
- Columns of the edges to clear. All columns will be cleared if it is null
-
clearRowData
void clearRowData(Element row, Column[] columnsToClear)
Clears row attributes except computed attributes and id if node/edge row.
Columns to clear can be specified, but id of node/edge and computed columns will not be cleared.
- Parameters:
row
- Array of rows to clear datacolumnsToClear
- Columns of the row to clear. All columns will be cleared if it is null
-
copyNodeDataToOtherNodes
void copyNodeDataToOtherNodes(Node node, Node[] otherNodes, Column[] columnsToCopy)
Copies attributes data of the given node to the other rows except computed attributes and id.
Columns to copy can be specified, but id node and computed columns will not be copied.
- Parameters:
node
- Node to copy data fromotherNodes
- Nodes to copy data tocolumnsToCopy
- Columns of the node to copy. All columns will be copied if it is null
-
copyEdgeDataToOtherEdges
void copyEdgeDataToOtherEdges(Edge edge, Edge[] otherEdges, Column[] columnsToCopy)
Copies attributes data of the given edge to the other rows except computed attributes and id.
Columns to copy can be specified, but id edge and computed columns will not be copied.
- Parameters:
edge
- Edge to copy data fromotherEdges
- Edges to copy data tocolumnsToCopy
- Columns of the edge to copy. All columns will be copied if it is null
-
copyRowDataToOtherRows
void copyRowDataToOtherRows(Element row, Element[] otherRows, Column[] columnsToCopy)
Copies attributes data of the given row to the other rows except computed attributes and id if node/edge.
Columns to copy can be specified, but id of node/edge and computed columns will not be copied.
- Parameters:
row
- Row to copy data fromotherRows
- Rows to copy data tocolumnsToCopy
- Columns of the row to copy. All columns will be copied if it is null
-
getTableAttributeRows
Element[] getTableAttributeRows(Table table)
Returns all rows of a given table (node or edges table).
Used for iterating through all attribute rows of a table
- Parameters:
table
- Table to get attribute rows- Returns:
- Array of attribute rows of the table
-
getTableRowsCount
int getTableRowsCount(Table table)
Counts the number of rows of a table (nodes or edges table) and returns the result.
Uses
GraphElementsController
getNodesCount
andgetEdgesCount
to calculate the result.- Parameters:
table
-- Returns:
- the number of rows in
table
-
isNodeTable
boolean isNodeTable(Table table)
Checks if the given table is nodes table.
- Parameters:
table
- Table to check- Returns:
- True if the table is nodes table, false otherwise
-
isEdgeTable
boolean isEdgeTable(Table table)
Checks if the given table is edges table.
- Parameters:
table
- Table to check- Returns:
- True if the table is edges table, false otherwise
-
isNodeColumn
boolean isNodeColumn(Column column)
-
isEdgeColumn
boolean isEdgeColumn(Column column)
-
canDeleteColumn
boolean canDeleteColumn(Column column)
Indicates if the Data Laboratory API behaviour allows to delete the given column of a table.
The behaviour is: Any column that does not have a
AttributeOrigin
of typePROPERTY
can be deleted.- Parameters:
column
- Column to check if it can be deleted- Returns:
- True if it can be deleted, false otherwise
-
canChangeColumnData
boolean canChangeColumnData(Column column)
Indicates if the Data Laboratory API behaviour allows to change a value of the given column of a table.
The behaviour is: Only values of columns with
AttributeOrigin
of typeDATA
or a node/edge label and weight column can be changed. (but weight can't be null. seecanClearColumnData
method).- Parameters:
column
- Column to check if values can be changed- Returns:
- True if the column values can be changed, false otherwise
-
canClearColumnData
boolean canClearColumnData(Column column)
Indicates if the Data Laboratory API behaviour allows to set as null a value of the given column of a table.
The behaviour is: Only values of columns with
AttributeOrigin
of typeDATA
or a node/edge label column can be set to null. Edge weight can't be null- Parameters:
column
- Column to check if values can be changed- Returns:
- True if the column values can be changed, false otherwise
-
canConvertColumnToDynamic
boolean canConvertColumnToDynamic(Column column)
Indicates if the Data Laboratory API behaviour allows to convert an existing column into its dynamic equivalent.
The behaviour is: Only values of columns with
AttributeOrigin
of typeDATA
and edge weight can be converted.- Parameters:
column
- Column to check if can be converted- Returns:
- True if the column can be converted to dynamic, false otherwise
-
getNumberOrNumberListColumnStatistics
BigDecimal[] getNumberOrNumberListColumnStatistics(Table table, Column column)
Calculates all statistics at once from a number/number list column using
Returns an array of length=8 ofMathUtils
class.BigDecimal
numbers with the results in the following order:- average
- first quartile (Q1)
- median
- third quartile (Q3)
- interquartile range (IQR)
- sum
- minimumValue
- maximumValue
The column can only be a number/number list column.
Otherwise, a IllegalArgumentException will be thrown.
- Parameters:
table
- Table of the columncolumn
- Column to get statistics- Returns:
- Array with statistics
-
getColumnNumbers
Number[] getColumnNumbers(Table table, Column column)
Prepares an array with all not null numbers of all the rows of a given column.
The column can only be a number/number list column.
Otherwise, a IllegalArgumentException will be thrown.
- Parameters:
table
- Table of the column to get numberscolumn
- Column to get numbers- Returns:
- Array with all numbers.
-
getRowsColumnNumbers
Number[] getRowsColumnNumbers(Element[] rows, Column column)
Prepares an array only with all not null numbers the indicated rows of a given column.
The column can only be a number/number list column.
Otherwise, a IllegalArgumentException will be thrown.
- Parameters:
rows
- Rows to get numberscolumn
- Column to get numbers- Returns:
- Array with all numbers.
-
getRowNumbers
Number[] getRowNumbers(Element row, Column[] columns)
Prepares an array with all not null numbers of a row using only the given columns.
The columns can only be number/dynamic number/number list columns (in any combination).
All numbers intervals of a dynamic number column will be used.
Otherwise, a IllegalArgumentException will be thrown.
- Parameters:
row
- Row to get numberscolumns
- Columns of the row to use- Returns:
- Array with all numbers
-
mergeRowsValues
void mergeRowsValues(Column[] columns, AttributeRowsMergeStrategy[] mergeStrategies, Element[] rows, Element selectedRow, Element resultRow)
Merges the given rows values to the given result row using one merge strategy for each column of the table.
The number of columns must be equal to the number of merge strategies provided
No parameters can be null except selectedRow (first row will be used in case selectedRow is null)
If any strategy is null, the value of the selectedRow will be used
- Parameters:
columns
- Columns to apply a merge strategy in each rowmergeStrategies
- Strategies for each column incolumns
rows
- Rows to merge (at least 1)selectedRow
- Main selected row or null (first row will be used in case selectedRow is null)resultRow
- Already existing row to put the values on
-
detectNodeDuplicatesByColumn
List<List<Node>> detectNodeDuplicatesByColumn(Column column, boolean caseSensitive)
Finds and returns nodes duplicates based on the values of a given column of nodes table
A node is a duplicate of other if they have the same value (String representation of the values is used) in the given column.
This is useful to be used to automatically merge duplicated nodes
- Parameters:
column
- Column to use values to detect duplicatescaseSensitive
- Case insensitivity when comparing the column values- Returns:
- List of node duplicates groups (at least 2 nodes in each group)
-
-