Search in sources :

Example 1 with ActionDefinition

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

the class RunActionWizard method getActions.

@Override
public List<SelectItem> getActions() {
    if (this.actions == null) {
        NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), this.parameters.get("id"));
        List<ActionDefinition> ruleActions = this.getActionService().getActionDefinitions(nodeRef);
        this.actions = new ArrayList<SelectItem>();
        for (ActionDefinition ruleActionDef : ruleActions) {
            String title = ruleActionDef.getTitle();
            if (title == null || title.length() == 0) {
                title = ruleActionDef.getName();
            }
            this.actions.add(new SelectItem(ruleActionDef.getName(), title));
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.actions, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
        // add the select an action item at the start of the list
        this.actions.add(0, new SelectItem("null", Application.getMessage(FacesContext.getCurrentInstance(), "select_an_action")));
    }
    return this.actions;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) QuickSort(org.alfresco.web.data.QuickSort) SelectItem(javax.faces.model.SelectItem) ActionDefinition(org.alfresco.service.cmr.action.ActionDefinition)

Example 2 with ActionDefinition

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

the class RMActionExecuterAbstractBase method getActionDefinition.

/**
 * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#getActionDefinition()
 */
@Override
public ActionDefinition getActionDefinition() {
    ActionDefinition actionDefinition = super.getActionDefinition();
    ((RecordsManagementActionDefinitionImpl) this.actionDefinition).setApplicableKinds(applicableKinds);
    return actionDefinition;
}
Also used : ActionDefinition(org.alfresco.service.cmr.action.ActionDefinition)

Example 3 with ActionDefinition

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

the class ExtendedActionServiceImpl method getActionDefinitions.

/**
 * @see org.alfresco.repo.action.ActionServiceImpl#getActionDefinitions(org.alfresco.service.cmr.repository.NodeRef)
 */
@Override
public List<ActionDefinition> getActionDefinitions(NodeRef nodeRef) {
    List<ActionDefinition> result = null;
    // first use the base implementation to get the list of action definitions
    List<ActionDefinition> actionDefinitions = super.getActionDefinitions(nodeRef);
    if (nodeRef == null) {
        // nothing to filter
        result = actionDefinitions;
    } else {
        // get the file component kind of the node reference
        FilePlanComponentKind kind = filePlanService.getFilePlanComponentKind(nodeRef);
        result = new ArrayList<ActionDefinition>(actionDefinitions.size());
        // check each action definition
        for (ActionDefinition actionDefinition : actionDefinitions) {
            if (actionDefinition instanceof RecordsManagementActionDefinition) {
                if (kind != null) {
                    Set<FilePlanComponentKind> applicableKinds = ((RecordsManagementActionDefinition) actionDefinition).getApplicableKinds();
                    if (applicableKinds == null || applicableKinds.size() == 0 || applicableKinds.contains(kind)) {
                        // an RM action can only act on a RM artifact
                        result.add(actionDefinition);
                    }
                }
            } else {
                if (kind == null) {
                    // a non-RM action can only act on a non-RM artifact
                    result.add(actionDefinition);
                }
            }
        }
    }
    return result;
}
Also used : RecordsManagementActionDefinition(org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition) RecordsManagementActionDefinition(org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition) ActionDefinition(org.alfresco.service.cmr.action.ActionDefinition) FilePlanComponentKind(org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind)

Example 4 with ActionDefinition

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

the class BaseActionWizard method getActions.

/**
 * @return Returns the list of selectable actions
 */
public List<SelectItem> getActions() {
    if (this.actions == null) {
        List<ActionDefinition> ruleActions = this.getActionService().getActionDefinitions();
        this.actions = new ArrayList<SelectItem>();
        for (ActionDefinition ruleActionDef : ruleActions) {
            String title = ruleActionDef.getTitle();
            if (title == null || title.length() == 0) {
                title = ruleActionDef.getName();
            }
            this.actions.add(new SelectItem(ruleActionDef.getName(), title));
        }
        // make sure the list is sorted by the label
        QuickSort sorter = new QuickSort(this.actions, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
        sorter.sort();
        // add the select an action item at the start of the list
        this.actions.add(0, new SelectItem("null", Application.getMessage(FacesContext.getCurrentInstance(), "select_an_action")));
    }
    return this.actions;
}
Also used : QuickSort(org.alfresco.web.data.QuickSort) SelectItem(javax.faces.model.SelectItem) ActionDefinition(org.alfresco.service.cmr.action.ActionDefinition)

Example 5 with ActionDefinition

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

the class BaseActionWizard method promptForActionValues.

// ------------------------------------------------------------------------------
// Action event handlers
/**
 * Displays the settings page for the current action being added
 */
public void promptForActionValues() {
    // set the flag to show we are creating a new action
    this.editingAction = false;
    FacesContext context = FacesContext.getCurrentInstance();
    this.returnViewId = context.getViewRoot().getViewId();
    String viewId = null;
    HashMap<String, Serializable> actionProps = new HashMap<String, Serializable>(3);
    actionProps.put(PROP_ACTION_NAME, this.action);
    this.currentActionProperties = actionProps;
    this.currentEmailRecipientsDataModel = null;
    // get the handler for the action, if there isn't one we presume it
    // is a no-parameter action
    IHandler handler = this.actionHandlers.get(this.action);
    if (handler != null && !handler.isAllowMultiple() && isActionPresent(this.action)) {
        Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(), ERROR_ACTION_CANNOT_BE_EXECUTE_REPEATEDLY));
        return;
    }
    if (handler != null) {
        // setup any UI defaults the action may have and get the location of
        // the JSP used to collect the parameters
        handler.setupUIDefaults(actionProps);
        viewId = handler.getJSPPath();
    } else {
        // just add the action to the list and use the title as the summary
        ActionDefinition actionDef = this.getActionService().getActionDefinition(this.action);
        actionProps.put(PROP_ACTION_SUMMARY, actionDef.getTitle());
        // add the no params marker so we can disable the edit action
        actionProps.put(NO_PARAMS_MARKER, "no-params");
        this.allActionsProperties.add(actionProps);
        // 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("Added '" + this.action + "' action to list");
    // go to the page to collect the settings
    goToPage(context, viewId);
}
Also used : FacesContext(javax.faces.context.FacesContext) Serializable(java.io.Serializable) HashMap(java.util.HashMap) ActionDefinition(org.alfresco.service.cmr.action.ActionDefinition)

Aggregations

ActionDefinition (org.alfresco.service.cmr.action.ActionDefinition)9 Serializable (java.io.Serializable)2 HashMap (java.util.HashMap)2 SelectItem (javax.faces.model.SelectItem)2 Action (org.alfresco.service.cmr.action.Action)2 QuickSort (org.alfresco.web.data.QuickSort)2 HashSet (java.util.HashSet)1 FacesContext (javax.faces.context.FacesContext)1 RecordsManagementAction (org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementAction)1 RecordsManagementActionDefinition (org.alfresco.module.org_alfresco_module_rm.action.RecordsManagementActionDefinition)1 FilePlanComponentKind (org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind)1 CompositeAction (org.alfresco.service.cmr.action.CompositeAction)1 ParameterDefinition (org.alfresco.service.cmr.action.ParameterDefinition)1 NodeRef (org.alfresco.service.cmr.repository.NodeRef)1 IHandler (org.alfresco.web.bean.actions.IHandler)1