001/*
002 * (C) Copyright 2010 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *    Mariana Cedica
016 *
017 * $Id$
018 */
019package org.nuxeo.ecm.platform.routing.web;
020
021import static org.jboss.seam.ScopeType.CONVERSATION;
022
023import java.io.Serializable;
024import java.util.List;
025
026import org.jboss.seam.annotations.In;
027import org.jboss.seam.annotations.Install;
028import org.jboss.seam.annotations.Name;
029import org.jboss.seam.annotations.Observer;
030import org.jboss.seam.annotations.Scope;
031import org.jboss.seam.annotations.intercept.BypassInterceptors;
032import org.nuxeo.ecm.core.api.DocumentModel;
033import org.nuxeo.ecm.platform.actions.Action;
034import org.nuxeo.ecm.platform.actions.ActionContext;
035import org.nuxeo.ecm.platform.ui.web.api.WebActions;
036import org.nuxeo.ecm.webapp.action.ActionContextProvider;
037import org.nuxeo.ecm.webapp.helpers.EventNames;
038
039/**
040 * Web Actions to edit a document route
041 *
042 * @author Mariana Cedica
043 * @deprecated since 5.9.2 - Use only routes of type 'graph'
044 */
045@Deprecated
046@Name("routingWebActions")
047@Scope(CONVERSATION)
048@Install(precedence = Install.FRAMEWORK)
049public class DocumentRoutingWebActionsBean implements Serializable {
050
051    /**
052     *
053     */
054    private static final long serialVersionUID = 1L;
055
056    @In(create = true, required = false)
057    protected transient WebActions webActions;
058
059    @In(create = true, required = false)
060    protected transient ActionContextProvider actionContextProvider;
061
062    protected List<Action> addStepActions;
063
064    protected List<Action> addStepInForkActions;
065
066    protected List<Action> removeStepActions;
067
068    protected List<Action> editStepActions;
069
070    /**
071     * @deprecated since 5.9.2 - Use only routes of type 'graph'
072     */
073    @Deprecated
074    public List<Action> getAddStepActions(DocumentModel step) {
075        ActionContext context = actionContextProvider.createActionContext();
076        context.setCurrentDocument(step);
077        addStepActions = webActions.getActionsList(DocumentRoutingWebConstants.ADD_STEP_ACTIONS_LIST, context);
078        return addStepActions;
079    }
080
081    /**
082     * @deprecated since 5.9.2 - Use only routes of type 'graph'
083     */
084    @Deprecated
085    public List<Action> getAddStepInActions(DocumentModel step) {
086        ActionContext context = actionContextProvider.createActionContext();
087        context.setCurrentDocument(step);
088        addStepInForkActions = webActions.getActionsList(DocumentRoutingWebConstants.ADD_STEP_IN_FORK_ACTIONS_LIST,
089                context);
090        return addStepInForkActions;
091    }
092
093    /**
094     * @deprecated since 5.9.2 - Use only routes of type 'graph'
095     */
096    @Deprecated
097    public List<Action> getRemoveStepActions(DocumentModel step) {
098        ActionContext context = actionContextProvider.createActionContext();
099        context.setCurrentDocument(step);
100        removeStepActions = webActions.getActionsList(DocumentRoutingWebConstants.REMOVE_STEP_ACTIONS_LIST, context);
101        return removeStepActions;
102    }
103
104    /**
105     * @deprecated since 5.9.2 - Use only routes of type 'graph'
106     */
107    @Deprecated
108    public List<Action> getEditStepActions(DocumentModel step) {
109        ActionContext context = actionContextProvider.createActionContext();
110        context.setCurrentDocument(step);
111        editStepActions = webActions.getActionsList(DocumentRoutingWebConstants.EDIT_STEP_ACTIONS_LIST, context);
112        return editStepActions;
113    }
114
115    @Observer(value = { EventNames.USER_ALL_DOCUMENT_TYPES_SELECTION_CHANGED, EventNames.LOCATION_SELECTION_CHANGED }, create = false)
116    @BypassInterceptors
117    public void resetTabList() {
118        addStepActions = null;
119        removeStepActions = null;
120        addStepInForkActions = null;
121        editStepActions = null;
122    }
123
124}