Finished customisability of action based wizards

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2756 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-05-04 11:27:17 +00:00
parent abdcacffe4
commit f07af6f403
3 changed files with 140 additions and 111 deletions

View File

@@ -22,6 +22,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter; import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
import org.alfresco.repo.action.executer.CheckInActionExecuter; import org.alfresco.repo.action.executer.CheckInActionExecuter;
import org.alfresco.repo.action.executer.CheckOutActionExecuter; import org.alfresco.repo.action.executer.CheckOutActionExecuter;
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
import org.alfresco.repo.action.executer.CopyActionExecuter; import org.alfresco.repo.action.executer.CopyActionExecuter;
import org.alfresco.repo.action.executer.ImageTransformActionExecuter; import org.alfresco.repo.action.executer.ImageTransformActionExecuter;
import org.alfresco.repo.action.executer.ImporterActionExecuter; import org.alfresco.repo.action.executer.ImporterActionExecuter;
@@ -543,41 +544,15 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionProps.put(PROP_ACTION_NAME, this.action); actionProps.put(PROP_ACTION_NAME, this.action);
this.currentActionProperties = actionProps; this.currentActionProperties = actionProps;
if (SimpleWorkflowActionExecuter.NAME.equals(this.action)) // setup any defaults for the UI or handle actions with no parameters
String overridenViewId = setupUIDefaultsForAction(actionProps);
if (overridenViewId != null)
{ {
this.currentActionProperties.put("approveAction", "move"); viewId = overridenViewId;
this.currentActionProperties.put("rejectStepPresent", "yes");
this.currentActionProperties.put("rejectAction", "move");
if (logger.isDebugEnabled())
logger.debug("Added '" + SimpleWorkflowActionExecuter.NAME +
"' action to list");
} }
else if (CheckInActionExecuter.NAME.equals(this.action))
{ if (logger.isDebugEnabled())
this.currentActionProperties.put(PROP_CHECKIN_MINOR, new Boolean(true));
if (logger.isDebugEnabled())
logger.debug("Added '" + CheckInActionExecuter.NAME +
"' action to list");
}
else if ("extract-metadata".equals(this.action))
{
// This one (currently) has no parameters, so just add it...
actionProps.put(PROP_ACTION_SUMMARY, buildActionSummary(actionProps));
this.allActionsProperties.add(actionProps);
// come back to the same page we're on now
viewId = this.returnViewId;
if (logger.isDebugEnabled())
logger.debug("Added 'extract-metadata' action to list");
}
else
{
if (logger.isDebugEnabled())
logger.debug("Added '" + this.action + "' action to list"); logger.debug("Added '" + this.action + "' action to list");
}
// reset the selected action drop down // reset the selected action drop down
this.action = null; this.action = null;
@@ -615,7 +590,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
public void addAction() public void addAction()
{ {
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
String summary = buildActionSummary(this.currentActionProperties); String summary = buildActionSummary();
if (summary != null) if (summary != null)
{ {
@@ -826,6 +801,41 @@ public abstract class BaseActionWizard extends BaseWizardBean
return label; return label;
} }
/**
* Sets up any default state required by the UI for collecting the
* action settings. The view id to use for the action UI can also
* be overridden by returing the path to the relevant JSP.
*
* @props The map of properties being used for the current action
* @return An optional overridden JSP to use for action settings collection
*/
protected String setupUIDefaultsForAction(HashMap<String, Serializable> props)
{
String overridenViewId = null;
if (SimpleWorkflowActionExecuter.NAME.equals(this.action))
{
this.currentActionProperties.put("approveAction", "move");
this.currentActionProperties.put("rejectStepPresent", "yes");
this.currentActionProperties.put("rejectAction", "move");
}
else if (CheckInActionExecuter.NAME.equals(this.action))
{
this.currentActionProperties.put(PROP_CHECKIN_MINOR, new Boolean(true));
}
else if (ContentMetadataExtracter.NAME.equals(this.action))
{
// This one (currently) has no parameters, so just add it...
props.put(PROP_ACTION_SUMMARY, buildActionSummary());
this.allActionsProperties.add(props);
// come back to the same page we're on now
overridenViewId = this.returnViewId;
}
return overridenViewId;
}
/** /**
* Build the param map for the current Action instance. * Build the param map for the current Action instance.
* <p> * <p>
@@ -838,17 +848,17 @@ public abstract class BaseActionWizard extends BaseWizardBean
// set up parameters maps for the action // set up parameters maps for the action
Map<String, Serializable> actionParams = new HashMap<String, Serializable>(); Map<String, Serializable> actionParams = new HashMap<String, Serializable>();
if (this.action.equals(AddFeaturesActionExecuter.NAME)) if (AddFeaturesActionExecuter.NAME.equals(this.action))
{ {
QName aspect = Repository.resolveToQName((String)this.currentActionProperties.get(PROP_ASPECT)); QName aspect = Repository.resolveToQName((String)this.currentActionProperties.get(PROP_ASPECT));
actionParams.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect); actionParams.put(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect);
} }
else if (this.action.equals(RemoveFeaturesActionExecuter.NAME)) else if (RemoveFeaturesActionExecuter.NAME.equals(this.action))
{ {
QName aspect = Repository.resolveToQName((String)this.currentActionProperties.get(PROP_ASPECT)); QName aspect = Repository.resolveToQName((String)this.currentActionProperties.get(PROP_ASPECT));
actionParams.put(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect); actionParams.put(RemoveFeaturesActionExecuter.PARAM_ASPECT_NAME, aspect);
} }
else if (this.action.equals(CopyActionExecuter.NAME)) else if (CopyActionExecuter.NAME.equals(this.action))
{ {
// add the destination space id to the action properties // add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION); NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
@@ -861,7 +871,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(CopyActionExecuter.PARAM_ASSOC_QNAME, actionParams.put(CopyActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy")); QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
} }
else if (this.action.equals(MoveActionExecuter.NAME)) else if (MoveActionExecuter.NAME.equals(this.action))
{ {
// add the destination space id to the action properties // add the destination space id to the action properties
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION); NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
@@ -874,7 +884,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(MoveActionExecuter.PARAM_ASSOC_QNAME, actionParams.put(MoveActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "move")); QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "move"));
} }
else if (this.action.equals(SimpleWorkflowActionExecuter.NAME)) else if (SimpleWorkflowActionExecuter.NAME.equals(this.action))
{ {
// add the approve step name // add the approve step name
actionParams.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_STEP, actionParams.put(SimpleWorkflowActionExecuter.PARAM_APPROVE_STEP,
@@ -941,7 +951,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(SimpleWorkflowActionExecuter.PARAM_REJECT_FOLDER, rejectDestNodeRef); actionParams.put(SimpleWorkflowActionExecuter.PARAM_REJECT_FOLDER, rejectDestNodeRef);
} }
} }
else if (this.action.equals(LinkCategoryActionExecuter.NAME)) else if (LinkCategoryActionExecuter.NAME.equals(this.action))
{ {
// add the classifiable aspect // add the classifiable aspect
actionParams.put(LinkCategoryActionExecuter.PARAM_CATEGORY_ASPECT, actionParams.put(LinkCategoryActionExecuter.PARAM_CATEGORY_ASPECT,
@@ -952,7 +962,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE, actionParams.put(LinkCategoryActionExecuter.PARAM_CATEGORY_VALUE,
catNodeRef); catNodeRef);
} }
else if (this.action.equals(CheckOutActionExecuter.NAME)) else if (CheckOutActionExecuter.NAME.equals(this.action))
{ {
// specify the location the checked out working copy should go // specify the location the checked out working copy should go
// add the destination space id to the action properties // add the destination space id to the action properties
@@ -966,7 +976,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(CheckOutActionExecuter.PARAM_ASSOC_QNAME, actionParams.put(CheckOutActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "checkout")); QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "checkout"));
} }
else if (this.action.equals(CheckInActionExecuter.NAME)) else if (CheckInActionExecuter.NAME.equals(this.action))
{ {
// add the description for the checkin to the action params // add the description for the checkin to the action params
actionParams.put(CheckInActionExecuter.PARAM_DESCRIPTION, actionParams.put(CheckInActionExecuter.PARAM_DESCRIPTION,
@@ -976,7 +986,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(CheckInActionExecuter.PARAM_MINOR_CHANGE, actionParams.put(CheckInActionExecuter.PARAM_MINOR_CHANGE,
this.currentActionProperties.get(PROP_CHECKIN_MINOR)); this.currentActionProperties.get(PROP_CHECKIN_MINOR));
} }
else if (this.action.equals(TransformActionExecuter.NAME)) else if (TransformActionExecuter.NAME.equals(this.action))
{ {
// add the transformer to use // add the transformer to use
actionParams.put(TransformActionExecuter.PARAM_MIME_TYPE, actionParams.put(TransformActionExecuter.PARAM_MIME_TYPE,
@@ -993,7 +1003,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(TransformActionExecuter.PARAM_ASSOC_QNAME, actionParams.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy")); QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
} }
else if (this.action.equals(ImageTransformActionExecuter.NAME)) else if (ImageTransformActionExecuter.NAME.equals(this.action))
{ {
// add the transformer to use // add the transformer to use
actionParams.put(ImageTransformActionExecuter.PARAM_MIME_TYPE, actionParams.put(ImageTransformActionExecuter.PARAM_MIME_TYPE,
@@ -1014,7 +1024,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(TransformActionExecuter.PARAM_ASSOC_QNAME, actionParams.put(TransformActionExecuter.PARAM_ASSOC_QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy")); QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "copy"));
} }
else if (this.action.equals(MailActionExecuter.NAME)) else if (MailActionExecuter.NAME.equals(this.action))
{ {
// add the person(s) it's going to as a list of authorities // add the person(s) it's going to as a list of authorities
List<String> recipients = new ArrayList<String>(emailRecipients.size()); List<String> recipients = new ArrayList<String>(emailRecipients.size());
@@ -1044,7 +1054,7 @@ public abstract class BaseActionWizard extends BaseWizardBean
actionParams.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(), this.usingTemplate)); actionParams.put(MailActionExecuter.PARAM_TEMPLATE, new NodeRef(Repository.getStoreRef(), this.usingTemplate));
} }
} }
else if (this.action.equals(ImporterActionExecuter.NAME)) else if (ImporterActionExecuter.NAME.equals(this.action))
{ {
// add the encoding // add the encoding
actionParams.put(ImporterActionExecuter.PARAM_ENCODING, IMPORT_ENCODING); actionParams.put(ImporterActionExecuter.PARAM_ENCODING, IMPORT_ENCODING);
@@ -1053,13 +1063,13 @@ public abstract class BaseActionWizard extends BaseWizardBean
NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION); NodeRef destNodeRef = (NodeRef)this.currentActionProperties.get(PROP_DESTINATION);
actionParams.put(ImporterActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef); actionParams.put(ImporterActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
} }
else if (this.action.equals(SpecialiseTypeActionExecuter.NAME)) else if (SpecialiseTypeActionExecuter.NAME.equals(this.action))
{ {
// add the specialisation type // add the specialisation type
String objectType = (String)this.currentActionProperties.get(PROP_OBJECT_TYPE); String objectType = (String)this.currentActionProperties.get(PROP_OBJECT_TYPE);
actionParams.put(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME, QName.createQName(objectType)); actionParams.put(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME, QName.createQName(objectType));
} }
else if (this.action.equals(ScriptActionExecutor.NAME)) else if (ScriptActionExecutor.NAME.equals(this.action))
{ {
// add the selected script noderef to the action properties // add the selected script noderef to the action properties
String id = (String)this.currentActionProperties.get(PROP_SCRIPT); String id = (String)this.currentActionProperties.get(PROP_SCRIPT);
@@ -1072,11 +1082,11 @@ public abstract class BaseActionWizard extends BaseWizardBean
} }
/** /**
* Returns a summary string for the given action parameters * Returns a summary string for the current action
* *
* @return The summary or null if a summary could not be built * @return The summary or null if a summary could not be built
*/ */
protected String buildActionSummary(Map<String, Serializable> props) protected String buildActionSummary()
{ {
String summaryResult = null; String summaryResult = null;

View File

@@ -21,6 +21,9 @@ import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator;
import org.alfresco.repo.action.evaluator.HasAspectEvaluator; import org.alfresco.repo.action.evaluator.HasAspectEvaluator;
import org.alfresco.repo.action.evaluator.InCategoryEvaluator; import org.alfresco.repo.action.evaluator.InCategoryEvaluator;
import org.alfresco.repo.action.evaluator.IsSubTypeEvaluator; import org.alfresco.repo.action.evaluator.IsSubTypeEvaluator;
import org.alfresco.repo.action.executer.CheckInActionExecuter;
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
import org.alfresco.repo.action.executer.SimpleWorkflowActionExecuter;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ActionCondition; import org.alfresco.service.cmr.action.ActionCondition;
import org.alfresco.service.cmr.action.ActionConditionDefinition; import org.alfresco.service.cmr.action.ActionConditionDefinition;
@@ -535,27 +538,17 @@ public class CreateRuleWizard extends BaseActionWizard
HashMap<String, Serializable> condProps = new HashMap<String, Serializable>(3); HashMap<String, Serializable> condProps = new HashMap<String, Serializable>(3);
condProps.put(PROP_CONDITION_NAME, this.condition); condProps.put(PROP_CONDITION_NAME, this.condition);
this.currentConditionProperties = condProps;
if ("no-condition".equals(this.condition)) // setup any defaults for the UI or handle actions with no parameters
String overridenViewId = setupUIDefaultsForCondition(condProps);
if (overridenViewId != null)
{ {
condProps.put(PROP_CONDITION_SUMMARY, Application.getMessage( viewId = overridenViewId;
FacesContext.getCurrentInstance(), "condition_no_condition"));
condProps.put(PROP_CONDITION_NOT, Boolean.FALSE);
this.allConditionsProperties.add(condProps);
// come back to the same page we're on now
viewId = this.returnViewId;
if (logger.isDebugEnabled())
logger.debug("Add 'no-condition' condition to list");
} }
else if (this.condition != null)
{ if (logger.isDebugEnabled())
this.currentConditionProperties = condProps;
if (logger.isDebugEnabled())
logger.debug("Added '" + this.condition + "' condition to list"); logger.debug("Added '" + this.condition + "' condition to list");
}
// reset the selected condition drop down // reset the selected condition drop down
this.condition = null; this.condition = null;
@@ -593,7 +586,7 @@ public class CreateRuleWizard extends BaseActionWizard
public void addCondition() public void addCondition()
{ {
FacesContext context = FacesContext.getCurrentInstance(); FacesContext context = FacesContext.getCurrentInstance();
String summary = buildConditionSummary(this.currentConditionProperties); String summary = buildConditionSummary();
if (summary != null) if (summary != null)
{ {
@@ -675,6 +668,33 @@ public class CreateRuleWizard extends BaseActionWizard
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Helper methods // Helper methods
/**
* Sets up any default state required by the UI for collecting the
* condition settings. The view id to use for the condition UI can also
* be overridden by returing the path to the relevant JSP.
*
* @props The map of properties being used for the current condition
* @return An optional overridden JSP to use for condition settings collection
*/
protected String setupUIDefaultsForCondition(HashMap<String, Serializable> props)
{
String overridenViewId = null;
if ("no-condition".equals(this.condition))
{
// there are no parameters so just add it
props.put(PROP_CONDITION_SUMMARY, Application.getMessage(
FacesContext.getCurrentInstance(), "condition_no_condition"));
props.put(PROP_CONDITION_NOT, Boolean.FALSE);
this.allConditionsProperties.add(props);
// come back to the same page we're on now
overridenViewId = this.returnViewId;
}
return overridenViewId;
}
/** /**
* Builds the Map of properties for the given condition in the format the repo is expecting * Builds the Map of properties for the given condition in the format the repo is expecting
* *
@@ -717,15 +737,15 @@ public class CreateRuleWizard extends BaseActionWizard
} }
/** /**
* Returns a summary string for the given condition parameters * Returns a summary string for the current condition
* *
* @return The summary or null if a summary could not be built * @return The summary or null if a summary could not be built
*/ */
protected String buildConditionSummary(Map<String, Serializable> props) protected String buildConditionSummary()
{ {
String summaryResult = null; String summaryResult = null;
String condName = (String)props.get(PROP_CONDITION_NAME); String condName = (String)this.currentConditionProperties.get(PROP_CONDITION_NAME);
if (condName != null) if (condName != null)
{ {
StringBuilder summary = new StringBuilder(); StringBuilder summary = new StringBuilder();
@@ -734,7 +754,7 @@ public class CreateRuleWizard extends BaseActionWizard
// JSF is putting the boolean into the map as a Boolean object so we // JSF is putting the boolean into the map as a Boolean object so we
// need to handle that - adding a converter doesn't seem to help! // need to handle that - adding a converter doesn't seem to help!
Boolean not = (Boolean)props.get(PROP_CONDITION_NOT); Boolean not = (Boolean)this.currentConditionProperties.get(PROP_CONDITION_NOT);
if (not.booleanValue()) if (not.booleanValue())
{ {
msgId = msgId + "_not"; msgId = msgId + "_not";
@@ -749,19 +769,20 @@ public class CreateRuleWizard extends BaseActionWizard
// define a summary to be added for each condition // define a summary to be added for each condition
if (InCategoryEvaluator.NAME.equals(condName)) if (InCategoryEvaluator.NAME.equals(condName))
{ {
String name = Repository.getNameForNode(this.nodeService, (NodeRef)props.get(PROP_CATEGORY)); String name = Repository.getNameForNode(this.nodeService,
(NodeRef)this.currentConditionProperties.get(PROP_CATEGORY));
summary.append("'").append(name).append("'"); summary.append("'").append(name).append("'");
} }
else if (ComparePropertyValueEvaluator.NAME.equals(condName)) else if (ComparePropertyValueEvaluator.NAME.equals(condName))
{ {
summary.append("'"); summary.append("'");
summary.append(props.get(PROP_CONTAINS_TEXT)); summary.append(this.currentConditionProperties.get(PROP_CONTAINS_TEXT));
summary.append("'"); summary.append("'");
} }
else if (IsSubTypeEvaluator.NAME.equals(condName)) else if (IsSubTypeEvaluator.NAME.equals(condName))
{ {
// find the label used by looking through the SelectItem list // find the label used by looking through the SelectItem list
String typeName = (String)props.get(PROP_MODEL_TYPE); String typeName = (String)this.currentConditionProperties.get(PROP_MODEL_TYPE);
for (SelectItem item : this.getModelTypes()) for (SelectItem item : this.getModelTypes())
{ {
if (item.getValue().equals(typeName)) if (item.getValue().equals(typeName))
@@ -774,7 +795,7 @@ public class CreateRuleWizard extends BaseActionWizard
else if (HasAspectEvaluator.NAME.equals(condName)) else if (HasAspectEvaluator.NAME.equals(condName))
{ {
// find the label used by looking through the SelectItem list // find the label used by looking through the SelectItem list
String aspectName = (String)props.get(PROP_ASPECT); String aspectName = (String)this.currentConditionProperties.get(PROP_ASPECT);
for (SelectItem item : this.getAspects()) for (SelectItem item : this.getAspects())
{ {
if (item.getValue().equals(aspectName)) if (item.getValue().equals(aspectName))
@@ -786,7 +807,7 @@ public class CreateRuleWizard extends BaseActionWizard
} }
else if (CompareMimeTypeEvaluator.NAME.equals(condName)) else if (CompareMimeTypeEvaluator.NAME.equals(condName))
{ {
String mimetype = (String)props.get(PROP_MIMETYPE); String mimetype = (String)this.currentConditionProperties.get(PROP_MIMETYPE);
for (SelectItem item : this.getMimeTypes()) for (SelectItem item : this.getMimeTypes())
{ {
if (item.getValue().equals(mimetype)) if (item.getValue().equals(mimetype))

View File

@@ -96,30 +96,39 @@ public class EditRuleWizard extends CreateRuleWizard
List<ActionCondition> conditions = rule.getActionConditions(); List<ActionCondition> conditions = rule.getActionConditions();
for (ActionCondition condition : conditions) for (ActionCondition condition : conditions)
{ {
Map<String, Serializable> params = populateCondition(condition); this.currentConditionProperties = new HashMap<String, Serializable>(3);
this.allConditionsProperties.add(params); this.condition = condition.getActionConditionDefinitionName();
populateCondition(condition.getParameterValues());
// add the name, summary and not condition flag
this.currentConditionProperties.put(PROP_CONDITION_NAME, this.condition);
this.currentConditionProperties.put(PROP_CONDITION_NOT,
Boolean.valueOf(condition.getInvertCondition()));
this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, buildConditionSummary());
// add the populated currentConditionProperties to the list
this.allConditionsProperties.add(this.currentConditionProperties);
} }
// populate the actions list with maps of properties representing each action
List<Action> actions = rule.getActions(); List<Action> actions = rule.getActions();
for (Action action : actions) for (Action action : actions)
{ {
// use the base class version of populateActionFromProperties(),
// but for this we need to setup the currentActionProperties and
// action variables
this.currentActionProperties = new HashMap<String, Serializable>(3); this.currentActionProperties = new HashMap<String, Serializable>(3);
this.action = action.getActionDefinitionName(); this.action = action.getActionDefinitionName();
populateAction(action.getParameterValues()); populateAction(action.getParameterValues());
// also add the name and summary // also add the name and summary
this.currentActionProperties.put(PROP_ACTION_NAME, this.action); this.currentActionProperties.put(PROP_ACTION_NAME, this.action);
// generate the summary this.currentActionProperties.put(PROP_ACTION_SUMMARY, buildActionSummary());
this.currentActionProperties.put(PROP_ACTION_SUMMARY,
buildActionSummary(this.currentActionProperties));
// add the populated currentActionProperties to the list // add the populated currentActionProperties to the list
this.allActionsProperties.add(this.currentActionProperties); this.allActionsProperties.add(this.currentActionProperties);
} }
// reset the current condition
this.condition = null;
// reset the current action // reset the current action
this.action = null; this.action = null;
} }
@@ -129,44 +138,33 @@ public class EditRuleWizard extends CreateRuleWizard
* *
* @param condition The condition to build the map for * @param condition The condition to build the map for
*/ */
protected Map<String, Serializable> populateCondition(ActionCondition condition) protected void populateCondition(Map<String, Serializable> conditionProps)
{ {
// find out what the condition is called if (ComparePropertyValueEvaluator.NAME.equals(this.condition))
Map<String, Serializable> condProps = new HashMap<String, Serializable>(3);
String name = condition.getActionConditionDefinitionName();
condProps.put(PROP_CONDITION_NAME, name);
// add the appropriate properties
Map<String, Serializable> repoCondProps = condition.getParameterValues();
if (name.equals(ComparePropertyValueEvaluator.NAME))
{ {
condProps.put(PROP_CONTAINS_TEXT, (String)repoCondProps.get(ComparePropertyValueEvaluator.PARAM_VALUE)); String propValue = (String)conditionProps.get(ComparePropertyValueEvaluator.PARAM_VALUE);
this.currentConditionProperties.put(PROP_CONTAINS_TEXT, propValue);
} }
else if (name.equals(InCategoryEvaluator.NAME)) else if (InCategoryEvaluator.NAME.equals(this.condition))
{ {
NodeRef catNodeRef = (NodeRef)repoCondProps.get(InCategoryEvaluator.PARAM_CATEGORY_VALUE); NodeRef catNodeRef = (NodeRef)conditionProps.get(InCategoryEvaluator.PARAM_CATEGORY_VALUE);
condProps.put(PROP_CATEGORY, catNodeRef); this.currentConditionProperties.put(PROP_CATEGORY, catNodeRef);
} }
else if (name.equals(IsSubTypeEvaluator.NAME)) else if (IsSubTypeEvaluator.NAME.equals(this.condition))
{ {
condProps.put(PROP_MODEL_TYPE, ((QName)repoCondProps.get(IsSubTypeEvaluator.PARAM_TYPE)).toString()); QName type = (QName)conditionProps.get(IsSubTypeEvaluator.PARAM_TYPE);
this.currentConditionProperties.put(PROP_MODEL_TYPE, type.toString());
} }
else if (name.equals(HasAspectEvaluator.NAME)) else if (HasAspectEvaluator.NAME.equals(this.condition))
{ {
condProps.put(PROP_ASPECT, ((QName)repoCondProps.get(HasAspectEvaluator.PARAM_ASPECT)).toString()); QName aspect = (QName)conditionProps.get(HasAspectEvaluator.PARAM_ASPECT);
this.currentConditionProperties.put(PROP_ASPECT, aspect.toString());
} }
else if (name.equals(CompareMimeTypeEvaluator.NAME)) else if (CompareMimeTypeEvaluator.NAME.equals(this.condition))
{ {
condProps.put(PROP_MIMETYPE, repoCondProps.get(CompareMimeTypeEvaluator.PARAM_VALUE)); String mimeType = (String)conditionProps.get(CompareMimeTypeEvaluator.PARAM_VALUE);
this.currentConditionProperties.put(PROP_MIMETYPE, mimeType);
} }
// specify whether the condition result should be inverted
condProps.put(PROP_CONDITION_NOT, Boolean.valueOf(condition.getInvertCondition()));
// generate the summary
condProps.put(PROP_CONDITION_SUMMARY, buildConditionSummary(condProps));
return condProps;
} }
/** /**