mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-1341: Couldn't complete event if link record before completing it
* some refactoring to ensure complete, undo and refresh logic was encapsulated in the service layer (not in the actions) * integration test for complete event to check interactions * restructure integration test packages git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@67986 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
package org.alfresco.module.org_alfresco_module_rm.action;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -27,12 +26,8 @@ import java.util.Set;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.admin.RecordsManagementAdminService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
@@ -51,7 +46,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.OwnableService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
@@ -468,73 +462,4 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the given records management event for the given 'next action'.
|
||||
*
|
||||
* @param event The event to create
|
||||
* @param nextActionNodeRef The next action node
|
||||
* @return The created event NodeRef
|
||||
*/
|
||||
protected NodeRef createEvent(RecordsManagementEvent event, NodeRef nextActionNodeRef)
|
||||
{
|
||||
NodeRef eventNodeRef = null;
|
||||
|
||||
Map<QName, Serializable> eventProps = new HashMap<QName, Serializable>(7);
|
||||
eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName());
|
||||
// TODO display label
|
||||
RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, eventType.isAutomaticEvent());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
|
||||
// Create the event execution object
|
||||
this.nodeService.createNode(nextActionNodeRef, ASSOC_EVENT_EXECUTIONS,
|
||||
ASSOC_EVENT_EXECUTIONS, TYPE_EVENT_EXECUTION, eventProps);
|
||||
|
||||
return eventNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates and updates the <code>rma:dispositionEventsEligible</code>
|
||||
* property for the given next disposition action.
|
||||
*
|
||||
* @param nextAction The next disposition action
|
||||
* @return The result of calculation
|
||||
*/
|
||||
protected boolean updateEventEligible(DispositionAction nextAction)
|
||||
{
|
||||
List<EventCompletionDetails> events = nextAction.getEventCompletionDetails();
|
||||
|
||||
boolean eligible = false;
|
||||
if (!nextAction.getDispositionActionDefinition().eligibleOnFirstCompleteEvent())
|
||||
{
|
||||
eligible = true;
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (!event.isEventComplete())
|
||||
{
|
||||
eligible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (event.isEventComplete())
|
||||
{
|
||||
eligible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the property with the eligible value
|
||||
this.nodeService.setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE, eligible);
|
||||
|
||||
return eligible;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -192,7 +192,7 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
|
||||
|
||||
if (changedProps.contains(PROP_DISPOSITION_EVENT) || changedProps.contains(PROP_DISPOSITION_EVENT_COMBINATION))
|
||||
{
|
||||
persistEventChanges(dispositionActionDef, nextAction);
|
||||
nextAction.refreshEvents();
|
||||
}
|
||||
|
||||
if (changedProps.contains(PROP_DISPOSITION_ACTION_NAME))
|
||||
@@ -265,63 +265,88 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
|
||||
* @param dispositionActionDef The disposition action definition node
|
||||
* @param nextAction The next disposition action
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void persistEventChanges(NodeRef dispositionActionDef, DispositionAction nextAction)
|
||||
{
|
||||
// go through the current events on the next action and remove any that are not present any more
|
||||
List<String> stepEvents = (List<String>) nodeService.getProperty(dispositionActionDef, PROP_DISPOSITION_EVENT);
|
||||
List<EventCompletionDetails> eventsList = nextAction.getEventCompletionDetails();
|
||||
List<String> nextActionEvents = new ArrayList<String>(eventsList.size());
|
||||
for (EventCompletionDetails event : eventsList)
|
||||
{
|
||||
// take note of the event names present on the next action
|
||||
String eventName = event.getEventName();
|
||||
nextActionEvents.add(eventName);
|
||||
|
||||
// if the event has been removed delete from next action
|
||||
if (stepEvents != null && !stepEvents.contains(event.getEventName()))
|
||||
{
|
||||
// remove the child association representing the event
|
||||
nodeService.removeChild(nextAction.getNodeRef(), event.getNodeRef());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Removed '" + eventName + "' from next action '" + nextAction.getName() +
|
||||
"' (" + nextAction.getNodeRef() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// go through the disposition action definition step events and add any new ones
|
||||
if (stepEvents != null)
|
||||
{
|
||||
for (String eventName : stepEvents)
|
||||
{
|
||||
if (!nextActionEvents.contains(eventName))
|
||||
{
|
||||
createEvent(recordsManagementEventService.getEvent(eventName), nextAction.getNodeRef());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Added '" + eventName + "' to next action '" + nextAction.getName() +
|
||||
"' (" + nextAction.getNodeRef() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: eventsList contains all the events that have been updated!
|
||||
// TODO: manually update the search properties for the parent node!
|
||||
|
||||
// finally since events may have changed re-calculate the events eligible flag
|
||||
boolean eligible = updateEventEligible(nextAction);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Set events eligible flag to '" + eligible + "' for next action '" + nextAction.getName() +
|
||||
"' (" + nextAction.getNodeRef() + ")");
|
||||
}
|
||||
}
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private void persistEventChanges(NodeRef dispositionActionDef, DispositionAction nextAction)
|
||||
// {
|
||||
// // go through the current events on the next action and remove any that are not present any more
|
||||
// List<String> stepEvents = (List<String>) nodeService.getProperty(dispositionActionDef, PROP_DISPOSITION_EVENT);
|
||||
// List<EventCompletionDetails> eventsList = nextAction.getEventCompletionDetails();
|
||||
// List<String> nextActionEvents = new ArrayList<String>(eventsList.size());
|
||||
// for (EventCompletionDetails event : eventsList)
|
||||
// {
|
||||
// // take note of the event names present on the next action
|
||||
// String eventName = event.getEventName();
|
||||
// nextActionEvents.add(eventName);
|
||||
//
|
||||
// // if the event has been removed delete from next action
|
||||
// if (stepEvents != null && !stepEvents.contains(event.getEventName()))
|
||||
// {
|
||||
// // remove the child association representing the event
|
||||
// nodeService.removeChild(nextAction.getNodeRef(), event.getNodeRef());
|
||||
//
|
||||
// if (logger.isDebugEnabled())
|
||||
// {
|
||||
// logger.debug("Removed '" + eventName + "' from next action '" + nextAction.getName() +
|
||||
// "' (" + nextAction.getNodeRef() + ")");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // go through the disposition action definition step events and add any new ones
|
||||
// if (stepEvents != null)
|
||||
// {
|
||||
// for (String eventName : stepEvents)
|
||||
// {
|
||||
// if (!nextActionEvents.contains(eventName))
|
||||
// {
|
||||
// createEvent(recordsManagementEventService.getEvent(eventName), nextAction.getNodeRef());
|
||||
//
|
||||
// if (logger.isDebugEnabled())
|
||||
// {
|
||||
// logger.debug("Added '" + eventName + "' to next action '" + nextAction.getName() +
|
||||
// "' (" + nextAction.getNodeRef() + ")");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // NOTE: eventsList contains all the events that have been updated!
|
||||
// // TODO: manually update the search properties for the parent node!
|
||||
//
|
||||
// // finally since events may have changed re-calculate the events eligible flag
|
||||
// boolean eligible = updateEventEligible(nextAction);
|
||||
//
|
||||
// if (logger.isDebugEnabled())
|
||||
// {
|
||||
// logger.debug("Set events eligible flag to '" + eligible + "' for next action '" + nextAction.getName() +
|
||||
// "' (" + nextAction.getNodeRef() + ")");
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * Creates the given records management event for the given 'next action'.
|
||||
// *
|
||||
// * @param event The event to create
|
||||
// * @param nextActionNodeRef The next action node
|
||||
// * @return The created event NodeRef
|
||||
// */
|
||||
// protected NodeRef createEvent(RecordsManagementEvent event, NodeRef nextActionNodeRef)
|
||||
// {
|
||||
// NodeRef eventNodeRef = null;
|
||||
//
|
||||
// Map<QName, Serializable> eventProps = new HashMap<QName, Serializable>(7);
|
||||
// eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName());
|
||||
// // TODO display label
|
||||
// RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType());
|
||||
// eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, eventType.isAutomaticEvent());
|
||||
// eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
//
|
||||
// // Create the event execution object
|
||||
// this.nodeService.createNode(nextActionNodeRef, ASSOC_EVENT_EXECUTIONS,
|
||||
// ASSOC_EVENT_EXECUTIONS, TYPE_EVENT_EXECUTION, eventProps);
|
||||
//
|
||||
// return eventNodeRef;
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
|
@@ -18,30 +18,29 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
* Complete event action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 1.0
|
||||
*/
|
||||
public class CompleteEventAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** action name */
|
||||
public static final String NAME = "completeEvent";
|
||||
|
||||
/** action parameter names */
|
||||
public static final String PARAM_EVENT_NAME = "eventName";
|
||||
public static final String PARAM_EVENT_COMPLETED_BY = "eventCompletedBy";
|
||||
public static final String PARAM_EVENT_COMPLETED_AT = "eventCompletedAt";
|
||||
@@ -52,8 +51,12 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
|
||||
@Override
|
||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||
{
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME, DataTypeDefinition.TEXT, true,
|
||||
getParamDisplayLabel(PARAM_EVENT_NAME), false, "rm-ac-manual-events"));
|
||||
paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME,
|
||||
DataTypeDefinition.TEXT,
|
||||
true,
|
||||
getParamDisplayLabel(PARAM_EVENT_NAME),
|
||||
false,
|
||||
"rm-ac-manual-events"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,6 +69,7 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
|
||||
if (nodeService.exists(actionedUponNodeRef) &&
|
||||
!freezeService.isFrozen(actionedUponNodeRef))
|
||||
{
|
||||
/** get parameter values */
|
||||
String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME);
|
||||
String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY);
|
||||
Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT);
|
||||
@@ -76,61 +80,10 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
|
||||
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||
if (da != null)
|
||||
{
|
||||
// Get the disposition event
|
||||
EventCompletionDetails event = getEvent(da, eventName);
|
||||
if (event != null)
|
||||
{
|
||||
if (eventCompletedAt == null)
|
||||
{
|
||||
eventCompletedAt = new Date();
|
||||
}
|
||||
|
||||
if (eventCompletedBy == null)
|
||||
{
|
||||
eventCompletedBy = AuthenticationUtil.getRunAsUser();
|
||||
}
|
||||
|
||||
// Update the event so that it is complete
|
||||
NodeRef eventNodeRef = event.getNodeRef();
|
||||
Map<QName, Serializable> props = this.nodeService.getProperties(eventNodeRef);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETE, true);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, eventCompletedAt);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, eventCompletedBy);
|
||||
this.nodeService.setProperties(eventNodeRef, props);
|
||||
|
||||
// Check to see if the events eligible property needs to be updated
|
||||
updateEventEligible(da);
|
||||
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// RM-695: Commenting error handling out. If the current disposition stage does not define the event being completed nothing should happen.
|
||||
// throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NO_DISP_LC, eventName));
|
||||
// }
|
||||
// complete event
|
||||
da.completeEvent(eventName, eventCompletedAt, eventCompletedBy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event from the dispostion action
|
||||
*
|
||||
* @param da
|
||||
* @param eventName
|
||||
* @return
|
||||
*/
|
||||
private EventCompletionDetails getEvent(DispositionAction da, String eventName)
|
||||
{
|
||||
EventCompletionDetails result = null;
|
||||
List<EventCompletionDetails> events = da.getEventCompletionDetails();
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (eventName.equals(event.getEventName()))
|
||||
{
|
||||
result = event;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -18,30 +18,22 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Undo event action
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 1.0
|
||||
*/
|
||||
public class UndoEventAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
/** I18N */
|
||||
private static final String MSG_EVENT_NOT_DONE = "rm.action.event-not-undone";
|
||||
|
||||
/** Params */
|
||||
public static final String PARAM_EVENT_NAME = "eventName";
|
||||
|
||||
@@ -59,91 +51,12 @@ public class UndoEventAction extends RMActionExecuterAbstractBase
|
||||
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||
if (da != null)
|
||||
{
|
||||
// Get the disposition event
|
||||
EventCompletionDetails event = getEvent(da, eventName);
|
||||
if (event != null)
|
||||
{
|
||||
// Update the event so that it is undone
|
||||
NodeRef eventNodeRef = event.getNodeRef();
|
||||
Map<QName, Serializable> props = this.nodeService.getProperties(eventNodeRef);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, null);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, null);
|
||||
this.nodeService.setProperties(eventNodeRef, props);
|
||||
|
||||
// Check to see if the events eligible property needs to be updated
|
||||
updateEventEigible(da);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_EVENT_NOT_DONE, eventName));
|
||||
}
|
||||
// undo completed event
|
||||
da.undoEvent(eventName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event from the disposition action
|
||||
*
|
||||
* @param da
|
||||
* @param eventName
|
||||
* @return
|
||||
*/
|
||||
private EventCompletionDetails getEvent(DispositionAction da, String eventName)
|
||||
{
|
||||
EventCompletionDetails result = null;
|
||||
List<EventCompletionDetails> events = da.getEventCompletionDetails();
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (eventName.equals(event.getEventName()))
|
||||
{
|
||||
result = event;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param da
|
||||
* @param nodeRef
|
||||
*/
|
||||
private void updateEventEigible(DispositionAction da)
|
||||
{
|
||||
List<EventCompletionDetails> events = da.getEventCompletionDetails();
|
||||
|
||||
boolean eligible = false;
|
||||
if (!da.getDispositionActionDefinition().eligibleOnFirstCompleteEvent())
|
||||
{
|
||||
eligible = true;
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (!event.isEventComplete())
|
||||
{
|
||||
eligible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (event.isEventComplete())
|
||||
{
|
||||
eligible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the property with the eligible value
|
||||
this.nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE, eligible);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||
*/
|
||||
@@ -152,6 +65,5 @@ public class UndoEventAction extends RMActionExecuterAbstractBase
|
||||
{
|
||||
// TODO add parameter definitions ....
|
||||
// eventName
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
||||
*
|
||||
* @author Gavin Cornwell
|
||||
* @author Roy Wetherall
|
||||
* @since 1.0
|
||||
*/
|
||||
public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent>
|
||||
{
|
||||
@@ -42,9 +43,6 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
||||
/** Records management audit service */
|
||||
protected RecordsManagementAuditService recordsManagementAuditService;
|
||||
|
||||
/** Policy component */
|
||||
//protected PolicyComponent policyComponent;
|
||||
|
||||
/**
|
||||
* @param recordsManagementAuditService records management audit service
|
||||
*/
|
||||
@@ -52,14 +50,6 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
||||
{
|
||||
this.recordsManagementAuditService = recordsManagementAuditService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param policyComponent policy component
|
||||
*/
|
||||
// public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
// {
|
||||
// this.policyComponent = policyComponent;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Init method
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -22,12 +22,14 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Disposition action interface.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface DispositionAction
|
||||
{
|
||||
@@ -91,4 +93,52 @@ public interface DispositionAction
|
||||
* @return List of events that need to be completed for the action
|
||||
*/
|
||||
List<EventCompletionDetails> getEventCompletionDetails();
|
||||
|
||||
/**
|
||||
* Get the event completion details for a named event.
|
||||
*
|
||||
* @param eventName event name
|
||||
* @return {@link EventCompletionDetails} event completion details
|
||||
* @since 2.2
|
||||
*/
|
||||
EventCompletionDetails getEventCompletionDetails(String eventName);
|
||||
|
||||
/**
|
||||
* Add new completion details to the disposition action based on the provided
|
||||
* event.
|
||||
*
|
||||
* @param event records management event
|
||||
* @since 2.2
|
||||
*/
|
||||
void addEventCompletionDetails(RecordsManagementEvent event);
|
||||
|
||||
/**
|
||||
* Complete an event.
|
||||
* <p>
|
||||
* If null is provided, the complete at date will be take as 'now' and the completed by user
|
||||
* as the fully authenticated user.
|
||||
*
|
||||
* @param eventName event name
|
||||
* @param completedAt completed at 'date', now if null
|
||||
* @param completedBy completed by user, authenticated user if null
|
||||
* @since 2.2
|
||||
*/
|
||||
void completeEvent(String eventName, Date completedAt, String completedBy);
|
||||
|
||||
/**
|
||||
* Undo the completion of an event.
|
||||
*
|
||||
* @param eventName event name
|
||||
* @since 2.2
|
||||
*/
|
||||
void undoEvent(String eventName);
|
||||
|
||||
/**
|
||||
* Refresh events against current disposition action definition.
|
||||
* <p>
|
||||
* Called when disposition action definition has changed.
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
void refreshEvents();
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -21,33 +21,51 @@ package org.alfresco.module.org_alfresco_module_rm.disposition;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
|
||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Disposition action implementation.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 1.0
|
||||
*/
|
||||
public class DispositionActionImpl implements DispositionAction,
|
||||
RecordsManagementModel
|
||||
{
|
||||
/** logger */
|
||||
private static Log logger = LogFactory.getLog(DispositionActionImpl.class);
|
||||
|
||||
/** records management service registry */
|
||||
private RecordsManagementServiceRegistry services;
|
||||
|
||||
/** disposition node reference */
|
||||
private NodeRef dispositionNodeRef;
|
||||
|
||||
/** disposition action definition */
|
||||
private DispositionActionDefinition dispositionActionDefinition;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param services
|
||||
* @param dispositionActionNodeRef
|
||||
* @param services records management service registry
|
||||
* @param dispositionActionNodeRef disposition action node reference
|
||||
*/
|
||||
public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef)
|
||||
{
|
||||
@@ -60,26 +78,26 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
*/
|
||||
public DispositionActionDefinition getDispositionActionDefinition()
|
||||
{
|
||||
if (this.dispositionActionDefinition == null)
|
||||
if (dispositionActionDefinition == null)
|
||||
{
|
||||
// Get the current action
|
||||
String id = (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
|
||||
|
||||
// Get the disposition instructions for the owning node
|
||||
NodeRef recordNodeRef = this.services.getNodeService().getPrimaryParent(this.dispositionNodeRef).getParentRef();
|
||||
NodeRef recordNodeRef = services.getNodeService().getPrimaryParent(this.dispositionNodeRef).getParentRef();
|
||||
if (recordNodeRef != null)
|
||||
{
|
||||
DispositionSchedule ds = this.services.getDispositionService().getDispositionSchedule(recordNodeRef);
|
||||
DispositionSchedule ds = services.getDispositionService().getDispositionSchedule(recordNodeRef);
|
||||
|
||||
if (ds != null)
|
||||
{
|
||||
// Get the disposition action definition
|
||||
this.dispositionActionDefinition = ds.getDispositionActionDefinition(id);
|
||||
dispositionActionDefinition = ds.getDispositionActionDefinition(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.dispositionActionDefinition;
|
||||
return dispositionActionDefinition;
|
||||
|
||||
}
|
||||
|
||||
@@ -100,7 +118,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
String label = name;
|
||||
|
||||
// get the disposition action from the RM action service
|
||||
RecordsManagementAction action = this.services.getRecordsManagementActionService().getDispositionAction(name);
|
||||
RecordsManagementAction action = services.getRecordsManagementActionService().getDispositionAction(name);
|
||||
if (action != null)
|
||||
{
|
||||
label = action.getLabel();
|
||||
@@ -114,7 +132,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
|
||||
return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +140,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION);
|
||||
return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +148,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
*/
|
||||
public Date getAsOfDate()
|
||||
{
|
||||
return (Date)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_AS_OF);
|
||||
return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_AS_OF);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,7 +156,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
*/
|
||||
public boolean isEventsEligible()
|
||||
{
|
||||
return ((Boolean)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_EVENTS_ELIGIBLE)).booleanValue();
|
||||
return ((Boolean)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_EVENTS_ELIGIBLE)).booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +164,7 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
*/
|
||||
public Date getCompletedAt()
|
||||
{
|
||||
return (Date)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT);
|
||||
return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_AT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,23 +172,23 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
*/
|
||||
public String getCompletedBy()
|
||||
{
|
||||
return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY);
|
||||
return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_COMPLETED_BY);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.DispositionAction#getStartedAt()
|
||||
*/
|
||||
public Date getStartedAt()
|
||||
{
|
||||
return (Date)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT);
|
||||
return (Date)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_STARTED_AT);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.DispositionAction#getStartedBy()
|
||||
*/
|
||||
public String getStartedBy()
|
||||
{
|
||||
return (String)this.services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY);
|
||||
return (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_STARTED_BY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,27 +196,46 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
*/
|
||||
public List<EventCompletionDetails> getEventCompletionDetails()
|
||||
{
|
||||
List<ChildAssociationRef> assocs = this.services.getNodeService().getChildAssocs(
|
||||
List<ChildAssociationRef> assocs = services.getNodeService().getChildAssocs(
|
||||
this.dispositionNodeRef,
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
RegexQNamePattern.MATCH_ALL);
|
||||
List<EventCompletionDetails> result = new ArrayList<EventCompletionDetails>(assocs.size());
|
||||
for (ChildAssociationRef assoc : assocs)
|
||||
{
|
||||
Map<QName, Serializable> props = this.services.getNodeService().getProperties(assoc.getChildRef());
|
||||
String eventName = (String)props.get(PROP_EVENT_EXECUTION_NAME);
|
||||
EventCompletionDetails ecd = new EventCompletionDetails(
|
||||
assoc.getChildRef(), eventName,
|
||||
this.services.getRecordsManagementEventService().getEvent(eventName).getDisplayLabel(),
|
||||
getBooleanValue(props.get(PROP_EVENT_EXECUTION_AUTOMATIC), false),
|
||||
getBooleanValue(props.get(PROP_EVENT_EXECUTION_COMPLETE), false),
|
||||
(Date)props.get(PROP_EVENT_EXECUTION_COMPLETED_AT),
|
||||
(String)props.get(PROP_EVENT_EXECUTION_COMPLETED_BY));
|
||||
result.add(ecd);
|
||||
result.add(getEventCompletionDetailsFromNodeRef(assoc.getChildRef()));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create object representation of event completed details from
|
||||
* node reference.
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @return {@link EventCompletionDetails} event completion details
|
||||
*/
|
||||
private EventCompletionDetails getEventCompletionDetailsFromNodeRef(NodeRef nodeRef)
|
||||
{
|
||||
// get the properties
|
||||
Map<QName, Serializable> props = this.services.getNodeService().getProperties(nodeRef);
|
||||
|
||||
// get the event name
|
||||
String eventName = (String)props.get(PROP_EVENT_EXECUTION_NAME);
|
||||
|
||||
// create event completion details
|
||||
EventCompletionDetails ecd = new EventCompletionDetails(
|
||||
nodeRef,
|
||||
eventName,
|
||||
services.getRecordsManagementEventService().getEvent(eventName).getDisplayLabel(),
|
||||
getBooleanValue(props.get(PROP_EVENT_EXECUTION_AUTOMATIC), false),
|
||||
getBooleanValue(props.get(PROP_EVENT_EXECUTION_COMPLETE), false),
|
||||
(Date)props.get(PROP_EVENT_EXECUTION_COMPLETED_AT),
|
||||
(String)props.get(PROP_EVENT_EXECUTION_COMPLETED_BY));
|
||||
|
||||
return ecd;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to deal with boolean values
|
||||
@@ -217,4 +254,254 @@ public class DispositionActionImpl implements DispositionAction,
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the event completion details for the named event.
|
||||
* <p>
|
||||
* Returns null if event can not be found.
|
||||
*
|
||||
* @param eventName name of the event
|
||||
* @return {@link EventCompletionDetails} event completion details for named event, null otherwise
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
@Override
|
||||
public EventCompletionDetails getEventCompletionDetails(String eventName)
|
||||
{
|
||||
EventCompletionDetails result = null;
|
||||
List<ChildAssociationRef> assocs = services.getNodeService().getChildAssocsByPropertyValue(dispositionNodeRef, PROP_EVENT_EXECUTION_NAME, eventName);
|
||||
|
||||
if (!assocs.isEmpty())
|
||||
{
|
||||
if (assocs.size() != 1)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to get event completion details, because more than one child was found for event " + eventName);
|
||||
}
|
||||
|
||||
result = getEventCompletionDetailsFromNodeRef(assocs.get(0).getChildRef());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#completeEvent(java.lang.String, java.util.Date, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void completeEvent(final String eventName, final Date completedAt, final String completedBy)
|
||||
{
|
||||
final EventCompletionDetails event = getEventCompletionDetails(eventName);
|
||||
if (event != null && !event.isEventComplete())
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// use "now" if no completed date set
|
||||
Date completedAtValue = completedAt;
|
||||
if (completedAt == null)
|
||||
{
|
||||
completedAtValue = new Date();
|
||||
}
|
||||
|
||||
// use the currently authenticated user if none set
|
||||
String completedByValue = completedBy;
|
||||
if (completedBy == null)
|
||||
{
|
||||
completedByValue = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
}
|
||||
|
||||
// Update the event so that it is complete
|
||||
NodeRef eventNodeRef = event.getNodeRef();
|
||||
Map<QName, Serializable> props = services.getNodeService().getProperties(eventNodeRef);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETE, true);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, completedAtValue);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, completedByValue);
|
||||
services.getNodeService().setProperties(eventNodeRef, props);
|
||||
|
||||
// Check to see if the events eligible property needs to be updated
|
||||
updateEventEligible();
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#undoEvent(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void undoEvent(final String eventName)
|
||||
{
|
||||
final EventCompletionDetails event = getEventCompletionDetails(eventName);
|
||||
if (event != null && event.isEventComplete())
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// Update the event so that it is undone
|
||||
NodeRef eventNodeRef = event.getNodeRef();
|
||||
Map<QName, Serializable> props = services.getNodeService().getProperties(eventNodeRef);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_AT, null);
|
||||
props.put(PROP_EVENT_EXECUTION_COMPLETED_BY, null);
|
||||
services.getNodeService().setProperties(eventNodeRef, props);
|
||||
|
||||
// Check to see if the events eligible property needs to be updated
|
||||
updateEventEligible();
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#refreshEvents()
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void refreshEvents()
|
||||
{
|
||||
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
// go through the current events on the next action and remove any that are not present any more
|
||||
List<String> stepEvents = (List<String>) services.getNodeService().getProperty(getDispositionActionDefinition().getNodeRef(), PROP_DISPOSITION_EVENT);
|
||||
|
||||
List<EventCompletionDetails> eventsList = getEventCompletionDetails();
|
||||
List<String> nextActionEvents = new ArrayList<String>(eventsList.size());
|
||||
|
||||
for (EventCompletionDetails event : eventsList)
|
||||
{
|
||||
// take note of the event names present on the next action
|
||||
String eventName = event.getEventName();
|
||||
nextActionEvents.add(eventName);
|
||||
|
||||
// if the event has been removed delete from next action
|
||||
if (stepEvents != null && !stepEvents.contains(event.getEventName()))
|
||||
{
|
||||
// remove the child association representing the event
|
||||
services.getNodeService().removeChild(getNodeRef(), event.getNodeRef());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Removed '" + eventName + "' from next action '" + getName() +
|
||||
"' (" + getNodeRef() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// go through the disposition action definition step events and add any new ones
|
||||
if (stepEvents != null)
|
||||
{
|
||||
for (String eventName : stepEvents)
|
||||
{
|
||||
if (!nextActionEvents.contains(eventName))
|
||||
{
|
||||
// add the details of the new event
|
||||
addEventCompletionDetails(services.getRecordsManagementEventService().getEvent(eventName));
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Added '" + eventName + "' to next action '" + getName() +
|
||||
"' (" + getNodeRef() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: eventsList contains all the events that have been updated!
|
||||
// TODO: manually update the search properties for the parent node!
|
||||
|
||||
// finally since events may have changed re-calculate the events eligible flag
|
||||
boolean eligible = updateEventEligible();
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Set events eligible flag to '" + eligible + "' for next action '" + getName() +
|
||||
"' (" + getNodeRef() + ")");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction#addEventCompletionDetails(org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent)
|
||||
*/
|
||||
@Override
|
||||
public void addEventCompletionDetails(RecordsManagementEvent event)
|
||||
{
|
||||
Map<QName, Serializable> eventProps = new HashMap<QName, Serializable>(7);
|
||||
eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName());
|
||||
// TODO display label
|
||||
eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, event.getRecordsManagementEventType().isAutomaticEvent());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
|
||||
// Create the event execution object
|
||||
services.getNodeService().createNode(getNodeRef(),
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
TYPE_EVENT_EXECUTION,
|
||||
eventProps);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates and updates the <code>rma:dispositionEventsEligible</code>
|
||||
* property for the given next disposition action.
|
||||
*
|
||||
* @param nextAction The next disposition action
|
||||
* @return The result of calculation
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
private boolean updateEventEligible()
|
||||
{
|
||||
boolean eligible = false;
|
||||
|
||||
// get the events for the next disposition action
|
||||
List<EventCompletionDetails> events = getEventCompletionDetails();
|
||||
|
||||
if (!events.isEmpty())
|
||||
{
|
||||
if (!getDispositionActionDefinition().eligibleOnFirstCompleteEvent())
|
||||
{
|
||||
// if one event is complete then the disposition action is eligible
|
||||
eligible = true;
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (!event.isEventComplete())
|
||||
{
|
||||
eligible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// all events must be complete for the disposition action to be eligible
|
||||
for (EventCompletionDetails event : events)
|
||||
{
|
||||
if (event.isEventComplete())
|
||||
{
|
||||
eligible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the property with the eligible value
|
||||
services.getNodeService().setProperty(getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE, eligible);
|
||||
|
||||
return eligible;
|
||||
}
|
||||
}
|
||||
|
@@ -98,10 +98,7 @@ public class DispositionSelectionStrategy implements RecordsManagementModel
|
||||
else
|
||||
{
|
||||
SortedSet<NodeRef> sortedFolders = new TreeSet<NodeRef>(new DispositionableNodeRefComparator());
|
||||
for (NodeRef f : recordFolders)
|
||||
{
|
||||
sortedFolders.add(f);
|
||||
}
|
||||
sortedFolders.addAll(recordFolders);
|
||||
recordFolder = sortedFolders.first();
|
||||
}
|
||||
|
||||
@@ -137,16 +134,39 @@ public class DispositionSelectionStrategy implements RecordsManagementModel
|
||||
{
|
||||
public Integer doWork() throws Exception
|
||||
{
|
||||
return Integer.valueOf(compareImpl(f1, f2));
|
||||
return compareImpl(f1, f2);
|
||||
}
|
||||
|
||||
}).intValue();
|
||||
});
|
||||
}
|
||||
|
||||
private int compareImpl(NodeRef f1, NodeRef f2)
|
||||
{
|
||||
//TODO Check the nodeRefs have the correct aspect
|
||||
// quick check to see if the node references are the same
|
||||
if (f1.equals(f2))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// get the disposition schedules for the folders
|
||||
DispositionSchedule ds1 = dispositionService.getDispositionSchedule(f1);
|
||||
DispositionSchedule ds2 = dispositionService.getDispositionSchedule(f2);
|
||||
|
||||
// make sure each folder has a disposition schedule
|
||||
if (ds1 == null && ds2 != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else if (ds1 != null && ds2 == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if (ds1 == null && ds2 == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO this won't work correctly if we are trying to compare schedules that are record based!!
|
||||
DispositionAction da1 = dispositionService.getNextDispositionAction(f1);
|
||||
DispositionAction da2 = dispositionService.getNextDispositionAction(f2);
|
||||
|
||||
|
@@ -31,7 +31,6 @@ import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementServiceRegistry;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEventType;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||
@@ -654,44 +653,18 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
ASSOC_NEXT_DISPOSITION_ACTION,
|
||||
TYPE_DISPOSITION_ACTION,
|
||||
props).getChildRef();
|
||||
DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef);
|
||||
|
||||
// Create the events
|
||||
List<RecordsManagementEvent> events = dispositionActionDefinition.getEvents();
|
||||
for (RecordsManagementEvent event : events)
|
||||
{
|
||||
// For every event create an entry on the action
|
||||
createEvent(event, dispositionActionNodeRef);
|
||||
da.addEventCompletionDetails(event);
|
||||
// createEvent(event, dispositionActionNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the given records management event for the given 'next action'.
|
||||
*
|
||||
* @param event The event to create
|
||||
* @param nextActionNodeRef The next action node
|
||||
* @return The created event NodeRef
|
||||
*/
|
||||
private NodeRef createEvent(RecordsManagementEvent event, NodeRef nextActionNodeRef)
|
||||
{
|
||||
NodeRef eventNodeRef = null;
|
||||
|
||||
Map<QName, Serializable> eventProps = new HashMap<QName, Serializable>(7);
|
||||
eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName());
|
||||
// TODO display label
|
||||
RecordsManagementEventType eventType = serviceRegistry.getRecordsManagementEventService().getEventType(event.getType());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, eventType.isAutomaticEvent());
|
||||
eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||
|
||||
// Create the event execution object
|
||||
this.nodeService.createNode(nextActionNodeRef,
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
ASSOC_EVENT_EXECUTIONS,
|
||||
TYPE_EVENT_EXECUTION,
|
||||
eventProps);
|
||||
|
||||
return eventNodeRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#isNextDispositionActionEligible(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@@ -953,13 +926,14 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
||||
ASSOC_NEXT_DISPOSITION_ACTION,
|
||||
TYPE_DISPOSITION_ACTION,
|
||||
props).getChildRef();
|
||||
DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef);
|
||||
|
||||
// Create the events
|
||||
List<RecordsManagementEvent> events = nextDispositionActionDefinition.getEvents();
|
||||
for (RecordsManagementEvent event : events)
|
||||
{
|
||||
// For every event create an entry on the action
|
||||
createEvent(event, dispositionActionNodeRef);
|
||||
da.addEventCompletionDetails(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,10 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
*/
|
||||
public class EventCompletionDetails
|
||||
{
|
||||
/** node reference */
|
||||
private NodeRef nodeRef;
|
||||
|
||||
/** event name */
|
||||
private String eventName;
|
||||
private String eventLabel;
|
||||
private boolean eventExecutionAutomatic;
|
||||
@@ -39,13 +42,15 @@ public class EventCompletionDetails
|
||||
|
||||
|
||||
/**
|
||||
* @param nodeRef
|
||||
* @param eventName
|
||||
* @param eventLabel
|
||||
* @param eventExecutionAutomatic
|
||||
* @param eventComplete
|
||||
* @param eventCompletedAt
|
||||
* @param eventCompletedBy
|
||||
* Constructor
|
||||
*
|
||||
* @param nodeRef node reference
|
||||
* @param eventName event name
|
||||
* @param eventLabel event label
|
||||
* @param eventExecutionAutomatic indicates whether the event is executed automatically or not
|
||||
* @param eventComplete indicates whether the event is complete or not
|
||||
* @param eventCompletedAt when the event was completed
|
||||
* @param eventCompletedBy who completed the event
|
||||
*/
|
||||
public EventCompletionDetails( NodeRef nodeRef,
|
||||
String eventName,
|
||||
|
@@ -18,15 +18,18 @@
|
||||
*/
|
||||
package org.alfresco.module.org_alfresco_module_rm.event;
|
||||
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
* Records management event
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
* @since 1.0
|
||||
*/
|
||||
public class RecordsManagementEvent
|
||||
{
|
||||
/** Records management event type */
|
||||
private String type;
|
||||
private RecordsManagementEventType type;
|
||||
|
||||
/** Records management event name */
|
||||
private String name;
|
||||
@@ -41,21 +44,37 @@ public class RecordsManagementEvent
|
||||
* @param name event name
|
||||
* @param displayLabel event display label
|
||||
*/
|
||||
public RecordsManagementEvent(String type, String name, String displayLabel)
|
||||
public RecordsManagementEvent(RecordsManagementEventType type, String name, String displayLabel)
|
||||
{
|
||||
ParameterCheck.mandatory("type", type);
|
||||
ParameterCheck.mandatory("name", name);
|
||||
ParameterCheck.mandatory("displayLabel", displayLabel);
|
||||
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get records management type
|
||||
* Get records management type name
|
||||
*
|
||||
* @return String records management type
|
||||
* @return String records management event type name
|
||||
*/
|
||||
public String getType()
|
||||
{
|
||||
return this.type;
|
||||
return type.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the records management event type.
|
||||
*
|
||||
* @return {@link RecordsManagementEventType} records management event type
|
||||
*
|
||||
* @since 2.2
|
||||
*/
|
||||
public RecordsManagementEventType getRecordsManagementEventType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -229,13 +229,13 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
|
||||
}
|
||||
|
||||
// Create event and add to map
|
||||
RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel);
|
||||
RecordsManagementEvent event = new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel);
|
||||
getEventMap().put(event.getName(), event);
|
||||
|
||||
// Persist the changes to the event list
|
||||
saveEvents();
|
||||
|
||||
return new RecordsManagementEvent(eventType, eventName, eventDisplayLabel);
|
||||
return new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +318,7 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
|
||||
}
|
||||
|
||||
// Create event and add to map
|
||||
RecordsManagementEvent event = new RecordsManagementEvent(eventType, eventName, eventDisplayLabel);
|
||||
RecordsManagementEvent event = new RecordsManagementEvent(eventTypes.get(eventType), eventName, eventDisplayLabel);
|
||||
events.put(event.getName(), event);
|
||||
}
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user