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);
}
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.");
}
}
}
}
}
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());
}
}
Aggregations