mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-395: Edit Disposition Date action doesn't work
* edit disposition action now works * associated capability improved to only show action when disposition date available to be updated! * issue became apparent because the available disposition properties don't always make sense for a folder level disposition (eg: file date) Disposition properties are context sensitive: * UI dynamically pulls list of disposition properties based on disposition level and disposition action * WebScript added to retrieve disposition properties based on context * Disposition properties spring context indicates excluded actions and disposition level relevance * Added Created Date as disposition property for folder level disposition * Cutoff Date no longer shows as disposition property option for cutoff action git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.0@38394 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.capability.declarative.condition;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.capability.declarative.AbstractCapabilityCondition;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
|
||||
/**
|
||||
* Indicates whether a disposable item currently has a disposition date or not.
|
||||
*
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class HasDispositionDateCapabilityCondition extends AbstractCapabilityCondition
|
||||
{
|
||||
/** Disposition service */
|
||||
private DispositionService dispositionService;
|
||||
|
||||
/**
|
||||
* @param dispositionService disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.capability.declarative.CapabilityCondition#evaluate(org.alfresco.service.cmr.repository.NodeRef)
|
||||
*/
|
||||
@Override
|
||||
public boolean evaluate(NodeRef nodeRef)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
DispositionAction dispositionAction = dispositionService.getNextDispositionAction(nodeRef);
|
||||
if (dispositionAction != null)
|
||||
{
|
||||
if (dispositionAction.getAsOfDate() != null)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
@@ -45,10 +45,11 @@ public interface DispositionService
|
||||
void registerDispositionProperty(DispositionProperty dispositionProperty);
|
||||
|
||||
/**
|
||||
* Returns the list of disposition period properties
|
||||
* Returns the list of disposition period properties that apply given the context provided.
|
||||
*
|
||||
* @return list of disposition period properties
|
||||
* @return filtered list of disposition period properties
|
||||
*/
|
||||
Collection<DispositionProperty> getDispositionProperties(boolean isRecordLevel, String dispositionAction);
|
||||
Collection<DispositionProperty> getDispositionProperties();
|
||||
|
||||
|
||||
|
@@ -166,8 +166,24 @@ public class DispositionServiceImpl implements DispositionService, RecordsManage
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties()
|
||||
* @see org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService#getDispositionProperties(boolean, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public Collection<DispositionProperty> getDispositionProperties(boolean isRecordLevel, String dispositionAction)
|
||||
{
|
||||
Collection<DispositionProperty> values = dispositionProperties.values();
|
||||
List<DispositionProperty> result = new ArrayList<DispositionProperty>(values.size());
|
||||
for (DispositionProperty dispositionProperty : values)
|
||||
{
|
||||
boolean test = dispositionProperty.applies(isRecordLevel, dispositionAction);
|
||||
if (test == true)
|
||||
{
|
||||
result.add(dispositionProperty);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<DispositionProperty> getDispositionProperties()
|
||||
{
|
||||
|
@@ -6,6 +6,7 @@ package org.alfresco.module.org_alfresco_module_rm.disposition.property;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionAction;
|
||||
@@ -35,6 +36,7 @@ public class DispositionProperty implements NodeServicePolicies.OnUpdateProperti
|
||||
/** Property QName */
|
||||
private QName propertyName;
|
||||
|
||||
/** Behaviour */
|
||||
private JavaBehaviour behaviour;
|
||||
|
||||
/** Namespace service */
|
||||
@@ -52,6 +54,15 @@ public class DispositionProperty implements NodeServicePolicies.OnUpdateProperti
|
||||
/** Node service */
|
||||
private NodeService nodeService;
|
||||
|
||||
/** Indicates whether this disposition property applies to a folder level disposition */
|
||||
private boolean appliesToFolderLevel = true;
|
||||
|
||||
/** Indicates whether this disposition property applies to a record level disposition */
|
||||
private boolean appliesToRecordLevel = true;
|
||||
|
||||
/** Set of disposition actions this property does not apply to */
|
||||
private Set<String> excludedDispositionActions;
|
||||
|
||||
/**
|
||||
* @param namespaceService namespace service
|
||||
*/
|
||||
@@ -116,6 +127,30 @@ public class DispositionProperty implements NodeServicePolicies.OnUpdateProperti
|
||||
return dictionaryService.getProperty(propertyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param excludedDispositionActions list of excluded disposition actions
|
||||
*/
|
||||
public void setExcludedDispositionActions(Set<String> excludedDispositionActions)
|
||||
{
|
||||
this.excludedDispositionActions = excludedDispositionActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param appliesToFolderLevel
|
||||
*/
|
||||
public void setAppliesToFolderLevel(boolean appliesToFolderLevel)
|
||||
{
|
||||
this.appliesToFolderLevel = appliesToFolderLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param appliesToRecordLevel
|
||||
*/
|
||||
public void setAppliesToRecordLevel(boolean appliesToRecordLevel)
|
||||
{
|
||||
this.appliesToRecordLevel = appliesToRecordLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bean initialisation method
|
||||
*/
|
||||
@@ -131,7 +166,40 @@ public class DispositionProperty implements NodeServicePolicies.OnUpdateProperti
|
||||
ASPECT_DISPOSITION_LIFECYCLE,
|
||||
behaviour);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the disposition property applies given the context.
|
||||
*
|
||||
* @param isRecordLevel true if record level disposition schedule, false otherwise
|
||||
* @param dispositionAction disposition action name
|
||||
* @return boolean true if applies, false otherwise
|
||||
*/
|
||||
public boolean applies(boolean isRecordLevel, String dispositionAction)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
if ((isRecordLevel == true && appliesToRecordLevel == true) ||
|
||||
(isRecordLevel == false && appliesToFolderLevel == true))
|
||||
{
|
||||
if (excludedDispositionActions != null && excludedDispositionActions.size() != 0)
|
||||
{
|
||||
if (excludedDispositionActions.contains(dispositionAction) == false)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.OnUpdatePropertiesPolicy#onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef, java.util.Map, java.util.Map)
|
||||
*/
|
||||
@Override
|
||||
public void onUpdateProperties(
|
||||
final NodeRef nodeRef,
|
||||
@@ -197,6 +265,13 @@ public class DispositionProperty implements NodeServicePolicies.OnUpdateProperti
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the property has been updated or not.
|
||||
*
|
||||
* @param before
|
||||
* @param after
|
||||
* @return
|
||||
*/
|
||||
private boolean isPropertyUpdated(Map<QName, Serializable> before, Map<QName, Serializable> after)
|
||||
{
|
||||
boolean result = false;
|
||||
|
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.script;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
|
||||
import org.alfresco.module.org_alfresco_module_rm.disposition.property.DispositionProperty;
|
||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.DeclarativeWebScript;
|
||||
import org.springframework.extensions.webscripts.Status;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public class DispositionPropertiesGet extends DeclarativeWebScript
|
||||
{
|
||||
protected DispositionService dispositionService;
|
||||
protected NamespaceService namespaceService;
|
||||
|
||||
/**
|
||||
* Sets the disposition service
|
||||
*
|
||||
* @param dispositionService the disposition service
|
||||
*/
|
||||
public void setDispositionService(DispositionService dispositionService)
|
||||
{
|
||||
this.dispositionService = dispositionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the NamespaceService instance
|
||||
*
|
||||
* @param namespaceService The NamespaceService instance
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.Status, org.alfresco.web.scripts.Cache)
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
|
||||
{
|
||||
boolean recordLevel = false;
|
||||
String recordLevelValue = req.getParameter("recordlevel");
|
||||
if (recordLevelValue != null)
|
||||
{
|
||||
recordLevel = Boolean.valueOf(recordLevelValue);
|
||||
}
|
||||
String dispositionAction = req.getParameter("dispositionaction");
|
||||
|
||||
Collection<DispositionProperty> dispositionProperties = dispositionService.getDispositionProperties(recordLevel, dispositionAction);
|
||||
List<Map<String, String>> items = new ArrayList<Map<String, String>>(dispositionProperties.size());
|
||||
for (DispositionProperty dispositionProperty : dispositionProperties)
|
||||
{
|
||||
PropertyDefinition propDef = dispositionProperty.getPropertyDefinition();
|
||||
QName propName = dispositionProperty.getQName();
|
||||
|
||||
if (propDef != null)
|
||||
{
|
||||
Map<String, String> item = new HashMap<String, String>(2);
|
||||
String propTitle = propDef.getTitle();
|
||||
if (propTitle == null || propTitle.length() == 0)
|
||||
{
|
||||
propTitle = StringUtils.capitalize(propName.getLocalName());
|
||||
}
|
||||
item.put("label", propTitle);
|
||||
item.put("value", propName.toPrefixString(this.namespaceService));
|
||||
items.add(item);
|
||||
}
|
||||
}
|
||||
|
||||
// create model object with the lists model
|
||||
Map<String, Object> model = new HashMap<String, Object>(1);
|
||||
model.put("properties", items);
|
||||
return model;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user