Class Crosstab

  • All Implemented Interfaces:
    java.io.Serializable

    public class Crosstab
    extends java.lang.Object
    implements java.io.Serializable
    Cross table definition
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      Crosstab​(java.lang.String id, ObjectDB object, java.lang.String name, java.lang.String display, char method, char visible, boolean fixedcolors, boolean grantable)
      Constructor
    • Method Summary

      Modifier and Type Method Description
      void addAxis​(java.lang.String fullInput, char type, int order, ObjectField field, ObjectDB obj, char method, java.lang.String chart, int precision, boolean subtotal, java.lang.String formula, java.lang.String display, boolean hidden)
      Add a field in the crosstab
      void addGrantedGroup​(java.lang.String group)  
      void build​(ObjectDB obj)
      Build pivot table
      java.util.ArrayList<java.lang.Object>[][] build​(java.util.List<java.lang.String> columns, java.util.List<java.lang.String> lines, java.util.Map<java.lang.String,​java.lang.String> labels, Grant g)
      Build pivot table
      Crosstab.NodeLine buildLineTree​(Grant g, java.util.List<java.lang.String> lines, java.util.Map<java.lang.String,​java.lang.String> labels, java.util.List<java.lang.Object>[][] val, boolean bText)  
      void clear()
      Clear memory
      static Crosstab.Axis getAxis​(java.util.List<Crosstab.Axis> axis, int index)
      Get the field associated with axis
      Crosstab.Axis getAxisForFullInput​(char type, java.lang.String fullInput)
      Get axis of specified type for specified input name
      java.lang.String getCaption()
      Caption position top|bottom|left|right
      java.util.List<java.lang.Object>[][] getCellValues()  
      java.lang.String getChart()
      Chart to display on front (without back-end Graphic)
      java.lang.String getChartHeight()
      Chart height to display on front (without back-end Graphic)
      java.lang.String getChartWidth()
      Chart width to display on front (without back-end Graphic)
      java.lang.String getColor​(int lineIndex, java.lang.String serieLabel)
      Series color
      java.util.Map<java.lang.String,​java.lang.String> getColors()
      Serie label = #RRGGBB
      java.util.List<Crosstab.Axis> getColumnAxis​(boolean all)
      Definition of columns axis
      java.lang.String getColumnLabel​(java.lang.String key, java.lang.String separator)  
      java.util.List<java.lang.String> getColumnValues()  
      static java.lang.String getCrosstabId​(java.lang.String name)
      Crosstab id
      java.util.List<java.lang.String[]> getCurrentColors()
      Current displayed colors
      java.lang.String getDisplay()
      Get translation
      static ObjectField getField​(ObjectDB obj, java.util.List<Crosstab.Axis> axis, int index)
      Get the field associated with axis
      java.util.List<java.lang.String> getGrantedGroups()
      Granted groups
      Graphic getGraphic()  
      java.lang.String getId()
      Crosstab id
      java.lang.String getLabel()
      Get translation (alias to getDisplay)
      java.util.Map<java.lang.String,​java.lang.String> getLabels()  
      java.util.List<Crosstab.Axis> getLineAxis​(boolean all)
      Definition of lines axis
      java.lang.String getLineLabel​(java.lang.String key, java.lang.String separator, ObjectField value)  
      java.util.List<java.lang.String> getLineValues()  
      char getMethod()
      Crosstab method
      java.lang.String getName()
      Crosstab name
      ObjectDB getObject()
      Object
      java.lang.String getPaletteName()
      Palette of colors
      int getPrecision()
      Precision
      Crosstab.NodeLine getRoot()  
      java.lang.String getSubtotalColor​(int level)  
      java.util.List<Crosstab.Axis> getValueAxis​(boolean all)
      Definition of values axis
      char getVisibility()
      Action visibility Action.ACTION_ALL | ACTION_HIDDEN | ACTION_PLUS
      boolean hasFormulas()
      Has formula values ?
      void init​(ObjectDB obj)
      Initialize the data
      boolean isControlVisible()
      Controls visible
      boolean isEditable()
      EXPERIMENTAL
      The cell is editable if the value is linked to a unique row in DB:
      - functional keys = heads values (column and row)
      - other mandatory field are known
      boolean isEnabled()  
      boolean isFixedColors()
      Fixed colors ?
      boolean isGrantable()
      Grantable ?
      boolean isGranted​(Grant g)  
      boolean isLoaded()  
      boolean isSubtotalVisible()
      Display sub totals ?
      boolean isTableVisible()
      Crosstable visible ?
      boolean isVisible()
      Visible ?
      void nodeInsert​(int line, java.lang.String path, Crosstab.NodeLine n, java.util.List<java.lang.Object>[] val)  
      Crosstab.NodeLine nodeSearch​(java.lang.String path, Crosstab.NodeLine nl)  
      void removeGrantedGroup​(java.lang.String group)  
      void resetCurrentColors()  
      void setCaption​(java.lang.String caption)  
      void setCellValues​(java.util.ArrayList<java.lang.Object>[][] v)  
      void setChart​(java.lang.String chart)  
      void setChartHeight​(java.lang.String height)  
      void setChartWidth​(java.lang.String width)  
      void setColor​(java.lang.String serieLabel, java.lang.String color)  
      void setColumnValues​(java.util.List<java.lang.String> v)  
      void setControlVisible​(boolean b)  
      void setDisplay​(java.lang.String d)  
      void setEnabled​(boolean enabled)  
      void setFixedColors​(boolean fixed)  
      void setGrantable​(boolean b)  
      void setGraphic​(Graphic g)  
      void setLabel​(java.lang.String d)  
      void setLabels​(java.util.HashMap<java.lang.String,​java.lang.String> h)  
      void setLineValues​(java.util.List<java.lang.String> v)  
      void setLoaded​(boolean b)  
      void setMethod​(char m)  
      void setPaletteName​(java.lang.String name)  
      void setPrecision​(int n)  
      void setSubtotalColor​(java.lang.String c)
      Color of the total line (#RRGGBB)
      void setSubtotalVisible​(boolean b)  
      void setTableVisible​(boolean b)  
      void setVisible​(boolean b)  
      void setVisible​(char vis)
      Set action visibility
      java.lang.String toChartData​(java.lang.String type, int line, java.lang.String title)
      Publish to chart data
      java.lang.String toCSV​(java.lang.String sep, Grant g)
      Publish pivot table to CSV
      byte[] toExcel​(Grant g, java.lang.String table, java.lang.String format)
      Publish pivot table to Excel sheet
      java.lang.String toExcelHTML​(Grant g, java.lang.String table)
      Publish pivot table wrapped into an HTML Excel sheet
      byte[] toExcelPOI​(Grant g)
      Publish pivot table to binary Excel sheet
      java.lang.String toHTML​(Grant g, boolean cubes)
      Publish pivot table as raw HTML
      void toHTML​(Grant g, boolean cubes, java.io.PrintWriter out)
      Publish pivot table as raw HTML on specified print writer.
      java.lang.String toJSON()
      Publish to JSON { columns, lines, data } (does not support big decimals and sub-totals)
      java.lang.String toJSONCubes()
      Publish to JSON cubes
      java.lang.String toJSONDefinition()  
      java.lang.String toJSONTree()
      Prepared crosstab with tree of lines and up-to-date metadata { data:{columns,lines}, meta }, with sub-totals, colors and big decimals
      java.lang.String toString()  
      java.lang.String toXML()  
      java.lang.String toXSD()
      Publish pivot table in XSD format
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Crosstab

        public Crosstab​(java.lang.String id,
                        ObjectDB object,
                        java.lang.String name,
                        java.lang.String display,
                        char method,
                        char visible,
                        boolean fixedcolors,
                        boolean grantable)
        Constructor
        Parameters:
        id - Crosstab id
        object - Object
        name - Crosstable name
        display - Label to display
        method - Group method
        visible - Visible ?
        fixedcolors - Use fixed colors ?
        grantable - Granted to groups ?
    • Method Detail

      • getDisplay

        public java.lang.String getDisplay()
        Get translation
        Returns:
        translation
      • getLabel

        public java.lang.String getLabel()
        Get translation (alias to getDisplay)
        Returns:
        translation
      • setDisplay

        public void setDisplay​(java.lang.String d)
      • setLabel

        public void setLabel​(java.lang.String d)
      • isVisible

        public boolean isVisible()
        Visible ?
        Returns:
        is Visible ?
      • getVisibility

        public char getVisibility()
        Action visibility Action.ACTION_ALL | ACTION_HIDDEN | ACTION_PLUS
        Returns:
        Action visibility
      • setVisible

        public void setVisible​(boolean b)
      • setVisible

        public void setVisible​(char vis)
        Set action visibility
        Parameters:
        vis - Action.ACTION_ALL or Action.ACTION_HIDDEN or Action.ACTION_PLUS
      • isGrantable

        public boolean isGrantable()
        Grantable ?
        Returns:
        Grantable ?
      • setGrantable

        public void setGrantable​(boolean b)
      • getGrantedGroups

        public java.util.List<java.lang.String> getGrantedGroups()
        Granted groups
        Returns:
        Granted groups
      • addGrantedGroup

        public void addGrantedGroup​(java.lang.String group)
      • removeGrantedGroup

        public void removeGrantedGroup​(java.lang.String group)
      • isGranted

        public boolean isGranted​(Grant g)
      • isFixedColors

        public boolean isFixedColors()
        Fixed colors ?
        Returns:
        Fixed colors ?
      • setFixedColors

        public void setFixedColors​(boolean fixed)
      • getPaletteName

        public java.lang.String getPaletteName()
        Palette of colors
        Returns:
        Palette of colors
      • setPaletteName

        public void setPaletteName​(java.lang.String name)
      • getAxisForFullInput

        public Crosstab.Axis getAxisForFullInput​(char type,
                                                 java.lang.String fullInput)
        Get axis of specified type for specified input name
        Parameters:
        type - Axis type (one of Crosstab.Axis.AXIS_*)
        fullInput - Axis input name
        Returns:
        null if not found
      • getColumnAxis

        public java.util.List<Crosstab.Axis> getColumnAxis​(boolean all)
        Definition of columns axis
        Parameters:
        all - All axis (otherwise only non hidden axis are returned) ?
        Returns:
        Definition of columns axis
      • getLineAxis

        public java.util.List<Crosstab.Axis> getLineAxis​(boolean all)
        Definition of lines axis
        Parameters:
        all - All axis (otherwise only non hidden axis are returned) ?
        Returns:
        Definition of lines axis
      • getValueAxis

        public java.util.List<Crosstab.Axis> getValueAxis​(boolean all)
        Definition of values axis
        Parameters:
        all - All axis (otherwise only non hidden axis are returned) ?
        Returns:
        Definition of values axis
      • hasFormulas

        public boolean hasFormulas()
        Has formula values ?
        Returns:
        Has formula values ?
      • getMethod

        public char getMethod()
        Crosstab method
        Returns:
        Crosstab method
      • setMethod

        public void setMethod​(char m)
      • setColumnValues

        public void setColumnValues​(java.util.List<java.lang.String> v)
      • getColumnValues

        public java.util.List<java.lang.String> getColumnValues()
      • setLineValues

        public void setLineValues​(java.util.List<java.lang.String> v)
      • getLineValues

        public java.util.List<java.lang.String> getLineValues()
      • setLabels

        public void setLabels​(java.util.HashMap<java.lang.String,​java.lang.String> h)
      • getLabels

        public java.util.Map<java.lang.String,​java.lang.String> getLabels()
      • getColumnLabel

        public java.lang.String getColumnLabel​(java.lang.String key,
                                               java.lang.String separator)
      • getLineLabel

        public java.lang.String getLineLabel​(java.lang.String key,
                                             java.lang.String separator,
                                             ObjectField value)
      • setCellValues

        public void setCellValues​(java.util.ArrayList<java.lang.Object>[][] v)
      • getCellValues

        public java.util.List<java.lang.Object>[][] getCellValues()
      • setGraphic

        public void setGraphic​(Graphic g)
      • getGraphic

        public Graphic getGraphic()
      • getChart

        public java.lang.String getChart()
        Chart to display on front (without back-end Graphic)
      • setChart

        public void setChart​(java.lang.String chart)
      • getChartWidth

        public java.lang.String getChartWidth()
        Chart width to display on front (without back-end Graphic)
      • setChartWidth

        public void setChartWidth​(java.lang.String width)
      • getChartHeight

        public java.lang.String getChartHeight()
        Chart height to display on front (without back-end Graphic)
      • setChartHeight

        public void setChartHeight​(java.lang.String height)
      • getColor

        public java.lang.String getColor​(int lineIndex,
                                         java.lang.String serieLabel)
        Series color
        Parameters:
        lineIndex - line
        serieLabel - label
        Returns:
        color
      • setColor

        public void setColor​(java.lang.String serieLabel,
                             java.lang.String color)
      • getColors

        public java.util.Map<java.lang.String,​java.lang.String> getColors()
        Serie label = #RRGGBB
        Returns:
        colors
      • getCurrentColors

        public java.util.List<java.lang.String[]> getCurrentColors()
        Current displayed colors
        Returns:
        Current displayed colors
      • resetCurrentColors

        public void resetCurrentColors()
      • getId

        public java.lang.String getId()
        Crosstab id
        Returns:
        Crosstab id
      • getCrosstabId

        public static java.lang.String getCrosstabId​(java.lang.String name)
        Crosstab id
        Parameters:
        name - Crosstab name
        Returns:
        Crosstab id
      • getObject

        public ObjectDB getObject()
        Object
        Returns:
        Object
      • getName

        public java.lang.String getName()
        Crosstab name
        Returns:
        Crosstab name
      • isLoaded

        public boolean isLoaded()
      • setLoaded

        public void setLoaded​(boolean b)
      • isEnabled

        public boolean isEnabled()
      • setEnabled

        public void setEnabled​(boolean enabled)
      • isTableVisible

        public boolean isTableVisible()
        Crosstable visible ?
        Returns:
        Crosstable visible ?
      • setTableVisible

        public void setTableVisible​(boolean b)
      • getCaption

        public java.lang.String getCaption()
        Caption position top|bottom|left|right
        Returns:
        position CAPTION_*
      • setCaption

        public void setCaption​(java.lang.String caption)
      • isControlVisible

        public boolean isControlVisible()
        Controls visible
        Returns:
        Controls visible
      • setControlVisible

        public void setControlVisible​(boolean b)
      • isSubtotalVisible

        public boolean isSubtotalVisible()
        Display sub totals ?
        Returns:
        Display sub totals ?
      • setSubtotalVisible

        public void setSubtotalVisible​(boolean b)
      • setSubtotalColor

        public void setSubtotalColor​(java.lang.String c)
        Color of the total line (#RRGGBB)
        Parameters:
        c - subtotal color
      • getSubtotalColor

        public java.lang.String getSubtotalColor​(int level)
      • getPrecision

        public int getPrecision()
        Precision
        Returns:
        precision
      • setPrecision

        public void setPrecision​(int n)
      • addAxis

        public void addAxis​(java.lang.String fullInput,
                            char type,
                            int order,
                            ObjectField field,
                            ObjectDB obj,
                            char method,
                            java.lang.String chart,
                            int precision,
                            boolean subtotal,
                            java.lang.String formula,
                            java.lang.String display,
                            boolean hidden)
        Add a field in the crosstab
        Parameters:
        fullInput - Full input name
        type - Type (one of Crosstab.Axis.AXIS_*)
        order - Axis order
        field - Object field
        method - Group by method
        obj - Object
        chart - Chart type
        precision - Precision
        subtotal - Sub total ?
        formula - Formula
        display - Display
        hidden - Hidden ?
      • init

        public void init​(ObjectDB obj)
        Initialize the data
        Parameters:
        obj - Object with filters for search
      • clear

        public void clear()
        Clear memory
      • isEditable

        public boolean isEditable()
        EXPERIMENTAL
        The cell is editable if the value is linked to a unique row in DB:
        - functional keys = heads values (column and row)
        - other mandatory field are known
        Returns:
        True if the cell is editable
      • getAxis

        public static Crosstab.Axis getAxis​(java.util.List<Crosstab.Axis> axis,
                                            int index)
        Get the field associated with axis
        Parameters:
        axis - Axis
        index - Position
        Returns:
        Field or null
      • getField

        public static ObjectField getField​(ObjectDB obj,
                                           java.util.List<Crosstab.Axis> axis,
                                           int index)
        Get the field associated with axis
        Parameters:
        obj - Object
        axis - Axis
        index - Position
        Returns:
        Field or null
      • build

        public java.util.ArrayList<java.lang.Object>[][] build​(java.util.List<java.lang.String> columns,
                                                               java.util.List<java.lang.String> lines,
                                                               java.util.Map<java.lang.String,​java.lang.String> labels,
                                                               Grant g)
        Build pivot table
        Parameters:
        columns - Column headers
        lines - Row headers
        labels - Labels
        g - User rights
        Returns:
        Values for each table cell (String or Double)
      • build

        public void build​(ObjectDB obj)
        Build pivot table
        Parameters:
        obj - Object
      • toXSD

        public java.lang.String toXSD()
        Publish pivot table in XSD format
      • toJSONDefinition

        public java.lang.String toJSONDefinition()
      • toJSON

        public java.lang.String toJSON()
        Publish to JSON { columns, lines, data } (does not support big decimals and sub-totals)
      • toJSONTree

        public java.lang.String toJSONTree()
        Prepared crosstab with tree of lines and up-to-date metadata { data:{columns,lines}, meta }, with sub-totals, colors and big decimals
      • toJSONCubes

        public java.lang.String toJSONCubes()
        Publish to JSON cubes
      • toChartData

        public java.lang.String toChartData​(java.lang.String type,
                                            int line,
                                            java.lang.String title)
        Publish to chart data
        Parameters:
        type - Type
        line - Line
        title - Title
      • toExcel

        public byte[] toExcel​(Grant g,
                              java.lang.String table,
                              java.lang.String format)
        Publish pivot table to Excel sheet
        Parameters:
        g - Grant
        table - Table
        format - Format (one of Globals.EXCEL_*)
      • toExcelHTML

        public java.lang.String toExcelHTML​(Grant g,
                                            java.lang.String table)
        Publish pivot table wrapped into an HTML Excel sheet
        Parameters:
        g - Grant
        table - HTML table
      • toExcelPOI

        public byte[] toExcelPOI​(Grant g)
        Publish pivot table to binary Excel sheet
        Parameters:
        g - Grant
      • toCSV

        public java.lang.String toCSV​(java.lang.String sep,
                                      Grant g)
        Publish pivot table to CSV
        Parameters:
        sep - Separator
        g - Grant
        Returns:
        CSV
      • toHTML

        public java.lang.String toHTML​(Grant g,
                                       boolean cubes)
        Publish pivot table as raw HTML
        Parameters:
        g - Grant
        cubes - true generate data as cubes, false generates as pivot table
        Returns:
        Publish pivot table as raw HTML
      • toHTML

        public void toHTML​(Grant g,
                           boolean cubes,
                           java.io.PrintWriter out)
        Publish pivot table as raw HTML on specified print writer.
        Parameters:
        g - Grant
        cubes - true generate data as cubes, false generates as pivot table
        out - Print writer
      • toXML

        public java.lang.String toXML()
      • nodeInsert

        public void nodeInsert​(int line,
                               java.lang.String path,
                               Crosstab.NodeLine n,
                               java.util.List<java.lang.Object>[] val)
      • buildLineTree

        public Crosstab.NodeLine buildLineTree​(Grant g,
                                               java.util.List<java.lang.String> lines,
                                               java.util.Map<java.lang.String,​java.lang.String> labels,
                                               java.util.List<java.lang.Object>[][] val,
                                               boolean bText)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object