RM-694: A records manager has the following list of available rule conditions:

* New action conditions added:

Is classified
Is cutoff
Is frozen
Is record folder closed
Is vital
Has Disposition Action
Is kind
Is Record Type

* Action conditions dropdown list on the edit rule page reorganised


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@51812 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Craig Tan
2013-06-28 01:39:17 +00:00
parent 5d2d370696
commit 752c26c743
15 changed files with 760 additions and 20 deletions

View File

@@ -164,4 +164,10 @@
<property name="namespaceService" ref="NamespaceService"/>
</bean>
<bean id="capabilityCondition.isClassified"
parent="capabilityCondition.base"
class="org.alfresco.module.org_alfresco_module_rm.capability.declarative.condition.IsClassifiedCapabilityCondition">
<property name="dispositionService" ref="DispositionService"/>
</bean>
</beans>

View File

@@ -1,14 +1,48 @@
#
# i18n for Records Management Action Conditions
#
# Is classified
isClassified.title=Is Classified
isClassified.description=Is the record or record folder classified.
# Is cutoff
isCutoff.title=Is Cutoff
isCutoff.description=Is the record or record folder cutoff.
# Is declared
isDeclared.title=Is Record Declared
isDeclared.description=Is the record declared.
# Is frozen
isFrozen.title=Is Frozen
isFrozen.description=Is the record or record folder frozen.
# Is filed
isRecordFiled.title=Is Record Filed
isRecordFiled.description=Is the record filed.
# Is record folder closed
isRecordFolderClosed.title=Is Record Folder Closed
isRecordFolderClosed.description=Is the record folder closed.
# Is vital
isVital.title=Is Vital
isVital.description=Is the record or record folder vital.
# Has Disposition Action
hasDispositionAction.title=Has Disposition Action
hasDispositionAction.description=Has the node got the specified associated disposition action at the specified relative position.
# Is kind
isKind.title=Is Kind
isKind.description=Is the node of a file plan component kind.
isKind.kind.display-label=Kind
# Is Record Type
isRecordType.title=Is Record Type
isRecordType.description=Is the record of the specified type.
#
# i18n for Records Management Actions
#
@@ -56,3 +90,20 @@ requestInfo.description=Starts a workflow for requesting more information for a
executeScript.title=Execute script
executeScript.description=Execute a script.
executeScript.script-ref.display-label=Script
# Action parameter constraints
rm-ac-is-kind-kinds.file_plan=File Plan
rm-ac-is-kind-kinds.record_category=Record Category
rm-ac-is-kind-kinds.record_folder=Record Folder
rm-ac-is-kind-kinds.record=Record
rm-ac-disposition-action-relative-positions.next=Next
rm-ac-disposition-action-relative-positions.previous=Previous
rm-ac-disposition-action-relative-positions.current=Current
rm-ac-disposition-action-relative-positions.any=Any
#rm-ac-disposition-actions.Accession=Accession
#rm-ac-disposition-actions.destroy=Destroy
#rm-ac-disposition-actions.retain=Retain
#rm-ac-disposition-actions.transfer=Transfer
#rm-ac-disposition-actions.cutoff=Cutoff

View File

