RM-638: A records admin can choose from a specialised list of RM relevant conditions when defining a records rule

* refactor how we extend the rule's UI
  * existing rule's UI is left uneffected .. config no longer needs to be overriden .. so custom config will not effect RM
  * web scripts overriden to use RM specific action and condition UI config 
  * actions and conditions not added to general pool of those available from the rules service ... means no filtering is required on the main UI
  * module filter used to override component and redirect to the overridden webscripts
  * server side support of records management conditions added
  * isFiled and isDeclared conditions added
  * TODO .. still a couple of lose ends to tie up 



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@48659 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2013-03-28 05:24:03 +00:00
parent d777c295fe
commit 83c229d475
22 changed files with 385 additions and 250 deletions

View File

@@ -1,116 +0,0 @@
/*
* Copyright (C) 2005-2012 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.repo.web.scripts.rule;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionConditionDefinition;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition;
import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.alfresco.service.cmr.action.ActionService;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
/**
* An abstract class for the java backed webscripts to get the filtered action definition list.
*
* @author Tuna Aksoy
* @since 2.1
*/
public class AbstractActionDefinitionsGet extends DeclarativeWebScript
{
private ActionService actionService;
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
/**
* Returns a model with the filtered action definitions
*
* @param removeRmRelatedActionDefs if true the rm related action definitions will be removed, otherwise dm related actions
* @return Map<String, Object> the model with the filtered action definitions
*/
protected Map<String, Object> getModelWithFilteredActionDefinitions(boolean removeRmRelatedActionDefs)
{
// get all action definitions and filter them
List<ActionDefinition> actiondefinitions = filterActionDefinitons(actionService.getActionDefinitions(), removeRmRelatedActionDefs);
Map<String, Object> model = new HashMap<String, Object>();
model.put("actiondefinitions", actiondefinitions);
return model;
}
/**
*
* @param removeRmDefs
* @return
*/
protected Map<String, Object> getModelWithFilteredActionConditionDefinitions(boolean removeRmDefs)
{
List<ActionConditionDefinition> defs = filterActionConditionDefinitons(actionService.getActionConditionDefinitions(), removeRmDefs);
Map<String, Object> model = new HashMap<String, Object>();
model.put("actionconditiondefinitions", defs);
return model;
}
/**
* Filters the action definition list
*
* @param actionDefinitions the list of action definitions to filter
* @param removeRmRelatedActionDefs if true the rm related action definitions will be removed, otherwise dm related actions
* @return List<ActionDefinition> the filtered list of action definitions
*/
private List<ActionDefinition> filterActionDefinitons(List<ActionDefinition> actionDefinitions, boolean removeRmRelatedActionDefs)
{
for (Iterator<ActionDefinition> iterator = actionDefinitions.iterator(); iterator.hasNext();)
{
if ((iterator.next() instanceof RecordsManagementActionDefinition) == removeRmRelatedActionDefs)
{
iterator.remove();
}
}
return actionDefinitions;
}
/**
*
* @param defs
* @param removeRmRelated
* @return
*/
private List<ActionConditionDefinition> filterActionConditionDefinitons(List<ActionConditionDefinition> defs, boolean removeRmRelated)
{
for (Iterator<ActionConditionDefinition> iterator = defs.iterator(); iterator.hasNext();)
{
if ((iterator.next() instanceof RecordsManagementActionConditionDefinition) == removeRmRelated)
{
iterator.remove();
}
}
return defs;
}
}

View File

@@ -1,43 +0,0 @@
/*
* 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.repo.web.scripts.rule;
import java.util.Map;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Implementation for java backed webscript to get the DM related action condition definition list.
*
* @author Roy Wetherall
* @since 2.1
*/
public class DmActionConditionDefinitionsGet extends AbstractActionDefinitionsGet
{
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
return getModelWithFilteredActionConditionDefinitions(true);
}
}

View File

@@ -1,43 +0,0 @@
/*
* 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.repo.web.scripts.rule;
import java.util.Map;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* Implementation for java backed webscript to get the DM related action definition list.
*
* @author Tuna Aksoy
* @since 2.1
*/
public class DmActionDefinitionsGet extends AbstractActionDefinitionsGet
{
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
return getModelWithFilteredActionDefinitions(true);
}
}

View File

@@ -18,9 +18,17 @@
*/
package org.alfresco.repo.web.scripts.rule;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.service.cmr.action.ActionConditionDefinition;
import org.alfresco.service.cmr.action.ActionService;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
@@ -30,14 +38,44 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
* @author Roy Wetherall
* @since 2.1
*/
public class RmActionConditionDefinitionsGet extends AbstractActionDefinitionsGet
public class RmActionConditionDefinitionsGet extends DeclarativeWebScript
{
private ActionService actionService;
private RecordsManagementActionService recordsManagementActionService;
public void setActionService(ActionService actionService)
{
this.actionService = actionService;
}
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
{
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
return getModelWithFilteredActionConditionDefinitions(false);
List<ActionConditionDefinition> dmDefs = actionService.getActionConditionDefinitions();
List<RecordsManagementActionCondition> conditions = recordsManagementActionService.getRecordsManagementActionConditions();
List<ActionConditionDefinition> defs = new ArrayList<ActionConditionDefinition>(dmDefs.size()+conditions.size());
defs.addAll(dmDefs);
for (RecordsManagementActionCondition condition: conditions)
{
if (condition.isPublicCondition() == true)
{
defs.add(condition.getRecordsManagementActionConditionDefinition());
}
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("actionconditiondefinitions", defs);
return model;
}
}

View File

@@ -18,9 +18,17 @@
*/
package org.alfresco.repo.web.scripts.rule;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction;
import org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionService;
import org.alfresco.service.cmr.action.ActionDefinition;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
@@ -30,14 +38,34 @@ import org.springframework.extensions.webscripts.WebScriptRequest;
* @author Tuna Aksoy
* @since 2.1
*/
public class RmActionDefinitionsGet extends AbstractActionDefinitionsGet
public class RmActionDefinitionsGet extends DeclarativeWebScript
{
private RecordsManagementActionService recordsManagementActionService;
public void setRecordsManagementActionService(RecordsManagementActionService recordsManagementActionService)
{
this.recordsManagementActionService = recordsManagementActionService;
}
/**
* @see org.springframework.extensions.webscripts.DeclarativeWebScript#executeImpl(org.springframework.extensions.webscripts.WebScriptRequest, org.springframework.extensions.webscripts.Status, org.springframework.extensions.webscripts.Cache)
*/
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
return getModelWithFilteredActionDefinitions(false);
List<RecordsManagementAction> actions = recordsManagementActionService.getRecordsManagementActions();
Set<ActionDefinition> defs = new HashSet<ActionDefinition>(actions.size());
for (RecordsManagementAction action : actions)
{
if (action.isPublicAction() == true)
{
defs.add(action.getRecordsManagementActionDefinition());
}
}
Map<String, Object> model = new HashMap<String, Object>();
model.put("actiondefinitions", defs);
return model;
}
}