use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class DispositionServiceImpl method getNextDispositionActionNodeRef.
/**
* Get the next disposition action node. Null if none present.
*
* @param nodeRef the disposable node reference
* @return NodeRef the next disposition action, null if none
*/
private NodeRef getNextDispositionActionNodeRef(NodeRef nodeRef) {
NodeRef result = null;
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_NEXT_DISPOSITION_ACTION, ASSOC_NEXT_DISPOSITION_ACTION, 1, true);
if (!assocs.isEmpty()) {
result = assocs.get(0).getChildRef();
}
return result;
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class DispositionServiceImpl method createDispositionSchedule.
/**
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#createDispositionSchedule(org.alfresco.service.cmr.repository.NodeRef, java.util.Map)
*/
@Override
public DispositionSchedule createDispositionSchedule(NodeRef nodeRef, Map<QName, Serializable> props) {
NodeRef dsNodeRef = null;
// Check mandatory parameters
ParameterCheck.mandatory("nodeRef", nodeRef);
// Check exists
if (!nodeService.exists(nodeRef)) {
throw new AlfrescoRuntimeException("Unable to create retention schedule, because node does not exist. (nodeRef=" + nodeRef.toString() + ")");
}
// Check is sub-type of rm:recordCategory
QName nodeRefType = nodeService.getType(nodeRef);
if (!TYPE_RECORD_CATEGORY.equals(nodeRefType) && !dictionaryService.isSubClass(nodeRefType, TYPE_RECORD_CATEGORY)) {
throw new AlfrescoRuntimeException("Unable to create retention schedule on a node that is not a records management container.");
}
behaviourFilter.disableBehaviour(nodeRef, ASPECT_SCHEDULED);
try {
// Add the schedules aspect if required
if (!nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) {
nodeService.addAspect(nodeRef, ASPECT_SCHEDULED, null);
}
// Check whether there is already a disposition schedule object present
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
if (assocs.isEmpty()) {
DispositionSchedule currentDispositionSchdule = getDispositionSchedule(nodeRef);
if (currentDispositionSchdule != null) {
List<NodeRef> items = getDisposableItemsImpl(currentDispositionSchdule.isRecordLevelDisposition(), nodeRef);
if (!items.isEmpty()) {
throw new AlfrescoRuntimeException("Can not create a retention schedule if there are disposable items already under the control of an other retention schedule");
}
}
// Create the disposition schedule object
dsNodeRef = nodeService.createNode(nodeRef, ASSOC_DISPOSITION_SCHEDULE, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("dispositionSchedule")), TYPE_DISPOSITION_SCHEDULE, props).getChildRef();
} else {
// Error since the node already has a disposition schedule set
throw new AlfrescoRuntimeException("Unable to create retention schedule on node that already has a retention schedule.");
}
} finally {
behaviourFilter.enableBehaviour(nodeRef, ASPECT_SCHEDULED);
}
// Create the return object
return new DispositionScheduleImpl(serviceRegistry, nodeService, dsNodeRef);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class DispositionServiceImpl method getAssociatedDispositionScheduleImpl.
/**
* Gets the node reference of the disposition schedule associated with the container.
*
* @param nodeRef node reference of the container
* @return {@link NodeRef} node reference of the disposition schedule, null if none
*/
private NodeRef getAssociatedDispositionScheduleImpl(NodeRef nodeRef) {
NodeRef result = null;
ParameterCheck.mandatory("nodeRef", nodeRef);
// Make sure we are dealing with an RM node
if (!filePlanService.isFilePlanComponent(nodeRef)) {
throw new AlfrescoRuntimeException("Can not find the associated retention schedule for a non records management component. (nodeRef=" + nodeRef.toString() + ")");
}
if (this.nodeService.hasAspect(nodeRef, ASPECT_SCHEDULED)) {
List<ChildAssociationRef> childAssocs = this.nodeService.getChildAssocs(nodeRef, ASSOC_DISPOSITION_SCHEDULE, RegexQNamePattern.MATCH_ALL);
if (!childAssocs.isEmpty()) {
ChildAssociationRef firstChildAssocRef = childAssocs.get(0);
result = firstChildAssocRef.getChildRef();
}
}
return result;
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef 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.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class FilePlanServiceImpl method getContained.
/**
* Get contained nodes of a particular type. If null return all.
*
* @param container container node reference
* @param typeFilter type filter, null if none
* @return {@link List}<{@link NodeRef> list of contained node references
*/
private List<NodeRef> getContained(NodeRef container, QName typeFilter, boolean deep) {
// Parameter check
ParameterCheck.mandatory("container", container);
// Check we have a container in our hands
if (!isRecordCategory(container)) {
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_CONTAINER_EXPECTED));
}
List<NodeRef> result = new ArrayList<NodeRef>(1);
List<ChildAssociationRef> assocs = this.nodeService.getChildAssocs(container, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef assoc : assocs) {
NodeRef child = assoc.getChildRef();
QName childType = nodeService.getType(child);
if (typeFilter == null || typeFilter.equals(childType) || dictionaryService.isSubClass(childType, typeFilter)) {
result.add(child);
}
// Inspect the containers and add children if deep
if (deep && (TYPE_RECORD_CATEGORY.equals(childType) || dictionaryService.isSubClass(childType, TYPE_RECORD_CATEGORY))) {
result.addAll(getContained(child, typeFilter, deep));
}
}
return result;
}
Aggregations