Search in sources :

Example 46 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RM3993Test method createFile.

private NodeRef createFile(NodeRef parentNodeRef, String name, String descrption, QName typeQName) {
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>(11);
    properties.put(ContentModel.PROP_NAME, (Serializable) name);
    properties.put(ContentModel.PROP_DESCRIPTION, (Serializable) descrption);
    QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name));
    ChildAssociationRef assocRef = nodeService.createNode(parentNodeRef, ContentModel.ASSOC_CONTAINS, assocQName, typeQName, properties);
    NodeRef nodeRef = assocRef.getChildRef();
    return nodeRef;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 47 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RM4163Test method createFile.

private NodeRef createFile(NodeRef parentNodeRef, String name, String descrption, QName typeQName) {
    Map<QName, Serializable> properties = new HashMap<QName, Serializable>(11);
    properties.put(ContentModel.PROP_NAME, (Serializable) name);
    properties.put(ContentModel.PROP_DESCRIPTION, (Serializable) descrption);
    QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName(name));
    ChildAssociationRef assocRef = nodeService.createNode(parentNodeRef, ContentModel.ASSOC_CONTAINS, assocQName, typeQName, properties);
    NodeRef nodeRef = assocRef.getChildRef();
    return nodeRef;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 48 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RMv21InPlacePatch method moveExistingTransfers.

private void moveExistingTransfers(NodeRef filePlan) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("  ... moving existing transfers for file plan " + filePlan.toString());
    }
    NodeRef container = filePlanService.getTransferContainer(filePlan);
    List<ChildAssociationRef> assocs = nodeService.getChildAssocs(filePlan, ASSOC_TRANSFERS, RegexQNamePattern.MATCH_ALL);
    for (ChildAssociationRef assoc : assocs) {
        NodeRef transfer = assoc.getChildRef();
        String name = (String) nodeService.getProperty(transfer, ContentModel.PROP_NAME);
        nodeService.moveNode(transfer, container, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, name));
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 49 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class RMv21InPlacePatch method moveExistingHolds.

private void moveExistingHolds(NodeRef filePlan) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("  ... moving existing holds for file plan " + filePlan.toString());
    }
    NodeRef container = filePlanService.getHoldContainer(filePlan);
    List<ChildAssociationRef> assocs = nodeService.getChildAssocs(filePlan, ASSOC_HOLDS, RegexQNamePattern.MATCH_ALL);
    for (ChildAssociationRef assoc : assocs) {
        NodeRef hold = assoc.getChildRef();
        String name = (String) nodeService.getProperty(hold, ContentModel.PROP_NAME);
        nodeService.moveNode(hold, container, ContentModel.ASSOC_CONTAINS, QName.createQName(RM_URI, name));
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Example 50 with ChildAssociationRef

use of org.alfresco.service.cmr.repository.ChildAssociationRef in project records-management by Alfresco.

the class TransferEvaluator method getTransferNodeRef.

/**
 * Helper method to get the transfer node reference.
 * <p>
 * Takes into account records in tranferred record folders.
 *
 * @param nodeRef               node reference
 * @return {@link NodeRef}      transfer node
 */
private NodeRef getTransferNodeRef(NodeRef nodeRef) {
    NodeRef result = null;
    List<ChildAssociationRef> parents = nodeService.getParentAssocs(nodeRef, RecordsManagementModel.ASSOC_TRANSFERRED, RegexQNamePattern.MATCH_ALL);
    if (parents.size() == 1) {
        result = parents.get(0).getParentRef();
    } else {
        if (recordService.isRecord(nodeRef)) {
            for (NodeRef recordFolder : recordFolderService.getRecordFolders(nodeRef)) {
                result = getTransferNodeRef(recordFolder);
                if (result != null) {
                    break;
                }
            }
        }
    }
    return result;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) ChildAssociationRef(org.alfresco.service.cmr.repository.ChildAssociationRef)

Aggregations

ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)260 NodeRef (org.alfresco.service.cmr.repository.NodeRef)204 QName (org.alfresco.service.namespace.QName)110 Test (org.junit.Test)57 HashMap (java.util.HashMap)54 BaseUnitTest (org.alfresco.module.org_alfresco_module_rm.test.util.BaseUnitTest)53 ArrayList (java.util.ArrayList)52 Serializable (java.io.Serializable)42 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)25 FacesContext (javax.faces.context.FacesContext)22 Map (java.util.Map)19 UserTransaction (javax.transaction.UserTransaction)18 Node (org.alfresco.web.bean.repository.Node)17 Date (java.util.Date)15 StoreRef (org.alfresco.service.cmr.repository.StoreRef)13 NodeService (org.alfresco.service.cmr.repository.NodeService)12 SiteInfo (org.alfresco.service.cmr.site.SiteInfo)12 List (java.util.List)11 StringPropertyValue (org.alfresco.solr.client.StringPropertyValue)11 IOException (java.io.IOException)10