use of org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails in project records-management by Alfresco.
the class DispositionLifecycleGet method executeImpl.
/*
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
// parse the request to retrieve the next action
NodeRef nodeRef = parseRequestForNodeRef(req);
// make sure the node passed in has a next action attached
DispositionAction nextAction = getDispositionService().getNextDispositionAction(nodeRef);
if (nextAction == null) {
Map<String, Object> nextActionModel = new HashMap<String, Object>(2);
nextActionModel.put("notFound", true);
nextActionModel.put("message", "Node " + nodeRef.toString() + " does not have a disposition lifecycle");
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("nextaction", nextActionModel);
return model;
} else {
// add all the next action data to Map
Map<String, Object> nextActionModel = new HashMap<String, Object>(8);
String serviceUrl = req.getServiceContextPath() + req.getPathInfo();
nextActionModel.put("url", serviceUrl);
nextActionModel.put("name", nextAction.getName());
nextActionModel.put("label", nextAction.getLabel());
nextActionModel.put("eventsEligible", getDispositionService().isNextDispositionActionEligible(nodeRef));
if (nextAction.getAsOfDate() != null) {
nextActionModel.put("asOf", ISO8601DateFormat.format(nextAction.getAsOfDate()));
}
if (nextAction.getStartedAt() != null) {
nextActionModel.put("startedAt", ISO8601DateFormat.format(nextAction.getStartedAt()));
}
String startedBy = nextAction.getStartedBy();
if (startedBy != null) {
nextActionModel.put("startedBy", startedBy);
addUsersRealName(nextActionModel, startedBy, "startedBy");
}
if (nextAction.getCompletedAt() != null) {
nextActionModel.put("completedAt", ISO8601DateFormat.format(nextAction.getCompletedAt()));
}
String completedBy = nextAction.getCompletedBy();
if (completedBy != null) {
nextActionModel.put("completedBy", completedBy);
addUsersRealName(nextActionModel, completedBy, "completedBy");
}
List<Map<String, Object>> events = new ArrayList<Map<String, Object>>();
for (EventCompletionDetails event : nextAction.getEventCompletionDetails()) {
events.add(createEventModel(event));
}
nextActionModel.put("events", events);
// create model object with just the schedule data
Map<String, Object> model = new HashMap<String, Object>(1);
model.put("nextaction", nextActionModel);
return model;
}
}
use of org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails in project records-management by Alfresco.
the class BroadcastDispositionActionDefinitionUpdateAction method rollupSearchProperties.
/**
* Manually update the rolled up search properties
*
* @param disposableItem disposable item
*/
private void rollupSearchProperties(NodeRef disposableItem) {
DispositionAction da = getDispositionService().getNextDispositionAction(disposableItem);
if (da != null) {
Map<QName, Serializable> props = getNodeService().getProperties(disposableItem);
props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName());
props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate());
props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, getNodeService().getProperty(da.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE));
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
Period period = daDefinition.getPeriod();
if (period != null) {
props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType());
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression());
} else {
props.put(PROP_RS_DISPOSITION_PERIOD, null);
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null);
}
List<EventCompletionDetails> events = da.getEventCompletionDetails();
List<String> list = new ArrayList<String>(events.size());
for (EventCompletionDetails event : events) {
list.add(event.getEventName());
}
props.put(PROP_RS_DISPOSITION_EVENTS, (Serializable) list);
getNodeService().setProperties(disposableItem, props);
}
}
use of org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails in project records-management by Alfresco.
the class DispositionServiceImplTest method checkDispositionAction.
/**
* @param da
* @param name
* @param arrEventNames
* @param strPeriod
*/
private void checkDispositionAction(DispositionAction da, String name, String[] arrEventNames, String strPeriod) {
assertNotNull(da);
assertEquals(name, da.getName());
List<EventCompletionDetails> events = da.getEventCompletionDetails();
assertNotNull(events);
assertEquals(arrEventNames.length, events.size());
List<String> origEvents = new ArrayList<String>(events.size());
for (EventCompletionDetails event : events) {
origEvents.add(event.getEventName());
}
List<String> expectedEvents = Arrays.asList(arrEventNames);
Collection<String> copy = new ArrayList<String>(origEvents);
for (Iterator<String> i = origEvents.iterator(); i.hasNext(); ) {
String origEvent = i.next();
if (expectedEvents.contains(origEvent)) {
i.remove();
copy.remove(origEvent);
}
}
if (copy.size() != 0 && expectedEvents.size() != 0) {
StringBuffer buff = new StringBuffer(255);
if (copy.size() != 0) {
buff.append("The following events where found, but not expected: (");
for (String eventName : copy) {
buff.append(eventName).append(", ");
}
buff.append("). ");
}
if (expectedEvents.size() != 0) {
buff.append("The following events where not found, but expected: (");
for (String eventName : expectedEvents) {
buff.append(eventName).append(", ");
}
buff.append(").");
}
fail(buff.toString());
}
if (CommonRMTestUtils.PERIOD_NONE.equals(strPeriod)) {
assertNull(da.getAsOfDate());
} else {
assertNotNull(da.getAsOfDate());
}
}
use of org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails in project records-management by Alfresco.
the class DispositionActionImpl method updateEventEligible.
/**
* 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()) {
// get the disposition action definition
DispositionActionDefinition dispositionActionDefinition = getDispositionActionDefinition();
if (dispositionActionDefinition != null) {
if (!dispositionActionDefinition.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;
}
use of org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails in project records-management by Alfresco.
the class DispositionActionImpl method getEventCompletionDetailsFromNodeRef.
/**
* 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;
}
Aggregations