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