Class CommandContext

java.lang.Object
overit.geocall.da.CommandContext

public class CommandContext extends Object
Class that defines a context of operation of each command associated with a DAO. Each object will contain a Command and can have filters and / or values, that are the maps that will be used by DAO to determine the SQL code, through the inferential rules contained in it.
In addition to filters and values, the context may contain other parameters, such as the maximum number of rows to extract or the number of rows to skip for select commands; moreover the context will contain, at the end of the execution of the associated command, the result obtained.
  • Field Details

  • Constructor Details

    • CommandContext

      public CommandContext(Command c)
      Creates a new instance of CommandContext
      Parameters:
      c - The Command associated to the context
  • Method Details

    • getFilter

      public Map<String,Object> getFilter()
      Returns the filter of the context
      Returns:
      The Map that contains the key / value pairs (where the keys are field names or control variables) that will be used as filters by the command
    • setFilter

      public CommandContext setFilter(Map<String,Object> filter)
      Sets the filter for the context
      Parameters:
      filter - An Map that contains the key / value pairs (where the keys are field names or control variables) that will be used as filters by the command
      Returns:
      This instance of CommandContext with the given filter
    • addFilter

      public CommandContext addFilter(Object... pairs)
      Adds one or more key / value pairs to the filters
      Parameters:
      pairs - The pairs to add to the filter map
      Returns:
      This instance of CommandContext with the filter added
    • getValues

      public Map<String,Object> getValues()
      Returns the values of the context
      Returns:
      The Map that contains the key / value pairs (where the keys are field) that will be used as values by the command
    • setValues

      public CommandContext setValues(Map<String,Object> values)
      Sets the values for the context
      Parameters:
      values - An Map that contains the key / value pairs (where the keys are field names or control variables) that will be used as values by the command
      Returns:
      This instance of CommandContext with the given values
    • addValues

      public CommandContext addValues(Object... pairs)
      Adds one or more key / value pairs to the values
      Parameters:
      pairs - The pairs to add to the values map
      Returns:
      This instance of CommandContext with the values added
    • getParams

      public Map<String,Object> getParams()
      Returns the map that is the result of the merge of the filters and values map and in which for each filter field name the string F: is prefixed and for each values field name the string V: is prefixed, to avoid conflicts
      Returns:
      The Map containing the parameters
    • setParams

      public void setParams(HashMap<String,Object> params)
      Sets the parameters
      Parameters:
      params - The HashMap that is the result of the merge of the filters and values map and in which for each filter field name the string F: is prefixed and for each values field name the string V: is prefixed
    • getMaxRows

      public int getMaxRows()
      Return the maximum number of rows that can be extracted with the queries of this CommandContext
      Returns:
      The int that represent the maximum number of rows that can be extracted with the queries
    • setMaxRows

      public CommandContext setMaxRows(int maxRows)
      Sets the maximum number of rows that can be extracted with the queries of this CommandContext
      Parameters:
      maxRows - The maximum number of rows
      Returns:
      This instance of CommandContext with the given attribute
    • getSkipRows

      public int getSkipRows()
      Return the number of rows that must be skipped for the queries of this CommandContext
      Returns:
      The int that represent the number of rows that must be skipped for the queries
    • setSkipRows

      public CommandContext setSkipRows(int skipRows)
      Sets the number of rows that must be skipped for the queries of this CommandContext
      Parameters:
      skipRows - The number of rows to skip
      Returns:
      This instance of CommandContext with the given attribute
    • getOrder

      public String getOrder()
      Returns the string that can be used to define a particular sorting. How to use this string depends on the specific implementation and instance of DAO
      Returns:
      The string that can define a particular sorting; it can be a control field (lowercase), a list of fields (uppercase), etc.
    • setOrder

      public CommandContext setOrder(String order)
      Sets a string that can be used by the DAO, in particular by the DAO.getOrder(overit.geocall.da.CommandContext) method, to specify a particular sorting; it can be a control field (lowercase), a list of fields (uppercase), etc. How to use this string depends on the specific implementation and instance of DAO
      Parameters:
      order - A string that can define a particular sorting
      Returns:
      This instance of CommandContext with the given attribute
    • setOrder

      public CommandContext setOrder(@NotNull @NotNull Order order)
      Sets a String starting from the Order object passed as parameter.
      It can be used by the DAO, in particular by the DAO.getOrder(overit.geocall.da.CommandContext) method, to specify a particular sorting
      How to use this string depends on the specific implementation and instance of DAO
      Parameters:
      order - An object that can define a particular sorting
      Returns:
      This instance of CommandContext with the given attribute
    • getCommand

      public Command getCommand()
      Returns the Command associated to this context
      Returns:
      The Command associated to this context
    • setCommand

      public void setCommand(Command command)
      Sets the Command to this context
      Parameters:
      command - The Command to set to this context
    • getSql

      public Sql getSql()
      Returns the SQL code of this context
      Returns:
      The Sql object that defines the SQL code for this context
    • setSql

      public void setSql(Sql sql)
      Sets the SQL code of this context
      Parameters:
      sql - The Sql object that defines the SQL code for this context
    • getStatementObserver

      public DBStatementObserver getStatementObserver()
      Returns the DBStatementObserver used by the context to notify the operating phases of the DBStatement
      Returns:
      The instance of DBStatementObserver
    • setStatementObserver

      public void setStatementObserver(DBStatementObserver dbso)
      Sets the DBStatementObserver used by the context to notify the operating phases of the DBStatement
      Parameters:
      dbso - The instance of DBStatementObserver to set
    • getResult

      public Object getResult()
      Returns the result of the command
      Returns:
      The object that defines the result of the command (it can be a DBView) or an integer
    • setResult

      public void setResult(Object result)
      Sets the result of the command
      Parameters:
      result - The object that defines the result of the command (it can be a DBView) or an integer
    • setSequenceNextVal

      public void setSequenceNextVal(Long sequenceNextVal)
      Sets the sequence value required to perform an insert using the DAO.
      Parameters:
      sequenceNextVal - Long about the sequence value.
    • getSequenceNextVal

      public Long getSequenceNextVal(PoolKit poolKit, String table, String sequence) throws DAException
      Returns a Long about the sequence value.
      Returns:
      a Long about the sequence value.
      Throws:
      DAException