mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Addresed code review comments.
This commit is contained in:
@@ -1,199 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This file is part of Alfresco
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.alfresco.module.org_alfresco_module_rm.disposition;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.SortedSet;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class offers the default implementation of a strategy for selection of
|
|
||||||
* disposition schedule for a record when there is more than one which is applicable.
|
|
||||||
* An example of where this strategy might be used would be in the case of a record
|
|
||||||
* which was multiply filed.
|
|
||||||
*
|
|
||||||
* @author neilm
|
|
||||||
*/
|
|
||||||
public class DispositionSelectionStrategy implements RecordsManagementModel
|
|
||||||
{
|
|
||||||
/** Logger */
|
|
||||||
private static Log logger = LogFactory.getLog(DispositionSelectionStrategy.class);
|
|
||||||
|
|
||||||
/** Disposition service */
|
|
||||||
private DispositionService dispositionService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the disposition service
|
|
||||||
*
|
|
||||||
* @param dispositionService disposition service
|
|
||||||
*/
|
|
||||||
public void setDispositionService(DispositionService dispositionService)
|
|
||||||
{
|
|
||||||
this.dispositionService = dispositionService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Select the disposition schedule to use given there is more than one
|
|
||||||
*
|
|
||||||
* @param recordFolders
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public NodeRef selectDispositionScheduleFrom(List<NodeRef> recordFolders)
|
|
||||||
{
|
|
||||||
if (recordFolders == null || recordFolders.isEmpty())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 46 CHAPTER 2
|
|
||||||
// Records assigned more than 1 disposition must be retained and linked to the record folder (category) with the longest
|
|
||||||
// retention period.
|
|
||||||
|
|
||||||
// Assumption: an event-based disposition action has a longer retention
|
|
||||||
// period than a time-based one - as we cannot know when an event will occur
|
|
||||||
// TODO Automatic events?
|
|
||||||
|
|
||||||
NodeRef recordFolder = null;
|
|
||||||
if (recordFolders.size() == 1)
|
|
||||||
{
|
|
||||||
recordFolder = recordFolders.get(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SortedSet<NodeRef> sortedFolders = new TreeSet<NodeRef>(new DispositionableNodeRefComparator());
|
|
||||||
sortedFolders.addAll(recordFolders);
|
|
||||||
recordFolder = sortedFolders.first();
|
|
||||||
}
|
|
||||||
|
|
||||||
DispositionSchedule dispSchedule = dispositionService.getDispositionSchedule(recordFolder);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("Selected disposition schedule: " + dispSchedule);
|
|
||||||
}
|
|
||||||
|
|
||||||
NodeRef result = null;
|
|
||||||
if (dispSchedule != null)
|
|
||||||
{
|
|
||||||
result = dispSchedule.getNodeRef();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class defines a natural comparison order between NodeRefs that have
|
|
||||||
* the dispositionLifecycle aspect applied.
|
|
||||||
* This order has the following meaning: NodeRefs with a 'lesser' value are considered
|
|
||||||
* to have a shorter retention period, although the actual retention period may
|
|
||||||
* not be straightforwardly determined in all cases.
|
|
||||||
*/
|
|
||||||
class DispositionableNodeRefComparator implements Comparator<NodeRef>
|
|
||||||
{
|
|
||||||
public int compare(final NodeRef f1, final NodeRef f2)
|
|
||||||
{
|
|
||||||
// Run as admin user
|
|
||||||
return AuthenticationUtil.runAs(new RunAsWork<Integer>()
|
|
||||||
{
|
|
||||||
public Integer doWork()
|
|
||||||
{
|
|
||||||
return compareImpl(f1, f2);
|
|
||||||
}
|
|
||||||
}, AuthenticationUtil.getAdminUserName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private int compareImpl(NodeRef f1, NodeRef f2)
|
|
||||||
{
|
|
||||||
// quick check to see if the node references are the same
|
|
||||||
if (f1.equals(f2))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the disposition schedules for the folders
|
|
||||||
DispositionSchedule ds1 = dispositionService.getDispositionSchedule(f1);
|
|
||||||
DispositionSchedule ds2 = dispositionService.getDispositionSchedule(f2);
|
|
||||||
|
|
||||||
// make sure each folder has a disposition schedule
|
|
||||||
if (ds1 == null && ds2 != null)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (ds1 != null && ds2 == null)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (ds1 == null && ds2 == null)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO this won't work correctly if we are trying to compare schedules that are record based!!
|
|
||||||
DispositionAction da1 = dispositionService.getNextDispositionAction(f1);
|
|
||||||
DispositionAction da2 = dispositionService.getNextDispositionAction(f2);
|
|
||||||
|
|
||||||
if (da1 != null && da2 != null)
|
|
||||||
{
|
|
||||||
Date asOfDate1 = da1.getAsOfDate();
|
|
||||||
Date asOfDate2 = da2.getAsOfDate();
|
|
||||||
// If both record(Folder)s have asOfDates, then use these to compare
|
|
||||||
if (asOfDate1 != null && asOfDate2 != null)
|
|
||||||
{
|
|
||||||
return asOfDate1.compareTo(asOfDate2);
|
|
||||||
}
|
|
||||||
// If one has a date and the other doesn't, the one with the date is "less".
|
|
||||||
// (Defined date is 'shorter' than undefined date as an undefined date means it may be retained forever - theoretically)
|
|
||||||
else if (asOfDate1 != null || asOfDate2 != null)
|
|
||||||
{
|
|
||||||
return asOfDate1 == null ? +1 : -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Neither has an asOfDate. (Somewhat arbitrarily) we'll use the number of events to compare now.
|
|
||||||
DispositionActionDefinition dad1 = da1.getDispositionActionDefinition();
|
|
||||||
DispositionActionDefinition dad2 = da2.getDispositionActionDefinition();
|
|
||||||
int eventsCount1 = 0;
|
|
||||||
int eventsCount2 = 0;
|
|
||||||
|
|
||||||
if (dad1 != null)
|
|
||||||
{
|
|
||||||
eventsCount1 = dad1.getEvents().size();
|
|
||||||
}
|
|
||||||
if (dad2 != null)
|
|
||||||
{
|
|
||||||
eventsCount2 = dad2.getEvents().size();
|
|
||||||
}
|
|
||||||
return Integer.valueOf(eventsCount1).compareTo(eventsCount2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -71,7 +71,8 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
/** Logger */
|
/** Logger */
|
||||||
private static Log logger = LogFactory.getLog(DispositionServiceImpl.class);
|
private static Log logger = LogFactory.getLog(DispositionServiceImpl.class);
|
||||||
|
|
||||||
public enum WriteMode {ReadOnly, DateOnly, DateAndName};
|
/** Transaction mode for setting next action */
|
||||||
|
public enum WriteMode {READ_ONLY, DATE_ONLY, DATE_AND_NAME};
|
||||||
|
|
||||||
/** Behaviour filter */
|
/** Behaviour filter */
|
||||||
private BehaviourFilter behaviourFilter;
|
private BehaviourFilter behaviourFilter;
|
||||||
@@ -79,9 +80,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
/** Records management service registry */
|
/** Records management service registry */
|
||||||
private RecordsManagementServiceRegistry serviceRegistry;
|
private RecordsManagementServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
/** Disposition selection strategy */
|
|
||||||
private DispositionSelectionStrategy dispositionSelectionStrategy;
|
|
||||||
|
|
||||||
/** File plan service */
|
/** File plan service */
|
||||||
private FilePlanService filePlanService;
|
private FilePlanService filePlanService;
|
||||||
|
|
||||||
@@ -171,16 +169,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
this.freezeService = freezeService;
|
this.freezeService = freezeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the dispositionSelectionStrategy bean.
|
|
||||||
*
|
|
||||||
* @param dispositionSelectionStrategy
|
|
||||||
*/
|
|
||||||
public void setDispositionSelectionStrategy(DispositionSelectionStrategy dispositionSelectionStrategy)
|
|
||||||
{
|
|
||||||
this.dispositionSelectionStrategy = dispositionSelectionStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Behavior to initialize the disposition schedule of a newly filed record.
|
* Behavior to initialize the disposition schedule of a newly filed record.
|
||||||
*
|
*
|
||||||
@@ -278,7 +266,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
{
|
{
|
||||||
final NextActionFromDisposition dsNextAction = getDispositionActionByNameForRecord(nodeRef);
|
final NextActionFromDisposition dsNextAction = getDispositionActionByNameForRecord(nodeRef);
|
||||||
|
|
||||||
if (!dsNextAction.getWriteMode().equals(WriteMode.ReadOnly))
|
if (dsNextAction != null && !dsNextAction.getWriteMode().equals(WriteMode.READ_ONLY))
|
||||||
{
|
{
|
||||||
final NodeRef action = dsNextAction.getNextActionNodeRef();
|
final NodeRef action = dsNextAction.getNextActionNodeRef();
|
||||||
final String dispositionActionName = dsNextAction.getNextActionName();
|
final String dispositionActionName = dsNextAction.getNextActionName();
|
||||||
@@ -290,7 +278,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
public Void doWork()
|
public Void doWork()
|
||||||
{
|
{
|
||||||
nodeService.setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
|
nodeService.setProperty(action, PROP_DISPOSITION_AS_OF, dispositionActionDate);
|
||||||
if (dsNextAction.getWriteMode().equals(WriteMode.DateAndName))
|
if (dsNextAction.getWriteMode().equals(WriteMode.DATE_AND_NAME))
|
||||||
{
|
{
|
||||||
nodeService.setProperty(action, PROP_DISPOSITION_ACTION_NAME, dispositionActionName);
|
nodeService.setProperty(action, PROP_DISPOSITION_ACTION_NAME, dispositionActionName);
|
||||||
}
|
}
|
||||||
@@ -1129,79 +1117,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class NextActionFromDisposition
|
|
||||||
{
|
|
||||||
public NextActionFromDisposition(NodeRef dispositionNodeRef, NodeRef nextActionNodeRef,
|
|
||||||
String nextActionName, Date nextActionDateAsOf, WriteMode writeMode)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.dispositionNodeRef = dispositionNodeRef;
|
|
||||||
this.nextActionNodeRef = nextActionNodeRef;
|
|
||||||
this.nextActionName = nextActionName;
|
|
||||||
this.nextActionDateAsOf = nextActionDateAsOf;
|
|
||||||
this.writeMode = writeMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
private NodeRef dispositionNodeRef;
|
|
||||||
|
|
||||||
private NodeRef nextActionNodeRef;
|
|
||||||
|
|
||||||
private String nextActionName;
|
|
||||||
|
|
||||||
private Date nextActionDateAsOf;
|
|
||||||
|
|
||||||
private WriteMode writeMode;
|
|
||||||
|
|
||||||
public WriteMode getWriteMode()
|
|
||||||
{
|
|
||||||
return writeMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWriteMode(WriteMode writeMode)
|
|
||||||
{
|
|
||||||
this.writeMode = writeMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NodeRef getNextActionNodeRef()
|
|
||||||
{
|
|
||||||
return nextActionNodeRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNextActionNodeRef(NodeRef nextActionNodeRef)
|
|
||||||
{
|
|
||||||
this.nextActionNodeRef = nextActionNodeRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NodeRef getDispositionNodeRef()
|
|
||||||
{
|
|
||||||
return dispositionNodeRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDispositionNodeRef(NodeRef dispositionNodeRef)
|
|
||||||
{
|
|
||||||
this.dispositionNodeRef = dispositionNodeRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNextActionName()
|
|
||||||
{
|
|
||||||
return nextActionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNextActionName(String nextActionName)
|
|
||||||
{
|
|
||||||
this.nextActionName = nextActionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getNextActionDateAsOf()
|
|
||||||
{
|
|
||||||
return nextActionDateAsOf;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNextActionDateAsOf(Date nextActionDateAsOf)
|
|
||||||
{
|
|
||||||
this.nextActionDateAsOf = nextActionDateAsOf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate next disposition action for a record
|
* Calculate next disposition action for a record
|
||||||
@@ -1217,87 +1133,101 @@ public class DispositionServiceImpl extends ServiceBaseImpl
|
|||||||
|
|
||||||
if (nextDispositionAction == null)
|
if (nextDispositionAction == null)
|
||||||
{
|
{
|
||||||
NodeRef newAction = null;
|
return getFirstDispositionAction(recordFolders);
|
||||||
String newDispositionActionName = null;
|
|
||||||
Date newDispositionActionDateAsOf = null;
|
|
||||||
NodeRef dispositionNodeRef = null;
|
|
||||||
for (NodeRef folder : recordFolders)
|
|
||||||
{
|
|
||||||
NodeRef folderDS = getDispositionScheduleImpl(folder);
|
|
||||||
if (folderDS != null)
|
|
||||||
{
|
|
||||||
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(folderDS);
|
|
||||||
if (assocs != null && assocs.size() > 0)
|
|
||||||
{
|
|
||||||
NodeRef firstAction = assocs.get(0).getChildRef();
|
|
||||||
DispositionAction firstDispositionAction = new DispositionActionImpl(serviceRegistry, firstAction);
|
|
||||||
|
|
||||||
if (newAction == null)
|
|
||||||
{
|
|
||||||
newAction = firstAction;
|
|
||||||
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
|
|
||||||
newDispositionActionDateAsOf = getDispositionActionDate(folderDS, newDispositionActionName);
|
|
||||||
}
|
|
||||||
else if (firstDispositionAction.getAsOfDate() != null && newDispositionActionDateAsOf.before(firstDispositionAction.getAsOfDate()))
|
|
||||||
{
|
|
||||||
newDispositionActionName = (String)nodeService.getProperty(firstAction, PROP_DISPOSITION_ACTION_NAME);
|
|
||||||
newDispositionActionDateAsOf = firstDispositionAction.getAsOfDate();
|
|
||||||
}
|
|
||||||
dispositionNodeRef = folderDS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (newDispositionActionName != null && newDispositionActionDateAsOf != null
|
|
||||||
&& dispositionNodeRef != null && newAction != null)
|
|
||||||
{
|
|
||||||
return new NextActionFromDisposition(dispositionNodeRef, newAction,
|
|
||||||
newDispositionActionName, newDispositionActionDateAsOf, WriteMode.DateAndName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get the longest period for the given action name
|
return getNextDispositionAction(recordFolders, nextDispositionAction);
|
||||||
String recordNextDispositionActionName = nextDispositionAction.getName();
|
|
||||||
Date recordNextDispositionActionDate = nextDispositionAction.getAsOfDate();
|
|
||||||
Date nextDispositionActionDate = null;
|
|
||||||
NodeRef dispositionNodeRef = null;
|
|
||||||
|
|
||||||
for (NodeRef folder : recordFolders)
|
|
||||||
{
|
|
||||||
NodeRef dsNodeRef = getDispositionScheduleImpl(folder);
|
|
||||||
if (dsNodeRef != null)
|
|
||||||
{
|
|
||||||
Date dispActionDate = getDispositionActionDate(dsNodeRef, recordNextDispositionActionName);
|
|
||||||
if (nextDispositionActionDate == null || nextDispositionActionDate.before(dispActionDate))
|
|
||||||
{
|
|
||||||
nextDispositionActionDate = dispActionDate;
|
|
||||||
dispositionNodeRef = dsNodeRef;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nextDispositionActionDate != null && dispositionNodeRef != null)
|
|
||||||
{
|
|
||||||
WriteMode mode = null;
|
|
||||||
if (!nextDispositionActionDate.equals(recordNextDispositionActionDate)
|
|
||||||
&& recordNextDispositionActionDate.before(nextDispositionActionDate))
|
|
||||||
{
|
|
||||||
mode = WriteMode.DateOnly;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mode = WriteMode.ReadOnly;
|
|
||||||
}
|
|
||||||
return new NextActionFromDisposition(dispositionNodeRef, nextDispositionAction.getNodeRef(),
|
|
||||||
recordNextDispositionActionName, nextDispositionActionDate, mode);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate next disposition action when the record already has one
|
||||||
|
* @param recordFolders
|
||||||
|
* @param nextDispositionAction
|
||||||
|
* @return next disposition action and the associated disposition schedule
|
||||||
|
*/
|
||||||
|
private NextActionFromDisposition getNextDispositionAction(List<NodeRef> recordFolders, DispositionAction nextDispositionAction)
|
||||||
|
{
|
||||||
|
String recordNextDispositionActionName = nextDispositionAction.getName();
|
||||||
|
Date recordNextDispositionActionDate = nextDispositionAction.getAsOfDate();
|
||||||
|
Date nextDispositionActionDate = null;
|
||||||
|
NodeRef dispositionNodeRef = null;
|
||||||
|
|
||||||
|
for (NodeRef folder : recordFolders)
|
||||||
|
{
|
||||||
|
NodeRef dsNodeRef = getDispositionScheduleImpl(folder);
|
||||||
|
if (dsNodeRef != null)
|
||||||
|
{
|
||||||
|
Date dispActionDate = getDispositionActionDate(dsNodeRef, recordNextDispositionActionName);
|
||||||
|
if (nextDispositionActionDate == null || nextDispositionActionDate.before(dispActionDate))
|
||||||
|
{
|
||||||
|
nextDispositionActionDate = dispActionDate;
|
||||||
|
dispositionNodeRef = dsNodeRef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nextDispositionActionDate == null || dispositionNodeRef == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
WriteMode mode = null;
|
||||||
|
if (!nextDispositionActionDate.equals(recordNextDispositionActionDate)
|
||||||
|
&& recordNextDispositionActionDate.before(nextDispositionActionDate))
|
||||||
|
{
|
||||||
|
mode = WriteMode.DATE_ONLY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mode = WriteMode.READ_ONLY;
|
||||||
|
}
|
||||||
|
return new NextActionFromDisposition(dispositionNodeRef, nextDispositionAction.getNodeRef(),
|
||||||
|
recordNextDispositionActionName, nextDispositionActionDate, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate first disposition action when the record doesn't have one
|
||||||
|
* @param recordFolders
|
||||||
|
* @return next disposition action and the associated disposition schedule
|
||||||
|
*/
|
||||||
|
private NextActionFromDisposition getFirstDispositionAction(List<NodeRef> recordFolders)
|
||||||
|
{
|
||||||
|
NodeRef newAction = null;
|
||||||
|
String newDispositionActionName = null;
|
||||||
|
Date newDispositionActionDateAsOf = null;
|
||||||
|
NodeRef dispositionNodeRef = null;
|
||||||
|
for (NodeRef folder : recordFolders)
|
||||||
|
{
|
||||||
|
NodeRef folderDS = getDispositionScheduleImpl(folder);
|
||||||
|
if (folderDS != null)
|
||||||
|
{
|
||||||
|
List<ChildAssociationRef> assocs = nodeService.getChildAssocs(folderDS);
|
||||||
|
if (assocs != null && assocs.size() > 0)
|
||||||
|
{
|
||||||
|
NodeRef firstAction = assocs.get(0).getChildRef();
|
||||||
|
DispositionAction firstDispositionAction = new DispositionActionImpl(serviceRegistry, firstAction);
|
||||||
|
|
||||||
|
if (newAction == null)
|
||||||
|
{
|
||||||
|
newAction = firstAction;
|
||||||
|
newDispositionActionName = (String)nodeService.getProperty(newAction, PROP_DISPOSITION_ACTION_NAME);
|
||||||
|
newDispositionActionDateAsOf = getDispositionActionDate(folderDS, newDispositionActionName);
|
||||||
|
}
|
||||||
|
else if (firstDispositionAction.getAsOfDate() != null && newDispositionActionDateAsOf.before(firstDispositionAction.getAsOfDate()))
|
||||||
|
{
|
||||||
|
newDispositionActionName = (String)nodeService.getProperty(firstAction, PROP_DISPOSITION_ACTION_NAME);
|
||||||
|
newDispositionActionDateAsOf = firstDispositionAction.getAsOfDate();
|
||||||
|
}
|
||||||
|
dispositionNodeRef = folderDS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newDispositionActionName == null || newDispositionActionDateAsOf == null
|
||||||
|
|| dispositionNodeRef == null || newAction == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new NextActionFromDisposition(dispositionNodeRef, newAction,
|
||||||
|
newDispositionActionName, newDispositionActionDateAsOf, WriteMode.DATE_AND_NAME);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,80 @@
|
|||||||
|
package org.alfresco.module.org_alfresco_module_rm.disposition;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionServiceImpl.WriteMode;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
public class NextActionFromDisposition
|
||||||
|
{
|
||||||
|
public NextActionFromDisposition(NodeRef dispositionNodeRef, NodeRef nextActionNodeRef, String nextActionName, Date nextActionDateAsOf,
|
||||||
|
WriteMode writeMode)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.dispositionNodeRef = dispositionNodeRef;
|
||||||
|
this.nextActionNodeRef = nextActionNodeRef;
|
||||||
|
this.nextActionName = nextActionName;
|
||||||
|
this.nextActionDateAsOf = nextActionDateAsOf;
|
||||||
|
this.writeMode = writeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NodeRef dispositionNodeRef;
|
||||||
|
|
||||||
|
private NodeRef nextActionNodeRef;
|
||||||
|
|
||||||
|
private String nextActionName;
|
||||||
|
|
||||||
|
private Date nextActionDateAsOf;
|
||||||
|
|
||||||
|
private WriteMode writeMode;
|
||||||
|
|
||||||
|
public WriteMode getWriteMode()
|
||||||
|
{
|
||||||
|
return writeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWriteMode(WriteMode writeMode)
|
||||||
|
{
|
||||||
|
this.writeMode = writeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeRef getNextActionNodeRef()
|
||||||
|
{
|
||||||
|
return nextActionNodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextActionNodeRef(NodeRef nextActionNodeRef)
|
||||||
|
{
|
||||||
|
this.nextActionNodeRef = nextActionNodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeRef getDispositionNodeRef()
|
||||||
|
{
|
||||||
|
return dispositionNodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDispositionNodeRef(NodeRef dispositionNodeRef)
|
||||||
|
{
|
||||||
|
this.dispositionNodeRef = dispositionNodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNextActionName()
|
||||||
|
{
|
||||||
|
return nextActionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextActionName(String nextActionName)
|
||||||
|
{
|
||||||
|
this.nextActionName = nextActionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getNextActionDateAsOf()
|
||||||
|
{
|
||||||
|
return nextActionDateAsOf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextActionDateAsOf(Date nextActionDateAsOf)
|
||||||
|
{
|
||||||
|
this.nextActionDateAsOf = nextActionDateAsOf;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user