@@ -13,16 +13,39 @@
</bean>
<!-- Action parameter constraints -->
<bean id="rm-ac-is-kind-kinds" class="org.alfresco.module.org_alfresco_module_rm.action.constraint.CustomParameterConstraint" parent="action-constraint">
<property name="parameterValues">
<list>
<value>FILE_PLAN</value>
<value>RECORD_CATEGORY</value>
<value>RECORD_FOLDER</value>
<value>RECORD</value>
</list>
</property>
</bean>
<bean id="rm-ac-manual-event" class="org.alfresco.module.org_alfresco_module_rm.action.constraint.ManualEventParameterConstraint" parent="action-constraint">
<property name="recordsManagementEventService" ref="recordsManagementEventService"/>
<bean id="rm-ac-disposition-action-relative-positions" class="org.alfresco.repo.action.constraint.EnumParameterConstraint" parent="action-constraint">
<property name="enumClassName" value="org.alfresco.module.org_alfresco_module_rm.DispositionActionRelativePositions" />
</bean>
<bean id="rm-ac-disposition-actions" class="org.alfresco.module.org_alfresco_module_rm.action.constraint.DispositionActionParameterConstraint" parent="action-constraint">
<property name="recordsManagementActionService" ref="RecordsManagementActionService"/>
</bean>
<bean id="rm-ac-record-types" class="org.alfresco.module.org_alfresco_module_rm.action.constraint.RecordTypeParameterConstraint" parent="action-constraint">
<property name="recordService" ref="RecordService"/>
<property name="dictionaryService" ref="DictionaryService"/>
</bean>
<bean id="rm-ac-manual-events" class="org.alfresco.module.org_alfresco_module_rm.action.constraint.ManualEventParameterConstraint" parent="action-constraint">
<property name="recordsManagementEventService" ref="RecordsManagementEventService"/>
</bean>
<bean id="rm-ac-scripts" class="org.alfresco.repo.action.constraint.FolderContentsParameterConstraint" parent="action-constraint">
<property name="dictionaryService" ref="dictionaryService"/>
<property name="searchService" ref="searchService"/>
<property name="nodeService" ref="nodeService"/>
<property name="namespaceService" ref="namespaceService" />
<property name="dictionaryService" ref="DictionaryService"/>
<property name="searchService" ref="SearchService"/>
<property name="nodeService" ref="NodeService"/>
<property name="namespaceService" ref="NamespaceService" />
<property name="repository" ref="repositoryHelper" />
<property name="searchPath" value="/app:company_home/app:dictionary/cm:records_management/cm:records_management_scripts"/>
<property name="cacheAllowableValues" value="false" />
@@ -34,7 +57,6 @@
</bean>
<!-- Conditions -->
<bean id="rmCapabilityConditionEvaluator"
parent="action-condition-evaluator"
abstract="true"
@@ -42,14 +64,55 @@
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
</bean>
<bean id="isKind"
parent="action-condition-evaluator"
class="org.alfresco.module.org_alfresco_module_rm.action.evaluator.IsKindEvaluator">
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
<property name="recordsManagementService" ref="RecordsManagementService" />
</bean>
<bean id="hasDispositionAction"
parent="action-condition-evaluator"
class="org.alfresco.module.org_alfresco_module_rm.action.evaluator.HasDispositionActionEvaluator">
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
<property name="dispositionService" ref="DispositionService" />
</bean>
<bean id="isRecordType"
parent="action-condition-evaluator"
class="org.alfresco.module.org_alfresco_module_rm.action.evaluator.IsRecordTypeEvaluator">
<property name="recordsManagementActionService" ref="recordsManagementActionService" />
<property name="nodeService" ref="NodeService" />
</bean>
<bean id="isCutoff" parent="rmCapabilityConditionEvaluator">
<property name="capabilityCondition" ref="capabilityCondition.cutoff"/>
</bean>
<bean id="isClassified" parent="rmCapabilityConditionEvaluator">
<property name="capabilityCondition" ref="capabilityCondition.isClassified"/>
</bean>
<bean id="isDeclared" parent="rmCapabilityConditionEvaluator">
<property name="capabilityCondition" ref="capabilityCondition.declared"/>
</bean>
<bean id="isFrozen" parent="rmCapabilityConditionEvaluator">
<property name="capabilityCondition" ref="capabilityCondition.frozen"/>
</bean>
<bean id="isRecordFiled" parent="rmCapabilityConditionEvaluator">
<property name="capabilityCondition" ref="capabilityCondition.recordFiled"/>
</bean>
<bean id="isRecordFolderClosed" parent="rmCapabilityConditionEvaluator">
<property name="capabilityCondition" ref="capabilityCondition.closed"/>
</bean>
<bean id="isVital" parent="rmCapabilityConditionEvaluator">
<property name="capabilityCondition" ref="capabilityCondition.vitalRecordOrFolder"/>
</bean>
<!-- Actions -->
<bean id="rmAction" parent="action-executer" abstract="true">
@@ -795,7 +858,7 @@
<ref bean="ServiceRegistry" />
</property>
<property name="personService">
<ref bean="personService" />
<ref bean="PersonService" />
</property>
<property name="storeUrl">
<value>${spaces.store}</value>

