Class StaticView

java.lang.Object
overit.geocall.platform.ui.UINode
overit.geocall.basic.ui.StaticView
All Implemented Interfaces:
Serializable, overit.geocall.marks.MethodExposer, overit.geocall.marks.NameExposer, Identified

@Component public class StaticView extends UINode implements Identified, overit.geocall.marks.NameExposer, overit.geocall.marks.MethodExposer, Serializable
This class implements a logical view of a portion of a database table. It is a static object that can be automatically loaded (the system makes a query to the database, depending on the attributes set to the object) in the startup phase of the application, and can be maintained in memory.
Being kept in memory, each access to this object is very quick, because we don't need to interrogate the database to retrieve the records.
When we change a table that has a StaticView associated, we must invalidate the view, to force the system to load the updated data from the database, and maintain in memory an up to date view.
Every StaticView is defined by an xml placed inside the folder named global located under the applicative root folder.
A typical example of tables that can be mapped into StaticViews is the tables that defines the typologies, because this type of tables has the right characteristics of dimensionality and staticity suitable to be kept in memory and don't be often loaded from the database.
See Also:
  • Field Details

    • _KEY_MAP

      public static final String _KEY_MAP
      String that defines the name of the attribute that will contains the key map
      See Also:
    • LOAD_DATE

      public static final String LOAD_DATE
      String that defines the name of the attribute that will contains the date of last load
      See Also:
    • KEY_FIELD

      public static final String KEY_FIELD
      String that defines the name of the attribute that contains the key field
      See Also:
    • _ord

      protected String _ord
    • _pool

      protected String _pool
    • _visible

      protected String _visible
    • _table

      protected String _table
    • _branch

      protected String _branch
    • _factory

      protected String _factory
    • _keyField

      protected String _keyField
    • _from

      protected String _from
    • _to

      protected String _to
    • _filter

      protected String _filter
    • _clause

      protected String _clause
    • _unusedField

      protected String _unusedField
      Recyclable field that can be used for future purpose (ex callcenter)
    • _clauses

      protected ArrayList _clauses
    • branch

      protected Long branch
    • _dbt

      protected transient DBTable _dbt
    • _bogus

      protected boolean _bogus
    • _hm

      protected static HashMap _hm
    • _identity

      protected Identity _identity
  • Constructor Details

    • StaticView

      public StaticView()
  • Method Details

    • setORD

      public void setORD(String s)
      Sets the name of the field (or the list of fields, separated by the comma) used for the sorting of the values of the StaticView
      Parameters:
      s - The string that defines the name of the field used for sorting
    • setPOOL

      public void setPOOL(String s)
      Sets the name of the ConnectionPool from which extract the connection to retrieve the table to which the StaticView refers
      Parameters:
      s - The string that defines the name of the pool
    • setTABLE

      public void setTABLE(String s)
      Sets the name of the table to which the StaticView refers
      Parameters:
      s - The string that defines the name of the table
    • setVISIBLE

      public void setVISIBLE(String s)
      Sets the name of the field used to determine if a record is visible (must be inserted in the StaticView) or not
      Parameters:
      s - The string that defines the name of the field used for the visibility
    • setCLAUSE

      public void setCLAUSE(String s)
      Sets an sql clause used to filter the records of the StaticView. The records loaded are the ones that we obtains making a query like SELECT * FROM TABLE WHERE CLAUSE
      Parameters:
      s - A string that defines an sql clause used to extract the records
    • setFILTER

      public void setFILTER(String s)
      Sets a condition used to filter the records of the StaticView.
      Parameters:
      s - A string that defines a filter on the records
    • setBRANCH

      public void setBRANCH(String s)
      Sets the name of the field used as foreign key field of the branches table
      Parameters:
      s - The string that defines the name of the foreign key field of the branches table
    • setFACTORY

      public void setFACTORY(String s)
      Sets the name of the field used as foreign key field of the companies table
      Parameters:
      s - The string that defines the name of the foreign key field of the companies table
    • setKEYFIELD

      public void setKEYFIELD(String s)
      Sets the name of the field that contains the key of the table
      Parameters:
      s - The string that defines the name of the key field of the table
    • setFROM

      public void setFROM(String s)
      Sets the name of the field that contains a date value that will be used as constraint in the extraction of the records. The record extracted will have, in the field settet by this method, a date that is greater or equal to the one returned by Date()
      Parameters:
      s - The name of a date field, used as range constraints
    • setTO

      public void setTO(String s)
      Sets the name of the field that contains a date value that will be used as constraint in the extraction of the records. The record extracted will have, in the field settet by this method, a date that is less or equal to the one returned by Date()
      Parameters:
      s - The name of a date field, used as range constraints
    • setBOGUS

      public void setBOGUS(String s)
      If set to true defines that the StaticView must reload its values (making a query) on every access to its DBView. A bogus StaticView is a StaticView that don't use the caching mechanism
      Parameters:
      s - true to obtain a bogus StaticView, false otherwise
    • getCacheKey

      protected String getCacheKey()
    • getCacheKeyPart

      protected String getCacheKeyPart()
    • getCacheViewPart

      protected String getCacheViewPart()
    • invalidate

      public void invalidate()
      Invalidates the StaticView (if it is not a bogus one), that means that is cleared from the cache and the next access to the getDBView() will make a query to the database to extract the records
    • invalidateAll

      public static void invalidateAll()
      Invalidates all the StaticViews
    • getDBView

      public DBView getDBView()
      Returns the DBView that corresponds to the StaticView. It makes the query to the database only if it is necessary (ie if the StaticView is a bogus one or if it has been invalidated), otherwise it returns the DBView stored in memory.
      Returns:
      A new DBView that contains the StaticView records
    • isChangedSince

      public boolean isChangedSince(Date currentDate)
      Check if the date of the last loading made from the database, it was made before the date passed as a parameter.
      It can be used,for example, to check if the StaticView has been invalidated, previously to the date passed as parameter.
      Parameters:
      currentDate - The Date passed as parameter, after which you want to know if the StaticView's DBView, has been reloaded from the database or not.
      Returns:
      true if the StaticView was invalidated after the date passed as a parameter,false otherwise.
    • selectDBView

      protected DBView selectDBView()
    • getDBView

      public DBView getDBView(boolean filterDeleted)
      Returns a DBView corresponding to the current StaticView, optionally filtering out records based on a visibility condition.

      If filterDeleted is false, this method behaves exactly like getDBView() and returns the unmodifiable underlying view as-is, without applying any filtering.

      If filterDeleted is true, and a visibility field has been defined using setVISIBLE(String), this method creates a new, editable DBView instance. This new view will include only those rows for which the visibility field equals Boolean.TRUE. This filtering process creates a full copy of the visible data.

      Note: If your goal is to work with a filtered subset of the data, it is generally more efficient to retrieve the full unfiltered DBView via getDBView(), and then compute the subset manually, based on your own logic. Use getDBView(true) only if you specifically need a filtered, editable copy of the data.

      Parameters:
      filterDeleted - false to return the original unfiltered and unmodifiable view (same as getDBView()); true to return a new editable view containing only rows marked as visible (if a visibility field has been defined)
      Returns:
      A DBView representing either the full data or a filtered subset, depending on the parameter
    • getKeyField

      public String getKeyField()
      Returns the name of the field that contains the key of the table
      Returns:
      The string that defines the name of the key field of the table
    • getTable

      public String getTable()
      Returns the name of the table to which the StaticView refers
      Returns:
      The string that defines the name of the table
    • getVisibleField

      public String getVisibleField()
      Returns the name of the field used to determine if a record is visible (must be inserted in the StaticView) or not
      Returns:
      The string that defines the name of the field used for the visibility
    • getLoadDate

      public static Date getLoadDate(DBView dbv)
      Returns the date of the last load of the StaticView
      Parameters:
      dbv - The DBView associated to the StaticView
      Returns:
      The date of the last load. It gets the attribute LOAD_DATE
    • getIndexByKey

      public static int getIndexByKey(DBView dbv, Object o)
      Returns the index of the record of the StaticView with the key passed as parameter
      Parameters:
      dbv - The DBView in which search the record
      o - The object used as the key searched
      Returns:
      The index of the record, or -1 if the record does not exists
    • getRowMapByKey

      public static HashGetter getRowMapByKey(DBView dbv, Object o)
      Returns the row map DBView.getRowMap(int) of the record of the StaticView with the key passed as parameter
      Parameters:
      dbv - The DBView in which search the record
      o - The object used as the key searched
      Returns:
      The row map of the record, or null if the record does not exists
    • getRowListByKey

      public static ArrayList getRowListByKey(DBView dbv, Object o)
      Returns the row list DBView.getRowList(int) of the record of the StaticView with the key passed as parameter
      Parameters:
      dbv - The DBView in which search the record
      o - The object used as the key searched
      Returns:
      The row list of the record, or null if the record does not exists
    • getViews

      public static HashMap getViews()
      Returns the views
      Returns:
      The views
    • getIdentity

      public Identity getIdentity()
      Description copied from interface: Identified
      Returns the Identity associated to the component
      Specified by:
      getIdentity in interface Identified
      Returns:
      The Identity of the user currently logged in the application
    • setIdentity

      public void setIdentity(Identity id)
      Description copied from interface: Identified
      Sets the Identity to the component
      Specified by:
      setIdentity in interface Identified
      Parameters:
      id - The Identity that must be associated to the component
    • getRoot

      public UINode getRoot()
      Description copied from class: UINode
      Returns the root of the user interface component definition tree of this UINode
      Overrides:
      getRoot in class UINode
      Returns:
      The root UINode