From cb11d527d47e0496d41033fb1408c6676eb9f025 Mon Sep 17 00:00:00 2001 From: roxana Date: Fri, 4 Nov 2016 10:19:24 +0200 Subject: [PATCH 1/2] Update record disposition action as of date if it changed, to have the same value as next disposition action as of date. --- .../RecordsManagementSearchBehaviour.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 80e3aec4b4..11fc347bce 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.model.behaviour; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -510,12 +511,16 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel */ private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) { - if (!methodCached("updateDispositionActionProperties", record)) + Date recordSearchDispositionActionAsOf = (Date)nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF); + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); + // update disposition action as of if it changed + // @since 2.3.1 + // @see https://issues.alfresco.com/jira/browse/RM-4313 + if (!methodCached("updateDispositionActionProperties", record) + || isDispositionActionAsOfChanged(recordSearchDispositionActionAsOf, da.getAsOfDate())) { Map props = nodeService.getProperties(record); - DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); - 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, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); @@ -553,6 +558,22 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel } } } + + /** + * Check if recordSearchDispositionActionAsOf property has been changed + * + * @param currentDate current as of date value + * @param updatedDate new as of date value + * @return true if the as of date has been changed + */ + private boolean isDispositionActionAsOfChanged(Date currentDate, Date updatedDate) + { + if ((currentDate != null && updatedDate == null) || (currentDate == null && updatedDate != null)) + { + return true; + } + return currentDate.compareTo(updatedDate) != 0; + } /** * On update of event execution information behaviour\ From 373439822c77d69ba3d0a6df5c360b5732f4fc8c Mon Sep 17 00:00:00 2001 From: roxana Date: Fri, 4 Nov 2016 17:08:09 +0200 Subject: [PATCH 2/2] Revert changes and removed cache check. --- .../RecordsManagementSearchBehaviour.java | 84 +++++++------------ 1 file changed, 30 insertions(+), 54 deletions(-) diff --git a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java index 11fc347bce..ed3c445788 100644 --- a/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java +++ b/rm-server/source/java/org/alfresco/module/org_alfresco_module_rm/model/behaviour/RecordsManagementSearchBehaviour.java @@ -21,7 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.model.behaviour; import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; -import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -511,68 +510,45 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel */ private void updateDispositionActionProperties(NodeRef record, NodeRef dispositionAction) { - Date recordSearchDispositionActionAsOf = (Date)nodeService.getProperty(record, PROP_RS_DISPOSITION_ACTION_AS_OF); + Map props = nodeService.getProperties(record); + DispositionAction da = new DispositionActionImpl(recordsManagementServiceRegistry, dispositionAction); - // update disposition action as of if it changed - // @since 2.3.1 - // @see https://issues.alfresco.com/jira/browse/RM-4313 - if (!methodCached("updateDispositionActionProperties", record) - || isDispositionActionAsOfChanged(recordSearchDispositionActionAsOf, da.getAsOfDate())) + + 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, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); + + DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); + if (daDefinition != null) { - Map props = nodeService.getProperties(record); - - 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, nodeService.getProperty(dispositionAction, PROP_DISPOSITION_EVENTS_ELIGIBLE)); - - DispositionActionDefinition daDefinition = da.getDispositionActionDefinition(); - if (daDefinition != null) + Period period = daDefinition.getPeriod(); + if (period != null) { - 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); - } + props.put(PROP_RS_DISPOSITION_PERIOD, period.getPeriodType()); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, period.getExpression()); } - - nodeService.setProperties(record, props); - - if (logger.isDebugEnabled()) + else { - logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_ACTION_NAME)); - logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); - logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); - logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_PERIOD)); - logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + - props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); + props.put(PROP_RS_DISPOSITION_PERIOD, null); + props.put(PROP_RS_DISPOSITION_PERIOD_EXPRESSION, null); } } - } - - /** - * Check if recordSearchDispositionActionAsOf property has been changed - * - * @param currentDate current as of date value - * @param updatedDate new as of date value - * @return true if the as of date has been changed - */ - private boolean isDispositionActionAsOfChanged(Date currentDate, Date updatedDate) - { - if ((currentDate != null && updatedDate == null) || (currentDate == null && updatedDate != null)) + + nodeService.setProperties(record, props); + + if (logger.isDebugEnabled()) { - return true; + logger.debug("Set rma:recordSearchDispositionActionName for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_ACTION_NAME)); + logger.debug("Set rma:recordSearchDispositionActionAsOf for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_ACTION_AS_OF)); + logger.debug("Set rma:recordSearchDispositionEventsEligible for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_EVENTS_ELIGIBLE)); + logger.debug("Set rma:recordSearchDispositionPeriod for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_PERIOD)); + logger.debug("Set rma:recordSearchDispositionPeriodExpression for node " + record + " to: " + + props.get(PROP_RS_DISPOSITION_PERIOD_EXPRESSION)); } - return currentDate.compareTo(updatedDate) != 0; } /**