1
package
hudsonfog.voc.system;
2
3
import
com.fogx.webdav.DavResource;
4
import
com.fogx.webdav.DavClass;
5
import
com.fogx.webdav.DavBean;
6
import
com.fogx.webdav.DavProperty;
7
import
static
com.fogx.webdav.DavProperty.*;
8
import
com.fogx.webdav.packages.DavBeanPackage;
9
import
com.fogx.webdav.util.DavResourceSupport;
10
import
com.fogx.webdav.util.UrlUtil;
11
import
java.util.Date;
12
import
java.util.Map;
13
import
java.util.HashMap;
14
import
java.util.List;
15
import
java.util.Collections;
16
import
java.util.Arrays;
17
18
import
hudsonfog.voc.model.company
.*;
19
import
hudsonfog.voc.system.primitiveTypes
.*;
20
import
hudsonfog.voc.system.fog
.*;
21
import
hudsonfog.voc.model.recurrence
.*;
22
import
hudsonfog.voc.system.scheduler
.*;
23
import
hudsonfog.voc.model.portal
.*;
24
import
hudsonfog.voc.system.parse
.*;
25
import
hudsonfog.voc.system.security
.*;
26
import
hudsonfog.voc.system.XMLSchema
.*;
27
28
import
hudsonfog.voc.system.fog
.*;
29
30
31
public
abstract
class
scheduler {
32
33
/**
34
* A Job that will be executed by a Scheduler on a schedule defined by jregularity property
35
*/
36
@DavClass._uniquePropertySet(
"jobName, jobUrl"
)
37
@DavClass._avoidIndexing
// do not index system jobs
38
@DavClass._largeIcon(
"icons/classes/Job-large.gif"
)
39
@DavClass._viewCols(
"jobName, dateCreated, jobUrl, frequency, errors, suspended"
)
40
@DavClass._skipAccessControl
41
@DavClass._icon(
"icons/classes/Job.gif"
)
42
public
static
class
Job
implements
RecurrentItem {
43
@_maxSize(
70
)
44
@k
public
String jobName;
45
@_maxSize(
250
)
46
@_oldName(
"jurl"
)
47
@k
public
String jobUrl;
//* URL for which scheduler will be issueing HTTP GET request
48
@_oldName(
"jregularity"
)
49
@c
public
Frequency frequency;
//* specifies the pattern for recurrent Job execution
50
@c
public
dateTime repeatFrom;
//* marks that this event should not start repeating until this date
51
@c
public
dateTime repeatUntil;
//* marks that this event should not stop repeating after this date
52
@_abstract
53
@c
public
ComplexDate start;
//* at what date/time event should start
54
@_abstract
55
@c
public
ComplexDate end;
//* at what date/time event should end
56
@_abstract
57
@c
public
ComplexDate eventTime;
58
public
Boolean runOnStart;
//* instruction to run this Job at the start of the server
59
public
Boolean executeOnce;
//* execute this job only once
60
@_avoidDisplaying
61
public
Boolean createdOnline;
//* this job was created online
62
@_autoincrement
63
@_readOnly
64
public
Integer jobSequence;
65
@_icon(
"icons/important.gif"
)
66
public
Boolean critical;
//* if this job fails - scheduler will stop the server
67
@_icon(
"icons/dateReceived.gif"
)
68
@_sortAscending(
false
)
69
@_onCreate
70
@_dateFormat(
"~MMM-dd, yyyy HH:mm"
)
71
@_readOnly
72
public
ComplexDate dateCreated = writeJS(
"dateCreated ? dateCreated : new Date().getTime()"
);
//* when this Job was created
73
@_icon(
"icons/classes/JobError.gif"
)
74
@_readOnly
75
@_backLink(
"forJob"
)
76
public
JobError[] errors;
//* record of error executing a Job
77
@_icon(
"icons/pause.gif"
)
78
@_colorCoding(
"'False' icons/status-message-read.gif; 'True' icons/pause.gif;"
)
79
public
Boolean suspended;
//* suspended jobs are not executed (uncheck to resume)
80
}
81
82
/**
83
* A Job that runs under the profile of a specific user
84
*/
85
@DavClass._uniquePropertySet(
"owner, jobName, jobUrl"
)
86
public
static
class
UserJob
extends
Job {
87
@_icon(
"icons/openedBy.gif"
)
88
@_readOnly
89
@_onCreate
90
public
Contact owner = writeJS(
"owner == null ? getContactIfNotGuest() : owner"
);
91
@k@s
public
String jobName;
92
@k@s
public
String jobUrl;
93
}
94
95
/*
96
* A Job that runs under the profile of a specific user to execute a report specified by pageUri and to send it by email.
97
* The report that will be executed on a scheduled basis and <br>will be delivered as an email with attachment
98
* in user-specified format (e.g. HTML, MS Excel) to a <br>chosen recepient.
99
*/
100
@DavClass._avoidIndexing(
false
)
// index personal reports
101
@DavClass._viewCols(
"title, dateCreated, format, frequency, repeatFrom, repeatUntil, errors, suspended"
)
102
@DavClass._largeIcon(
"icons/classes/Report-large.gif"
)
103
@DavClass._icon(
"icons/classes/Report.gif"
)
104
public
static
class
ScheduledReport
extends
UserJob {
105
@k@s
public
Contact owner;
106
@_avoidDisplaying
107
@k
public
Integer seq;
108
@_uiFocus
109
@_clientScript(
"onFocus: this.value=document.title;"
)
110
@_subPropertyOf(
"jobName"
)
111
@
r
@s
public
String title;
//* give it a name that will remind you later what this report does
112
@_avoidDisplaying
113
@_onCreate
114
@_readOnly
115
@
r
@s
public
String jobUrl = writeJS(
"'page2email'"
);
116
@_immutable
117
@_onCreate
118
@_readOnly
119
@_maxSize(
10000
)
120
@
r
public
href pageUrl = writeJS(
"pageUrl ? pageUrl : getRequest().getHeader('Referer')"
);
121
@_onCreate
122
public
DataFileFormat format = writeJS(
"format == null ? 'html' : format"
);
//* email attachment format
123
@_onCreate
124
public
GenericMessageAccount recepient = writeJS(
"recepient == null ? getContact() : recepient"
);
//* recepient of the report, such as yourself (default), another Contact or a Workplace
125
@h@s
public
Boolean runOnStart;
126
@h@s
public
Boolean executeOnce;
127
@h@s
public
Boolean createdOnline;
128
@h@s
public
Integer jobSequence;
129
@h@s
public
Boolean critical;
130
@_avoidDisplaying
131
public
DavClass forClass = writeJS(
"pageUrl ? Packages.com.fogx.webdav.DavClass.getClassFromUrl(pageUrl) : null"
);
//* class of resources produced by this report
132
@_avoidDisplaying
133
public
Boolean isList = writeJS(
"pageUrl ? Packages.com.fog.webdav.WebDavUtils.isList(pageUrl) : null"
);
//* is this report for a list of resources or a single resource
134
}
135
136
public
static
enum DataFileFormat {
137
excel, html;
138
}
139
140
@DavClass._largeIcon(
"icons/classes/JobError-large.gif"
)
141
@DavClass._icon(
"icons/classes/JobError.gif"
)
142
public
static
class
JobError {
143
@k
public
Job forJob;
144
@k
public
Integer seq;
145
public
Integer responseCode;
146
@_maxSize(
2000
)
147
public
String responseMsg;
148
@_dateFormat(
"~MMM-dd, yyyy HH:mm"
)
149
@_icon(
"icons/dateReceived.gif"
)
150
@_readOnly
151
@_onCreate
152
public
ComplexDate dateOccured = writeJS(
"(dateOccured == null) ? dateOccured : new Date().getTime()"
);
//* when this Error occured
153
}
154
155
@DavClass._avoidIndexing
// no need to include in full-text index
156
@DavClass._nonTransactional
// job is updated every time it is run and we do not want Transic created for that
157
public
static
class
UserJobEntry
extends
hudsonfog.voc.system.fog.Entry
{
158
@k
public
UserJob forJob;
159
@_readOnly
160
@_icon(
"icons/lastExecuted.gif"
)
161
public
ComplexDate lastExecuted;
//* last time this Job was executed
162
@_readOnly
163
@_icon(
"icons/executionCount.gif"
)
164
@_onCreate
165
public
Integer executionCount = writeJS(
"0"
);
//* how many times this Job was already executed
166
@_readOnly
167
public
Integer lastStatus;
// last job run error status
168
@_maxSize(
1000
)
169
@_readOnly
170
public
String lastMessage;
// last job run error msg
171
}
172
}
173