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.plugins.explorer.tasks;
017
018import java.util.Date;
019import java.util.List;
020
021import org.ametys.core.user.UserIdentity;
022import org.ametys.plugins.repository.AmetysObject;
023import org.ametys.plugins.repository.metadata.RichText;
024import org.ametys.runtime.i18n.I18nizableText;
025
026/**
027 * Task interface
028 */
029public interface Task extends AmetysObject
030{
031    /**
032     *  Status of a task
033     */
034    public enum TaskStatus
035    {
036        /** Task currently opened */
037        OPEN("open", new I18nizableText("plugin.explorer", "PLUGINS_EXPLORER_TASKS_STATUS_OPEN_LABEL")),
038        /** Task assigned */
039        ASSIGNED("assigned", new I18nizableText("plugin.explorer", "PLUGINS_EXPLORER_TASKS_STATUS_ASSIGNED_LABEL")),
040        /** Task in progress */
041        IN_PROGRESS("in_progress", new I18nizableText("plugin.explorer", "PLUGINS_EXPLORER_TASKS_STATUS_IN_PROGRESS_LABEL")),
042        /** Task ended */
043        ENDED("ended", new I18nizableText("plugin.explorer", "PLUGINS_EXPLORER_TASKS_STATUS_ENDED_LABEL"));
044        
045        private String _value;
046        private I18nizableText _label;
047        
048        private TaskStatus(String value, I18nizableText label)
049        {
050            this._value = value;
051            this._label = label;
052        }  
053           
054        @Override
055        public String toString() 
056        {
057            return _value;
058        }
059        
060        /**
061         * label getter
062         * @return the task priority label
063         */
064        public I18nizableText getLabel()
065        {
066            return this._label;
067        }
068        
069        /**
070         * Converts a string to a TaskStatus
071         * @param status The status to convert
072         * @return The status corresponding to the string or null if unknown
073         */
074        public static TaskStatus createsFromString(String status)
075        {
076            for (TaskStatus v : TaskStatus.values())
077            {
078                if (v.toString().equals(status))
079                {
080                    return v;
081                }
082            }
083            return null;
084        }
085    }
086    
087    /**
088     * Priority of a task
089     */
090    public enum TaskPriority
091    {
092        /** Low priority */
093        LOW("low", new I18nizableText("plugin.explorer", "PLUGINS_EXPLORER_TASKS_PRIORITY_LOW_LABEL")),
094        /** Default priority */
095        NORMAL("normal", new I18nizableText("plugin.explorer", "PLUGINS_EXPLORER_TASKS_PRIORITY_NORMAL_LABEL")),
096        /** Urgent priority */
097        URGENT("urgent", new I18nizableText("plugin.explorer", "PLUGINS_EXPLORER_TASKS_PRIORITY_URGENT_LABEL"));
098        
099        private String _value;
100        private I18nizableText _label;
101        
102        private TaskPriority(String value, I18nizableText label)
103        {
104            this._value = value;
105            this._label = label;
106        }  
107           
108        @Override
109        public String toString() 
110        {
111            return _value;
112        }
113        
114        /**
115         * label getter
116         * @return the task priority label
117         */
118        public I18nizableText getLabel()
119        {
120            return this._label;
121        }
122
123        /**
124         * Converts a string to a TaskPriority
125         * @param priority The priority to convert
126         * @return The priority corresponding to the string or null if unknown
127         */
128        public static TaskPriority createsFromString(String priority)
129        {
130            for (TaskPriority v : TaskPriority.values())
131            {
132                if (v.toString().equals(priority))
133                {
134                    return v;
135                }
136            }
137            return null;
138        }
139    }
140    
141    /**
142     * The identifier of a task
143     * @return The id
144     */
145    public String getTaskId();
146    
147    /**
148     * The title of the task
149     * @return The title
150     */
151    public String getLabel();
152    
153    /**
154     * The description of the task
155     * @return The description
156     */
157    public RichText getDescription();
158    
159    /**
160     * The starting date of the task
161     * @return The start date
162     */
163    public Date getStartDate();
164    
165    /**
166     * The ending date of the task
167     * @return The end date
168     */
169    public Date getEndDate();
170    
171    /**
172     * The status of the task
173     * @return The status
174     */
175    public TaskStatus getStatus();
176    
177    /**
178     * Get the task priority
179     * @return the priority
180     */
181    public TaskPriority getPriority();
182    
183    /**
184     * Get the initial load estimated for this task
185     * @return The initial load
186     */
187    public Double getInitialLoad();
188    
189    /**
190     * Get the progress of the task
191     * @return The progress, in percentage
192     */
193    public Double getProgress();
194    
195    /**
196     * Get the creator of the task
197     * @return the creator
198     */
199    public UserIdentity getAuthor();
200    
201    /**
202     * Get the list of user assigned to this task
203     * @return The assignment list
204     */
205    public List<UserIdentity> getAssignment();
206    
207    /**
208     * Get the list of user subscribed to this task
209     * @return The list of subscribers
210     */
211    public List<UserIdentity> getSubscribers();
212    
213    /**
214     * Get the post's creation date.
215     * @return the post's creation date.
216     */
217    public Date getCreationDate();
218    
219    /**
220     * Get the post's last modification date.
221     * @return the post's last modification date.
222     */
223    public Date getLastModified();
224}