001/*
002 *  Copyright 2023 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.workflow;
017import java.util.ArrayList;
018import java.util.List;
019import java.util.Map;
020
021import org.ametys.plugins.workflow.component.WorkflowArgument;
022import org.ametys.plugins.workflow.support.WorkflowHelper.WorkflowVisibility;
023import org.ametys.runtime.i18n.I18nizableText;
024
025import com.opensymphony.workflow.Condition;
026
027/**
028 * Interface for adding description and arguments to {@link Condition}
029 */
030public interface EnhancedCondition  extends Condition
031{
032    /**
033     * Get the list of accepted arguments for this condition
034     * @return a List of argument names and associated description
035     */
036    public default List<WorkflowArgument> getArguments()
037    {
038        return new ArrayList<>();
039    }
040    
041    /**
042     * Get the label for this condition
043     * @return the label
044     */
045    public I18nizableText getLabel();
046    
047    /**
048     * Get the condition label depending on arguments values
049     * @param argumentsValues a map of the arguments with their values in current workflow
050     * @return a label to display in workflow editor vue
051     */
052    public default I18nizableText getFullLabel(Map<String, String> argumentsValues)
053    {
054        return getLabel();
055    }
056    
057    /**
058     * Get the condition's visibilities depending on rights
059     * @return a list of all the allowed right profiles
060     */
061    public default List<WorkflowVisibility> getVisibilities()
062    {
063        ArrayList<WorkflowVisibility> visibilityList = new ArrayList<>();
064        visibilityList.add(WorkflowVisibility.SYSTEM); //By default, none of the enhanced condition can be visible without system rights 
065        return visibilityList;
066    }
067}