Search in sources :

Example 11 with Period

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

the class VitalRecordDefinitionImpl method create.

/**
 * Helper method to create vital record definition from node reference.
 *
 * @param nodeService
 * @param nodeRef
 * @return
 */
/* package */
static VitalRecordDefinition create(NodeService nodeService, NodeRef nodeRef) {
    Boolean enabled = (Boolean) nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR);
    if (enabled == null) {
        enabled = Boolean.FALSE;
    }
    Period reviewPeriod = (Period) nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD);
    return new VitalRecordDefinitionImpl(enabled, reviewPeriod);
}
Also used : Period(org.alfresco.service.cmr.repository.Period)

Example 12 with Period

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

the class RMv2FilePlanNodeRefPatch method executePatch.

/**
 * @see org.alfresco.repo.module.AbstractModuleComponent#executeInternal()
 */
@Override
protected void executePatch() {
    Pair<Long, QName> aspectPair = qnameDAO.getQName(RecordsManagementModel.ASPECT_FILE_PLAN_COMPONENT);
    if (aspectPair != null) {
        List<Long> filePlanComponents = patchDAO.getNodesByAspectQNameId(aspectPair.getFirst(), 0L, patchDAO.getMaxAdmNodeID());
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("   ... updating " + filePlanComponents.size() + " items");
        }
        for (Long filePlanComponent : filePlanComponents) {
            Pair<Long, NodeRef> recordPair = nodeDAO.getNodePair(filePlanComponent);
            NodeRef filePlanComponentNodeRef = recordPair.getSecond();
            NodeRef filePlan = filePlanService.getFilePlan(filePlanComponentNodeRef);
            if (filePlan != null) {
                // set the file plan node reference
                if (nodeService.getProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF) == null) {
                    nodeService.setProperty(filePlanComponentNodeRef, PROP_ROOT_NODEREF, filePlan);
                }
                // only set the admin permissions on record categories, record folders and records
                FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(filePlanComponentNodeRef);
                if (FilePlanComponentKind.RECORD_CATEGORY.equals(kind) || FilePlanComponentKind.RECORD_FOLDER.equals(kind) || FilePlanComponentKind.RECORD.equals(kind)) {
                    // ensure the that the records management role has read and file on the node
                    Role adminRole = filePlanRoleService.getRole(filePlan, "Administrator");
                    if (adminRole != null) {
                        permissionService.setPermission(filePlanComponentNodeRef, adminRole.getRoleGroupName(), RMPermissionModel.FILING, true);
                    }
                    // ensure that the default vital record default values have been set (RM-753)
                    Serializable vitalRecordIndicator = nodeService.getProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR);
                    if (vitalRecordIndicator == null) {
                        nodeService.setProperty(filePlanComponentNodeRef, PROP_VITAL_RECORD_INDICATOR, false);
                    }
                    Serializable reviewPeriod = nodeService.getProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD);
                    if (reviewPeriod == null) {
                        nodeService.setProperty(filePlanComponentNodeRef, PROP_REVIEW_PERIOD, new Period("none|0"));
                    }
                }
            } else {
                if (LOGGER.isWarnEnabled()) {
                    LOGGER.warn("   ... node " + filePlanComponent.toString() + " was skiped, beacuse there was no associated file plan.");
                }
            }
        }
    }
}
Also used : Role(org.alfresco.module.org_alfresco_module_rm.role.Role) NodeRef(org.alfresco.service.cmr.repository.NodeRef) Serializable(java.io.Serializable) QName(org.alfresco.service.namespace.QName) Period(org.alfresco.service.cmr.repository.Period) FilePlanComponentKind(org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind)

Example 13 with Period

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

the class VitalRecordServiceImplTest method assertHasVitalRecordDefinition.

@SuppressWarnings("deprecation")
private void assertHasVitalRecordDefinition(NodeRef nodeRef, boolean enabled, Period period) {
    assertTrue(nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD_DEFINITION));
    VitalRecordDefinition def = vitalRecordService.getVitalRecordDefinition(nodeRef);
    assertNotNull(def);
    Boolean vitalRecordIndicator = (Boolean) nodeService.getProperty(nodeRef, PROP_VITAL_RECORD_INDICATOR);
    assertNotNull(vitalRecordIndicator);
    assertEquals(enabled, vitalRecordIndicator.booleanValue());
    assertEquals(enabled, def.isEnabled());
    if (enabled) {
        Period reviewPeriod = (Period) nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD);
        assertNotNull(reviewPeriod);
        assertEquals(period, reviewPeriod);
        assertEquals(period, def.getReviewPeriod());
        assertEquals(period.getNextDate(new Date()).getDate(), def.getNextReviewDate().getDate());
    }
}
Also used : VitalRecordDefinition(org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition) Period(org.alfresco.service.cmr.repository.Period) Date(java.util.Date)

Aggregations

Period (org.alfresco.service.cmr.repository.Period)13 QName (org.alfresco.service.namespace.QName)7 NodeRef (org.alfresco.service.cmr.repository.NodeRef)6 Serializable (java.io.Serializable)5 Date (java.util.Date)5 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 DispositionAction (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction)2 DispositionActionDefinition (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition)2 FilePlanComponentKind (org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind)2 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)2 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 Locale (java.util.Locale)1 DispositionActionImpl (org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionImpl)1 EventCompletionDetails (org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails)1 Role (org.alfresco.module.org_alfresco_module_rm.role.Role)1 VitalRecordDefinition (org.alfresco.module.org_alfresco_module_rm.vital.VitalRecordDefinition)1 StoreRef (org.alfresco.service.cmr.repository.StoreRef)1