public abstract class AbstractChangeBusinessObjectDocumentCmdImpl extends AbstractActionBusinessObjectDocumentCmdImpl implements BusinessObjectDocumentCmd
The abstract change business object document command is an abstract controller implementation for processing Change requests. The abstract controller extracts the verb from the requests and create the appropriate tasks to represent the actions. This abstract controller is responsible for the common processing logic and has specific call out to fetch and persist the data that is involved with the request.
For the change request processing pattern, the logic is broken into three types of commands. The first command is the Change controller command that helps to break the request into smaller tasks and execute these tasks. These smaller task commands will act upon parts of the noun instead of the entire noun. The controller also attempts to fetch the required data for the request and pass this data to the other task commands so the command uses and update common data elements. This is to avoid data collision between task commands where they may act upon the same data and to avoid the performance overhead of each task commit changes and the next task must read from the database to pick up those changes. Once all the tasks are executed, the data read upfront is persisted so the changes is committed in the database.
The second type of command is the Add, Change and Delete task commands that will perform the appropriate action on the noun. These task only needs to deal with a particular part of the noun and is passed the action to perform, the part of the noun that has changed and the original request noun along with the data that was retrieved by the controller. The controller can have many instances of these task commands to act upon the many parts that are being changed as part of the message. The controller is responsible to executing the different task commands to perform the entire change operation and these change tasks just need to work with a single noun and single part being modified.
The final type of command is any post business logic that may result because of a change of that part of the noun. These business logic tasks may not be necessary but there are cases where post evaluation on the changed business object is needed as a result of changing specific parts. The change controller will create instances of these business tasks and execute them after performing the change actions. These tasks are given the actions performed on the part, the original request noun and the currently read and updated data that has not been persisted yet. These business logic tasks are optional so if no implementation is found then the change controller will assume no additional business logic is required.
Constructor and Description |
---|
AbstractChangeBusinessObjectDocumentCmdImpl()
Creates an instance of the change controller business object document command.
|
Modifier and Type | Method and Description |
---|---|
protected BusinessObjectDocumentType | buildRespondBusinessObjectDocument(java.util.Map nounsAndActions, java.util.Map persistentObjects)
This method builds and returns the business object document that represents the response of this change request.
|
protected void | canPerformAction(java.util.Map nounsAndActions, java.util.Map persistentObjects)
This method performs an authorization check to determine whether the current user has the appropriate permissions to perform the actions on the specified nouns.
|
protected java.lang.String | getChangeNounPartActionCommandInterface()
This method returns the interface name of the command that represents the tasks to change selected parts of the noun.
|
protected java.lang.String | getChangeNounPartPostActionCommandInterface()
This method returns the interface name of the command that represents the tasks to change selected parts of the noun.
|
protected java.lang.String | getChangeNounPartPreActionCommandInterface()
This method returns the interface name of the command that represents the pre-action tasks which could be done before to change the selected parts of the noun.
|
java.lang.String | getNounName()
This method returns the name of the noun extracted from the request business object document.
|
protected java.lang.String | getVerbName()
This method returns the name of the verb to extract from the request business object document.
|
protected boolean | isAuthorizationOnNounParts()
This method indicates when performing the authorization check on the actions being performed on the noun, whether to use the noun or the noun part as part of the check.
|
protected void | performAction()
Performs the request by executing the pre-noun change, pre-noun part change, change noun parts, post noun part, post noun change business logic commands instantiated in the validateAction() method.
|
protected java.util.Map | read(java.util.Set nouns)
The purpose of this method is to return a list of objects that represent the data that is involved with this change request.
|
protected void | save(java.util.Map persistentObjects)
The purpose of this method is to save the changes that are contained in the list of persistent objects.
|
void | setAuthorizationOnNounParts(java.lang.String authorizationOnNounParts)
This method sets whether the authorization check should be performed on the noun or the part of the noun being changed.
|
void | setChangeNounPartActionCommandInterface(java.lang.String changeNounPartActionCmdInterface)
This method sets the command interface name that represents the business logic that will perform the change noun part tasks.
|
void | setChangeNounPartPostActionCommandInterface(java.lang.String changeNounPartPostActionCmdInterface)
This method sets the command interface name that represents the business logic that will perform the change noun part tasks post action logic.
|
protected void | validate(java.util.Map nounsAndActions, java.util.Map persistentObjects)
This method should perform any high level validation on the nouns and actions that have been parsed from the request business object document along with the read operation.
|
protected void | validateAction()
This method will validate the action and all the action expressions associated with the action before executing the tasks.
|
public AbstractChangeBusinessObjectDocumentCmdImpl()
protected java.lang.String getChangeNounPartPreActionCommandInterface()
protected java.lang.String getChangeNounPartActionCommandInterface()
public void setChangeNounPartActionCommandInterface(java.lang.String changeNounPartActionCmdInterface)
protected java.lang.String getChangeNounPartPostActionCommandInterface()
public void setChangeNounPartPostActionCommandInterface(java.lang.String changeNounPartPostActionCmdInterface)
protected boolean isAuthorizationOnNounParts()
public void setAuthorizationOnNounParts(java.lang.String authorizationOnNounParts)
protected void validateAction() throws java.lang.Exception
This method will validate the action and all the action expressions associated with the action before executing the tasks. The validate action will extract the action expressions from the request business object document. Then the action expressions are grouped by noun for the parts of the noun that is changed. Each group of noun parts will have the corresponding change task command instantiated, passing the list of action expressions and the noun to work on. After the read(), validate() and canPerformActions() is invoked to resolve the nouns, perform common noun validation and perform an access control check to ensure the request can be processed.
If the change request is to be processed the change noun part task commands have the read() and validate() methods invoked to retrieve the data required for this command and validate the data. The post business logic commands are also instantiated for each noun and changed noun part. It is not required to have a post business logic task command.
protected java.lang.String getVerbName()
protected java.util.Map read(java.util.Set nouns) throws AbstractApplicationException
protected void validate(java.util.Map nounsAndActions, java.util.Map persistentObjects) throws AbstractApplicationException
protected void canPerformAction(java.util.Map nounsAndActions, java.util.Map persistentObjects) throws AbstractApplicationException
protected void performAction() throws java.lang.Exception
protected BusinessObjectDocumentType buildRespondBusinessObjectDocument(java.util.Map nounsAndActions, java.util.Map persistentObjects)
protected void save(java.util.Map persistentObjects) throws AbstractApplicationException
public java.lang.String getNounName()