View File

@@ -777,6 +777,7 @@
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.executeRecordsManagementAction=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.executeRecordsManagementAction=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.register=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.register=RM_ALLOW
org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService.*=RM_DENY
]]>
</value>

View File

@@ -0,0 +1,30 @@
/*
* 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;
/**
* Disposition action relative position enumeration class. <br>
*
* @author Craig Tan
* @since 2.1
*/
public enum DispositionActionRelativePositions
{
ANY, NEXT, PREVIOUS;
}

View File

@@ -27,9 +27,9 @@ import java.util.Map;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPoliciesUtil;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.BeforeRMActionExecution;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies.OnRMActionExecution;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPoliciesUtil;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
@@ -57,7 +57,8 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
/** Registered records management actions */
private Map<String, RecordsManagementAction> rmActions = new HashMap<String, RecordsManagementAction>(13);
private Map<String, RecordsManagementActionCondition> rmConditions = new HashMap<String, RecordsManagementActionCondition>(13);
private Map<String, RecordsManagementAction> dispositionActions = new HashMap<String, RecordsManagementAction>(4);
private Map<String, RecordsManagementAction> dispositionActions = new HashMap<String, RecordsManagementAction>(5);
/** Policy component */
PolicyComponent policyComponent;
@@ -104,13 +105,13 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
*/
public void register(RecordsManagementAction rmAction)
{
if (this.rmActions.containsKey(rmAction.getName()) == false)
if (rmActions.containsKey(rmAction.getName()) == false)
{
this.rmActions.put(rmAction.getName(), rmAction);
rmActions.put(rmAction.getName(), rmAction);
if (rmAction.isDispositionAction() == true)
{
this.dispositionActions.put(rmAction.getName(), rmAction);
dispositionActions.put(rmAction.getName(), rmAction);
}
}
}
@@ -198,8 +199,8 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
*/
public List<RecordsManagementAction> getDispositionActions()
{
List<RecordsManagementAction> result = new ArrayList<RecordsManagementAction>(this.rmActions.size());
result.addAll(this.dispositionActions.values());
List<RecordsManagementAction> result = new ArrayList<RecordsManagementAction>(dispositionActions.size());
result.addAll(dispositionActions.values());
return Collections.unmodifiableList(result);
}
@@ -208,7 +209,7 @@ public class RecordsManagementActionServiceImpl implements RecordsManagementActi
*/
public RecordsManagementAction getDispositionAction(String name)
{
return this.dispositionActions.get(name);
return dispositionActions.get(name);
}
/*

View File

@@ -0,0 +1,65 @@
/*
* Copyright (C) 2009-2010 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.action.constraint;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
/**
* A parameter constraint that reads in a list of allowable values from Spring configuration
*
* @author Craig Tan
* @since 2.1
*/
public class CustomParameterConstraint extends BaseParameterConstraint
{
private List<String> parameterValues;
/**
* @param parameterValues
*/
public void setParameterValues(List<String> parameterValues)
{
this.parameterValues = parameterValues;
}
/**
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
*/
protected Map<String, String> getAllowableValuesImpl()
{
Map<String, String> allowableValues = new HashMap<String, String>(parameterValues.size());
for (Object parameterValue : parameterValues)
{
// Look up the I18N value
String displayLabel = getI18NLabel(parameterValue.toString());
// Add to the map of allowed values
allowableValues.put(parameterValue.toString(), displayLabel);
}
return allowableValues;
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2009-2010 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.action.constraint;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
/**
* Record type parameter constraint
*
* @author Craig Tan
* @since 2.1
*/
public class DispositionActionParameterConstraint extends BaseParameterConstraint
{
/** Name constant */
public static final String NAME = "rm-ac-record-types";
private RecordsManagementActionService rmActionService;
public void setRecordsManagementActionService(RecordsManagementActionService rmActionService)
{
this.rmActionService = rmActionService;
}
/**
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
*/
protected Map<String, String> getAllowableValuesImpl()
{
List<RecordsManagementAction> rmActions = rmActionService.getDispositionActions();
Map<String, String> result = new HashMap<String, String>(rmActions.size());
for (RecordsManagementAction rmAction : rmActions)
{
result.put(rmAction.getName(), rmAction.getLabel());
}
return result;
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (C) 2009-2010 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.action.constraint;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.repo.action.constraint.BaseParameterConstraint;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.namespace.QName;
/**
* Record type parameter constraint
*
* @author Craig Tan
* @since 2.1
*/
public class RecordTypeParameterConstraint extends BaseParameterConstraint
{
/** Name constant */
public static final String NAME = "rm-ac-record-types";
private RecordService recordService;
private DictionaryService dictionaryService;
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/**
* @see org.alfresco.service.cmr.action.ParameterConstraint#getAllowableValues()
*/
protected Map<String, String> getAllowableValuesImpl()
{
Set<QName> recordTypes = recordService.getRecordMetaDataAspects();
Map<String, String> result = new HashMap<String, String>(recordTypes.size());
for (QName recordType : recordTypes)
{
AspectDefinition aspectDefinition = dictionaryService.getAspect(recordType);
if (aspectDefinition != null)
{
result.put(aspectDefinition.getName().getLocalName(), aspectDefinition.getTitle());
}
}
return result;
}
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 2005-2013 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.action.evaluator;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.DispositionActionRelativePositions;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
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.disposition.DispositionService;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* Records management hasDispositionAction evaluator that evaluates whether the given node's disposition schedule has the specified disposition action.
*
* @author Craig Tan
* @since 2.1
*/
public class HasDispositionActionEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase
{
/**
* Evaluator constants
*/
public static final String NAME = "hasDispositionAction";
public static final String PARAM_DISPOSITION_ACTION_RELATIVE_POSITION = "position";
public static final String PARAM_DISPOSITION_ACTION = "action";
private DispositionService dispositionService;
/**
* @param dispositionService
*/
public void setDispositionService(DispositionService dispositionService)
{
this.dispositionService = dispositionService;
}
@Override
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
{
boolean result = false;
String position = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION)).getLocalName();
String action = ((QName) actionCondition.getParameterValue(PARAM_DISPOSITION_ACTION)).getLocalName();
if (position.equals(DispositionActionRelativePositions.ANY.toString()))
{
DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(actionedUponNodeRef);
if (dispositionSchedule != null)
{
for (DispositionActionDefinition dispositionActionDefinition : dispositionSchedule.getDispositionActionDefinitions())
{
if (dispositionActionDefinition.getName().equals(action) == true)
{
result = true;
break;
}
}
}
}
else if (position.equals(DispositionActionRelativePositions.NEXT.toString()))
{
DispositionAction nextDispositionAction = dispositionService.getNextDispositionAction(actionedUponNodeRef);
if (nextDispositionAction != null)
{
// Get the disposition actions name
String actionName = nextDispositionAction.getName();
if (actionName.equals(action) == true)
{
result = true;
}
}
}
else if (position.equals(DispositionActionRelativePositions.PREVIOUS.toString()))
{
DispositionAction lastCompletedDispositionAction = dispositionService.getLastCompletedDispostionAction(actionedUponNodeRef);
if (lastCompletedDispositionAction != null)
{
// Get the disposition actions name
String actionName = lastCompletedDispositionAction.getName();
if (actionName.equals(action) == true)
{
result = true;
}
}
}
return result;
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION, DataTypeDefinition.QNAME, true,
getParamDisplayLabel(PARAM_DISPOSITION_ACTION_RELATIVE_POSITION), false, "rm-ac-disposition-action-relative-positions"));
paramList.add(new ParameterDefinitionImpl(PARAM_DISPOSITION_ACTION, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_DISPOSITION_ACTION), false,
"rm-ac-disposition-actions"));
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (C) 2005-2013 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.action.evaluator;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* Records management IsKind evaluator that evaluates according to the file plan
* component kind passed in.
*
* @author Craig Tan
* @since 2.1
*/
/**
* @author ctan
*/
public class IsKindEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase
{
/**
* Evaluator constants
*/
public static final String NAME = "isKind";
public static final String PARAM_KIND = "kind";
private RecordsManagementService rmService;
/**
* @param rmService
*/
public void setRecordsManagementService(RecordsManagementService rmService)
{
this.rmService = rmService;
}
@Override
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
{
boolean result = false;
String kind = ((QName) actionCondition.getParameterValue(PARAM_KIND)).getLocalName();
FilePlanComponentKind filePlanComponentKind = rmService.getFilePlanComponentKind(actionedUponNodeRef);
if (filePlanComponentKind.equals(kind))
{
result = true;
}
return result;
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_KIND, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_KIND), false, "rm-ac-is-kind-kinds"));
}
}

