Search in sources :

Example 1 with ActionConditionDefinition

use of org.alfresco.service.cmr.action.ActionConditionDefinition in project acs-community-packaging by Alfresco.

the class CreateRuleWizard method promptForConditionValues.

// ------------------------------------------------------------------------------
// Action event handlers
/**
 * Displays the settings page for the current condition being added (if required)
 */
public void promptForConditionValues() {
    // set the flag to show we are creating a new condition
    this.editingCondition = false;
    FacesContext context = FacesContext.getCurrentInstance();
    this.returnViewId = context.getViewRoot().getViewId();
    String viewId = null;
    this.currentConditionProperties = new HashMap<String, Serializable>(3);
    this.currentConditionProperties.put(PROP_CONDITION_NAME, this.selectedCondition);
    this.currentConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.FALSE);
    // get the handler for the condition, if there isn't one we presume it
    // is a no-parameter condition
    IHandler handler = this.conditionHandlers.get(this.selectedCondition);
    if (handler != null) {
        if (logger.isDebugEnabled())
            logger.debug("Found Handler for selected condition - '" + this.selectedCondition + "'");
        // setup any UI defaults the condition may have and get the location of
        // the JSP used to collect the parameters
        handler.setupUIDefaults(this.currentConditionProperties);
        viewId = handler.getJSPPath();
        if (logger.isDebugEnabled())
            logger.debug("Handler returned JSP page- '" + viewId + "'  Handler Type " + handler.getClass().toString());
    } else {
        if (logger.isDebugEnabled())
            logger.debug("Did Not Find a handler for selected condition - '" + this.selectedCondition + "'");
        // just add the action to the list and use the title as the summary
        ActionConditionDefinition conditionDef = this.getActionService().getActionConditionDefinition(this.selectedCondition);
        this.currentConditionProperties.put(PROP_CONDITION_SUMMARY, conditionDef.getTitle());
        this.currentConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.FALSE);
        // add the no params marker so we can disable the edit action
        this.currentConditionProperties.put(NO_PARAMS_MARKER, "no-params");
        this.allConditionsPropertiesList.add(this.currentConditionProperties);
        // come back to the same page we're on now as there are no params to collect
        viewId = this.returnViewId;
    }
    if (logger.isDebugEnabled())
        logger.debug("Currently creating '" + this.selectedCondition + "' condition");
    // go to the page to collect the settings
    goToPage(context, viewId);
}
Also used : FacesContext(javax.faces.context.FacesContext) Serializable(java.io.Serializable) IHandler(org.alfresco.web.bean.actions.IHandler) ActionConditionDefinition(org.alfresco.service.cmr.action.ActionConditionDefinition)

Example 2 with ActionConditionDefinition

use of org.alfresco.service.cmr.action.ActionConditionDefinition in project acs-community-packaging by Alfresco.

the class EditRuleWizard method populateProperties.

protected void populateProperties(FacesContext context, ActionCondition condition, Map<String, Serializable> uiConditionProperties) {
    uiConditionProperties.put(PROP_CONDITION_NAME, this.selectedCondition);
    uiConditionProperties.put(BaseConditionHandler.PROP_CONDITION_NOT, Boolean.valueOf(condition.getInvertCondition()));
    IHandler handler = this.conditionHandlers.get(this.selectedCondition);
    if (handler != null) {
        // use the handler to populate the properties and summary
        handler.prepareForEdit(uiConditionProperties, condition.getParameterValues());
        uiConditionProperties.put(PROP_CONDITION_SUMMARY, handler.generateSummary(context, this, uiConditionProperties));
    } else {
        // there's no handler, so we presume it is a no-parameter
        // condition, use the condition title as the summary
        ActionConditionDefinition conditionDef = this.getActionService().getActionConditionDefinition(this.selectedCondition);
        uiConditionProperties.put(PROP_CONDITION_SUMMARY, conditionDef.getTitle());
        // add the no params marker so we can disable the edit action
        uiConditionProperties.put(NO_PARAMS_MARKER, "no-params");
    }
}
Also used : IHandler(org.alfresco.web.bean.actions.IHandler) ActionConditionDefinition(org.alfresco.service.cmr.action.ActionConditionDefinition)

Example 3 with ActionConditionDefinition

use of org.alfresco.service.cmr.action.ActionConditionDefinition in project acs-community-packaging by Alfresco.

the class CreateRuleWizard method getConditions.

/**
 * @return Returns the list of selectable conditions
 */
public List<SelectItem> getConditions() {
    if (this.conditions == null) {
        List<ActionConditionDefinition> ruleConditions = this.getActionService().getActionConditionDefinitions();
        this.conditions = new ArrayList<SelectItem>(ruleConditions.size());
        for (ActionConditionDefinition ruleConditionDef : ruleConditions) {
            // add to SelectItem list
            this.conditions.add(new SelectItem(ruleConditionDef.getName(), ruleConditionDef.getTitle()));
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.conditions, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
        // add the "Select a condition" entry at the beginning of the list
        this.conditions.add(0, new SelectItem("null", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_condition")));
    }
    return this.conditions;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) SelectItem(javax.faces.model.SelectItem) ActionConditionDefinition(org.alfresco.service.cmr.action.ActionConditionDefinition)

Example 4 with ActionConditionDefinition

use of org.alfresco.service.cmr.action.ActionConditionDefinition in project records-management by Alfresco.

the class ExtendedActionServiceImpl method getActionConditionDefinition.

/**
 * @see org.alfresco.repo.action.ActionServiceImpl#getActionConditionDefinition(java.lang.String)
 */
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 instanceof ActionConditionEvaluator) {
        ActionConditionEvaluator evaluator = (ActionConditionEvaluator) bean;
        definition = evaluator.getActionConditionDefintion();
    }
    return definition;
}
Also used : ActionConditionDefinition(org.alfresco.service.cmr.action.ActionConditionDefinition) ActionConditionEvaluator(org.alfresco.repo.action.evaluator.ActionConditionEvaluator)

Example 5 with ActionConditionDefinition

use of org.alfresco.service.cmr.action.ActionConditionDefinition in project records-management by Alfresco.

the class RmActionConditionDefinitionsGet method executeImpl.

/**
 * @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) {
    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()) {
            defs.add(condition.getRecordsManagementActionConditionDefinition());
        }
    }
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("actionconditiondefinitions", defs);
    return model;
}
Also used : HashMap(java.util.HashMap) ActionConditionDefinition(org.alfresco.service.cmr.action.ActionConditionDefinition) ArrayList(java.util.ArrayList) RecordsManagementActionCondition(org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition)

Aggregations

ActionConditionDefinition (org.alfresco.service.cmr.action.ActionConditionDefinition)5 IHandler (org.alfresco.web.bean.actions.IHandler)2 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 FacesContext (javax.faces.context.FacesContext)1 SelectItem (javax.faces.model.SelectItem)1 RecordsManagementActionCondition (org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionCondition)1 ActionConditionEvaluator (org.alfresco.repo.action.evaluator.ActionConditionEvaluator)1 QuickSort (org.alfresco.web.data.QuickSort)1