001/*
002 *  Copyright 2018 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.odfpilotage.clientsideelement;
017
018import java.util.Map;
019
020import org.apache.avalon.framework.service.ServiceException;
021import org.apache.avalon.framework.service.ServiceManager;
022
023import org.ametys.core.ui.Callable;
024import org.ametys.core.ui.SimpleMenu;
025import org.ametys.plugins.odfpilotage.helper.PilotageStatusHelper;
026import org.ametys.plugins.repository.AmetysObjectResolver;
027
028/**
029 * Override button for odf content to take into account the pilotage status 
030 */
031public class ODFPilotageSimpleMenuClientSideElement extends SimpleMenu
032{
033    /** The pilotage status helper */
034    protected PilotageStatusHelper _pilotageStatusHelper;
035    
036    /** The ametys object resolver */
037    protected AmetysObjectResolver _resolver;
038    
039    @Override
040    public void service(ServiceManager smanager) throws ServiceException
041    {
042        super.service(smanager);
043        _pilotageStatusHelper = (PilotageStatusHelper) smanager.lookup(PilotageStatusHelper.ROLE);
044        _resolver = (AmetysObjectResolver) smanager.lookup(AmetysObjectResolver.ROLE);
045    }
046    
047    /**
048     * Get informations on content's state
049     * @param contentId the id of content
050     * @return informations on contents' state
051     */
052    @Callable
053    public Map<String, Object> getStatus(String contentId)
054    {
055        return _pilotageStatusHelper.getPilotageButtonInfo(contentId);
056    }
057}