Class BTSaveUserChangesNew

java.lang.Object
overit.geocall.bl.BusinessTask<Void>
overit.geocall.basic.bl.user.task.BTSaveUserChangesNew
All Implemented Interfaces:
Serializable, Tool

public class BTSaveUserChangesNew extends BusinessTask<Void>
Task used to save a copy of the user information into a table containing the historic user's data. In particular, it requires the user identifier on which a change has been made, starting from which the information is extracted from the registry table, compared with the most recent status saved in the history table, therefore, only if there is any variation in any of the specific fields, a new record is added to the history. This record will contain the user's data, the date on which the modification took place and the reference to the user authorizing the modification (potentially different from the modified user).
It is mandatory to provide the user identification key by invoking the setUser(long) method before starting the task.
Here is a code snippet that illustrate a typical use of this task inside a custom task:

 public class DATOperation {
      protected void body(PoolKit pk) throws DAException, DAValidateException {
          saveUserChanges(pk);
      }

      protected void saveUserChanges(PoolKit pk) {
          long userId=1L;
          boolean isPasswordChanged = true;
          try {
              BTSaveUserChangesNew btSaveUserChanges = Factory.make(BTSaveUserChangesNew.class, this);
              btSaveUserChanges.setUser(userId); // mandatory
              btSaveUserChanges.setPasswordChanged(isPasswordChanged); // optional
              btSaveUserChanges.start(null,pk);
          } catch (DAValidateException|DAException e) {
              // cannot register the user's change
          }
      }
 }
See Also:
  • Field Details

    • user

      protected Long user
    • passwordChanged

      protected boolean passwordChanged
  • Constructor Details

  • Method Details

    • setUser

      public void setUser(long user)
      Used to indicate the user that will be modified. For the correct operation of the task it is mandatory to invoke this method before execute the task.
      Parameters:
      user - user identification key
    • setPasswordChanged

      public void setPasswordChanged(boolean passwordChanged)
      Used to notify a change to the password field. If not invoked, no changes will be registered to the password field.
      Parameters:
      passwordChanged - boolean flag indicating if the password has been changed (true) or not (false).
    • body

      protected void body(Void i, PoolKit pk) throws DAException, DAValidateException
      Description copied from class: BusinessTask
      Implements this method to write the specific task logic to handle the input parameter.
      Specified by:
      body in class BusinessTask<Void>
      Parameters:
      i - the object upon which the task will works on
      pk - the poolkit containing the reference to the database connection that can be used
      Throws:
      DAException - in case of database error
      DAValidateException - in case of database validation error
    • isChangedSinceLastTime

      protected boolean isChangedSinceLastTime(HashGetter previousValues, HashGetter userData, Set<Long> roles)
    • isChanged

      protected boolean isChanged(HashGetter previousValues, String previousField, HashGetter currentValues, String currentField)
    • saveChanges

      protected void saveChanges(DAOUserChanges dao, PoolKit pk, HashGetter userData, Set<Long> roles) throws DAValidateException, DAException
      Throws:
      DAValidateException
      DAException