Merge branch 'RM-2526_LinkingMakesRecordPropertiesUnavailbale' into release/V2.3

This commit is contained in:
roxana
2016-10-25 17:38:07 +03:00
2 changed files with 36 additions and 8 deletions

View File

@@ -278,6 +278,22 @@ public class DispositionServiceImpl extends ServiceBaseImpl
NodeRef dsNodeRef = null; NodeRef dsNodeRef = null;
if (isRecord(nodeRef)) if (isRecord(nodeRef))
{ {
// calculate disposition schedule without taking into account the user
DispositionSchedule originDispositionSchedule = AuthenticationUtil.runAsSystem(new RunAsWork<DispositionSchedule>()
{
@Override
public DispositionSchedule doWork()
{
return getOriginDispositionSchedule(nodeRef);
}
});
// if the initial disposition schedule of the record is folder based
if (originDispositionSchedule == null ||
isNotTrue(originDispositionSchedule.isRecordLevelDisposition()))
{
return null;
}
final NextActionFromDisposition dsNextAction = getDispositionActionByNameForRecord(nodeRef); final NextActionFromDisposition dsNextAction = getDispositionActionByNameForRecord(nodeRef);
if (dsNextAction != null) if (dsNextAction != null)
@@ -1143,6 +1159,13 @@ public class DispositionServiceImpl extends ServiceBaseImpl
if (nextDispositionAction == null) if (nextDispositionAction == null)
{ {
DispositionAction lastCompletedDispositionAction = getLastCompletedDispostionAction(record);
if (lastCompletedDispositionAction != null)
{
// all disposition actions upon the given record were completed
return null;
}
return getFirstDispositionAction(record, recordFolders); return getFirstDispositionAction(record, recordFolders);
} }
else else

View File

@@ -3,11 +3,10 @@ package org.alfresco.module.org_alfresco_module_rm.test.integration.disposition;
import static org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest.test; import static org.alfresco.module.org_alfresco_module_rm.test.util.bdt.BehaviourTest.test;
import java.io.Serializable; import java.io.Serializable;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import com.google.common.collect.ImmutableMap;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction; import org.alfresco.module.org_alfresco_module_rm.action.impl.CutOffAction;
import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction; import org.alfresco.module.org_alfresco_module_rm.action.impl.DestroyAction;
@@ -21,6 +20,8 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.util.ApplicationContextHelper; import org.alfresco.util.ApplicationContextHelper;
import org.springframework.extensions.webscripts.GUID; import org.springframework.extensions.webscripts.GUID;
import com.google.common.collect.ImmutableMap;
public class MultipleSchedulesTest extends BaseRMTestCase public class MultipleSchedulesTest extends BaseRMTestCase
{ {
/** A unique prefix for the constants in this test. */ /** A unique prefix for the constants in this test. */
@@ -118,6 +119,7 @@ public class MultipleSchedulesTest extends BaseRMTestCase
*/ */
public void testLinkedToLongerSchedule() public void testLinkedToLongerSchedule()
{ {
Calendar calendar = Calendar.getInstance();
test() test()
.given(() -> { .given(() -> {
setUpFilePlan(); setUpFilePlan();
@@ -130,11 +132,12 @@ public class MultipleSchedulesTest extends BaseRMTestCase
dispositionService.cutoffDisposableItem(record); dispositionService.cutoffDisposableItem(record);
// Ensure the update has been applied to the record. // Ensure the update has been applied to the record.
internalDispositionService.updateNextDispositionAction(record); internalDispositionService.updateNextDispositionAction(record);
calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
calendar.add(Calendar.WEEK_OF_YEAR, 1);
}) })
.then() .then()
.expect(7 * 24 * 60 * 60 * 1000L) .expect(calendar.getTime())
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate().getTime() .from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
- ((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE)).getTime())
.because("Record should follow largest rentention schedule period, which is one week."); .because("Record should follow largest rentention schedule period, which is one week.");
} }
@@ -149,6 +152,7 @@ public class MultipleSchedulesTest extends BaseRMTestCase
*/ */
public void testLinkedToShorterSchedule() public void testLinkedToShorterSchedule()
{ {
Calendar calendar = Calendar.getInstance();
test() test()
.given(() -> { .given(() -> {
setUpFilePlan(); setUpFilePlan();
@@ -161,11 +165,12 @@ public class MultipleSchedulesTest extends BaseRMTestCase
dispositionService.cutoffDisposableItem(record); dispositionService.cutoffDisposableItem(record);
// Ensure the update has been applied to the record. // Ensure the update has been applied to the record.
internalDispositionService.updateNextDispositionAction(record); internalDispositionService.updateNextDispositionAction(record);
calendar.setTime((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE));
calendar.add(Calendar.WEEK_OF_YEAR, 1);
}) })
.then() .then()
.expect(7 * 24 * 60 * 60 * 1000L) .expect(calendar.getTime())
.from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate().getTime() .from(() -> dispositionService.getNextDispositionAction(record).getAsOfDate())
- ((Date) nodeService.getProperty(record, PROP_CUT_OFF_DATE)).getTime())
.because("Record should follow largest rentention schedule period, which is one week."); .because("Record should follow largest rentention schedule period, which is one week.");
} }
} }