use of org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent in project records-management by Alfresco.
the class ListOfValuesGet method createEventsModel.
/**
* Creates the model for the list of events.
*
* @param baseUrl The base URL of the service
* @return model of events list
*/
protected Map<String, Object> createEventsModel(String baseUrl) {
// get all the events including their display labels from the event service
List<RecordsManagementEvent> events = this.rmEventService.getEvents();
List<Map<String, Object>> items = new ArrayList<Map<String, Object>>(events.size());
for (RecordsManagementEvent event : events) {
Map<String, Object> item = new HashMap<String, Object>(3);
item.put("label", event.getDisplayLabel());
item.put("value", event.getName());
item.put("automatic", this.rmEventService.getEventType(event.getType()).isAutomaticEvent());
items.add(item);
}
// create the model
Map<String, Object> model = new HashMap<String, Object>(2);
model.put("url", baseUrl + "/events");
model.put("items", items);
return model;
}
use of org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent in project records-management by Alfresco.
the class RmEventPut method executeImpl.
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest,
* org.springframework.extensions.webscripts.Status,
* org.springframework.extensions.webscripts.Cache)
*/
@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
ParameterCheck.mandatory("req", req);
Map<String, Object> model = new HashMap<String, Object>();
JSONObject json = null;
try {
// Convert the request content to JSON
json = new JSONObject(new JSONTokener(req.getContent().getContent()));
// Check the event name
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
String eventName = templateVars.get(PARAM_EVENTNAME);
if (eventName == null || eventName.isEmpty() || !rmEventService.existsEvent(eventName)) {
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided.");
}
// Check the event display label
String eventDisplayLabel = getValue(json, "eventDisplayLabel");
doCheck(eventDisplayLabel, "No event display label was provided.");
// Check the event type
String eventType = getValue(json, "eventType");
doCheck(eventType, "No event type was provided.");
// Check if the event can be edited or not
RecordsManagementEvent event = null;
if (canEditEvent(eventDisplayLabel, eventName, eventType)) {
// Create event
event = rmEventService.addEvent(eventType, eventName, eventDisplayLabel);
} else {
// Get event
event = rmEventService.getEvent(eventName);
}
model.put("event", event);
} catch (IOException iox) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not read content from req.", iox);
} catch (JSONException je) {
throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Could not parse JSON from req.", je);
}
return model;
}
use of org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent in project records-management by Alfresco.
the class DispositionActionDefinitionImpl method getEvents.
/**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition#getEvents()
*/
@Override
@SuppressWarnings("unchecked")
public List<RecordsManagementEvent> getEvents() {
List<RecordsManagementEvent> events = null;
Collection<String> eventNames = (Collection<String>) nodeService.getProperty(this.dispositionActionNodeRef, PROP_DISPOSITION_EVENT);
if (eventNames != null) {
events = new ArrayList<RecordsManagementEvent>(eventNames.size());
for (String eventName : eventNames) {
RecordsManagementEvent event = recordsManagementEventService.getEvent(eventName);
events.add(event);
}
} else {
events = java.util.Collections.EMPTY_LIST;
}
return events;
}
use of org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent in project records-management by Alfresco.
the class DispositionServiceImpl method initialiseDispositionAction.
/**
* ========= Disposition Action Methods =========
*/
/**
* Initialises the details of the next disposition action based on the details of a disposition
* action definition.
*
* @param nodeRef node reference
* @param dispositionActionDefinition disposition action definition
*/
private DispositionAction initialiseDispositionAction(NodeRef nodeRef, DispositionActionDefinition dispositionActionDefinition) {
List<ChildAssociationRef> childAssocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true);
if (childAssocs != null && !childAssocs.isEmpty()) {
return new DispositionActionImpl(serviceRegistry, childAssocs.get(0).getChildRef());
}
// Create the properties
Map<QName, Serializable> props = new HashMap<QName, Serializable>(10);
Date asOfDate = calculateAsOfDate(nodeRef, dispositionActionDefinition);
// Set the property values
props.put(PROP_DISPOSITION_ACTION_ID, dispositionActionDefinition.getId());
props.put(PROP_DISPOSITION_ACTION, dispositionActionDefinition.getName());
if (asOfDate != null) {
props.put(PROP_DISPOSITION_AS_OF, asOfDate);
}
// Create a new disposition action object
NodeRef dispositionActionNodeRef = this.nodeService.createNode(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, TYPE_DISPOSITION_ACTION, props).getChildRef();
DispositionAction da = new DispositionActionImpl(serviceRegistry, dispositionActionNodeRef);
// Create the events
List<RecordsManagementEvent> events = dispositionActionDefinition.getEvents();
for (RecordsManagementEvent event : events) {
// For every event create an entry on the action
da.addEventCompletionDetails(event);
}
return da;
}
use of org.alfresco.module.org_alfresco_module_rm.event.RecordsManagementEvent in project records-management by Alfresco.
the class RmEventGet method executeImpl.
@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
Map<String, Object> model = new HashMap<String, Object>();
// Event name
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
String eventName = templateVars.get("eventname");
if (eventName == null) {
throw new WebScriptException(Status.STATUS_NOT_FOUND, "No event name was provided on the URL.");
}
// Check the event exists
if (!rmEventService.existsEvent(eventName)) {
throw new WebScriptException(Status.STATUS_NOT_FOUND, "The event " + eventName + " does not exist.");
}
// Get the event
RecordsManagementEvent event = rmEventService.getEvent(eventName);
model.put("event", event);
return model;
}
Aggregations