com.ibm.commerce.approval.commands

Class HandleApprovalsCmdImpl

  • java.lang.Object
    • com.ibm.websphere.command.CacheableCommandImpl
      • com.ibm.commerce.command.MeasuredCacheableCommandImpl
        • com.ibm.commerce.command.AbstractECTargetableCommand
          • com.ibm.commerce.command.ControllerCommandImpl
            • com.ibm.commerce.tools.command.ToolsControllerCommandImpl
              • com.ibm.commerce.approval.commands.HandleApprovalsCmdImpl
  • All Implemented Interfaces:
    HandleApprovalsCmd, com.ibm.commerce.command.AccCommand, com.ibm.commerce.command.ControllerCommand, com.ibm.commerce.command.ECCommand, com.ibm.commerce.command.ECTargetableCommand, com.ibm.commerce.security.Protectable, com.ibm.commerce.tools.command.ToolsControllerCommand, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command


    public class HandleApprovalsCmdImpl
    extends com.ibm.commerce.tools.command.ToolsControllerCommandImpl
    implements HandleApprovalsCmd
    Processes approvals or rejections. The approver may either approve or reject one or more approval requests. The approver may supply an optional comment which will be stored in the approval request's record in the APRVSTATUS table. This comment can be viewed by the request submitter.

    Behaviour

    This command will raise a business flow event to handle each approval or rejection. The business flow event will handle the updating of the APRVSTATUS table as well as any other activities which have been defined for this transition. The status of the approval requests record in the APRVSTATUS table will be updated to 1 for approved or 2 for rejected.

    The command treats each approval or rejection as a separate transaction. It is possible that if command is invoked to process a batch of approvals or rejections, some may succeed and others may fail.

    The command will set the resultMsg for the view it sets to indicate the success or failure of the processing. The value of resultmsg will be the appropriate key into the approvalsNLS properties file for the message to be displayed by the JSP.

    This command uses the following AccessBeans:

    • ApprovalStatusAccessBean
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Integer getAprvAct()
      Gets the action.
      java.lang.String getAprvIds()
      Gets the list of approval status IDs to be acted on.
      java.lang.String getComments()
      Gets the comments
      com.ibm.commerce.datatype.TypedProperty getViewInputProperties()
      This method is called by the Web controller to retrieve the request properties set by the setRequestProperties() method.
      java.lang.String getViewTask()
      Gets the view task name.
      void performExecute()
      Processes the approval or rejection.
      void reset()
      Reset the command so that it can be invoked again.
      void setAprvAct(java.lang.Integer newAprvAct)
      Sets the approval action.
      void setAprvIds(java.lang.String newAprvIds)
      Sets the list of approval status IDs to be acted on.
      void setComments(java.lang.String newComments)
      Sets the comments.
      void setRequestProperties(com.ibm.commerce.datatype.TypedProperty reqParms)
      Sets the request parameters.
      void setViewTask(java.lang.String newViewTask)
      Sets the view task name.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from class com.ibm.commerce.command.ControllerCommandImpl

        checkPermission, fulfills, getForUserId, getGeneric, getOwner, getRequestProperties, getResolvedRequestProperties, getResourceOwners, getResponseProperties, getRetriable, isGeneric, isRetriable, mergeProperties, setForUserId, setGeneric, setOwner, setResponseProperties, setRetriable, setViewInputProperties
      • Methods inherited from class com.ibm.commerce.command.AbstractECTargetableCommand

        accessControlCheck, checkIsAllowed, checkResourcePermission, createCommandExecutionEvent, execute, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getExceptionInvokeParameters, getObjectSize, getPostInvokeParameters, getPreInvokeParameters, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties, validateParameters
      • Methods inherited from interface com.ibm.commerce.command.ControllerCommand

        checkPermission, execute, getGeneric, getRequestProperties, getResolvedRequestProperties, getResponseProperties, getRetriable, isGeneric, isRetriable, mergeProperties, setGeneric, setRetriable, setViewInputProperties
      • Methods inherited from interface com.ibm.commerce.command.AccCommand

        accessControlCheck, getAccCheck, getForUserId, getResourceOwners, setAccCheck, setForUserId, setOwner
      • Methods inherited from interface com.ibm.commerce.command.ECCommand

        checkIsAllowed, checkResourcePermission, createCommandExecutionEvent, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getExceptionInvokeParameters, getPostInvokeParameters, getPreInvokeParameters, getResources, getStoreId, getUser, getUserId, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties, validateParameters
      • Methods inherited from interface com.ibm.commerce.security.Protectable

        fulfills, getOwner
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • EC_APPROVAL_FLOWTYPE_RESELLER_USER_REGISTRATION

        public static final java.lang.String EC_APPROVAL_FLOWTYPE_RESELLER_USER_REGISTRATION
        Reseller user registration add flow type
        See Also:
        Constant Field Values
    • Constructor Detail

      • HandleApprovalsCmdImpl

        public HandleApprovalsCmdImpl()
    • Method Detail

      • getAprvAct

        public java.lang.Integer getAprvAct()
        Gets the action.
        Specified by:
        getAprvAct in interface HandleApprovalsCmd
        Returns:
        aprvAct The action. This corresponds to the value of the APPROVAL column in the flow transition (FLTRANSITN) table which will be used to select the appropriate transition.
      • getAprvIds

        public java.lang.String getAprvIds()
        Gets the list of approval status IDs to be acted on.
        Specified by:
        getAprvIds in interface HandleApprovalsCmd
        Returns:
        aprvIds The list of comma delimited approval request IDs to be acted on.
      • getComments

        public java.lang.String getComments()
        Gets the comments
        Specified by:
        getComments in interface HandleApprovalsCmd
        Returns:
        comments The optional approval/rejection comments supplied by the approver.
      • getViewInputProperties

        public com.ibm.commerce.datatype.TypedProperty getViewInputProperties()
        This method is called by the Web controller to retrieve the request properties set by the setRequestProperties() method. The command need to override this method because otherwise the properties passed into the controller command would be then passed onto the view command. This is unnecessary. The command calls the getViewInputProperties() method in the ToolsControllerCommandImpl command. This takes care of removing the parameters specific to the tools framework.
        Specified by:
        getViewInputProperties in interface com.ibm.commerce.command.ControllerCommand
        Overrides:
        getViewInputProperties in class com.ibm.commerce.tools.command.ToolsControllerCommandImpl
        Returns:
        com.ibm.commerce.datatype.TypeProperty
      • getViewTask

        public java.lang.String getViewTask()
        Gets the view task name.
        Specified by:
        getViewTask in interface HandleApprovalsCmd
        Returns:
        viewTask The view to set upon completion of the command.
      • performExecute

        public void performExecute()
                            throws com.ibm.commerce.exception.ECSystemException
        Processes the approval or rejection.

        After setting some return messages based on the action,this method will loop through the approval requests to be processed. For each request to be processed, it will:

        • Set a transaction scope for the request.
        • Retrieve the APRVSTATUS record corresponding to the request to obtain the entityIid, the flowId, the flowTypeId and the stateId.
        • Retrieve the FlowType record to obtain the flow type identifier.
        • Retrieve the Transition record to obtain the event identifier.
        • Put the event identifier,the flow type identifier and the entity id into the request properties for the Business Flow event. If comments have been supplied by the approver, they will also be put into the request properties.
        • Raise the Business Flow Event.
        • If the Business Flow Event throws an exception, increment the failure count otherwise increment the success count.

        After all approval requests have been processed, it will use the success and failure counts to determine which message to return to the JSP.

        Specified by:
        performExecute in interface com.ibm.commerce.command.ECCommand
        Overrides:
        performExecute in class com.ibm.commerce.command.AbstractECTargetableCommand
        Throws:
        com.ibm.commerce.exception.ECSystemException - if a CreateExeception, FinderException, RemoteException, NamingException or any other exception is thrown by the AccessBean or by the BusinessFlowManager.
      • reset

        public void reset()
        Reset the command so that it can be invoked again.
        Overrides:
        reset in class com.ibm.commerce.command.AbstractECTargetableCommand
      • setAprvAct

        public void setAprvAct(java.lang.Integer newAprvAct)
        Sets the approval action.
        Specified by:
        setAprvAct in interface HandleApprovalsCmd
        Parameters:
        newAprvAct - The approval action.
      • setAprvIds

        public void setAprvIds(java.lang.String newAprvIds)
        Sets the list of approval status IDs to be acted on.
        Specified by:
        setAprvIds in interface HandleApprovalsCmd
        Parameters:
        newAprvIds - The list of approval status ids to be acted on.
      • setComments

        public void setComments(java.lang.String newComments)
        Sets the comments.
        Specified by:
        setComments in interface HandleApprovalsCmd
        Parameters:
        newComments - The optional approval/rejection comments supplied by the approver.
      • setRequestProperties

        public void setRequestProperties(com.ibm.commerce.datatype.TypedProperty reqParms)
                                  throws com.ibm.commerce.exception.ECApplicationException
        Sets the request parameters.
        Specified by:
        setRequestProperties in interface com.ibm.commerce.command.ControllerCommand
        Overrides:
        setRequestProperties in class com.ibm.commerce.tools.command.ToolsControllerCommandImpl
        Parameters:
        reqParms - The TypedProperty containing the request parameters.
        Throws:
        com.ibm.commerce.exception.ECApplicationException - if:
        • The action (aprv_act) is not specified or is not a valid integer.
        • The list of approval request ids (aprv_ids) is not specified or is null.
        • The view task to set upon completion (viewtask) is not specified or is null.
        • The list of approval request ids (aprv_ids) contains an invalid Long.
        • The comments field is longer than 254 characters.
      • setViewTask

        public void setViewTask(java.lang.String newViewTask)
        Sets the view task name.
        Specified by:
        setViewTask in interface HandleApprovalsCmd
        Parameters:
        newViewTask - The view task to be set upon completion of the command.