public class UserFormTransformer<U extends User,UA extends UserAttribute> extends Object implements org.apache.commons.collections.Transformer
Transformer that takes in a MapUser or UserAttribute instance.Map with the entities replaced by the merged or transformed versions.
Transformer does not perform validation. One can put a MapTransformer that validates every entity before this one is called.
getSessionUser(HttpServletRequest) if you want to use this in a non Wicket environment.ServletRequestToEntitiesTransformer,
(for more advanced merge dynamic scenarios)| Modifier and Type | Class and Description |
|---|---|
static class |
UserFormTransformer.UserIdSetter |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
mergeWithCurrentSessionUser
If true The form input are assumed to represent the user with the Current Web Session.
|
protected UserAttributesDao<UA> |
userAttributesDao |
protected UserDao<U> |
userDao |
| Constructor and Description |
|---|
UserFormTransformer() |
| Modifier and Type | Method and Description |
|---|---|
String |
getServletRequestContextAccessor()
Expected name of the key/accessor in the input Map that will contain the
HttpServletRequest context variable |
protected U |
getSessionUser(javax.servlet.http.HttpServletRequest r) |
UserAttributesDao<UA> |
getUserAttributesDao() |
UserDao<U> |
getUserDao() |
boolean |
isMergeWithCurrentSessionUser()
If true The form input are assumed to represent the user with the Current Web Session.
|
Map |
merge(Map entityMap,
U user) |
protected U |
saveUser(U userObject,
U userSessionObject)
Identify if the entity is a fresh independent entity or an update of an existing one.
Persist accordingly |
protected UA |
saveUserAttribute(UA userAttribObject,
U userSessionObject)
The resultant object is a merged object to ensure an update can be performed if the userSessioObject is valid and related to this user
Persist accordingly |
void |
setMergeWithCurrentSessionUser(boolean mergeWithCurrentSessionUser)
If true The form input are assumed to represent the user with the Current Web Session.
|
void |
setServletRequestContextAccessor(String servletRequestContextAccessor)
Expected name of the key/accessor in the input Map that will contain the
HttpServletRequest context variable |
void |
setUserAttributesDao(UserAttributesDao<UA> userAttributesDao) |
void |
setUserDao(UserDao<U> userDao) |
Object |
transform(Object input) |
protected void |
updateExisting(UA userAttribObject,
U userSessionObject)
To ensure if the attribute being saved is updated, we need to check for existing attribute for the userSessionObject
and accordingly set it up to be updated or keep it an insert operation.
|
protected void |
validate(U user)
Custom Validation for raw input
User |
protected void |
validate(UA userAttribute)
Custom Validation for raw input
UserAttribute |
protected UserAttributesDao<UA extends UserAttribute> userAttributesDao
protected boolean mergeWithCurrentSessionUser
protected void validate(U user)
Useruser - as Uprotected void validate(UA userAttribute)
UserAttributeuserAttribute - as UA@Transactional(readOnly=false) protected U saveUser(U userObject, U userSessionObject)
userObject - as UuserSessionObject - as Userprotected void updateExisting(UA userAttribObject, U userSessionObject)
userAttribObject - as UAuserSessionObject - as U@Transactional(readOnly=false) protected UA saveUserAttribute(UA userAttribObject, U userSessionObject)
userObject - as UuserSessionObject - as User@Transactional(readOnly=false) public Object transform(Object input)
transform in interface org.apache.commons.collections.Transformerprotected U getSessionUser(javax.servlet.http.HttpServletRequest r)
public UserAttributesDao<UA> getUserAttributesDao()
public void setUserAttributesDao(UserAttributesDao<UA> userAttributesDao)
public boolean isMergeWithCurrentSessionUser()
public void setMergeWithCurrentSessionUser(boolean mergeWithCurrentSessionUser)
public String getServletRequestContextAccessor()
HttpServletRequest context variablepublic void setServletRequestContextAccessor(String servletRequestContextAccessor)
HttpServletRequest context variableCopyright © 2018. All rights reserved.