Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Ivan Tyagov
jio
Commits
282d28d5
Commit
282d28d5
authored
Jan 10, 2013
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jslint pass jobRules.js
parent
2534a5e1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
209 additions
and
183 deletions
+209
-183
src/jio/jobs/jobRules.js
src/jio/jobs/jobRules.js
+209
-183
No files found.
src/jio/jobs/jobRules.js
View file @
282d28d5
var
jobRules
=
(
function
(
spec
)
{
var
that
=
{};
// Attributes //
var
priv
=
{};
/*jslint indent: 2, maxlen: 80, sloppy: true */
var
jobRules
=
(
function
()
{
var
that
=
{},
priv
=
{};
priv
.
compare
=
{};
priv
.
action
=
{};
Object
.
defineProperty
(
that
,
"
eliminate
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
eliminate
'
;
}
Object
.
defineProperty
(
that
,
"
eliminate
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
eliminate
'
;
}
});
Object
.
defineProperty
(
that
,
"
update
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
update
'
;
}
Object
.
defineProperty
(
that
,
"
update
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
update
'
;
}
});
Object
.
defineProperty
(
that
,
"
dontAccept
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
dont accept
'
;
}
Object
.
defineProperty
(
that
,
"
dontAccept
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
dont accept
'
;
}
});
Object
.
defineProperty
(
that
,
"
wait
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
wait
'
;
}
Object
.
defineProperty
(
that
,
"
wait
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
wait
'
;
}
});
Object
.
defineProperty
(
that
,
"
none
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
none
'
;
}
Object
.
defineProperty
(
that
,
"
none
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
()
{
return
'
none
'
;
}
});
that
.
default_action
=
that
.
none
;
that
.
default_compare
=
function
(
job1
,
job2
)
{
return
(
job1
.
getCommand
().
getDocId
()
===
job2
.
getCommand
().
getDocId
()
&&
that
.
default_compare
=
function
(
job1
,
job2
)
{
return
(
job1
.
getCommand
().
getDocId
()
===
job2
.
getCommand
().
getDocId
()
&&
job1
.
getCommand
().
getDocInfo
(
'
_rev
'
)
===
job2
.
getCommand
().
getDocInfo
(
'
_rev
'
)
&&
job1
.
getCommand
().
getOption
(
'
rev
'
)
===
...
...
@@ -45,19 +64,17 @@ var jobRules = (function(spec) {
* @param {object} job2 The job to compare with.
* @return {string} An action string.
*/
priv
.
getAction
=
function
(
job1
,
job2
)
{
priv
.
getAction
=
function
(
job1
,
job2
)
{
var
j1label
,
j2label
,
j1status
;
j1label
=
job1
.
getCommand
().
getLabel
();
j2label
=
job2
.
getCommand
().
getLabel
();
j1status
=
(
job1
.
getStatus
().
getLabel
()
===
'
on going
'
?
'
on going
'
:
'
not on going
'
);
if
(
priv
.
action
[
j1label
]
&&
priv
.
action
[
j1label
][
j1status
]
&&
j1status
=
(
job1
.
getStatus
().
getLabel
()
===
'
on going
'
?
'
on going
'
:
'
not on going
'
);
if
(
priv
.
action
[
j1label
]
&&
priv
.
action
[
j1label
][
j1status
]
&&
priv
.
action
[
j1label
][
j1status
][
j2label
])
{
return
priv
.
action
[
j1label
][
j1status
][
j2label
](
job1
,
job2
);
}
else
{
return
that
.
default_action
(
job1
,
job2
);
return
priv
.
action
[
j1label
][
j1status
][
j2label
](
job1
,
job2
);
}
return
that
.
default_action
(
job1
,
job2
);
};
/**
...
...
@@ -67,15 +84,13 @@ var jobRules = (function(spec) {
* @param {object} job2 The job to compare with.
* @return {boolean} true if comparable, else false.
*/
priv
.
canCompare
=
function
(
job1
,
job2
)
{
priv
.
canCompare
=
function
(
job1
,
job2
)
{
var
job1label
=
job1
.
getCommand
().
getLabel
(),
job2label
=
job2
.
getCommand
().
getLabel
();
if
(
priv
.
compare
[
job1label
]
&&
priv
.
compare
[
job2label
])
{
return
priv
.
compare
[
job1label
][
job2label
](
job1
,
job2
);
}
else
{
return
that
.
default_compare
(
job1
,
job2
);
if
(
priv
.
compare
[
job1label
]
&&
priv
.
compare
[
job2label
])
{
return
priv
.
compare
[
job1label
][
job2label
](
job1
,
job2
);
}
return
that
.
default_compare
(
job1
,
job2
);
};
/**
...
...
@@ -85,13 +100,21 @@ var jobRules = (function(spec) {
* @param {object} job2 The new job.
* @return {string} The action string.
*/
Object
.
defineProperty
(
that
,
"
validateJobAccordingToJob
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
job1
,
job2
)
{
if
(
priv
.
canCompare
(
job1
,
job2
))
{
return
{
action
:
priv
.
getAction
(
job1
,
job2
),
job
:
job1
};
Object
.
defineProperty
(
that
,
"
validateJobAccordingToJob
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
job1
,
job2
)
{
if
(
priv
.
canCompare
(
job1
,
job2
))
{
return
{
action
:
priv
.
getAction
(
job1
,
job2
),
job
:
job1
};
}
return
{
action
:
that
.
default_action
(
job1
,
job2
),
job
:
job1
};
return
{
action
:
that
.
default_action
(
job1
,
job2
),
job
:
job1
};
}
});
...
...
@@ -103,13 +126,14 @@ var jobRules = (function(spec) {
* @param {string} method2 The action label from the new job.
* @param {function} rule The rule that return an action string.
*/
Object
.
defineProperty
(
that
,
"
addActionRule
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
method1
,
ongoing
,
method2
,
rule
)
{
var
ongoing_s
=
(
ongoing
?
'
on going
'
:
'
not on going
'
);
Object
.
defineProperty
(
that
,
"
addActionRule
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
method1
,
ongoing
,
method2
,
rule
)
{
var
ongoing_s
=
(
ongoing
?
'
on going
'
:
'
not on going
'
);
priv
.
action
[
method1
]
=
priv
.
action
[
method1
]
||
{};
priv
.
action
[
method1
][
ongoing_s
]
=
priv
.
action
[
method1
][
ongoing_s
]
||
{};
priv
.
action
[
method1
][
ongoing_s
]
=
priv
.
action
[
method1
][
ongoing_s
]
||
{};
priv
.
action
[
method1
][
ongoing_s
][
method2
]
=
rule
;
}
});
...
...
@@ -122,9 +146,11 @@ var jobRules = (function(spec) {
* @param {function} rule The rule that return a boolean
* - true if job1 and job2 can be compared, else false.
*/
Object
.
defineProperty
(
that
,
"
addCompareRule
"
,{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
method1
,
method2
,
rule
)
{
Object
.
defineProperty
(
that
,
"
addCompareRule
"
,
{
configurable
:
false
,
enumerable
:
false
,
writable
:
false
,
value
:
function
(
method1
,
method2
,
rule
)
{
priv
.
compare
[
method1
]
=
priv
.
compare
[
method1
]
||
{};
priv
.
compare
[
method1
][
method2
]
=
rule
;
}
...
...
@@ -182,62 +208,62 @@ var jobRules = (function(spec) {
For more information, see documentation
*/
that
.
addActionRule
(
'
post
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
post
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
false
,
'
post
'
,
that
.
update
);
that
.
addActionRule
(
'
post
'
,
false
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
post
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
post
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
false
,
'
post
'
,
that
.
update
);
that
.
addActionRule
(
'
post
'
,
false
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
post
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
post
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
put
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
false
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
put
'
,
false
,
'
put
'
,
that
.
update
);
that
.
addActionRule
(
'
put
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
put
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
put
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
false
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
put
'
,
false
,
'
put
'
,
that
.
update
);
that
.
addActionRule
(
'
put
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
put
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
put
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
get
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
get
'
,
that
.
update
);
that
.
addActionRule
(
'
get
'
,
false
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
get
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
get
'
,
that
.
update
);
that
.
addActionRule
(
'
get
'
,
false
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
get
'
,
false
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
remove
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
putAttachment
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
post
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
put
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
remove
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
putAttachment
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
post
'
,
that
.
wait
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
remove
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
true
,
'
putAttachment
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
post
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
put
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
get
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
remove
'
,
that
.
update
);
that
.
addActionRule
(
'
remove
'
,
false
,
'
putAttachment
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
allDocs
'
,
true
,
'
allDocs
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
allDocs
'
,
false
,
'
allDocs
'
,
that
.
update
);
that
.
addActionRule
(
'
allDocs
'
,
true
,
'
allDocs
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
allDocs
'
,
false
,
'
allDocs
'
,
that
.
update
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
putAttachment
'
,
that
.
update
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
remove
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
true
,
'
putAttachment
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
post
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
put
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
get
'
,
that
.
wait
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
remove
'
,
that
.
eliminate
);
that
.
addActionRule
(
'
putAttachment
'
,
false
,
'
putAttachment
'
,
that
.
update
);
// end adding rules
////////////////////////////////////////////////////////////////////////////
return
that
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment