use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction 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.disposition.DispositionAction in project records-management by Alfresco.
the class TransferServiceImpl method transfer.
/**
* @see org.alfresco.module.org_alfresco_module_rm.transfer.TransferService#transfer(NodeRef, boolean)
*/
@Override
public NodeRef transfer(NodeRef nodeRef, boolean isAccession) {
ParameterCheck.mandatory("nodeRef", nodeRef);
// Get the root rm node
NodeRef root = filePlanService.getFilePlan(nodeRef);
// Get the transfer object
NodeRef transferNodeRef = (NodeRef) AlfrescoTransactionSupport.getResource(KEY_TRANSFER_NODEREF);
if (transferNodeRef == null) {
// Calculate a transfer name
QName nodeDbid = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "node-dbid");
Long dbId = (Long) nodeService.getProperty(nodeRef, nodeDbid);
String transferName = StringUtils.leftPad(dbId.toString(), 10, "0");
// Create the transfer object
Map<QName, Serializable> transferProps = new HashMap<QName, Serializable>(2);
transferProps.put(ContentModel.PROP_NAME, transferName);
transferProps.put(PROP_TRANSFER_ACCESSION_INDICATOR, isAccession);
// setup location property from disposition schedule
DispositionAction da = dispositionService.getNextDispositionAction(nodeRef);
if (da != null) {
DispositionActionDefinition actionDef = da.getDispositionActionDefinition();
if (actionDef != null) {
transferProps.put(PROP_TRANSFER_LOCATION, actionDef.getLocation());
}
}
NodeRef transferContainer = filePlanService.getTransferContainer(root);
transferContainerType.disable();
transferType.disable();
try {
transferNodeRef = nodeService.createNode(transferContainer, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, transferName), TYPE_TRANSFER, transferProps).getChildRef();
} finally {
transferContainerType.enable();
transferType.enable();
}
// Bind the hold node reference to the transaction
AlfrescoTransactionSupport.bindResource(KEY_TRANSFER_NODEREF, transferNodeRef);
} else {
// ensure this node has not already in the process of being transferred
List<ChildAssociationRef> transferredAlready = nodeService.getChildAssocs(transferNodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED);
for (ChildAssociationRef car : transferredAlready) {
if (car.getChildRef().equals(nodeRef)) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_NODE_ALREADY_TRANSFER, nodeRef.toString()));
}
}
}
// Link the record to the trasnfer object
transferType.disable();
try {
nodeService.addChild(transferNodeRef, nodeRef, ASSOC_TRANSFERRED, ASSOC_TRANSFERRED);
// Set PDF indicator flag
setPDFIndicationFlag(transferNodeRef, nodeRef);
} finally {
transferType.enable();
}
// Set the transferring indicator aspect
nodeService.addAspect(nodeRef, ASPECT_TRANSFERRING, null);
if (isRecordFolder(nodeRef)) {
// add the transferring indicator aspect to all the child records
for (NodeRef record : recordService.getRecords(nodeRef)) {
nodeService.addAspect(record, ASPECT_TRANSFERRING, null);
}
}
return transferNodeRef;
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction in project records-management by Alfresco.
the class TransferServiceImpl method markComplete.
/**
* Marks the node complete
*
* @param nodeRef
* disposition lifecycle node reference
*/
private void markComplete(NodeRef nodeRef, boolean accessionIndicator, String transferLocation) {
// Set the completed date
DispositionAction da = dispositionService.getNextDispositionAction(nodeRef);
if (da != null) {
nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_AT, new Date());
nodeService.setProperty(da.getNodeRef(), PROP_DISPOSITION_ACTION_COMPLETED_BY, AuthenticationUtil.getRunAsUser());
}
// Remove the transferring indicator aspect
nodeService.removeAspect(nodeRef, ASPECT_TRANSFERRING);
nodeService.setProperty(nodeRef, PROP_LOCATION, transferLocation);
// Determine which marker aspect to use
QName markerAspectQName = null;
if (accessionIndicator) {
markerAspectQName = ASPECT_ASCENDED;
} else {
markerAspectQName = ASPECT_TRANSFERRED;
}
// Mark the object and children accordingly
nodeService.addAspect(nodeRef, markerAspectQName, null);
if (recordFolderService.isRecordFolder(nodeRef)) {
List<NodeRef> records = recordService.getRecords(nodeRef);
for (NodeRef record : records) {
nodeService.addAspect(record, markerAspectQName, null);
nodeService.setProperty(record, PROP_LOCATION, transferLocation);
}
}
// Update to the next disposition action
dispositionService.updateNextDispositionAction(nodeRef);
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction in project records-management by Alfresco.
the class BroadcastDispositionActionDefinitionUpdateAction method processActionDefinitionChanges.
/**
* Processes all the changes applied to the given disposition
* action definition node for the given record or folder node.
*
* @param dispositionActionDef The disposition action definition node
* @param changedProps The set of properties changed on the action definition
* @param recordOrFolder The record or folder the changes potentially need to be applied to
*/
private void processActionDefinitionChanges(NodeRef dispositionActionDef, List<QName> changedProps, NodeRef recordOrFolder) {
// check that the step being edited is the current step for the folder,
// if not, the change has no effect on the current step so ignore
DispositionAction nextAction = getDispositionService().getNextDispositionAction(recordOrFolder);
if (doesChangedStepAffectNextAction(dispositionActionDef, nextAction)) {
// so go ahead and determine what needs updating
if ((changedProps.contains(PROP_DISPOSITION_PERIOD) || changedProps.contains(PROP_DISPOSITION_PERIOD_PROPERTY)) && isNotTrue((Boolean) getNodeService().getProperty(nextAction.getNodeRef(), PROP_MANUALLY_SET_AS_OF))) {
persistPeriodChanges(dispositionActionDef, nextAction);
}
if (changedProps.contains(PROP_DISPOSITION_EVENT) || changedProps.contains(PROP_DISPOSITION_EVENT_COMBINATION)) {
nextAction.refreshEvents();
}
if (changedProps.contains(PROP_DISPOSITION_ACTION_NAME)) {
String action = (String) getNodeService().getProperty(dispositionActionDef, PROP_DISPOSITION_ACTION_NAME);
getNodeService().setProperty(nextAction.getNodeRef(), PROP_DISPOSITION_ACTION, action);
}
}
}
use of org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction 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);
}
}
Aggregations