RM-386: Rolled up search information out of date

* Rollup of search properties happens manually during the update of the disposition actions (for performance reasons)
  * Associated unit test



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@37272 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2012-05-31 05:11:52 +00:00
parent c166cf0ef6
commit f892f1f670
4 changed files with 176 additions and 17 deletions

View File

@@ -29,10 +29,10 @@ import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.action.RMActionExecuterAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionActionDefinition;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementSearchBehaviour;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
@@ -124,6 +124,50 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
// disposition lifecycle does not exist on the node so setup disposition
updateNextDispositionAction(disposableItem);
}
// update rolled up search information
rollupSearchProperties(disposableItem);
}
}
/**
* Manually update the rolled up search properties
*
* @param disposableItem disposable item
*/
private void rollupSearchProperties(NodeRef disposableItem)
{
DispositionAction da = dispositionService.getNextDispositionAction(disposableItem);
if (da != null)
{
Map<QName, Serializable> props = nodeService.getProperties(disposableItem);
props.put(PROP_RS_DISPOSITION_ACTION_NAME, da.getName());
props.put(PROP_RS_DISPOSITION_ACTION_AS_OF, da.getAsOfDate());
props.put(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE, this.nodeService.getProperty(da.getNodeRef(), PROP_DISPOSITION_EVENTS_ELIGIBLE));
DispositionActionDefinition daDefinition = da.getDispositionActionDefinition();
Period period = daDefinition.getPeriod();
if (period != null)
{
props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType());
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression());
}
else
{
props.put(PROP_RS_DISPOSITION_PERIOD, null);
props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null);
}
List<EventCompletionDetails> events = da.getEventCompletionDetails();
List<String> list = new ArrayList<String>(events.size());
for (EventCompletionDetails event : events)
{
list.add(event.getEventName());
}
props.put(PROP_RS_DISPOSITION_EVENTS, (Serializable)list);
nodeService.setProperties(disposableItem, props);
}
}

View File

@@ -204,4 +204,19 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
// Ghosted aspect
public static QName ASPECT_GHOSTED = QName.createQName(RM_URI, "ghosted");
// Search rollup aspect
public static final QName ASPECT_RM_SEARCH = QName.createQName(RM_URI, "recordSearch");
public static final QName PROP_RS_DISPOSITION_ACTION_NAME = QName.createQName(RM_URI, "recordSearchDispositionActionName");
public static final QName PROP_RS_DISPOSITION_ACTION_AS_OF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf");
public static final QName PROP_RS_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "recordSearchDispositionEventsEligible");
public static final QName PROP_RS_DISPOSITION_EVENTS = QName.createQName(RM_URI, "recordSearchDispositionEvents");
public static final QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriod");
public static final QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriodExpression");
public static final QName PROP_RS_DISPOSITION_PERIOD = QName.createQName(RM_URI, "recordSearchDispositionPeriod");
public static final QName PROP_RS_DISPOSITION_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchDispositionPeriodExpression");
public static final QName PROP_RS_HAS_DISPOITION_SCHEDULE = QName.createQName(RM_URI, "recordSearchHasDispositionSchedule");
public static final QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions");
public static final QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority");
public static final QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason");
}

View File

