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;
|
package org.alfresco.module.org_alfresco_module_rm.action;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.admin.RecordsManagementAdminService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.audit.RecordsManagementAuditService;
|
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.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.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.fileplan.FilePlanComponentKind;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
import org.alfresco.module.org_alfresco_module_rm.freeze.FreezeService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
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.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.security.OwnableService;
|
import org.alfresco.service.cmr.security.OwnableService;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.springframework.beans.factory.BeanNameAware;
|
import org.springframework.beans.factory.BeanNameAware;
|
||||||
@@ -468,73 +462,4 @@ public abstract class RMActionExecuterAbstractBase extends PropertySubActionExe
|
|||||||
{
|
{
|
||||||
return null;
|
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))
|
if (changedProps.contains(PROP_DISPOSITION_EVENT) || changedProps.contains(PROP_DISPOSITION_EVENT_COMBINATION))
|
||||||
{
|
{
|
||||||
persistEventChanges(dispositionActionDef, nextAction);
|
nextAction.refreshEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changedProps.contains(PROP_DISPOSITION_ACTION_NAME))
|
if (changedProps.contains(PROP_DISPOSITION_ACTION_NAME))
|
||||||
@@ -265,63 +265,88 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
|
|||||||
* @param dispositionActionDef The disposition action definition node
|
* @param dispositionActionDef The disposition action definition node
|
||||||
* @param nextAction The next disposition action
|
* @param nextAction The next disposition action
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
// @SuppressWarnings("unchecked")
|
||||||
private void persistEventChanges(NodeRef dispositionActionDef, DispositionAction nextAction)
|
// 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
|
// // 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<String> stepEvents = (List<String>) nodeService.getProperty(dispositionActionDef, PROP_DISPOSITION_EVENT);
|
||||||
List<EventCompletionDetails> eventsList = nextAction.getEventCompletionDetails();
|
// List<EventCompletionDetails> eventsList = nextAction.getEventCompletionDetails();
|
||||||
List<String> nextActionEvents = new ArrayList<String>(eventsList.size());
|
// List<String> nextActionEvents = new ArrayList<String>(eventsList.size());
|
||||||
for (EventCompletionDetails event : eventsList)
|
// for (EventCompletionDetails event : eventsList)
|
||||||
{
|
// {
|
||||||
// take note of the event names present on the next action
|
// // take note of the event names present on the next action
|
||||||
String eventName = event.getEventName();
|
// String eventName = event.getEventName();
|
||||||
nextActionEvents.add(eventName);
|
// 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() + ")");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// if the event has been removed delete from next action
|
// /**
|
||||||
if (stepEvents != null && !stepEvents.contains(event.getEventName()))
|
// * Creates the given records management event for the given 'next action'.
|
||||||
{
|
// *
|
||||||
// remove the child association representing the event
|
// * @param event The event to create
|
||||||
nodeService.removeChild(nextAction.getNodeRef(), event.getNodeRef());
|
// * @param nextActionNodeRef The next action node
|
||||||
|
// * @return The created event NodeRef
|
||||||
if (logger.isDebugEnabled())
|
// */
|
||||||
{
|
// protected NodeRef createEvent(RecordsManagementEvent event, NodeRef nextActionNodeRef)
|
||||||
logger.debug("Removed '" + eventName + "' from next action '" + nextAction.getName() +
|
// {
|
||||||
"' (" + nextAction.getNodeRef() + ")");
|
// NodeRef eventNodeRef = null;
|
||||||
}
|
//
|
||||||
}
|
// Map<QName, Serializable> eventProps = new HashMap<QName, Serializable>(7);
|
||||||
}
|
// eventProps.put(PROP_EVENT_EXECUTION_NAME, event.getName());
|
||||||
|
// // TODO display label
|
||||||
// go through the disposition action definition step events and add any new ones
|
// RecordsManagementEventType eventType = recordsManagementEventService.getEventType(event.getType());
|
||||||
if (stepEvents != null)
|
// eventProps.put(PROP_EVENT_EXECUTION_AUTOMATIC, eventType.isAutomaticEvent());
|
||||||
{
|
// eventProps.put(PROP_EVENT_EXECUTION_COMPLETE, false);
|
||||||
for (String eventName : stepEvents)
|
//
|
||||||
{
|
// // Create the event execution object
|
||||||
if (!nextActionEvents.contains(eventName))
|
// this.nodeService.createNode(nextActionNodeRef, ASSOC_EVENT_EXECUTIONS,
|
||||||
{
|
// ASSOC_EVENT_EXECUTIONS, TYPE_EVENT_EXECUTION, eventProps);
|
||||||
createEvent(recordsManagementEventService.getEvent(eventName), nextAction.getNodeRef());
|
//
|
||||||
|
// return eventNodeRef;
|
||||||
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() + ")");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||||
|
@@ -18,30 +18,29 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
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.action.RMActionExecuterAbstractBase;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
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.action.ParameterDefinitionImpl;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete event action
|
* Complete event action
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class CompleteEventAction extends RMActionExecuterAbstractBase
|
public class CompleteEventAction extends RMActionExecuterAbstractBase
|
||||||
{
|
{
|
||||||
|
/** action name */
|
||||||
public static final String NAME = "completeEvent";
|
public static final String NAME = "completeEvent";
|
||||||
|
|
||||||
|
/** action parameter names */
|
||||||
public static final String PARAM_EVENT_NAME = "eventName";
|
public static final String PARAM_EVENT_NAME = "eventName";
|
||||||
public static final String PARAM_EVENT_COMPLETED_BY = "eventCompletedBy";
|
public static final String PARAM_EVENT_COMPLETED_BY = "eventCompletedBy";
|
||||||
public static final String PARAM_EVENT_COMPLETED_AT = "eventCompletedAt";
|
public static final String PARAM_EVENT_COMPLETED_AT = "eventCompletedAt";
|
||||||
@@ -52,8 +51,12 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
|
|||||||
@Override
|
@Override
|
||||||
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
|
||||||
{
|
{
|
||||||
paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME, DataTypeDefinition.TEXT, true,
|
paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME,
|
||||||
getParamDisplayLabel(PARAM_EVENT_NAME), false, "rm-ac-manual-events"));
|
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) &&
|
if (nodeService.exists(actionedUponNodeRef) &&
|
||||||
!freezeService.isFrozen(actionedUponNodeRef))
|
!freezeService.isFrozen(actionedUponNodeRef))
|
||||||
{
|
{
|
||||||
|
/** get parameter values */
|
||||||
String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME);
|
String eventName = (String)action.getParameterValue(PARAM_EVENT_NAME);
|
||||||
String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY);
|
String eventCompletedBy = (String)action.getParameterValue(PARAM_EVENT_COMPLETED_BY);
|
||||||
Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT);
|
Date eventCompletedAt = (Date)action.getParameterValue(PARAM_EVENT_COMPLETED_AT);
|
||||||
@@ -76,61 +80,10 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
|
|||||||
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||||
if (da != null)
|
if (da != null)
|
||||||
{
|
{
|
||||||
// Get the disposition event
|
// complete event
|
||||||
EventCompletionDetails event = getEvent(da, eventName);
|
da.completeEvent(eventName, eventCompletedAt, eventCompletedBy);
|
||||||
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));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
package org.alfresco.module.org_alfresco_module_rm.action.impl;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
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.action.RMActionExecuterAbstractBase;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
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.Action;
|
||||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undo event action
|
* Undo event action
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class UndoEventAction extends RMActionExecuterAbstractBase
|
public class UndoEventAction extends RMActionExecuterAbstractBase
|
||||||
{
|
{
|
||||||
/** I18N */
|
|
||||||
private static final String MSG_EVENT_NOT_DONE = "rm.action.event-not-undone";
|
|
||||||
|
|
||||||
/** Params */
|
/** Params */
|
||||||
public static final String PARAM_EVENT_NAME = "eventName";
|
public static final String PARAM_EVENT_NAME = "eventName";
|
||||||
|
|
||||||
@@ -59,91 +51,12 @@ public class UndoEventAction extends RMActionExecuterAbstractBase
|
|||||||
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
DispositionAction da = this.dispositionService.getNextDispositionAction(actionedUponNodeRef);
|
||||||
if (da != null)
|
if (da != null)
|
||||||
{
|
{
|
||||||
// Get the disposition event
|
// undo completed event
|
||||||
EventCompletionDetails event = getEvent(da, eventName);
|
da.undoEvent(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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
|
||||||
*/
|
*/
|
||||||
@@ -152,6 +65,5 @@ public class UndoEventAction extends RMActionExecuterAbstractBase
|
|||||||
{
|
{
|
||||||
// TODO add parameter definitions ....
|
// TODO add parameter definitions ....
|
||||||
// eventName
|
// eventName
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,7 @@ import org.springframework.extensions.surf.util.I18NUtil;
|
|||||||
*
|
*
|
||||||
* @author Gavin Cornwell
|
* @author Gavin Cornwell
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent>
|
public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent>
|
||||||
{
|
{
|
||||||
@@ -42,9 +43,6 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
|||||||
/** Records management audit service */
|
/** Records management audit service */
|
||||||
protected RecordsManagementAuditService recordsManagementAuditService;
|
protected RecordsManagementAuditService recordsManagementAuditService;
|
||||||
|
|
||||||
/** Policy component */
|
|
||||||
//protected PolicyComponent policyComponent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recordsManagementAuditService records management audit service
|
* @param recordsManagementAuditService records management audit service
|
||||||
*/
|
*/
|
||||||
@@ -53,14 +51,6 @@ public class AuditEvent implements RecordsManagementModel, Comparator<AuditEvent
|
|||||||
this.recordsManagementAuditService = recordsManagementAuditService;
|
this.recordsManagementAuditService = recordsManagementAuditService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param policyComponent policy component
|
|
||||||
*/
|
|
||||||
// public void setPolicyComponent(PolicyComponent policyComponent)
|
|
||||||
// {
|
|
||||||
// this.policyComponent = policyComponent;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init method
|
* 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
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
@@ -22,12 +22,14 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
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;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disposition action interface.
|
* Disposition action interface.
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public interface DispositionAction
|
public interface DispositionAction
|
||||||
{
|
{
|
||||||
@@ -91,4 +93,52 @@ public interface DispositionAction
|
|||||||
* @return List of events that need to be completed for the action
|
* @return List of events that need to be completed for the action
|
||||||
*/
|
*/
|
||||||
List<EventCompletionDetails> getEventCompletionDetails();
|
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
|
* 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.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
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.RecordsManagementServiceRegistry;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
|
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.EventCompletionDetails;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
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.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Disposition action implementation.
|
||||||
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class DispositionActionImpl implements DispositionAction,
|
public class DispositionActionImpl implements DispositionAction,
|
||||||
RecordsManagementModel
|
RecordsManagementModel
|
||||||
{
|
{
|
||||||
|
/** logger */
|
||||||
|
private static Log logger = LogFactory.getLog(DispositionActionImpl.class);
|
||||||
|
|
||||||
|
/** records management service registry */
|
||||||
private RecordsManagementServiceRegistry services;
|
private RecordsManagementServiceRegistry services;
|
||||||
|
|
||||||
|
/** disposition node reference */
|
||||||
private NodeRef dispositionNodeRef;
|
private NodeRef dispositionNodeRef;
|
||||||
|
|
||||||
|
/** disposition action definition */
|
||||||
private DispositionActionDefinition dispositionActionDefinition;
|
private DispositionActionDefinition dispositionActionDefinition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param services
|
* @param services records management service registry
|
||||||
* @param dispositionActionNodeRef
|
* @param dispositionActionNodeRef disposition action node reference
|
||||||
*/
|
*/
|
||||||
public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef)
|
public DispositionActionImpl(RecordsManagementServiceRegistry services, NodeRef dispositionActionNodeRef)
|
||||||
{
|
{
|
||||||
@@ -60,26 +78,26 @@ public class DispositionActionImpl implements DispositionAction,
|
|||||||
*/
|
*/
|
||||||
public DispositionActionDefinition getDispositionActionDefinition()
|
public DispositionActionDefinition getDispositionActionDefinition()
|
||||||
{
|
{
|
||||||
if (this.dispositionActionDefinition == null)
|
if (dispositionActionDefinition == null)
|
||||||
{
|
{
|
||||||
// Get the current action
|
// Get the current action
|
||||||
String id = (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
|
String id = (String)services.getNodeService().getProperty(this.dispositionNodeRef, PROP_DISPOSITION_ACTION_ID);
|
||||||
|
|
||||||
// Get the disposition instructions for the owning node
|
// 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)
|
if (recordNodeRef != null)
|
||||||
{
|
{
|
||||||
DispositionSchedule ds = this.services.getDispositionService().getDispositionSchedule(recordNodeRef);
|
DispositionSchedule ds = services.getDispositionService().getDispositionSchedule(recordNodeRef);
|
||||||
|
|
||||||
if (ds != null)
|
if (ds != null)
|
||||||
{
|
{
|
||||||
// Get the disposition action definition
|
// 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;
|
String label = name;
|
||||||
|
|
||||||
// get the disposition action from the RM action service
|
// 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)
|
if (action != null)
|
||||||
{
|
{
|
||||||
label = action.getLabel();
|
label = action.getLabel();
|
||||||
@@ -114,7 +132,7 @@ public class DispositionActionImpl implements DispositionAction,
|
|||||||
*/
|
*/
|
||||||
public String getId()
|
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()
|
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()
|
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()
|
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()
|
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()
|
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()
|
* @see org.alfresco.module.org_alfresco_module_rm.DispositionAction#getStartedAt()
|
||||||
*/
|
*/
|
||||||
public Date 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()
|
* @see org.alfresco.module.org_alfresco_module_rm.DispositionAction#getStartedBy()
|
||||||
*/
|
*/
|
||||||
public String 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,28 +196,47 @@ public class DispositionActionImpl implements DispositionAction,
|
|||||||
*/
|
*/
|
||||||
public List<EventCompletionDetails> getEventCompletionDetails()
|
public List<EventCompletionDetails> getEventCompletionDetails()
|
||||||
{
|
{
|
||||||
List<ChildAssociationRef> assocs = this.services.getNodeService().getChildAssocs(
|
List<ChildAssociationRef> assocs = services.getNodeService().getChildAssocs(
|
||||||
this.dispositionNodeRef,
|
this.dispositionNodeRef,
|
||||||
ASSOC_EVENT_EXECUTIONS,
|
ASSOC_EVENT_EXECUTIONS,
|
||||||
RegexQNamePattern.MATCH_ALL);
|
RegexQNamePattern.MATCH_ALL);
|
||||||
List<EventCompletionDetails> result = new ArrayList<EventCompletionDetails>(assocs.size());
|
List<EventCompletionDetails> result = new ArrayList<EventCompletionDetails>(assocs.size());
|
||||||
for (ChildAssociationRef assoc : assocs)
|
for (ChildAssociationRef assoc : assocs)
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> props = this.services.getNodeService().getProperties(assoc.getChildRef());
|
result.add(getEventCompletionDetailsFromNodeRef(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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
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
|
* Helper method to deal with boolean values
|
||||||
*
|
*
|
||||||
@@ -217,4 +254,254 @@ public class DispositionActionImpl implements DispositionAction,
|
|||||||
return result;
|
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
|
else
|
||||||
{
|
{
|
||||||
SortedSet<NodeRef> sortedFolders = new TreeSet<NodeRef>(new DispositionableNodeRefComparator());
|
SortedSet<NodeRef> sortedFolders = new TreeSet<NodeRef>(new DispositionableNodeRefComparator());
|
||||||
for (NodeRef f : recordFolders)
|
sortedFolders.addAll(recordFolders);
|
||||||
{
|
|
||||||
sortedFolders.add(f);
|
|
||||||
}
|
|
||||||
recordFolder = sortedFolders.first();
|
recordFolder = sortedFolders.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,16 +134,39 @@ public class DispositionSelectionStrategy implements RecordsManagementModel
|
|||||||
{
|
{
|
||||||
public Integer doWork() throws Exception
|
public Integer doWork() throws Exception
|
||||||
{
|
{
|
||||||
return Integer.valueOf(compareImpl(f1, f2));
|
return compareImpl(f1, f2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}).intValue();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private int compareImpl(NodeRef f1, NodeRef f2)
|
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 da1 = dispositionService.getNextDispositionAction(f1);
|
||||||
DispositionAction da2 = dispositionService.getNextDispositionAction(f2);
|
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.RecordsManagementServiceRegistry;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
|
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.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.FilePlanComponentKind;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
@@ -654,44 +653,18 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
ASSOC_NEXT_DISPOSITION_ACTION,
|
ASSOC_NEXT_DISPOSITION_ACTION,
|
||||||
TYPE_DISPOSITION_ACTION,
|
TYPE_DISPOSITION_ACTION,
|
||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
|
DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef);
|
||||||
|
|
||||||
// Create the events
|
// Create the events
|
||||||
List<RecordsManagementEvent> events = dispositionActionDefinition.getEvents();
|
List<RecordsManagementEvent> events = dispositionActionDefinition.getEvents();
|
||||||
for (RecordsManagementEvent event : events)
|
for (RecordsManagementEvent event : events)
|
||||||
{
|
{
|
||||||
// For every event create an entry on the action
|
// 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)
|
* @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,
|
ASSOC_NEXT_DISPOSITION_ACTION,
|
||||||
TYPE_DISPOSITION_ACTION,
|
TYPE_DISPOSITION_ACTION,
|
||||||
props).getChildRef();
|
props).getChildRef();
|
||||||
|
DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef);
|
||||||
|
|
||||||
// Create the events
|
// Create the events
|
||||||
List<RecordsManagementEvent> events = nextDispositionActionDefinition.getEvents();
|
List<RecordsManagementEvent> events = nextDispositionActionDefinition.getEvents();
|
||||||
for (RecordsManagementEvent event : events)
|
for (RecordsManagementEvent event : events)
|
||||||
{
|
{
|
||||||
// For every event create an entry on the action
|
// 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
|
public class EventCompletionDetails
|
||||||
{
|
{
|
||||||
|
/** node reference */
|
||||||
private NodeRef nodeRef;
|
private NodeRef nodeRef;
|
||||||
|
|
||||||
|
/** event name */
|
||||||
private String eventName;
|
private String eventName;
|
||||||
private String eventLabel;
|
private String eventLabel;
|
||||||
private boolean eventExecutionAutomatic;
|
private boolean eventExecutionAutomatic;
|
||||||
@@ -39,13 +42,15 @@ public class EventCompletionDetails
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeRef
|
* Constructor
|
||||||
* @param eventName
|
*
|
||||||
* @param eventLabel
|
* @param nodeRef node reference
|
||||||
* @param eventExecutionAutomatic
|
* @param eventName event name
|
||||||
* @param eventComplete
|
* @param eventLabel event label
|
||||||
* @param eventCompletedAt
|
* @param eventExecutionAutomatic indicates whether the event is executed automatically or not
|
||||||
* @param eventCompletedBy
|
* @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,
|
public EventCompletionDetails( NodeRef nodeRef,
|
||||||
String eventName,
|
String eventName,
|
||||||
|
@@ -18,15 +18,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.event;
|
package org.alfresco.module.org_alfresco_module_rm.event;
|
||||||
|
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records management event
|
* Records management event
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
public class RecordsManagementEvent
|
public class RecordsManagementEvent
|
||||||
{
|
{
|
||||||
/** Records management event type */
|
/** Records management event type */
|
||||||
private String type;
|
private RecordsManagementEventType type;
|
||||||
|
|
||||||
/** Records management event name */
|
/** Records management event name */
|
||||||
private String name;
|
private String name;
|
||||||
@@ -41,21 +44,37 @@ public class RecordsManagementEvent
|
|||||||
* @param name event name
|
* @param name event name
|
||||||
* @param displayLabel event display label
|
* @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.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.displayLabel = displayLabel;
|
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()
|
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
|
// 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);
|
getEventMap().put(event.getName(), event);
|
||||||
|
|
||||||
// Persist the changes to the event list
|
// Persist the changes to the event list
|
||||||
saveEvents();
|
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
|
// 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);
|
events.put(event.getName(), event);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test;
|
package org.alfresco.module.org_alfresco_module_rm.test;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.IntegrationTestSuite;
|
||||||
import org.alfresco.repo.ParameterProcessorTestSuite;
|
import org.alfresco.repo.ParameterProcessorTestSuite;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
@@ -37,9 +38,8 @@ import org.junit.runners.Suite.SuiteClasses;
|
|||||||
CapabilitiesTestSuite.class,
|
CapabilitiesTestSuite.class,
|
||||||
ServicesTestSuite.class,
|
ServicesTestSuite.class,
|
||||||
WebScriptTestSuite.class,
|
WebScriptTestSuite.class,
|
||||||
IssueTestSuite.class,
|
|
||||||
ParameterProcessorTestSuite.class,
|
ParameterProcessorTestSuite.class,
|
||||||
DoD5015TestSuite.class
|
IntegrationTestSuite.class
|
||||||
})
|
})
|
||||||
public class AllTestSuite
|
public class AllTestSuite
|
||||||
{
|
{
|
||||||
|
@@ -38,6 +38,7 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
|
import org.springframework.extensions.webscripts.GUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declarative capability unit test
|
* Declarative capability unit test
|
||||||
@@ -60,6 +61,8 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
|
|||||||
private NodeRef moveToFolder;
|
private NodeRef moveToFolder;
|
||||||
private NodeRef moveToCategory;
|
private NodeRef moveToCategory;
|
||||||
|
|
||||||
|
private NodeRef hold;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isUserTest()
|
protected boolean isUserTest()
|
||||||
{
|
{
|
||||||
@@ -106,9 +109,12 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
|
|||||||
utils.declareRecord(declaredRecord);
|
utils.declareRecord(declaredRecord);
|
||||||
utils.declareRecord(frozenRecord);
|
utils.declareRecord(frozenRecord);
|
||||||
utils.declareRecord(frozenRecord2);
|
utils.declareRecord(frozenRecord2);
|
||||||
utils.freeze(frozenRecord);
|
|
||||||
utils.freeze(frozenRecordFolder);
|
hold = holdService.createHold(filePlan, GUID.generate(), "reason", "description");
|
||||||
utils.freeze(frozenRecord2);
|
|
||||||
|
holdService.addToHold(hold, frozenRecord);
|
||||||
|
holdService.addToHold(hold, frozenRecordFolder);
|
||||||
|
holdService.addToHold(hold, frozenRecord2);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -119,9 +125,9 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
|
|||||||
protected void tearDownImpl()
|
protected void tearDownImpl()
|
||||||
{
|
{
|
||||||
// Unfreeze stuff so it can be deleted
|
// Unfreeze stuff so it can be deleted
|
||||||
utils.unfreeze(frozenRecord);
|
holdService.removeFromHold(hold, frozenRecord);
|
||||||
utils.unfreeze(frozenRecordFolder);
|
holdService.removeFromHold(hold, frozenRecordFolder);
|
||||||
utils.unfreeze(frozenRecord2);
|
holdService.removeFromHold(hold, frozenRecord2);
|
||||||
|
|
||||||
super.tearDownImpl();
|
super.tearDownImpl();
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.integration;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.dod.DoD5015TestSuite;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.event.EventTestSuite;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.integration.issue.IssueTestSuite;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Suite;
|
||||||
|
import org.junit.runners.Suite.SuiteClasses;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RM Integration Test Suite
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
@RunWith(Suite.class)
|
||||||
|
@SuiteClasses(
|
||||||
|
{
|
||||||
|
DoD5015TestSuite.class,
|
||||||
|
IssueTestSuite.class,
|
||||||
|
EventTestSuite.class
|
||||||
|
})
|
||||||
|
public class IntegrationTestSuite
|
||||||
|
{
|
||||||
|
}
|
@@ -16,10 +16,8 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.dod;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.dod.RM1147DODRMSiteTest;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.dod.RM1194ExcludeDoDRecordTypesTest;
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
import org.junit.runners.Suite.SuiteClasses;
|
import org.junit.runners.Suite.SuiteClasses;
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.dod;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.dod;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.dod;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.dod;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@@ -0,0 +1,447 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.event;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.CompleteEventAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.test.util.CommonRMTestUtils;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
import org.springframework.extensions.webscripts.GUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Complete events integration tests.
|
||||||
|
* <p>
|
||||||
|
* Relates to:
|
||||||
|
* - https://issues.alfresco.com/jira/browse/RM-1341
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
public class CompleteEventsTest extends BaseRMTestCase
|
||||||
|
{
|
||||||
|
private static final String ANOTHER_EVENT = "abolished";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test completion of a single event on a record level disposition schedule
|
||||||
|
*/
|
||||||
|
public void testCompleteSingleEventRecordLevel()
|
||||||
|
{
|
||||||
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
|
{
|
||||||
|
private NodeRef record;
|
||||||
|
|
||||||
|
public void given()
|
||||||
|
{
|
||||||
|
// create record category
|
||||||
|
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
|
||||||
|
// create disposition schedule
|
||||||
|
utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", true, true);
|
||||||
|
|
||||||
|
// create record folder
|
||||||
|
NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||||
|
|
||||||
|
// file record
|
||||||
|
record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
|
utils.declareRecord(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void when()
|
||||||
|
{
|
||||||
|
// build action properties
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
|
||||||
|
// complete event
|
||||||
|
rmActionService.executeRecordsManagementAction(record, CompleteEventAction.NAME, params);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void then()
|
||||||
|
{
|
||||||
|
// check that the record is now eligible for the next disposition action
|
||||||
|
assertTrue(dispositionService.isNextDispositionActionEligible(record));
|
||||||
|
|
||||||
|
// check the next disposition action
|
||||||
|
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
|
||||||
|
assertNotNull(dispositionAction);
|
||||||
|
assertEquals("cutoff", dispositionAction.getName());
|
||||||
|
|
||||||
|
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||||
|
assertTrue(eventDetails.isEventComplete());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedBy());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test completion of a single event at the record level
|
||||||
|
*/
|
||||||
|
public void testCompleteSimpleSingleEventRecordFolderLevel()
|
||||||
|
{
|
||||||
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
|
{
|
||||||
|
private NodeRef recordFolder;
|
||||||
|
|
||||||
|
public void given()
|
||||||
|
{
|
||||||
|
// create record category
|
||||||
|
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
|
||||||
|
// create disposition schedule
|
||||||
|
utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, true);
|
||||||
|
|
||||||
|
// create record folder
|
||||||
|
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||||
|
|
||||||
|
// file record
|
||||||
|
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
|
utils.declareRecord(record);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void when()
|
||||||
|
{
|
||||||
|
// build action properties
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
|
||||||
|
// complete event
|
||||||
|
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void then()
|
||||||
|
{
|
||||||
|
// check that the record is now eligible for the next disposition action
|
||||||
|
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
|
||||||
|
|
||||||
|
// check the next disposition action
|
||||||
|
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
|
||||||
|
assertNotNull(dispositionAction);
|
||||||
|
assertEquals("cutoff", dispositionAction.getName());
|
||||||
|
|
||||||
|
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||||
|
assertTrue(eventDetails.isEventComplete());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedBy());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test complete event given at least one event is needed for the disposition action to be eligible
|
||||||
|
*/
|
||||||
|
public void testAtLeastOneEventToBeEligible()
|
||||||
|
{
|
||||||
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
|
{
|
||||||
|
NodeRef recordFolder = null;
|
||||||
|
|
||||||
|
public void given()
|
||||||
|
{
|
||||||
|
// create record category
|
||||||
|
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
|
||||||
|
// create disposition schedule
|
||||||
|
DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false);
|
||||||
|
|
||||||
|
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
|
||||||
|
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||||
|
adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION);
|
||||||
|
|
||||||
|
List<String> events = new ArrayList<String>(1);
|
||||||
|
events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
events.add(ANOTHER_EVENT);
|
||||||
|
adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events);
|
||||||
|
dispositionService.addDispositionActionDefinition(mySchedule, adParams);
|
||||||
|
|
||||||
|
// create record folder
|
||||||
|
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||||
|
|
||||||
|
// file record
|
||||||
|
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
|
utils.declareRecord(record);
|
||||||
|
|
||||||
|
}
|
||||||
|
public void when()
|
||||||
|
{
|
||||||
|
// build action properties
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
|
||||||
|
// complete event
|
||||||
|
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void then()
|
||||||
|
{
|
||||||
|
// check that the record is now eligible for the next disposition action
|
||||||
|
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
|
||||||
|
|
||||||
|
// check the next disposition action
|
||||||
|
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
|
||||||
|
assertNotNull(dispositionAction);
|
||||||
|
assertEquals("cutoff", dispositionAction.getName());
|
||||||
|
|
||||||
|
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||||
|
assertTrue(eventDetails.isEventComplete());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedBy());
|
||||||
|
|
||||||
|
eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(ANOTHER_EVENT, eventDetails.getEventName());
|
||||||
|
assertFalse(eventDetails.isEventComplete());
|
||||||
|
assertNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNull(eventDetails.getEventCompletedBy());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that disposition action is not eligible given all events need to be completed and only has been
|
||||||
|
*/
|
||||||
|
public void testOnlyOneOfAllEventsSoNotEligible()
|
||||||
|
{
|
||||||
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
|
{
|
||||||
|
NodeRef recordFolder = null;
|
||||||
|
|
||||||
|
public void given()
|
||||||
|
{
|
||||||
|
// create record category
|
||||||
|
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
|
||||||
|
// create disposition schedule
|
||||||
|
DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false);
|
||||||
|
|
||||||
|
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
|
||||||
|
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||||
|
adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION);
|
||||||
|
adParams.put(PROP_DISPOSITION_EVENT_COMBINATION, "and");
|
||||||
|
|
||||||
|
List<String> events = new ArrayList<String>(1);
|
||||||
|
events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
events.add(ANOTHER_EVENT);
|
||||||
|
adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events);
|
||||||
|
dispositionService.addDispositionActionDefinition(mySchedule, adParams);
|
||||||
|
|
||||||
|
// create record folder
|
||||||
|
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||||
|
|
||||||
|
// file record
|
||||||
|
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
|
utils.declareRecord(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void when()
|
||||||
|
{
|
||||||
|
// build action properties
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
|
||||||
|
// complete event
|
||||||
|
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void then()
|
||||||
|
{
|
||||||
|
assertFalse(dispositionService.isNextDispositionActionEligible(recordFolder));
|
||||||
|
|
||||||
|
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
|
||||||
|
assertNotNull(dispositionAction);
|
||||||
|
assertEquals("cutoff", dispositionAction.getName());
|
||||||
|
|
||||||
|
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||||
|
assertTrue(eventDetails.isEventComplete());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedBy());
|
||||||
|
|
||||||
|
eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(ANOTHER_EVENT, eventDetails.getEventName());
|
||||||
|
assertFalse(eventDetails.isEventComplete());
|
||||||
|
assertNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNull(eventDetails.getEventCompletedBy());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test event complete makes disposition eligible given that all events are complete and required
|
||||||
|
*/
|
||||||
|
public void testAllEventsSoEligible()
|
||||||
|
{
|
||||||
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
|
{
|
||||||
|
NodeRef recordFolder = null;
|
||||||
|
|
||||||
|
public void given()
|
||||||
|
{
|
||||||
|
// create record category
|
||||||
|
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
|
||||||
|
// create disposition schedule
|
||||||
|
DispositionSchedule mySchedule = utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", false, false);
|
||||||
|
|
||||||
|
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
|
||||||
|
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
|
||||||
|
adParams.put(PROP_DISPOSITION_DESCRIPTION, CommonRMTestUtils.DEFAULT_DISPOSITION_DESCRIPTION);
|
||||||
|
adParams.put(PROP_DISPOSITION_EVENT_COMBINATION, "and");
|
||||||
|
|
||||||
|
List<String> events = new ArrayList<String>(1);
|
||||||
|
events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
events.add(ANOTHER_EVENT);
|
||||||
|
adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events);
|
||||||
|
dispositionService.addDispositionActionDefinition(mySchedule, adParams);
|
||||||
|
|
||||||
|
// create record folder
|
||||||
|
recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||||
|
|
||||||
|
// file record
|
||||||
|
NodeRef record = utils.createRecord(recordFolder, GUID.generate(), "title");
|
||||||
|
utils.declareRecord(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void when()
|
||||||
|
{
|
||||||
|
// build action properties
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
|
||||||
|
// complete event
|
||||||
|
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||||
|
|
||||||
|
// build action properties
|
||||||
|
params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(CompleteEventAction.PARAM_EVENT_NAME, ANOTHER_EVENT);
|
||||||
|
|
||||||
|
// complete event
|
||||||
|
rmActionService.executeRecordsManagementAction(recordFolder, CompleteEventAction.NAME, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void then()
|
||||||
|
{
|
||||||
|
assertTrue(dispositionService.isNextDispositionActionEligible(recordFolder));
|
||||||
|
|
||||||
|
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(recordFolder);
|
||||||
|
assertNotNull(dispositionAction);
|
||||||
|
assertEquals("cutoff", dispositionAction.getName());
|
||||||
|
|
||||||
|
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||||
|
assertTrue(eventDetails.isEventComplete());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedBy());
|
||||||
|
|
||||||
|
eventDetails = dispositionAction.getEventCompletionDetails(ANOTHER_EVENT);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(ANOTHER_EVENT, eventDetails.getEventName());
|
||||||
|
assertTrue(eventDetails.isEventComplete());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedBy());
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test complete event works for multi-filed record
|
||||||
|
*/
|
||||||
|
public void testCompleteEventWhenCutoffMultiFiled_RM1341()
|
||||||
|
{
|
||||||
|
doBehaviourDrivenTest(new BehaviourDrivenTest()
|
||||||
|
{
|
||||||
|
private NodeRef record;
|
||||||
|
|
||||||
|
public void given()
|
||||||
|
{
|
||||||
|
// create record category
|
||||||
|
NodeRef recordCategory = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
NodeRef recordCategory2 = filePlanService.createRecordCategory(filePlan, GUID.generate());
|
||||||
|
|
||||||
|
// create disposition schedule
|
||||||
|
utils.createBasicDispositionSchedule(recordCategory, "instructions", "authority", true, true);
|
||||||
|
|
||||||
|
// create record folder
|
||||||
|
NodeRef recordFolder = recordFolderService.createRecordFolder(recordCategory, GUID.generate());
|
||||||
|
NodeRef recordFolder2 = recordFolderService.createRecordFolder(recordCategory2, GUID.generate());
|
||||||
|
|
||||||
|
// file record
|
||||||
|
String recordName = GUID.generate();
|
||||||
|
record = utils.createRecord(recordFolder, recordName, "title");
|
||||||
|
utils.declareRecord(record);
|
||||||
|
|
||||||
|
// link record to second record folder
|
||||||
|
nodeService.addChild(recordFolder2, record, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, recordName));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void when()
|
||||||
|
{
|
||||||
|
// build action properties
|
||||||
|
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
||||||
|
params.put(CompleteEventAction.PARAM_EVENT_NAME, CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
|
||||||
|
// complete event
|
||||||
|
rmActionService.executeRecordsManagementAction(record, CompleteEventAction.NAME, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void then()
|
||||||
|
{
|
||||||
|
// check that the record is now eligible for the next disposition action
|
||||||
|
assertTrue(dispositionService.isNextDispositionActionEligible(record));
|
||||||
|
|
||||||
|
// check the next disposition action
|
||||||
|
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(record);
|
||||||
|
assertNotNull(dispositionAction);
|
||||||
|
assertEquals("cutoff", dispositionAction.getName());
|
||||||
|
|
||||||
|
EventCompletionDetails eventDetails = dispositionAction.getEventCompletionDetails(CommonRMTestUtils.DEFAULT_EVENT_NAME);
|
||||||
|
assertNotNull(eventDetails);
|
||||||
|
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, eventDetails.getEventName());
|
||||||
|
assertTrue(eventDetails.isEventComplete());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedAt());
|
||||||
|
assertNotNull(eventDetails.getEventCompletedBy());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.event;
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Suite;
|
||||||
|
import org.junit.runners.Suite.SuiteClasses;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event integration test suite
|
||||||
|
*
|
||||||
|
* @author Roy Wetherall
|
||||||
|
* @since 2.2
|
||||||
|
*/
|
||||||
|
@RunWith(Suite.class)
|
||||||
|
@SuiteClasses(
|
||||||
|
{
|
||||||
|
CompleteEventsTest.class
|
||||||
|
})
|
||||||
|
public class EventTestSuite
|
||||||
|
{
|
||||||
|
}
|
@@ -16,15 +16,8 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1008Test;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1027Test;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1030Test;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM1039Test;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM452Test;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM804Test;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.issue.RM994Test;
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Suite;
|
import org.junit.runners.Suite;
|
||||||
import org.junit.runners.Suite.SuiteClasses;
|
import org.junit.runners.Suite.SuiteClasses;
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -38,7 +38,7 @@ import org.alfresco.util.GUID;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System test for RM-1008
|
* Test for RM-1008
|
||||||
*
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
* @since 2.1
|
* @since 2.1
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
@@ -16,7 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.issue;
|
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition;
|
import org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition;
|
@@ -808,7 +808,51 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
|
|||||||
{
|
{
|
||||||
// empty implementation
|
// empty implementation
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void doBehaviourDrivenTest(BehaviourDrivenTest test)
|
||||||
|
{
|
||||||
|
test.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract class BehaviourDrivenTest
|
||||||
|
{
|
||||||
|
public abstract void given();
|
||||||
|
|
||||||
|
public abstract void when();
|
||||||
|
|
||||||
|
public abstract void then();
|
||||||
|
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
doTestInTransaction(new VoidTest()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void runImpl() throws Exception
|
||||||
|
{
|
||||||
|
given();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
doTestInTransaction(new VoidTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runImpl() throws Exception
|
||||||
|
{
|
||||||
|
when();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
doTestInTransaction(new VoidTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void runImpl() throws Exception
|
||||||
|
{
|
||||||
|
then();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
|
@@ -1,5 +1,20 @@
|
|||||||
/**
|
/*
|
||||||
|
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.module.org_alfresco_module_rm.test.util;
|
package org.alfresco.module.org_alfresco_module_rm.test.util;
|
||||||
|
|
||||||
@@ -17,13 +32,11 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.FreezeAction;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
|
import org.alfresco.module.org_alfresco_module_rm.action.impl.TransferAction;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
import org.alfresco.module.org_alfresco_module_rm.capability.Capability;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
import org.alfresco.module.org_alfresco_module_rm.capability.CapabilityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.dod5015.DOD5015Model;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
|
import org.alfresco.module.org_alfresco_module_rm.model.security.ModelSecurityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||||
@@ -41,6 +54,8 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Common RM test utility methods.
|
||||||
|
*
|
||||||
* @author Roy Wetherall
|
* @author Roy Wetherall
|
||||||
*/
|
*/
|
||||||
public class CommonRMTestUtils implements RecordsManagementModel
|
public class CommonRMTestUtils implements RecordsManagementModel
|
||||||
@@ -73,9 +88,10 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Create a disposition schedule
|
||||||
*
|
*
|
||||||
* @param container
|
* @param container record category
|
||||||
* @return
|
* @return {@link DispositionSchedule} created disposition schedule node reference
|
||||||
*/
|
*/
|
||||||
public DispositionSchedule createBasicDispositionSchedule(NodeRef container)
|
public DispositionSchedule createBasicDispositionSchedule(NodeRef container)
|
||||||
{
|
{
|
||||||
@@ -207,14 +223,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
|||||||
modelSecurityService.setEnabled(false);
|
modelSecurityService.setEnabled(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Declare record
|
|
||||||
nodeService.setProperty(record, DOD5015Model.PROP_PUBLICATION_DATE, new Date());
|
|
||||||
nodeService.setProperty(record, DOD5015Model.PROP_MEDIA_TYPE, "mediaTypeValue");
|
|
||||||
nodeService.setProperty(record, DOD5015Model.PROP_FORMAT, "formatValue");
|
|
||||||
nodeService.setProperty(record, DOD5015Model.PROP_DATE_RECEIVED, new Date());
|
|
||||||
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date());
|
nodeService.setProperty(record, RecordsManagementModel.PROP_DATE_FILED, new Date());
|
||||||
nodeService.setProperty(record, DOD5015Model.PROP_ORIGINATOR, "origValue");
|
|
||||||
nodeService.setProperty(record, DOD5015Model.PROP_ORIGINATING_ORGANIZATION, "origOrgValue");
|
|
||||||
nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue");
|
nodeService.setProperty(record, ContentModel.PROP_TITLE, "titleValue");
|
||||||
actionService.executeRecordsManagementAction(record, "declareRecord");
|
actionService.executeRecordsManagementAction(record, "declareRecord");
|
||||||
}
|
}
|
||||||
@@ -251,37 +260,6 @@ public class CommonRMTestUtils implements RecordsManagementModel
|
|||||||
}, AuthenticationUtil.getAdminUserName());
|
}, AuthenticationUtil.getAdminUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void freeze(final NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Void doWork() throws Exception
|
|
||||||
{
|
|
||||||
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
|
|
||||||
params.put(FreezeAction.PARAM_REASON, "Freeze reason.");
|
|
||||||
actionService.executeRecordsManagementAction(nodeRef, "freeze", params);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unfreeze(final NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Void doWork() throws Exception
|
|
||||||
{
|
|
||||||
actionService.executeRecordsManagementAction(nodeRef, "unfreeze");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}, AuthenticationUtil.getSystemUserName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Role createRole(NodeRef filePlan, String roleName, String ... capabilityNames)
|
public Role createRole(NodeRef filePlan, String roleName, String ... capabilityNames)
|
||||||
{
|
{
|
||||||
Set<Capability> capabilities = new HashSet<Capability>(capabilityNames.length);
|
Set<Capability> capabilities = new HashSet<Capability>(capabilityNames.length);
|
||||||
|
Reference in New Issue
Block a user