View File

@@ -0,0 +1,83 @@
/*
* Copyright (C) 2005-2013 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.action.evaluator;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionEvaluatorAbstractBase;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
/**
* Records management IsRecordType evaluator that evaluates whether the record is of the specified type.
*
* @author Craig Tan
* @since 2.1
*/
/**
* @author ctan
*/
public class IsRecordTypeEvaluator extends RecordsManagementActionConditionEvaluatorAbstractBase implements RecordsManagementModel
{
/**
* Evaluator constants
*/
public static final String NAME = "isRecordType";
public static final String PARAM_RECORD_TYPE = "type";
private NodeService nodeService;
/**
* @param nodeService
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
@Override
protected boolean evaluateImpl(ActionCondition actionCondition, NodeRef actionedUponNodeRef)
{
boolean result = false;
String type = ((QName) actionCondition.getParameterValue(PARAM_RECORD_TYPE)).getLocalName();
if (type != null)
{
result = nodeService.hasAspect(actionedUponNodeRef, QName.createQName(RM_URI, type));
}
return result;
}
@Override
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_RECORD_TYPE, DataTypeDefinition.QNAME, true, getParamDisplayLabel(PARAM_RECORD_TYPE), false, "rm-ac-record-types"));
}
}

View File

@@ -55,7 +55,7 @@ public class CompleteEventAction extends RMActionExecuterAbstractBase
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_EVENT_NAME, DataTypeDefinition.TEXT, true,
getParamDisplayLabel(PARAM_EVENT_NAME), false, "rm-ac-manual-event"));
getParamDisplayLabel(PARAM_EVENT_NAME), false, "rm-ac-manual-events"));
}
/**

View File

@@ -0,0 +1,60 @@
/*
* 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.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Indicates whether the given node has an associated disposition schedule
*
* @author Craig Tan
* @since 2.1
*/
public class IsClassifiedCapabilityCondition 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;
DispositionSchedule dispositionSchedule = dispositionService.getDispositionSchedule(nodeRef);
if (dispositionSchedule != null)
{
result = true;
}
return result;
}
}

