Class DAO0

java.lang.Object
overit.geocall.da.DAO0
All Implemented Interfaces:
Serializable, overit.geocall.marks.FieldExposer, overit.geocall.marks.NameExposer, DBFieldMapper, DBObjectMapper, Identified
Direct Known Subclasses:
overit.geocallapp.wfm.workorder.scheduling.DAOIntervention, DAONotifications, DAOUserState, overit.geocallapp.wfm.schedulazione.anagrafiche.tipiodltestate.DAOWOTypes

@Deprecated public class DAO0 extends Object implements DBFieldMapper, DBObjectMapper, Identified, overit.geocall.marks.FieldExposer, overit.geocall.marks.NameExposer, Serializable
Deprecated.
Use DAO instead Class to extend when you want to create an object that accesses a table of the database. The goal of the class is to avoid writing SQL and going to build inferential rules that, based on the parameter map passed, can deduce the SQL code to be created. To use the class you need to extend it and using the annotation that gives the fundamental information of the table that you want to map.
This class implements some basic functions such the selection of one or all the table records or the deletion, insertion or updating of a record.
The methods that can be extended to create the desired logic are: validate(CommandContext, PooledConnection) to perform a validation on the data, defineValues(CommandContext, PooledConnection) to set up the values, getFilterCriterion(CommandContext) to insert the Criteria that will build the SQL code and feedback(CommandContext, PooledConnection, DBStatement) to manage the results.
See Also:
  • Field Details

    • SELECT_FILTER

      public static final Command SELECT_FILTER
      Deprecated.
      Standard Command that implements the query: SELECT * FROM TABLE WHERE ... = ?
    • SELECT_NONE

      public static final Command SELECT_NONE
      Deprecated.
      Standard Command that implements the empty query: SELECT * FROM TABLE WHERE 1 = 0
    • SELECT_PK

      public static final Command SELECT_PK
      Deprecated.
      Standard Command that implements the query: SELECT * FROM TABLE WHERE PRIMARY_KEY = ?
    • DELETE_FILTER

      public static final Command DELETE_FILTER
      Deprecated.
      Standard Command that deletes a record, using the filter passed to the CommandContext
    • DELETE_PK

      public static final Command DELETE_PK
      Deprecated.
      Standard Command that deletes a record, using the primary key field passed to the CommandContext
    • UPDATE_FILTER

      public static final Command UPDATE_FILTER
      Deprecated.
      Standard Command that updates a record, using the filter passed to the CommandContext
    • UPDATE_PK

      public static final Command UPDATE_PK
      Deprecated.
      Standard Command that updates a record, using the primary key passed to the CommandContext
    • INSERT

      public static final Command INSERT
      Deprecated.
      Standard Command that inserts a new record
    • INSERT_ATTEMPT

      public static final Command INSERT_ATTEMPT
      Deprecated.
      Standard Command that tries to insert a new record; if the insert fails, returns the value 0 and not an error
    • UPSERT

      public static final Command UPSERT
      Deprecated.
      Standard UPSERT Command: tries to make an update, if fails do an insert
    • INSATE

      @Deprecated public static final Command INSATE
      Deprecated.
      use DAO.UPSERT, DAO.INSERT or DAO.UPDATE_PK according to your needs. The correct functioning of this Command on all databases is not guaranteed (Postgres aborts the transaction if the INSERT raises a unique constraint violation, and the subsequent UPDATE will fail).
      Standard INSATE Command: tries to make an insert with the INSERT_ATTEMPT, if obtains 0 (meaning that the insert has failed) do an update
    • _dbfm

      protected DBFieldMap _dbfm
      Deprecated.
    • _dbom

      protected DBObjectMap _dbom
      Deprecated.
  • Constructor Details

    • DAO0

      public DAO0()
      Deprecated.
  • Method Details

    • commandForName

      public final Command commandForName(String name)
      Deprecated.
      Returns the Command that corresponds to the query or command name passed as parameter
      Parameters:
      name - The string that defines the name of a query or command
      Returns:
      The instance of Command that corresponds to the string passed as parameter or null if there isn't such Command, or an exception occurs
    • getTeacher

      public Teacher getTeacher()
      Deprecated.
      Returns the Teacher used for the translations by the DAO
      Returns:
      The Teacher instance associated to the DAO
    • getDBFieldMap

      public DBFieldMap getDBFieldMap()
      Deprecated.
      Description copied from interface: DBFieldMapper
      Returns the DBFieldMap object
      Specified by:
      getDBFieldMap in interface DBFieldMapper
      Returns:
      The map used for the transformations of fields names
    • setDBFieldMap

      public void setDBFieldMap(DBFieldMap dbfm)
      Deprecated.
      Description copied from interface: DBFieldMapper
      Sets the DBFieldMap object
      Specified by:
      setDBFieldMap in interface DBFieldMapper
      Parameters:
      dbfm - The map used for the transformations of fields names
    • haveDBFieldMap

      public boolean haveDBFieldMap()
      Deprecated.
      Description copied from interface: DBFieldMapper
      Checks if there is a correct DBFieldMap object
      Specified by:
      haveDBFieldMap in interface DBFieldMapper
      Returns:
      true if there is a correct DBFieldMap, false otherwise
    • getDBObjectMap

      public DBObjectMap getDBObjectMap()
      Deprecated.
      Description copied from interface: DBObjectMapper
      Returns the DBObjectMap contained in the instance
      Specified by:
      getDBObjectMap in interface DBObjectMapper
      Returns:
      The map of objects used in this instance
    • setDBObjectMap

      public void setDBObjectMap(DBObjectMap dbom)
      Deprecated.
      Description copied from interface: DBObjectMapper
      Sets the DBObjectMap contained in the instance
      Specified by:
      setDBObjectMap in interface DBObjectMapper
      Parameters:
      dbom - The map of objects used in this instance
    • haveDBObjectMap

      public boolean haveDBObjectMap()
      Deprecated.
      Description copied from interface: DBObjectMapper
      Checks the presence of a valid DBObjectMap contained in the instance.
      Specified by:
      haveDBObjectMap in interface DBObjectMapper
      Returns:
      true if the instance contains a map of object that is not null, false otherwise
    • getIdentity

      public Identity getIdentity()
      Deprecated.
      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 identity)
      Deprecated.
      Description copied from interface: Identified
      Sets the Identity to the component
      Specified by:
      setIdentity in interface Identified
      Parameters:
      identity - The Identity that must be associated to the component
    • getFactory

      public String getFactory()
      Deprecated.
      Returns the name of the field of the table in which is stored the "factory id" value, set with the Factory annotation
      Returns:
      The string that represents the name of the field of the table in which is stored the "factory id" value, that is, the foreign key to the factories table
    • getBranch

      public String getBranch()
      Deprecated.
      Returns the name of the field of the table in which is stored the "branch id" value, set with the Branch annotation
      Returns:
      The string that represents the name of the field of the table in which is stored the "branch id" value, that is, the foreign key to the branches table
    • getPool

      public String getPool()
      Deprecated.
      Returns the name of the pool from which the specific DAO extracts the connections when they are not explicitly passed to methods.
      Returns:
      The name of the pool, as indicated in the configuration file, from which the specific DAO extracts the connections.
    • getPk

      public String[] getPk()
      Deprecated.
      Returns the array that contains the primary keys of the specific table on which the DAO acts.
      Returns:
      Array that contains the names of the fields that are primary keys of the specific table
    • getSequence

      public String getSequence()
      Deprecated.
      Returns a string that represent the name of the field used as sequence for the insert commands on the table.
      Returns:
      The name of the sequence field or null if there isn't a defined sequence
    • isService

      public boolean isService()
      Deprecated.
      Returns the boolean value that determines whether connection extraction takes place from the standard pool or the service pool
      Returns:
      false for ordinary connection extraction, true for ServicePool extraction
    • isDistinct

      public boolean isDistinct(CommandContext cc)
      Deprecated.
      Returns the boolean value that determines whether the queries use the DISTINCT clause or not
      Parameters:
      cc - The CommandContext associated to the DAO
      Returns:
      true if the queries use the DISTINCT, false otherwise
    • getStar

      public String[] getStar(CommandContext cc)
      Deprecated.
      Returns the array that contains the field list for all the select queries.
      Parameters:
      cc - The CommandContext associated to the DAO
      Returns:
      The array of strings that represents the names of the columns to be extracted; the default value is the array consisting of a single element, the character *
    • getTable

      public String getTable(CommandContext cc)
      Deprecated.
      Returns the name of the table on which the specific DAO acts
      Parameters:
      cc - The CommandContext associated to the DAO
      Returns:
      The string that represents the name of the table on which the DAO want to access and operate
    • getLevel

      public String getLevel()
      Deprecated.
      Returns the name of the field of the table in which is stored the "level" value, so that the optimistic lock can be managed.
      Returns:
      The String about the name of the field of the table in which is stored the "level" value, so that the optimistic lock can be managed.
    • getOrder

      public String[] getOrder(CommandContext cc)
      Deprecated.
      Returns the array that contains the names of the columns on which we want to make the sorting of the results of the queries.
      The method checks for the presence of a sort string in the CommandContext, the one returned by the CommandContext.getOrder() method; the default implementation interprets the string as a comma-separated list of field names on which you want to sort query results. The presence of the exclamation point in front of a field name defines the will to order in a descending direction with respect to that field.
      The extensions of this method can define their own grammar for the received string.
      If there is no sort string in the CommandContext, the fields are searched using the annotation Group
      Parameters:
      cc - The {CommandContext} associated to the DAO
      Returns:
      The array of strings that represents the name of the columns, and the corresponding sorting verse, used for the sorting of the results of the queries;
    • getGroup

      public String[] getGroup(CommandContext cc)
      Deprecated.
      Returns the array that contains the names of the columns on which we want to group the reults of the queries.
      Parameters:
      cc - The CommandContext associated to the DAO
      Returns:
      The array of strings that represents the name of the columns used for the grouping of the results of the queries
    • getFilterCriterion

      protected Criterion getFilterCriterion(CommandContext cc)
      Deprecated.
      Method to extend to go to introduce the inferential rules with which to deduce the SQL automatically based on the context passed as a parameter.
      Parameters:
      cc - The CommandContext associated to the DAO
      Returns:
      The Criterion used to create the SQL By default the method returns the Criteria.SEARCH_STRONG for the commands that refers to key fields and the Criteria.SEARCH for all the other commands.
    • getValuesCriterion

      protected Criterion getValuesCriterion(CommandContext cc)
      Deprecated.
      Method that defines the Criterion used for the different commands
      Parameters:
      cc - The CommandContext associated to the DAO
      Returns:
      Criteria.INSERT_ASSIGN for the Command.Type.INSERT commands, Criteria.UPDATE_ASSIGN for the Command.Type.UPDATE commands
    • execute

      public void execute(CommandContext cc) throws DAException, DAValidateException
      Deprecated.
      Executes the command; it extracts a new PooledConnection from the pool
      Parameters:
      cc - The CommandContext associated to the DAO
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • execute

      public void execute(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException
      Deprecated.
      Executes the command
      Parameters:
      cc - The CommandContext associated to the DAO; it can't be null
      pc - The PooledConnection used to connect to the database; it can't be null
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • query

      Deprecated.
      Executes the query defined by the CommandContext passed as parameter
      Parameters:
      cc - The CommandContext associated to the DAO;
      Returns:
      The DBView that contains the records extracted
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • query

      Deprecated.
      Executes the query defined by the CommandContext passed as parameter
      Parameters:
      cc - The CommandContext associated to the DAO;
      pc - The PooledConnection used to connect to the database;
      Returns:
      The DBView that contains the records extracted
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • command

      public int command(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException
      Deprecated.
      Executes the command defined by the CommandContext passed as parameter
      Parameters:
      cc - The CommandContext associated to the DAO;
      pc - The PooledConnection used to connect to the database;
      Returns:
      The number of records that have been entered, modified or deleted
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • command

      public int command(CommandContext cc) throws DAException, DAValidateException
      Deprecated.
      Executes the command defined by the CommandContext passed as parameter
      Parameters:
      cc - The CommandContext associated to the DAO;
      Returns:
      The number of records that have been entered, modified or deleted
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • validate

      protected void validate(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException
      Deprecated.
      Method to extend if you want to implement some logic of data validation; it can raise a DAException, or better, a DAValidateException. By default the method verifies that, if the command requested is a command that refers to a key field, that key field has been defined for the DAO and that the key field is among those passed as filter.
      Parameters:
      cc - The CommandContext associated to the DAO
      pc - The PooledConnection from which extract the connections
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • defineValues

      protected void defineValues(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException
      Deprecated.
      Method to extend to go to prepare the values operating Java side, for example making calculations, avoiding to operate SQL side that is much more difficult, inconvenient, difficult to maintain and not portable. Changing the values in this method can have a return in the application mask, since the same map of values is used, and not a clone of it. By default the method sets the correct values for the sequence, the datastamp and login, where necessary.
      Parameters:
      cc - The CommandContext associated to the DAO
      pc - The PooledConnection from which extract the connections
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • defineParams

      protected void defineParams(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException
      Deprecated.
      The method performs a cloning of the maps of the filters and of the values and makes a merge, putting before the filter field names the string F: and before the value field names the string V: to avoid possible conflicts; this is necessary because the same field can be used with different semantics, as a filter and as a value, for example for the UPDATE_FILTER commands
      Parameters:
      cc - The CommandContext associated to the DAO
      pc - The PooledConnection from which extract the connections
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • defineSql

      protected void defineSql(CommandContext cc, PooledConnection pc) throws DAException, DAValidateException
      Deprecated.
      The method creates the SQL command using the language of the criteria, and in particular based on the method getFilterCriterion(CommandContext)
      Parameters:
      cc - The CommandContext associated to the DAO
      pc - The PooledConnection from which extract the connections
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • defineStatement

      protected void defineStatement(CommandContext cc, PooledConnection pc, DBStatement dbs) throws DAException, DAValidateException
      Deprecated.
      The method defines the DBStatement, sets the SQL and the parameters for the execution of the commands
      Parameters:
      cc - The CommandContext associated to the DAO
      pc - The PooledConnection from which extract the connections
      dbs - The DBStatement that is used to access the database
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown
    • feedback

      protected void feedback(CommandContext cc, PooledConnection pc, DBStatement dbs) throws DAException, DAValidateException
      Deprecated.
      Method to be extended to carry out operations exploiting the result of the executed command; for example it can be used to implement CASE WHEN logics that can therefore be deleted from the SQL. The standard makes recursive calls for the correct execution of the UPSERT and INSATE operations
      Parameters:
      cc - The CommandContext associated to the DAO
      pc - The PooledConnection from which extract the connections
      dbs - The DBStatement that is used to access the database
      Throws:
      DAException - If there is a (blocking) data-access error, a DAException must be thrown
      DAValidateException - If there are error in the validation phase, a DAValidateException must be thrown