Subversion Repositories bacoAlunos

Rev

Rev 1310 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
995 jmachado 1
package pt.estgp.estgweb.domain;
2
 
3
import java.io.Serializable;
4
import java.util.Date;
5
 
6
/**
7
 * Created by jorgemachado on 02/11/15.
8
 */
9
public class JobServiceTaskSchedulerImpl extends JobServiceTaskScheduler {
10
 
11
    public JobServiceTaskSchedulerImpl()
12
    {
13
        setLastScheduleDate(new 5+0%2Fdocs%2Fapi+Date">Date(0));
14
    }
15
    @1.5.0/docs/api/java/lang/Override.html">Override
16
    public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable() {
17
        return getId();
18
    }
1070 jmachado 19
 
20
    public 1.5.0/docs/api/java/lang/String.html">String getWeekDayMsgKey()
21
    {
22
        1.5.0/docs/api/java/lang/String.html">String dayOfTheWeek = "";
23
        int i = getWeekday();
24
        if(i == 2){
25
            dayOfTheWeek = "Mon";
26
        } else if (i==3){
27
            dayOfTheWeek = "Tue";
28
        } else if (i==4){
29
            dayOfTheWeek = "Wed";
30
        } else if (i==5){
31
            dayOfTheWeek = "Thu";
32
        } else if (i==6){
33
            dayOfTheWeek = "Fri";
34
        } else if (i==7){
35
            dayOfTheWeek = "Sat";
36
        } else if (i==1){
37
            dayOfTheWeek = "Sun";
38
        }
39
        return dayOfTheWeek;
40
    }
41
 
42
    public 1.5.0/docs/api/java/lang/String.html">String getTypeMsgKey()
43
    {
1312 jmachado 44
        if(isRunOnlyOnDemand())
45
            return "ondemand";
46
        else if(isDaily())
1070 jmachado 47
            return "dally";
48
        else if(isMonthly())
49
            return "monthly";
50
        else if(isWeekly())
51
            return "weekly";
52
        else if(isNow())
53
            return "now";
54
        else
55
            return "unknown";
56
    }
57
 
1133 jmachado 58
    private 1.5.0/docs/api/java/lang/String.html">String calendarization;
59
 
60
    public 1.5.0/docs/api/java/lang/String.html">String getCalendarization() {
61
 
62
        if(calendarization == null)
63
        {
1312 jmachado 64
            if(isRunOnlyOnDemand())
65
                return CalendarizationEnum.ONDEMAND.name();
66
            else if(isDaily())
1133 jmachado 67
                return CalendarizationEnum.DAILY.name();
68
            else if(isMonthly())
69
                return CalendarizationEnum.MONTLY.name();
70
            else if(isWeekly())
71
                return CalendarizationEnum.WEEKLY.name();
72
            else
73
                return CalendarizationEnum.DAILY.name();
74
        }
75
        return calendarization;
76
 
77
    }
78
 
79
    public void setCalendarization(1.5.0/docs/api/java/lang/String.html">String calendarization) {
80
 
81
        this.calendarization = calendarization;
82
        CalendarizationEnum calendarizationEnum = CalendarizationEnum.parse(calendarization);
83
        setDaily(false);
84
        setMonthly(false);
85
        setWeekly(false);
1312 jmachado 86
        setRunOnlyOnDemand(false);
87
        if(calendarizationEnum == CalendarizationEnum.ONDEMAND)
88
            setRunOnlyOnDemand(true);
89
        else if(calendarizationEnum == CalendarizationEnum.DAILY)
1133 jmachado 90
            setDaily(true);
91
        else if(calendarizationEnum == CalendarizationEnum.MONTLY)
92
            setMonthly(true);
93
        else if(calendarizationEnum == CalendarizationEnum.WEEKLY)
94
            setWeekly(true);
95
 
1312 jmachado 96
 
1133 jmachado 97
    }
98
 
99
 
100
 
101
    public enum CalendarizationEnum
102
    {
1312 jmachado 103
        ONDEMAND,DAILY,WEEKLY,MONTLY;
1133 jmachado 104
 
105
        public static CalendarizationEnum parse(1.5.0/docs/api/java/lang/String.html">String cal)
106
        {
107
            if(cal == null)
1312 jmachado 108
                return ONDEMAND;
1133 jmachado 109
            for(CalendarizationEnum en: CalendarizationEnum.values())
110
                if(en.name().equals(cal))
111
                    return en;
1312 jmachado 112
            return ONDEMAND;
1133 jmachado 113
        }
114
    }
995 jmachado 115
}