Class BTSaveUserChangesNew
- All Implemented Interfaces:
Serializable,Tool
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
Here is a code snippet that illustrate a typical use of this task inside a custom task:
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBTSaveUserChangesNew(DAOUsers daoUsers, DAOUserTypesUsers daoUserTypesUsers, DAOUserChanges daoUserChanges) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidImplements this method to write the specific task logic to handle the input parameter.protected booleanisChanged(HashGetter previousValues, String previousField, HashGetter currentValues, String currentField) protected booleanisChangedSinceLastTime(HashGetter previousValues, HashGetter userData, Set<Long> roles) protected voidsaveChanges(DAOUserChanges dao, PoolKit pk, HashGetter userData, Set<Long> roles) voidsetPasswordChanged(boolean passwordChanged) Used to notify a change to the password field.voidsetUser(long user) Used to indicate the user that will be modified.Methods inherited from class overit.geocall.bl.BusinessTask
start, start, startAlone, startInBackground
-
Field Details
-
user
-
passwordChanged
protected boolean passwordChanged
-
-
Constructor Details
-
BTSaveUserChangesNew
public BTSaveUserChangesNew(DAOUsers daoUsers, @Qualifier("default") DAOUserTypesUsers daoUserTypesUsers, @Qualifier("default") DAOUserChanges daoUserChanges)
-
-
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
Description copied from class:BusinessTaskImplements this method to write the specific task logic to handle the input parameter.- Specified by:
bodyin classBusinessTask<Void>- Parameters:
i- the object upon which the task will works onpk- the poolkit containing the reference to the database connection that can be used- Throws:
DAException- in case of database errorDAValidateException- 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:
DAValidateExceptionDAException
-