@@ -62,22 +62,7 @@ import org.apache.commons.logging.LogFactory;
*/
public class RecordsManagementSearchBehaviour implements RecordsManagementModel
{
private static Log logger = LogFactory.getLog(RecordsManagementSearchBehaviour.class);
/** Search specific elements of the RM model */
public static final QName ASPECT_RM_SEARCH = QName.createQName(RM_URI, "recordSearch");
public static final QName PROP_RS_DISPOSITION_ACTION_NAME = QName.createQName(RM_URI, "recordSearchDispositionActionName");
public static final QName PROP_RS_DISPOSITION_ACTION_AS_OF = QName.createQName(RM_URI, "recordSearchDispositionActionAsOf");
public static final QName PROP_RS_DISPOSITION_EVENTS_ELIGIBLE = QName.createQName(RM_URI, "recordSearchDispositionEventsEligible");
public static final QName PROP_RS_DISPOSITION_EVENTS = QName.createQName(RM_URI, "recordSearchDispositionEvents");
public static final QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriod");
public static final QName PROP_RS_VITAL_RECORD_REVIEW_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchVitalRecordReviewPeriodExpression");
public static final QName PROP_RS_DISPOSITION_PERIOD = QName.createQName(RM_URI, "recordSearchDispositionPeriod");
public static final QName PROP_RS_DISPOSITION_PERIOD_EXPRESSION = QName.createQName(RM_URI, "recordSearchDispositionPeriodExpression");
public static final QName PROP_RS_HAS_DISPOITION_SCHEDULE = QName.createQName(RM_URI, "recordSearchHasDispositionSchedule");
public static final QName PROP_RS_DISPOITION_INSTRUCTIONS = QName.createQName(RM_URI, "recordSearchDispositionInstructions");
public static final QName PROP_RS_DISPOITION_AUTHORITY = QName.createQName(RM_URI, "recordSearchDispositionAuthority");
public static final QName PROP_RS_HOLD_REASON = QName.createQName(RM_URI, "recordSearchHoldReason");
private static Log logger = LogFactory.getLog(RecordsManagementSearchBehaviour.class);
/** Policy component */
private PolicyComponent policyComponent;

View File

@@ -35,6 +35,7 @@ import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedul
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
import org.alfresco.module.org_alfresco_module_rm.event.EventCompletionDetails;
import org.alfresco.module.org_alfresco_module_rm.job.PublishUpdatesJobExecuter;
import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutor;
import org.alfresco.module.org_alfresco_module_rm.job.publish.PublishExecutorRegistry;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
@@ -898,4 +899,118 @@ public class DispositionServiceImplTest extends BaseRMTestCase
});
}
private NodeRef testRM386RecordCategory;
private DispositionSchedule testRM386DispositionSchedule;
private NodeRef testRM386Record;
/**
* Test to make sure all the search rollups are correct after schedule is updated
* @throws Exception
*/
public void testRM386() throws Exception
{
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
testRM386RecordCategory = rmService.createRecordCategory(rmContainer, "RM386");
testRM386DispositionSchedule = utils.createBasicDispositionSchedule(
testRM386RecordCategory,
"disposition instructions",
"disposition authority",
true, // record level
true); // set the default actions
NodeRef recordFolder = rmService.createRecordFolder(testRM386RecordCategory, "testRM386RecordFolder");
testRM386Record = utils.createRecord(recordFolder, "testRM386Record", "testRM386Record");
return null;
}
@SuppressWarnings("unchecked")
@Override
public void test(Void result) throws Exception
{
// Test the rollups for the record
Map<QName, Serializable> properties = nodeService.getProperties(testRM386Record);
assertEquals(Boolean.TRUE, properties.get(PROP_RS_HAS_DISPOITION_SCHEDULE));
assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, properties.get(PROP_RS_DISPOITION_AUTHORITY));
assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, properties.get(PROP_RS_DISPOITION_INSTRUCTIONS));
assertEquals("none", properties.get(PROP_RS_DISPOSITION_PERIOD));
assertEquals("0", properties.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION));
List<String> events = (List<String>)properties.get(PROP_RS_DISPOSITION_EVENTS);
assertNotNull(events);
assertEquals(1, events.size());
assertEquals(CommonRMTestUtils.DEFAULT_EVENT_NAME, events.get(0));
assertEquals(Boolean.FALSE, properties.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE));
assertEquals("cutoff", properties.get(PROP_RS_DISPOSITION_ACTION_NAME));
assertNull(properties.get(PROP_RS_DISPOSITION_ACTION_AS_OF));
}
});
doTestInTransaction(new Test<DispositionActionDefinition>()
{
@Override
public DispositionActionDefinition run() throws Exception
{
DispositionActionDefinition actionDefinition = testRM386DispositionSchedule.getDispositionActionDefinitionByName("cutoff");
assertNotNull(actionDefinition);
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
List<String> events = new ArrayList<String>(1);
events.add(CommonRMTestUtils.DEFAULT_EVENT_NAME);
events.add("obsolete");
adParams.put(PROP_DISPOSITION_EVENT, (Serializable)events);
adParams.put(PROP_DISPOSITION_PERIOD, "week|1");
dispositionService.updateDispositionActionDefinition(
actionDefinition,
adParams );
return actionDefinition;
}
@SuppressWarnings("unchecked")
@Override
public void test(DispositionActionDefinition result) throws Exception
{
// Publish the updates
PublishUpdatesJobExecuter updater = (PublishUpdatesJobExecuter)applicationContext.getBean("publishUpdatesJobExecuter");
updater.execute();
// Check the record has been updated
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(testRM386Record);
assertNotNull(dispositionAction);
assertEquals("cutoff", dispositionAction.getName());
assertNotNull(dispositionAction.getAsOfDate());
assertEquals(2, dispositionAction.getEventCompletionDetails().size());
// Test the rollups for the record
Map<QName, Serializable> properties = nodeService.getProperties(testRM386Record);
assertEquals(Boolean.TRUE, properties.get(PROP_RS_HAS_DISPOITION_SCHEDULE));
assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_AUTHORITY, properties.get(PROP_RS_DISPOITION_AUTHORITY));
assertEquals(CommonRMTestUtils.DEFAULT_DISPOSITION_INSTRUCTIONS, properties.get(PROP_RS_DISPOITION_INSTRUCTIONS));
assertEquals("week", properties.get(PROP_RS_DISPOSITION_PERIOD));
assertEquals("1", properties.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION));
List<String> events = (List<String>)properties.get(PROP_RS_DISPOSITION_EVENTS);
assertNotNull(events);
assertEquals(2, events.size());
assertEquals(Boolean.FALSE, properties.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE));
assertEquals("cutoff", properties.get(PROP_RS_DISPOSITION_ACTION_NAME));
assertNotNull(properties.get(PROP_RS_DISPOSITION_ACTION_AS_OF));
}
});
}
}