use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RecordsManagementSearchBehaviour method getRecordFolders.
/**
* Helper method to get the record folders contained in the provided record category.
*
* @param recordCategoryNode record category node reference
* @return List<NodeRef> contained record folders
*/
private List<NodeRef> getRecordFolders(NodeRef recordCategoryNode) {
List<NodeRef> results = new ArrayList<NodeRef>(8);
List<ChildAssociationRef> folderAssocs = nodeService.getChildAssocs(recordCategoryNode, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef folderAssoc : folderAssocs) {
NodeRef folder = folderAssoc.getChildRef();
if (recordFolderService.isRecordFolder(folder)) {
results.add(folder);
}
}
return results;
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class NotificationTemplatePatch_v21 method executePatch.
@Override
protected void executePatch() {
NodeRef nodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, CONFIG_NODEID);
// get the parent node
NodeRef supersededTemplate = notificationHelper.getSupersededTemplate();
if (!nodeService.exists(nodeRef) && nodeService.exists(supersededTemplate)) {
NodeRef parent = nodeService.getPrimaryParent(supersededTemplate).getParentRef();
// build the node properties
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4);
props.put(ContentModel.PROP_DESCRIPTION, "Record superseded email template.");
props.put(ContentModel.PROP_TITLE, "record-rejected-email.ftl");
props.put(ContentModel.PROP_NAME, "record-rejected-email.ftl");
props.put(ContentModel.PROP_NODE_UUID, "record_rejected_template");
// get the assoc qname
QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("record-rejected-email.ftl"));
// create the node
ChildAssociationRef node = nodeService.createNode(parent, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_CONTENT, props);
// put the content
ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true);
InputStream is = getClass().getClassLoader().getResourceAsStream(PATH_REJECTED);
writer.putContent(is);
}
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RMv22HoldReportPatch method applyInternal.
/**
* @see org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch#applyInternal()
*/
@Override
public void applyInternal() {
if (!nodeService.exists(REPORT)) {
// get the assoc qname
QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("report_rmr_holdReport.html.ftl"));
// build the node properties
Map<QName, Serializable> props = new HashMap<QName, Serializable>(4);
props.put(ContentModel.PROP_DESCRIPTION, "Hold report template.");
props.put(ContentModel.PROP_TITLE, "Hold Report Template");
props.put(ContentModel.PROP_NAME, "report_rmr_holdReport.html.ftl");
props.put(ContentModel.PROP_NODE_UUID, "rmr_holdReport");
// create the node
ChildAssociationRef node = nodeService.createNode(REPORT_FOLDER, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_CONTENT, props);
// put the content
ContentWriter writer = contentService.getWriter(node.getChildRef(), ContentModel.PROP_CONTENT, true);
writer.setEncoding("UTF-8");
writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
InputStream is = getClass().getClassLoader().getResourceAsStream(REPORT_TEMPLATE_PATH);
writer.putContent(is);
}
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class BaseUnitTest method makeChildrenOf.
/**
* Helper method to make a number of nodes children of another.
* <p>
* Assumes the cm:contains assoc type.
*
* @param parent
* @param children
*/
protected void makeChildrenOf(NodeRef parent, NodeRef... children) {
List<ChildAssociationRef> assocs = new ArrayList<ChildAssociationRef>(children.length);
for (NodeRef child : children) {
assocs.add(new ChildAssociationRef(ContentModel.ASSOC_CONTAINS, parent, generateQName(), child));
doReturn(assocs).when(mockedNodeService).getParentAssocs(child);
}
doReturn(assocs).when(mockedNodeService).getChildAssocs(parent, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
}
use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.
the class RecordFolderTypeUnitTest method testCreateNonFolderSubType.
/**
* Given that we try to add non cm:folder sub-type to a record folder,
* Then IntegrityException is thrown.
*/
@Test(expected = IntegrityException.class)
public void testCreateNonFolderSubType() throws Exception {
NodeRef recordFolderNodeRef = AlfMock.generateNodeRef(mockedNodeService, TYPE_RECORD_FOLDER);
QName type = AlfMock.generateQName();
when(mockedDictionaryService.isSubClass(type, TYPE_FOLDER)).thenReturn(false);
NodeRef nodeRef = AlfMock.generateNodeRef(mockedNodeService, type, true);
ChildAssociationRef childAssocRef = generateChildAssociationRef(recordFolderNodeRef, nodeRef);
recordFolderType.onCreateChildAssociation(childAssocRef, true);
}
Aggregations