001/*
002 *  Copyright 2016 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.core.schedule;
017
018import java.util.Map;
019
020import org.quartz.JobExecutionContext;
021
022import org.ametys.runtime.i18n.I18nizableText;
023import org.ametys.runtime.parameter.Parameter;
024import org.ametys.runtime.parameter.ParameterHelper.ParameterType;
025
026/**
027 * This interface represents a 'job' which can be performed and scheduled.
028 */
029public interface Schedulable
030{
031    /**
032     * The action to perform when a trigger is fired. Do not manually call this method.
033     * @param context the context
034     * @throws Exception if an error occured
035     */
036    public void execute(JobExecutionContext context) throws Exception;
037    
038    /**
039     * Returns the id
040     * @return the id
041     */
042    public String getId();
043    
044    /**
045     * Returns the label
046     * @return the i18n label
047     */
048    public I18nizableText getLabel();
049    
050    /**
051     * Return the description
052     * @return the i18n description
053     */
054    public I18nizableText getDescription();
055    
056    /**
057     * Returns the glyph icon
058     * @return the glyph icon
059     */
060    public String getIconGlyph();
061    
062    /**
063     * Returns the path to the small icon in 16x16 pixels
064     * @return the path to the 16x16 icon
065     */
066    public String getIconSmall();
067    
068    /**
069     * Returns the path to the medium icon in 32x32 pixels
070     * @return the path to the 32x32 icon
071     */
072    public String getIconMedium();
073    
074    /**
075     * Returns the path to the large icon in 48x48 pixels
076     * @return the path to the 48x48 icon
077     */
078    public String getIconLarge();
079    
080    /**
081     * Returns true if the schedulable is private
082     * @return true if the schedulable is private
083     */
084    public boolean isPrivate();
085    
086    /**
087     * Returns true if two runnables of this schedulable can be executed concurrently
088     * @return true if two runnables of this schedulable can be executed concurrently
089     */
090    public boolean acceptConcurrentExecution();
091    
092    /**
093     * Get the parameters for job execution
094     * @return the parameters
095     */
096    public Map<String, Parameter<ParameterType>> getParameters();
097}