diff --git a/src/java/fr/paris/lutece/plugins/workflowcore/business/resource/ResourceHistory.java b/src/java/fr/paris/lutece/plugins/workflowcore/business/resource/ResourceHistory.java index e6c1aff..42c3673 100644 --- a/src/java/fr/paris/lutece/plugins/workflowcore/business/resource/ResourceHistory.java +++ b/src/java/fr/paris/lutece/plugins/workflowcore/business/resource/ResourceHistory.java @@ -53,6 +53,7 @@ public class ResourceHistory private Timestamp _tCreationDate; private String _strUserAccessCode; private ResourceUserHistory _resourceUserHistory; + private int status; /** * return the id of the resource history @@ -219,4 +220,25 @@ public void setResourceUserHistory( ResourceUserHistory resourceUserHistory ) { this._resourceUserHistory = resourceUserHistory; } + + /** + * return the status + * + * @return the status + */ + public int getStatus( ) + { + return status; + } + + /** + * Sets the status + * + * @param status + * the status to set + */ + public void setStatus( int status ) + { + this.status = status; + } } diff --git a/src/java/fr/paris/lutece/plugins/workflowcore/service/workflow/IWorkflowService.java b/src/java/fr/paris/lutece/plugins/workflowcore/service/workflow/IWorkflowService.java index 5e0f1f1..4d4d0f9 100644 --- a/src/java/fr/paris/lutece/plugins/workflowcore/service/workflow/IWorkflowService.java +++ b/src/java/fr/paris/lutece/plugins/workflowcore/service/workflow/IWorkflowService.java @@ -35,6 +35,7 @@ import fr.paris.lutece.api.user.User; import fr.paris.lutece.plugins.workflowcore.business.action.Action; +import fr.paris.lutece.plugins.workflowcore.business.resource.ResourceHistory; import fr.paris.lutece.plugins.workflowcore.business.resource.ResourceWorkflow; import fr.paris.lutece.plugins.workflowcore.business.state.State; import fr.paris.lutece.plugins.workflowcore.business.workflow.Workflow; @@ -270,11 +271,42 @@ void doProcessAction( int nIdResource, String strResourceType, int nIdAction, In * @param the * user the user */ + @Deprecated default void doProcessAction( int nIdResource, String strResourceType, int nIdAction, Integer nExternalParentId, HttpServletRequest request, Locale locale, boolean bIsAutomatic, String strUserAccessCode, User user ) { doProcessAction( nIdResource, strResourceType, nIdAction, nExternalParentId, request, locale, bIsAutomatic, strUserAccessCode ); } + + /** + * Proceed action given in parameter + * + * @param nIdResource + * the resource id + * @param strResourceType + * the resource type + * @param nIdAction + * the action id + * @param nExternalParentId + * the external parent id* + * @param request + * the request + * @param locale + * locale + * @param bIsAutomatic + * true if action is automatic + * @param strUserAccessCode + * the user access code + * @param user + * the user + * @param actionHistoryResourceList + * the history of action performed on a resource + */ + default void doProcessAction( int nIdResource, String strResourceType, int nIdAction, Integer nExternalParentId, HttpServletRequest request, Locale locale, + boolean bIsAutomatic, String strUserAccessCode, User user, List actionHistoryResourceList ) + { + doProcessAction( nIdResource, strResourceType, nIdAction, nExternalParentId, request, locale, bIsAutomatic, strUserAccessCode ); + } /** * Proceed automatic reflexive actions of state given in parameter diff --git a/src/java/fr/paris/lutece/plugins/workflowcore/service/workflow/WorkflowService.java b/src/java/fr/paris/lutece/plugins/workflowcore/service/workflow/WorkflowService.java index 5aaade4..697af3e 100644 --- a/src/java/fr/paris/lutece/plugins/workflowcore/service/workflow/WorkflowService.java +++ b/src/java/fr/paris/lutece/plugins/workflowcore/service/workflow/WorkflowService.java @@ -46,6 +46,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; import fr.paris.lutece.api.user.User; import fr.paris.lutece.plugins.workflowcore.business.action.Action; @@ -455,7 +456,7 @@ public boolean isDisplayTasksForm( int nIdAction, Locale locale ) */ @Override public void doProcessAction( int nIdResource, String strResourceType, int nIdAction, Integer nIdExternalParent, HttpServletRequest request, Locale locale, - boolean bIsAutomatic, String strUserAccessCode, User user ) + boolean bIsAutomatic, String strUserAccessCode, User user, List actionHistoryResourceList ) { Action action = _actionService.findByPrimaryKey( nIdAction ); @@ -530,6 +531,15 @@ public void doProcessAction( int nIdResource, String strResourceType, int nIdAct resourceWorkflow.setExternalParentId( nIdExternalParent ); _resourceWorkflowService.update( resourceWorkflow ); + if ( actionHistoryResourceList != null ) + { + if ( !isSuccess ) + { + resourceHistory.setStatus( NumberUtils.INTEGER_MINUS_ONE ); + } + actionHistoryResourceList.add( resourceHistory ); + } + if ( ( resourceWorkflow.getState( ) != null ) && !action.isAutomaticReflexiveAction( ) ) { final State nextState = resourceWorkflow.getState( ); @@ -549,12 +559,22 @@ public void doProcessAction( int nIdResource, String strResourceType, int nIdAct if ( CollectionUtils.isNotEmpty( listAction ) && ( listAction.get( 0 ) != null ) ) { - doProcessAction( nIdResource, strResourceType, listAction.get( 0 ).getId( ), nIdExternalParent, request, locale, true, null, user ); + doProcessAction( nIdResource, strResourceType, listAction.get( 0 ).getId( ), nIdExternalParent, request, locale, true, null, user, actionHistoryResourceList ); } } } + /** + * {@inheritDoc} + */ + @Override + public void doProcessAction( int nIdResource, String strResourceType, int nIdAction, Integer nIdExternalParent, HttpServletRequest request, Locale locale, + boolean bIsAutomatic, String strUserAccessCode, User user ) + { + doProcessAction( nIdResource, strResourceType, nIdAction, nIdExternalParent, request, locale, bIsAutomatic, strUserAccessCode, null, null ); + } + /** * {@inheritDoc} */