View File

@@ -25,8 +25,12 @@ import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementService;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition;
import org.alfresco.repo.action.evaluator.ActionConditionEvaluator;
import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
/**
* Extended action service implementation.
@@ -34,11 +38,19 @@ import org.alfresco.service.cmr.repository.NodeRef;
* @author Roy Wetherall
* @since 2.1
*/
public class ExtendedActionServiceImpl extends ActionServiceImpl
public class ExtendedActionServiceImpl extends ActionServiceImpl implements ApplicationContextAware
{
/** Records management service */
private RecordsManagementService recordsManagementService;
private ApplicationContext extendedApplicationContext;
public void setApplicationContext(ApplicationContext applicationContext)
{
super.setApplicationContext(applicationContext);
extendedApplicationContext = applicationContext;
}
/**
* @param recordsManagementService records management service
*/
@@ -47,6 +59,19 @@ public class ExtendedActionServiceImpl extends ActionServiceImpl
this.recordsManagementService = recordsManagementService;
}
public ActionConditionDefinition getActionConditionDefinition(String name)
{
// get direct access to action condition definition (i.e. ignoring public flag of executer)
ActionConditionDefinition definition = null;
Object bean = extendedApplicationContext.getBean(name);
if (bean != null && bean instanceof ActionConditionEvaluator)
{
ActionConditionEvaluator evaluator = (ActionConditionEvaluator) bean;
definition = evaluator.getActionConditionDefintion();
}
return definition;
}
/**
* @see org.alfresco.repo.action.ActionServiceImpl#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef)
*/