Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
38cde22c
Commit
38cde22c
authored
Jun 14, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate `classes' from `singletons'.
parent
4e099262
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
1366 additions
and
1859 deletions
+1366
-1859
OfficeJS/grunt/10_gruntJIO/grunt.js
OfficeJS/grunt/10_gruntJIO/grunt.js
+2
-3
OfficeJS/grunt/20_gruntJIOStorage/grunt.js
OfficeJS/grunt/20_gruntJIOStorage/grunt.js
+3
-1
OfficeJS/lib/jio/jio.js
OfficeJS/lib/jio/jio.js
+275
-89
OfficeJS/lib/jio/jio.min.js
OfficeJS/lib/jio/jio.min.js
+2
-2
OfficeJS/lib/jio/jio.storage.js
OfficeJS/lib/jio/jio.storage.js
+482
-1253
OfficeJS/lib/jio/jio.storage.min.js
OfficeJS/lib/jio/jio.storage.min.js
+2
-2
OfficeJS/src/jio.dummystorages.js
OfficeJS/src/jio.dummystorages.js
+27
-31
OfficeJS/src/jio/activityUpdater.js
OfficeJS/src/jio/activityUpdater.js
+36
-0
OfficeJS/src/jio/announcements/announcement.js
OfficeJS/src/jio/announcements/announcement.js
+1
-0
OfficeJS/src/jio/commands/command.js
OfficeJS/src/jio/commands/command.js
+20
-4
OfficeJS/src/jio/commands/getDocumentList.js
OfficeJS/src/jio/commands/getDocumentList.js
+18
-0
OfficeJS/src/jio/commands/loadDocument.js
OfficeJS/src/jio/commands/loadDocument.js
+12
-0
OfficeJS/src/jio/jio.outro.js
OfficeJS/src/jio/jio.outro.js
+14
-10
OfficeJS/src/jio/jioNamespace.js
OfficeJS/src/jio/jioNamespace.js
+4
-1
OfficeJS/src/jio/jobs/job.js
OfficeJS/src/jio/jobs/job.js
+4
-4
OfficeJS/src/jio/jobs/jobManager.js
OfficeJS/src/jio/jobs/jobManager.js
+88
-18
OfficeJS/src/jio/jobs/jobRules.js
OfficeJS/src/jio/jobs/jobRules.js
+19
-0
OfficeJS/src/jio/jobs/status/jobStatus.js
OfficeJS/src/jio/jobs/status/jobStatus.js
+6
-1
OfficeJS/src/jio/jobs/status/waitStatus.js
OfficeJS/src/jio/jobs/status/waitStatus.js
+41
-1
OfficeJS/src/jio/storages/storage.js
OfficeJS/src/jio/storages/storage.js
+5
-1
OfficeJS/src/jio/storages/storageHandler.js
OfficeJS/src/jio/storages/storageHandler.js
+3
-46
OfficeJS/test/jiotests.js
OfficeJS/test/jiotests.js
+302
-392
No files found.
OfficeJS/grunt/10_gruntJIO/grunt.js
View file @
38cde22c
...
@@ -17,11 +17,9 @@ module.exports = function(grunt) {
...
@@ -17,11 +17,9 @@ module.exports = function(grunt) {
// Wrapper top
// Wrapper top
'
<file_strip_banner:../../src/<%= pkg.name %>/intro.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/intro.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/exceptions.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/exceptions.js>
'
,
// Jio wrapper top
'
<file_strip_banner:../../src/<%= pkg.name %>/storages/storage.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/storages/storage.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/storages/storageHandler.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/storages/storageHandler.js>
'
,
// Jio wrapper top
'
<file_strip_banner:../../src/<%= pkg.name %>/jio.intro.js>
'
,
// Jio Classes
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/command.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/command.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/getDocumentList.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/getDocumentList.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/loadDocument.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/commands/loadDocument.js>
'
,
...
@@ -35,6 +33,7 @@ module.exports = function(grunt) {
...
@@ -35,6 +33,7 @@ module.exports = function(grunt) {
'
<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/waitStatus.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/waitStatus.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/jobs/job.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/jobs/job.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcement.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcement.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/jio.intro.js>
'
,
// Singletons
// Singletons
'
<file_strip_banner:../../src/<%= pkg.name %>/activityUpdater.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/activityUpdater.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcer.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcer.js>
'
,
...
...
OfficeJS/grunt/20_gruntJIOStorage/grunt.js
View file @
38cde22c
...
@@ -15,7 +15,9 @@ module.exports = function(grunt) {
...
@@ -15,7 +15,9 @@ module.exports = function(grunt) {
dist
:
{
dist
:
{
src
:
[
'
<banner:meta.banner>
'
,
src
:
[
'
<banner:meta.banner>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/intro.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/intro.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/localStorage.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/localstorage.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/davstorage.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/replicatestorage.js>
'
,
'
<file_strip_banner:../../src/<%= pkg.name %>/outro.js>
'
],
'
<file_strip_banner:../../src/<%= pkg.name %>/outro.js>
'
],
dest
:
'
../../lib/jio/<%= pkg.name %>.js
'
dest
:
'
../../lib/jio/<%= pkg.name %>.js
'
}
}
...
...
OfficeJS/lib/jio/jio.js
View file @
38cde22c
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/jio.min.js
View file @
38cde22c
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/jio.storage.js
View file @
38cde22c
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/jio.storage.min.js
View file @
38cde22c
This diff is collapsed.
Click to expand it.
OfficeJS/src/jio.dummystorages.js
View file @
38cde22c
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
// Tells us that the document is saved.
// Tells us that the document is saved.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
done
();
that
.
done
();
},
100
);
},
100
);
};
// end saveDocument
};
// end saveDocument
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
'
content
'
:
'
content
'
,
'
content
'
:
'
content
'
,
'
creation_date
'
:
10000
,
'
creation_date
'
:
10000
,
'
last_modified
'
:
15000
};
'
last_modified
'
:
15000
};
command
.
done
(
doc
);
that
.
done
(
doc
);
},
100
);
},
100
);
};
// end loadDocument
};
// end loadDocument
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
delete
list
[
0
].
content
;
delete
list
[
0
].
content
;
delete
list
[
1
].
content
;
delete
list
[
1
].
content
;
}
}
command
.
done
(
list
);
that
.
done
(
list
);
},
100
);
},
100
);
};
// end getDocumentList
};
// end getDocumentList
...
@@ -61,7 +61,7 @@
...
@@ -61,7 +61,7 @@
// Remove a document from the storage.
// Remove a document from the storage.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
done
();
that
.
done
();
},
100
);
},
100
);
};
};
return
that
;
return
that
;
...
@@ -80,7 +80,7 @@
...
@@ -80,7 +80,7 @@
// Tells us that the document is not saved.
// Tells us that the document is not saved.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
fail
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
that
.
fail
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
message
:
'
Unknown error.
'
});
message
:
'
Unknown error.
'
});
},
100
);
},
100
);
};
// end saveDocument
};
// end saveDocument
...
@@ -89,7 +89,7 @@
...
@@ -89,7 +89,7 @@
// Returns a document object containing nothing.
// Returns a document object containing nothing.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
fail
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
that
.
fail
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
message
:
'
Unknown error.
'
});
message
:
'
Unknown error.
'
});
},
100
);
},
100
);
};
// end loadDocument
};
// end loadDocument
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
// It returns nothing.
// It returns nothing.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
fail
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
that
.
fail
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
message
:
'
Unknown error.
'
});
message
:
'
Unknown error.
'
});
},
100
);
},
100
);
};
// end getDocumentList
};
// end getDocumentList
...
@@ -107,7 +107,7 @@
...
@@ -107,7 +107,7 @@
// Remove a document from the storage.
// Remove a document from the storage.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
fail
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
that
.
fail
({
status
:
0
,
statusText
:
'
Unknown Error
'
,
message
:
'
Unknown error.
'
});
message
:
'
Unknown error.
'
});
},
100
);
},
100
);
};
};
...
@@ -127,7 +127,7 @@
...
@@ -127,7 +127,7 @@
// Document does not exists yet, create it.
// Document does not exists yet, create it.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
done
();
that
.
done
();
},
100
);
},
100
);
};
// end saveDocument
};
// end saveDocument
...
@@ -135,7 +135,7 @@
...
@@ -135,7 +135,7 @@
// Returns a document object containing nothing.
// Returns a document object containing nothing.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
fail
({
status
:
404
,
statusText
:
'
Not Found
'
,
that
.
fail
({
status
:
404
,
statusText
:
'
Not Found
'
,
message
:
'
Document "
'
+
command
.
getPath
()
+
message
:
'
Document "
'
+
command
.
getPath
()
+
'
" not found.
'
});
'
" not found.
'
});
},
100
);
},
100
);
...
@@ -145,7 +145,7 @@
...
@@ -145,7 +145,7 @@
// It returns nothing.
// It returns nothing.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
fail
({
status
:
404
,
statusText
:
'
Not Found
'
,
that
.
fail
({
status
:
404
,
statusText
:
'
Not Found
'
,
message
:
'
User list not found.
'
});
message
:
'
User list not found.
'
});
},
100
);
},
100
);
};
// end getDocumentList
};
// end getDocumentList
...
@@ -154,7 +154,7 @@
...
@@ -154,7 +154,7 @@
// Remove a document from the storage.
// Remove a document from the storage.
setTimeout
(
function
()
{
setTimeout
(
function
()
{
command
.
done
();
that
.
done
();
},
100
);
},
100
);
};
};
return
that
;
return
that
;
...
@@ -169,33 +169,31 @@
...
@@ -169,33 +169,31 @@
that
.
setType
(
'
dummyall3tries
'
);
that
.
setType
(
'
dummyall3tries
'
);
priv
.
doJob
=
function
(
if_ok_return
)
{
priv
.
doJob
=
function
(
command
,
if_ok_return
)
{
// wait a little in order to simulate asynchronous operation
// wait a little in order to simulate asynchronous operation
setTimeout
(
function
()
{
setTimeout
(
function
()
{
priv
.
Try3OKElseFail
(
priv
.
command
.
getTried
(),
if_ok_return
);
priv
.
Try3OKElseFail
(
command
.
getTried
(),
if_ok_return
);
},
100
);
},
100
);
};
};
priv
.
Try3OKElseFail
=
function
(
tries
,
if_ok_return
)
{
priv
.
Try3OKElseFail
=
function
(
tries
,
if_ok_return
)
{
if
(
tries
===
3
)
{
if
(
tries
===
3
)
{
return
priv
.
command
.
done
(
if_ok_return
);
return
that
.
done
(
if_ok_return
);
}
}
if
(
tries
<
3
)
{
if
(
tries
<
3
)
{
return
priv
.
command
.
fail
(
return
that
.
fail
(
{
message
:
''
+
(
3
-
tries
)
+
'
tries left.
'
});
{
message
:
''
+
(
3
-
tries
)
+
'
tries left.
'
});
}
}
if
(
tries
>
3
)
{
if
(
tries
>
3
)
{
return
priv
.
command
.
fail
({
message
:
'
Too much tries.
'
});
return
that
.
fail
({
message
:
'
Too much tries.
'
});
}
}
};
};
that
.
saveDocument
=
function
(
command
)
{
that
.
saveDocument
=
function
(
command
)
{
priv
.
command
=
command
;
priv
.
doJob
(
command
);
priv
.
doJob
();
};
// end saveDocument
};
// end saveDocument
that
.
loadDocument
=
function
(
command
)
{
that
.
loadDocument
=
function
(
command
)
{
priv
.
command
=
command
;
priv
.
doJob
(
command
,{
priv
.
doJob
({
'
content
'
:
'
content2
'
,
'
content
'
:
'
content2
'
,
'
name
'
:
'
file
'
,
'
name
'
:
'
file
'
,
'
creation_date
'
:
11000
,
'
creation_date
'
:
11000
,
...
@@ -204,19 +202,17 @@
...
@@ -204,19 +202,17 @@
};
// end loadDocument
};
// end loadDocument
that
.
getDocumentList
=
function
(
command
)
{
that
.
getDocumentList
=
function
(
command
)
{
priv
.
command
=
command
;
priv
.
doJob
(
command
,[{
'
name
'
:
'
file
'
,
priv
.
doJob
([{
'
name
'
:
'
file
'
,
'
creation_date
'
:
10000
,
'
creation_date
'
:
10000
,
'
last_modified
'
:
15000
},
'
last_modified
'
:
15000
},
{
'
name
'
:
'
memo
'
,
{
'
name
'
:
'
memo
'
,
'
creation_date
'
:
20000
,
'
creation_date
'
:
20000
,
'
last_modified
'
:
25000
}
'
last_modified
'
:
25000
}
]);
]);
};
// end getDocumentList
};
// end getDocumentList
that
.
removeDocument
=
function
(
command
)
{
that
.
removeDocument
=
function
(
command
)
{
priv
.
command
=
command
;
priv
.
doJob
(
command
);
priv
.
doJob
();
};
// end removeDocument
};
// end removeDocument
return
that
;
return
that
;
...
...
OfficeJS/src/jio/activityUpdater.js
View file @
38cde22c
...
@@ -7,19 +7,49 @@ var activityUpdater = (function(spec, my) {
...
@@ -7,19 +7,49 @@ var activityUpdater = (function(spec, my) {
priv
.
id
=
spec
.
id
||
0
;
priv
.
id
=
spec
.
id
||
0
;
priv
.
interval
=
400
;
priv
.
interval
=
400
;
priv
.
interval_id
=
null
;
priv
.
interval_id
=
null
;
// Methods //
// Methods //
/**
* Update the last activity date in the localStorage.
* @method touch
*/
priv
.
touch
=
function
()
{
priv
.
touch
=
function
()
{
LocalOrCookieStorage
.
setItem
(
'
jio/id/
'
+
priv
.
id
,
Date
.
now
());
LocalOrCookieStorage
.
setItem
(
'
jio/id/
'
+
priv
.
id
,
Date
.
now
());
};
};
/**
* Sets the jio id into the activity.
* @method setId
* @param {number} id The jio id.
*/
that
.
setId
=
function
(
id
)
{
that
.
setId
=
function
(
id
)
{
priv
.
id
=
id
;
priv
.
id
=
id
;
};
};
/**
* Sets the interval delay between two updates.
* @method setIntervalDelay
* @param {number} ms In milliseconds
*/
that
.
setIntervalDelay
=
function
(
ms
)
{
that
.
setIntervalDelay
=
function
(
ms
)
{
priv
.
interval
=
ms
;
priv
.
interval
=
ms
;
};
};
/**
* Gets the interval delay.
* @method getIntervalDelay
* @return {number} The interval delay.
*/
that
.
getIntervalDelay
=
function
()
{
that
.
getIntervalDelay
=
function
()
{
return
priv
.
interval
;
return
priv
.
interval
;
};
};
/**
* Starts the activity updater. It will update regulary the last activity
* date in the localStorage to show to other jio instance that this instance
* is active.
* @method start
*/
that
.
start
=
function
()
{
that
.
start
=
function
()
{
if
(
!
priv
.
interval_id
)
{
if
(
!
priv
.
interval_id
)
{
priv
.
touch
();
priv
.
touch
();
...
@@ -28,12 +58,18 @@ var activityUpdater = (function(spec, my) {
...
@@ -28,12 +58,18 @@ var activityUpdater = (function(spec, my) {
},
priv
.
interval
);
},
priv
.
interval
);
}
}
};
};
/**
* Stops the activity updater.
* @method stop
*/
that
.
stop
=
function
()
{
that
.
stop
=
function
()
{
if
(
priv
.
interval_id
!==
null
)
{
if
(
priv
.
interval_id
!==
null
)
{
clearInterval
(
priv
.
interval_id
);
clearInterval
(
priv
.
interval_id
);
priv
.
interval_id
=
null
;
priv
.
interval_id
=
null
;
}
}
};
};
return
that
;
return
that
;
}());
}());
OfficeJS/src/jio/announcements/announcement.js
View file @
38cde22c
...
@@ -5,6 +5,7 @@ var announcement = function(spec, my) {
...
@@ -5,6 +5,7 @@ var announcement = function(spec, my) {
// Attributes //
// Attributes //
var
callback_a
=
[];
var
callback_a
=
[];
var
name
=
spec
.
name
||
''
;
var
name
=
spec
.
name
||
''
;
var
announcer
=
spec
.
announcer
||
{};
// Methods //
// Methods //
that
.
add
=
function
(
callback
)
{
that
.
add
=
function
(
callback
)
{
callback_a
.
push
(
callback
);
callback_a
.
push
(
callback
);
...
...
OfficeJS/src/jio/commands/command.js
View file @
38cde22c
...
@@ -103,8 +103,8 @@ var command = function(spec, my) {
...
@@ -103,8 +103,8 @@ var command = function(spec, my) {
};
};
that
.
done
=
function
(
return_value
)
{
that
.
done
=
function
(
return_value
)
{
priv
.
done
(
return_value
);
priv
.
respond
({
status
:
doneStatus
(),
value
:
return_value
});
priv
.
respond
({
status
:
doneStatus
(),
value
:
return_value
});
priv
.
done
(
return_value
);
priv
.
end
();
priv
.
end
();
};
};
...
@@ -112,17 +112,29 @@ var command = function(spec, my) {
...
@@ -112,17 +112,29 @@ var command = function(spec, my) {
if
(
priv
.
option
.
max_retry
===
0
||
priv
.
tried
<
priv
.
option
.
max_retry
)
{
if
(
priv
.
option
.
max_retry
===
0
||
priv
.
tried
<
priv
.
option
.
max_retry
)
{
priv
.
retry
();
priv
.
retry
();
}
else
{
}
else
{
priv
.
fail
(
return_error
);
priv
.
respond
({
status
:
failStatus
(),
error
:
return_error
});
priv
.
respond
({
status
:
failStatus
(),
error
:
return_error
});
priv
.
fail
(
return_error
);
priv
.
end
();
priv
.
end
();
}
}
};
};
that
.
onEndDo
=
function
(
fun
)
{
that
.
onResponseDo
=
function
(
fun
)
{
priv
.
respond
=
fun
;
};
that
.
onDoneDo
=
function
(
fun
)
{
priv
.
done
=
fun
;
};
that
.
onFailDo
=
function
(
fun
)
{
priv
.
fail
=
fun
;
};
that
.
onEndDo
=
function
(
fun
)
{
priv
.
end
=
fun
;
priv
.
end
=
fun
;
};
};
that
.
onRetryDo
=
function
(
fun
)
{
that
.
onRetryDo
=
function
(
fun
)
{
priv
.
retry
=
fun
;
priv
.
retry
=
fun
;
};
};
...
@@ -144,5 +156,9 @@ var command = function(spec, my) {
...
@@ -144,5 +156,9 @@ var command = function(spec, my) {
return
true
;
return
true
;
};
};
that
.
clone
=
function
()
{
return
command
(
that
.
serialized
(),
my
);
};
return
that
;
return
that
;
};
};
OfficeJS/src/jio/commands/getDocumentList.js
View file @
38cde22c
...
@@ -16,5 +16,23 @@ var getDocumentList = function(spec, my) {
...
@@ -16,5 +16,23 @@ var getDocumentList = function(spec, my) {
return
false
;
return
false
;
};
};
var
super_done
=
that
.
done
;
that
.
done
=
function
(
res
)
{
var
i
;
if
(
res
)
{
for
(
i
=
0
;
i
<
res
.
length
;
i
+=
1
)
{
if
(
typeof
res
[
i
].
last_modified
!==
'
number
'
)
{
res
[
i
].
last_modified
=
new
Date
(
res
[
i
].
last_modified
).
getTime
();
}
if
(
typeof
res
[
i
].
creation_date
!==
'
number
'
)
{
res
[
i
].
creation_date
=
new
Date
(
res
[
i
].
creation_date
).
getTime
();
}
}
}
super_done
(
res
);
};
return
that
;
return
that
;
};
};
OfficeJS/src/jio/commands/loadDocument.js
View file @
38cde22c
...
@@ -16,5 +16,17 @@ var loadDocument = function(spec, my) {
...
@@ -16,5 +16,17 @@ var loadDocument = function(spec, my) {
return
false
;
return
false
;
};
};
var
super_done
=
that
.
done
;
that
.
done
=
function
(
res
)
{
if
(
res
)
{
if
(
typeof
res
.
last_modified
!==
'
number
'
)
{
res
.
last_modified
=
new
Date
(
res
.
last_modified
).
getTime
();
}
if
(
typeof
res
.
creation_date
!==
'
number
'
)
{
res
.
creation_date
=
new
Date
(
res
.
creation_date
).
getTime
();
}
}
super_done
(
res
);
};
return
that
;
return
that
;
};
};
OfficeJS/src/jio/jio.outro.js
View file @
38cde22c
...
@@ -6,7 +6,11 @@
...
@@ -6,7 +6,11 @@
var
priv
=
{};
var
priv
=
{};
var
jio_id_array_name
=
'
jio/id_array
'
;
var
jio_id_array_name
=
'
jio/id_array
'
;
priv
.
id
=
null
;
priv
.
id
=
null
;
priv
.
storage
=
jioNamespace
.
storage
(
spec
);
my
.
jobManager
=
jobManager
;
my
.
jobIdHandler
=
jobIdHandler
;
priv
.
storage
=
jioNamespace
.
storage
(
spec
,
my
);
// initialize //
// initialize //
priv
.
init
=
function
()
{
priv
.
init
=
function
()
{
...
@@ -68,7 +72,7 @@
...
@@ -68,7 +72,7 @@
* @return {boolean} true if ok, else false.
* @return {boolean} true if ok, else false.
*/
*/
that
.
validateStorageDescription
=
function
(
description
)
{
that
.
validateStorageDescription
=
function
(
description
)
{
return
jioNamespace
.
storage
(
description
.
type
)(
description
).
isValid
();
return
jioNamespace
.
storage
(
description
,
my
).
isValid
();
};
};
/**
/**
...
@@ -92,10 +96,10 @@
...
@@ -92,10 +96,10 @@
option
.
max_retry
=
option
.
max_retry
||
0
;
option
.
max_retry
=
option
.
max_retry
||
0
;
jobManager
.
addJob
(
jobManager
.
addJob
(
job
({
storage
:(
specificstorage
?
job
({
storage
:(
specificstorage
?
jioNamespace
.
storage
(
specificstorage
):
jioNamespace
.
storage
(
specificstorage
,
my
):
priv
.
storage
),
priv
.
storage
),
command
:
saveDocument
(
command
:
saveDocument
(
{
path
:
path
,
content
:
content
,
option
:
option
})}));
{
path
:
path
,
content
:
content
,
option
:
option
})}
,
my
));
};
};
/**
/**
...
@@ -121,10 +125,10 @@
...
@@ -121,10 +125,10 @@
option
.
metadata_only
:
false
);
option
.
metadata_only
:
false
);
jobManager
.
addJob
(
jobManager
.
addJob
(
job
({
storage
:(
specificstorage
?
job
({
storage
:(
specificstorage
?
jioNamespace
.
storage
(
specificstorage
):
jioNamespace
.
storage
(
specificstorage
,
my
):
priv
.
storage
),
priv
.
storage
),
command
:
loadDocument
(
command
:
loadDocument
(
{
path
:
path
,
option
:
option
})}));
{
path
:
path
,
option
:
option
})}
,
my
));
};
};
/**
/**
...
@@ -147,10 +151,10 @@
...
@@ -147,10 +151,10 @@
option
.
max_retry
=
option
.
max_retry
||
0
;
option
.
max_retry
=
option
.
max_retry
||
0
;
jobManager
.
addJob
(
jobManager
.
addJob
(
job
({
storage
:(
specificstorage
?
job
({
storage
:(
specificstorage
?
jioNamespace
.
storage
(
specificstorage
):
jioNamespace
.
storage
(
specificstorage
,
my
):
priv
.
storage
),
priv
.
storage
),
command
:
removeDocument
(
command
:
removeDocument
(
{
path
:
path
,
option
:
option
})}));
{
path
:
path
,
option
:
option
})}
,
my
));
};
};
/**
/**
...
@@ -176,10 +180,10 @@
...
@@ -176,10 +180,10 @@
option
.
metadata_only
:
true
);
option
.
metadata_only
:
true
);
jobManager
.
addJob
(
jobManager
.
addJob
(
job
({
storage
:(
specificstorage
?
job
({
storage
:(
specificstorage
?
jioNamespace
.
storage
(
specificstorage
):
jioNamespace
.
storage
(
specificstorage
,
my
):
priv
.
storage
),
priv
.
storage
),
command
:
getDocumentList
(
command
:
getDocumentList
(
{
path
:
path
,
option
:
option
})}));
{
path
:
path
,
option
:
option
})}
,
my
));
};
};
return
that
;
return
that
;
...
...
OfficeJS/src/jio/jioNamespace.js
View file @
38cde22c
...
@@ -3,7 +3,10 @@ var jioNamespace = (function(spec, my) {
...
@@ -3,7 +3,10 @@ var jioNamespace = (function(spec, my) {
spec
=
spec
||
{};
spec
=
spec
||
{};
my
=
my
||
{};
my
=
my
||
{};
// Attributes //
// Attributes //
var
storage_type_o
=
{
'
base
'
:
storage
,
'
handler
'
:
storageHandler
};
var
storage_type_o
=
{
// -> 'key':constructorFunction
'
base
'
:
storage
,
'
handler
'
:
storageHandler
};
// Methods //
// Methods //
...
...
OfficeJS/src/jio/jobs/job.js
View file @
38cde22c
...
@@ -4,7 +4,7 @@ var job = function(spec, my) {
...
@@ -4,7 +4,7 @@ var job = function(spec, my) {
my
=
my
||
{};
my
=
my
||
{};
// Attributes //
// Attributes //
var
priv
=
{};
var
priv
=
{};
priv
.
id
=
jobIdHandler
.
nextId
();
priv
.
id
=
my
.
jobIdHandler
.
nextId
();
priv
.
command
=
spec
.
command
;
priv
.
command
=
spec
.
command
;
priv
.
storage
=
spec
.
storage
;
priv
.
storage
=
spec
.
storage
;
priv
.
status
=
initialStatus
();
priv
.
status
=
initialStatus
();
...
@@ -78,7 +78,7 @@ var job = function(spec, my) {
...
@@ -78,7 +78,7 @@ var job = function(spec, my) {
*/
*/
that
.
waitForJob
=
function
(
job
)
{
that
.
waitForJob
=
function
(
job
)
{
if
(
priv
.
status
.
getLabel
()
!==
'
wait
'
)
{
if
(
priv
.
status
.
getLabel
()
!==
'
wait
'
)
{
priv
.
status
=
waitStatus
();
priv
.
status
=
waitStatus
(
{},
my
);
}
}
priv
.
status
.
waitForJob
(
job
);
priv
.
status
.
waitForJob
(
job
);
};
};
...
@@ -101,7 +101,7 @@ var job = function(spec, my) {
...
@@ -101,7 +101,7 @@ var job = function(spec, my) {
*/
*/
that
.
waitForTime
=
function
(
ms
)
{
that
.
waitForTime
=
function
(
ms
)
{
if
(
priv
.
status
.
getLabel
()
!==
'
wait
'
)
{
if
(
priv
.
status
.
getLabel
()
!==
'
wait
'
)
{
priv
.
status
=
waitStatus
();
priv
.
status
=
waitStatus
(
{},
my
);
}
}
priv
.
status
.
waitForTime
(
ms
);
priv
.
status
.
waitForTime
(
ms
);
};
};
...
@@ -148,7 +148,7 @@ var job = function(spec, my) {
...
@@ -148,7 +148,7 @@ var job = function(spec, my) {
that
.
waitForTime
(
ms
);
that
.
waitForTime
(
ms
);
});
});
priv
.
command
.
onEndDo
(
function
()
{
priv
.
command
.
onEndDo
(
function
()
{
jobManager
.
terminateJob
(
that
);
my
.
jobManager
.
terminateJob
(
that
);
});
});
priv
.
command
.
execute
(
priv
.
storage
);
priv
.
command
.
execute
(
priv
.
storage
);
};
};
...
...
OfficeJS/src/jio/jobs/jobManager.js
View file @
38cde22c
...
@@ -10,13 +10,32 @@ var jobManager = (function(spec, my) {
...
@@ -10,13 +10,32 @@ var jobManager = (function(spec, my) {
priv
.
interval
=
200
;
priv
.
interval
=
200
;
priv
.
job_a
=
[];
priv
.
job_a
=
[];
my
.
jobManager
=
that
;
my
.
jobIdHandler
=
that
;
// Methods //
// Methods //
/**
* Get the job array name in the localStorage
* @method getJobArrayName
* @return {string} The job array name
*/
priv
.
getJobArrayName
=
function
()
{
priv
.
getJobArrayName
=
function
()
{
return
job_array_name
+
'
/
'
+
priv
.
id
;
return
job_array_name
+
'
/
'
+
priv
.
id
;
};
};
/**
* Returns the job array from the localStorage
* @method getJobArray
* @return {array} The job array.
*/
priv
.
getJobArray
=
function
()
{
priv
.
getJobArray
=
function
()
{
return
LocalOrCookieStorage
.
getItem
(
priv
.
getJobArrayName
())
||
[];
return
LocalOrCookieStorage
.
getItem
(
priv
.
getJobArrayName
())
||
[];
};
};
/**
* Does a backup of the job array in the localStorage.
* @method copyJobArrayToLocal
*/
priv
.
copyJobArrayToLocal
=
function
()
{
priv
.
copyJobArrayToLocal
=
function
()
{
var
new_a
=
[],
i
;
var
new_a
=
[],
i
;
for
(
i
=
0
;
i
<
priv
.
job_a
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
priv
.
job_a
.
length
;
i
+=
1
)
{
...
@@ -25,6 +44,11 @@ var jobManager = (function(spec, my) {
...
@@ -25,6 +44,11 @@ var jobManager = (function(spec, my) {
LocalOrCookieStorage
.
setItem
(
priv
.
getJobArrayName
(),
new_a
);
LocalOrCookieStorage
.
setItem
(
priv
.
getJobArrayName
(),
new_a
);
};
};
/**
* Removes a job from the current job array.
* @method removeJob
* @param {object} job The job object.
*/
priv
.
removeJob
=
function
(
job
)
{
priv
.
removeJob
=
function
(
job
)
{
var
i
,
tmp_job_a
=
[];
var
i
,
tmp_job_a
=
[];
for
(
i
=
0
;
i
<
priv
.
job_a
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
priv
.
job_a
.
length
;
i
+=
1
)
{
...
@@ -75,6 +99,12 @@ var jobManager = (function(spec, my) {
...
@@ -75,6 +99,12 @@ var jobManager = (function(spec, my) {
}
}
};
};
/**
* Try to restore an the inactive older jio instances.
* It will restore the on going or initial jobs from their job array
* and it will add them to this job array.
* @method restoreOldJio
*/
priv
.
restoreOldJio
=
function
()
{
priv
.
restoreOldJio
=
function
()
{
var
i
,
jio_id_a
;
var
i
,
jio_id_a
;
priv
.
lastrestore
=
priv
.
lastrestore
||
0
;
priv
.
lastrestore
=
priv
.
lastrestore
||
0
;
...
@@ -86,6 +116,11 @@ var jobManager = (function(spec, my) {
...
@@ -86,6 +116,11 @@ var jobManager = (function(spec, my) {
priv
.
lastrestore
=
Date
.
now
();
priv
.
lastrestore
=
Date
.
now
();
};
};
/**
* Try to restore an old jio according to an id.
* @method restoreOldJioId
* @param {number} id The jio id.
*/
priv
.
restoreOldJioId
=
function
(
id
)
{
priv
.
restoreOldJioId
=
function
(
id
)
{
var
jio_date
;
var
jio_date
;
jio_date
=
LocalOrCookieStorage
.
getItem
(
'
jio/id/
'
+
id
)
||
0
;
jio_date
=
LocalOrCookieStorage
.
getItem
(
'
jio/id/
'
+
id
)
||
0
;
...
@@ -96,19 +131,29 @@ var jobManager = (function(spec, my) {
...
@@ -96,19 +131,29 @@ var jobManager = (function(spec, my) {
}
}
};
};
/**
* Try to restore all jobs from another jio according to an id.
* @method restoreOldJobFromJioId
* @param {number} id The jio id.
*/
priv
.
restoreOldJobFromJioId
=
function
(
id
)
{
priv
.
restoreOldJobFromJioId
=
function
(
id
)
{
var
i
,
jio_job_array
;
var
i
,
jio_job_array
;
jio_job_array
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
id
)
||
[];
jio_job_array
=
LocalOrCookieStorage
.
getItem
(
'
jio/job_array/
'
+
id
)
||
[];
for
(
i
=
0
;
i
<
jio_job_array
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
jio_job_array
.
length
;
i
+=
1
)
{
var
command_o
=
command
(
jio_job_array
[
i
].
command
);
var
command_o
=
command
(
jio_job_array
[
i
].
command
,
my
);
if
(
command_o
.
canBeRestored
())
{
if
(
command_o
.
canBeRestored
())
{
that
.
addJob
(
job
(
that
.
addJob
(
job
(
{
storage
:
jioNamespace
.
storage
(
jio_job_array
[
i
].
storage
),
{
storage
:
jioNamespace
.
storage
(
jio_job_array
[
i
].
storage
,
my
),
command
:
command_o
}));
command
:
command_o
}
,
my
));
}
}
}
}
};
};
/**
* Removes a jio instance according to an id.
* @method removeOldJioId
* @param {number} id The jio id.
*/
priv
.
removeOldJioId
=
function
(
id
)
{
priv
.
removeOldJioId
=
function
(
id
)
{
var
i
,
jio_id_a
,
new_a
=
[];
var
i
,
jio_id_a
,
new_a
=
[];
jio_id_a
=
LocalOrCookieStorage
.
getItem
(
'
jio/id_array
'
)
||
[];
jio_id_a
=
LocalOrCookieStorage
.
getItem
(
'
jio/id_array
'
)
||
[];
...
@@ -121,6 +166,11 @@ var jobManager = (function(spec, my) {
...
@@ -121,6 +166,11 @@ var jobManager = (function(spec, my) {
LocalOrCookieStorage
.
deleteItem
(
'
jio/id/
'
+
id
);
LocalOrCookieStorage
.
deleteItem
(
'
jio/id/
'
+
id
);
};
};
/**
* Removes a job array from a jio instance according to an id.
* @method removeJobArrayFromJioId
* @param {number} id The jio id.
*/
priv
.
removeJobArrayFromJioId
=
function
(
id
)
{
priv
.
removeJobArrayFromJioId
=
function
(
id
)
{
LocalOrCookieStorage
.
deleteItem
(
'
jio/job_array/
'
+
id
);
LocalOrCookieStorage
.
deleteItem
(
'
jio/job_array/
'
+
id
);
};
};
...
@@ -143,6 +193,12 @@ var jobManager = (function(spec, my) {
...
@@ -143,6 +193,12 @@ var jobManager = (function(spec, my) {
priv
.
copyJobArrayToLocal
();
priv
.
copyJobArrayToLocal
();
};
};
/**
* Checks if a job exists in the job array according to a job id.
* @method jobIdExists
* @param {number} id The job id.
* @return {boolean} true if exists, else false.
*/
that
.
jobIdExists
=
function
(
id
)
{
that
.
jobIdExists
=
function
(
id
)
{
var
i
;
var
i
;
for
(
i
=
0
;
i
<
priv
.
job_a
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
priv
.
job_a
.
length
;
i
+=
1
)
{
...
@@ -153,16 +209,32 @@ var jobManager = (function(spec, my) {
...
@@ -153,16 +209,32 @@ var jobManager = (function(spec, my) {
return
false
;
return
false
;
};
};
/**
* Terminate a job. It only remove it from the job array.
* @method terminateJob
* @param {object} job The job object
*/
that
.
terminateJob
=
function
(
job
)
{
that
.
terminateJob
=
function
(
job
)
{
priv
.
removeJob
(
job
);
priv
.
removeJob
(
job
);
priv
.
copyJobArrayToLocal
();
};
};
/**
* Adds a job to the current job array.
* @method addJob
* @param {object} job The new job.
*/
that
.
addJob
=
function
(
job
)
{
that
.
addJob
=
function
(
job
)
{
var
result_a
=
that
.
validateJobAccordingToJobList
(
priv
.
job_a
,
job
);
var
result_a
=
that
.
validateJobAccordingToJobList
(
priv
.
job_a
,
job
);
priv
.
manage
(
job
,
result_a
);
priv
.
appendJob
(
job
,
result_a
);
};
};
/**
* Generate a result array containing action string to do with the good job.
* @method validateJobAccordingToJobList
* @param {array} job_a A job array.
* @param {object} job The new job to compare with.
* @return {array} A result array.
*/
that
.
validateJobAccordingToJobList
=
function
(
job_a
,
job
)
{
that
.
validateJobAccordingToJobList
=
function
(
job_a
,
job
)
{
var
i
,
result_a
=
[];
var
i
,
result_a
=
[];
for
(
i
=
0
;
i
<
job_a
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
job_a
.
length
;
i
+=
1
)
{
...
@@ -171,7 +243,16 @@ var jobManager = (function(spec, my) {
...
@@ -171,7 +243,16 @@ var jobManager = (function(spec, my) {
return
result_a
;
return
result_a
;
};
};
priv
.
manage
=
function
(
job
,
result_a
)
{
/**
* It will manage the job in order to know what to do thanks to a result
* array. The new job can be added to the job array, but it can also be
* not accepted. It is this method which can tells jobs to wait for another
* one, to replace one or to eliminate some while browsing.
* @method appendJob
* @param {object} job The job to append.
* @param {array} result_a The result array.
*/
priv
.
appendJob
=
function
(
job
,
result_a
)
{
var
i
;
var
i
;
if
(
priv
.
job_a
.
length
!==
result_a
.
length
)
{
if
(
priv
.
job_a
.
length
!==
result_a
.
length
)
{
throw
new
RangeError
(
"
Array out of bound
"
);
throw
new
RangeError
(
"
Array out of bound
"
);
...
@@ -184,7 +265,7 @@ var jobManager = (function(spec, my) {
...
@@ -184,7 +265,7 @@ var jobManager = (function(spec, my) {
for
(
i
=
0
;
i
<
result_a
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
result_a
.
length
;
i
+=
1
)
{
switch
(
result_a
[
i
].
action
)
{
switch
(
result_a
[
i
].
action
)
{
case
'
eliminate
'
:
case
'
eliminate
'
:
that
.
eliminate
(
result_a
[
i
].
job
);
priv
.
removeJob
(
result_a
[
i
].
job
);
break
;
break
;
case
'
update
'
:
case
'
update
'
:
result_a
[
i
].
job
.
update
(
job
);
result_a
[
i
].
job
.
update
(
job
);
...
@@ -200,16 +281,5 @@ var jobManager = (function(spec, my) {
...
@@ -200,16 +281,5 @@ var jobManager = (function(spec, my) {
priv
.
copyJobArrayToLocal
();
priv
.
copyJobArrayToLocal
();
};
};
that
.
eliminate
=
function
(
job
)
{
var
i
,
tmp_a
=
[];
for
(
i
=
0
;
i
<
priv
.
job_a
.
length
;
i
+=
1
)
{
if
(
priv
.
job_a
[
i
].
getId
()
!==
job
.
getId
())
{
tmp_a
.
push
(
priv
.
job_a
[
i
]);
}
}
priv
.
job_a
=
tmp_a
;
priv
.
copyJobArrayToLocal
();
};
return
that
;
return
that
;
}());
}());
OfficeJS/src/jio/jobs/jobRules.js
View file @
38cde22c
...
@@ -18,6 +18,13 @@ var jobRules = (function(spec, my) {
...
@@ -18,6 +18,13 @@ var jobRules = (function(spec, my) {
};
};
// Methods //
// Methods //
/**
* Returns an action according the jobs given in parameters.
* @method getAction
* @param {object} job1 The already existant job.
* @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
;
var
j1label
,
j2label
,
j1status
;
j1label
=
job1
.
getCommand
().
getLabel
();
j1label
=
job1
.
getCommand
().
getLabel
();
...
@@ -32,6 +39,14 @@ var jobRules = (function(spec, my) {
...
@@ -32,6 +39,14 @@ var jobRules = (function(spec, my) {
return
that
.
default_action
(
job1
,
job2
);
return
that
.
default_action
(
job1
,
job2
);
}
}
};
};
/**
* Checks if the two jobs are comparable.
* @method canCompare
* @param {object} job1 The already existant job.
* @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
(),
var
job1label
=
job1
.
getCommand
().
getLabel
(),
job2label
=
job2
.
getCommand
().
getLabel
();
job2label
=
job2
.
getCommand
().
getLabel
();
...
@@ -85,6 +100,8 @@ var jobRules = (function(spec, my) {
...
@@ -85,6 +100,8 @@ var jobRules = (function(spec, my) {
priv
.
compare
[
method1
][
method2
]
=
rule
;
priv
.
compare
[
method1
][
method2
]
=
rule
;
};
};
////////////////////////////////////////////////////////////////////////////
// Adding some rules
/*
/*
LEGEND:
LEGEND:
- s: storage
- s: storage
...
@@ -165,5 +182,7 @@ var jobRules = (function(spec, my) {
...
@@ -165,5 +182,7 @@ var jobRules = (function(spec, my) {
that
.
addActionRule
(
'
getDocumentList
'
,
true
,
'
getDocumentList
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
getDocumentList
'
,
true
,
'
getDocumentList
'
,
that
.
dontAccept
);
that
.
addActionRule
(
'
getDocumentList
'
,
false
,
'
getDocumentList
'
,
that
.
update
);
that
.
addActionRule
(
'
getDocumentList
'
,
false
,
'
getDocumentList
'
,
that
.
update
);
// end adding rules
////////////////////////////////////////////////////////////////////////////
return
that
;
return
that
;
}());
}());
OfficeJS/src/jio/jobs/status/jobStatus.js
View file @
38cde22c
...
@@ -14,5 +14,10 @@ var jobStatus = function(spec, my) {
...
@@ -14,5 +14,10 @@ var jobStatus = function(spec, my) {
that
.
serialized
=
function
()
{
that
.
serialized
=
function
()
{
return
{
label
:
that
.
getLabel
()};
return
{
label
:
that
.
getLabel
()};
};
};
that
.
isWaitStatus
=
function
()
{
return
false
;
};
return
that
;
return
that
;
};
};
\ No newline at end of file
OfficeJS/src/jio/jobs/status/waitStatus.js
View file @
38cde22c
...
@@ -6,21 +6,36 @@ var waitStatus = function(spec, my) {
...
@@ -6,21 +6,36 @@ var waitStatus = function(spec, my) {
var
priv
=
{};
var
priv
=
{};
priv
.
job_id_a
=
spec
.
job_id_array
||
[];
priv
.
job_id_a
=
spec
.
job_id_array
||
[];
priv
.
threshold
=
0
;
priv
.
threshold
=
0
;
// Methods //
// Methods //
/**
* Returns the label of this status.
* @method getLabel
* @return {string} The label: 'wait'.
*/
that
.
getLabel
=
function
()
{
that
.
getLabel
=
function
()
{
return
'
wait
'
;
return
'
wait
'
;
};
};
/**
* Refresh the job id array to wait.
* @method refreshJobIdArray
*/
priv
.
refreshJobIdArray
=
function
()
{
priv
.
refreshJobIdArray
=
function
()
{
var
tmp_job_id_a
=
[],
i
;
var
tmp_job_id_a
=
[],
i
;
for
(
i
=
0
;
i
<
priv
.
job_id_a
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
priv
.
job_id_a
.
length
;
i
+=
1
)
{
if
(
jobManager
.
jobIdExists
(
priv
.
job_id_a
[
i
]))
{
if
(
my
.
jobManager
.
jobIdExists
(
priv
.
job_id_a
[
i
]))
{
tmp_job_id_a
.
push
(
priv
.
job_id_a
[
i
]);
tmp_job_id_a
.
push
(
priv
.
job_id_a
[
i
]);
}
}
}
}
priv
.
job_id_a
=
tmp_job_id_a
;
priv
.
job_id_a
=
tmp_job_id_a
;
};
};
/**
* The status must wait for the job end before start again.
* @method waitForJob
* @param {object} job The job to wait for.
*/
that
.
waitForJob
=
function
(
job
)
{
that
.
waitForJob
=
function
(
job
)
{
var
i
;
var
i
;
for
(
i
=
0
;
i
<
priv
.
job_id_a
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
priv
.
job_id_a
.
length
;
i
+=
1
)
{
...
@@ -30,6 +45,12 @@ var waitStatus = function(spec, my) {
...
@@ -30,6 +45,12 @@ var waitStatus = function(spec, my) {
}
}
priv
.
job_id_a
.
push
(
job
.
getId
());
priv
.
job_id_a
.
push
(
job
.
getId
());
};
};
/**
* The status stops to wait for this job.
* @method dontWaitForJob
* @param {object} job The job to stop waiting for.
*/
that
.
dontWaitForJob
=
function
(
job
)
{
that
.
dontWaitForJob
=
function
(
job
)
{
var
i
,
tmp_job_id_a
=
[];
var
i
,
tmp_job_id_a
=
[];
for
(
i
=
0
;
i
<
priv
.
job_id_a
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
priv
.
job_id_a
.
length
;
i
+=
1
)
{
...
@@ -40,9 +61,19 @@ var waitStatus = function(spec, my) {
...
@@ -40,9 +61,19 @@ var waitStatus = function(spec, my) {
priv
.
job_id_a
=
tmp_job_id_a
;
priv
.
job_id_a
=
tmp_job_id_a
;
};
};
/**
* The status must wait for some milliseconds.
* @method waitForTime
* @param {number} ms The number of milliseconds
*/
that
.
waitForTime
=
function
(
ms
)
{
that
.
waitForTime
=
function
(
ms
)
{
priv
.
threshold
=
Date
.
now
()
+
ms
;
priv
.
threshold
=
Date
.
now
()
+
ms
;
};
};
/**
* The status stops to wait for some time.
* @method stopWaitForTime
*/
that
.
stopWaitForTime
=
function
()
{
that
.
stopWaitForTime
=
function
()
{
priv
.
threshold
=
0
;
priv
.
threshold
=
0
;
};
};
...
@@ -61,5 +92,14 @@ var waitStatus = function(spec, my) {
...
@@ -61,5 +92,14 @@ var waitStatus = function(spec, my) {
waitforjob
:
priv
.
job_id_a
};
waitforjob
:
priv
.
job_id_a
};
};
};
/**
* Checks if this status is waitStatus
* @method isWaitStatus
* @return {boolean} true
*/
that
.
isWaitStatus
=
function
()
{
return
true
;
};
return
that
;
return
that
;
};
};
OfficeJS/src/jio/storages/storage.js
View file @
38cde22c
...
@@ -5,7 +5,6 @@ var storage = function(spec, my) {
...
@@ -5,7 +5,6 @@ var storage = function(spec, my) {
// Attributes //
// Attributes //
var
priv
=
{};
var
priv
=
{};
priv
.
type
=
spec
.
type
||
''
;
priv
.
type
=
spec
.
type
||
''
;
// my.jio exists
// Methods //
// Methods //
that
.
getType
=
function
()
{
that
.
getType
=
function
()
{
...
@@ -22,6 +21,8 @@ var storage = function(spec, my) {
...
@@ -22,6 +21,8 @@ var storage = function(spec, my) {
*/
*/
that
.
execute
=
function
(
command
)
{
that
.
execute
=
function
(
command
)
{
that
.
validate
(
command
);
that
.
validate
(
command
);
that
.
done
=
command
.
done
;
that
.
fail
=
command
.
fail
;
command
.
executeOn
(
that
);
command
.
executeOn
(
that
);
};
};
...
@@ -68,5 +69,8 @@ var storage = function(spec, my) {
...
@@ -68,5 +69,8 @@ var storage = function(spec, my) {
return
''
;
return
''
;
};
};
that
.
done
=
function
()
{};
that
.
fail
=
function
()
{};
return
that
;
return
that
;
};
};
OfficeJS/src/jio/storages/storageHandler.js
View file @
38cde22c
var
storageHandler
=
function
(
spec
,
my
)
{
var
storageHandler
=
function
(
spec
,
my
)
{
var
that
=
storage
(
spec
,
my
);
spec
=
spec
||
{};
spec
=
spec
||
{};
my
=
my
||
{};
my
=
my
||
{};
// Attributes //
var
that
=
storage
(
spec
,
my
);
var
priv
=
{};
priv
.
storage_a
=
spec
.
storagelist
||
[];
// Methods //
that
.
addJob
=
function
(
storage
,
command
)
{
/**
my
.
jobManager
.
addJob
(
job
({
storage
:
storage
,
command
:
command
}),
my
);
* It is called before the execution.
* Override this function.
* @method beforeExecute
* @param {object} command The command.
*/
that
.
beforeExecute
=
function
(
command
)
{};
/**
* Execute the command according to this storage.
* @method execute
* @param {object} command The command.
*/
that
.
execute
=
function
(
command
)
{
var
i
;
that
.
validate
(
command
);
that
.
beforeExecute
(
command
);
for
(
i
=
0
;
i
<
priv
.
storage_a
.
length
;
i
++
)
{
priv
.
storage_a
[
i
].
execute
(
command
);
}
that
.
afterExecute
(
command
);
};
/**
* Is is called after the execution.
* Override this function.
* @method afterExecute
* @param {object} command The command.
*/
that
.
afterExecute
=
function
(
command
)
{
command
.
done
();
};
/**
* Returns a serialized version of this storage
* @method serialized
* @return {object} The serialized storage.
*/
that
.
serialized
=
function
()
{
return
{
type
:
priv
.
type
,
storagelist
:
priv
.
storagelist
};
};
};
return
that
;
return
that
;
...
...
OfficeJS/test/jiotests.js
View file @
38cde22c
This diff is collapsed.
Click to expand it.
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