Commit b53f05b1 authored by Tristan Cavelier's avatar Tristan Cavelier

ComplexQueries put in JIO

See docs/query.rst for more informations
parent be091ae3
...@@ -54,26 +54,25 @@ module.exports = function (grunt) { ...@@ -54,26 +54,25 @@ module.exports = function (grunt) {
// duplicate files are ignored // duplicate files are ignored
src: [ src: [
'src/jio/intro.js', 'src/jio/intro.js',
// core
'src/jio/core/globals.js', 'src/jio/core/globals.js',
'src/jio/core/util.js', 'src/jio/core/util.js',
'src/jio/core/**/*.js', 'src/jio/core/**/*.js',
'src/jio/features/**/*.js', 'src/jio/features/**/*.js',
'src/jio/outro.js'
], // queries
dest: 'jio.js' 'src/queries/core/globals.js',
}, 'src/queries/core/query.js',
queries: {
src: [
'src/queries/begin.js',
'src/queries/parser-begin.js', 'src/queries/parser-begin.js',
'src/queries/build/parser.js', 'src/queries/build/parser.js',
'src/queries/parser-end.js', 'src/queries/parser-end.js',
'src/queries/core/globals.js',
'src/queries/core/tools.js', 'src/queries/core/tools.js',
'src/queries/core/**/*.js', 'src/queries/core/**/*.js',
'src/queries/end.js'
'src/jio/outro.js'
], ],
dest: 'complex_queries.js' dest: 'jio.js'
} }
}, },
uglify: { uglify: {
...@@ -88,10 +87,6 @@ module.exports = function (grunt) { ...@@ -88,10 +87,6 @@ module.exports = function (grunt) {
jiodate: { jiodate: {
src: 'src/jio.date/jiodate.js', src: 'src/jio.date/jiodate.js',
dest: 'jiodate.min.js' dest: 'jiodate.min.js'
},
queries: {
src: 'complex_queries.js',
dest: 'complex_queries.min.js'
} }
}, },
qunit: { qunit: {
......
...@@ -5,8 +5,6 @@ QUERIES_DIR = src/queries ...@@ -5,8 +5,6 @@ QUERIES_DIR = src/queries
JIO = jio.js JIO = jio.js
JIO_MIN = jio.min.js JIO_MIN = jio.min.js
JIODATE_MIN = jiodate.min.js JIODATE_MIN = jiodate.min.js
COMPLEX = complex_queries.js
COMPLEX_MIN = complex_queries.min.js
PARSER_PAR = $(QUERIES_DIR)/core/parser.par PARSER_PAR = $(QUERIES_DIR)/core/parser.par
PARSER_OUT = $(QUERIES_DIR)/build/parser.js PARSER_OUT = $(QUERIES_DIR)/build/parser.js
UGLIFY = ./node_modules/grunt-contrib-uglify/node_modules/uglify-js/bin/uglifyjs UGLIFY = ./node_modules/grunt-contrib-uglify/node_modules/uglify-js/bin/uglifyjs
...@@ -28,7 +26,7 @@ zip: ...@@ -28,7 +26,7 @@ zip:
@mkdir $(TMPDIR)/jio @mkdir $(TMPDIR)/jio
@mkdir $(TMPDIR)/jio/storage @mkdir $(TMPDIR)/jio/storage
@cp jio.js $(TMPDIR)/jio/ @cp jio.js $(TMPDIR)/jio/
@cp complex_queries.js $(TMPDIR)/jio/ @cp jioquery.js $(TMPDIR)/jio/
@cp src/sha1.amd.js $(TMPDIR)/jio/ @cp src/sha1.amd.js $(TMPDIR)/jio/
@cp src/sha2.amd.js $(TMPDIR)/jio/ @cp src/sha2.amd.js $(TMPDIR)/jio/
@cp src/sha256.amd.js $(TMPDIR)/jio/ @cp src/sha256.amd.js $(TMPDIR)/jio/
...@@ -57,7 +55,6 @@ zip: ...@@ -57,7 +55,6 @@ zip:
@mkdir $(TMPDIR)/jio/storage @mkdir $(TMPDIR)/jio/storage
@echo "Minimizing JS..." @echo "Minimizing JS..."
@cp jio.min.js $(TMPDIR)/jio/ @cp jio.min.js $(TMPDIR)/jio/
@cp complex_queries.min.js $(TMPDIR)/jio/
@$(UGLIFY) src/sha1.amd.js >$(TMPDIR)/jio/sha1.amd.min.js 2>/dev/null @$(UGLIFY) src/sha1.amd.js >$(TMPDIR)/jio/sha1.amd.min.js 2>/dev/null
@$(UGLIFY) src/sha2.amd.js >$(TMPDIR)/jio/sha2.amd.min.js 2>/dev/null @$(UGLIFY) src/sha2.amd.js >$(TMPDIR)/jio/sha2.amd.min.js 2>/dev/null
@$(UGLIFY) src/sha256.amd.js >$(TMPDIR)/jio/sha256.amd.min.js 2>/dev/null @$(UGLIFY) src/sha256.amd.js >$(TMPDIR)/jio/sha256.amd.min.js 2>/dev/null
...@@ -92,6 +89,4 @@ realclean: ...@@ -92,6 +89,4 @@ realclean:
rm -f "$(JIO)" rm -f "$(JIO)"
rm -f "$(JIO_MIN)" rm -f "$(JIO_MIN)"
rm -f "$(JIODATE_MIN)" rm -f "$(JIODATE_MIN)"
rm -f "$(COMPLEX)"
rm -f "$(COMPLEX_MIN)"
rm -f "$(PARSER_OUT)" rm -f "$(PARSER_OUT)"
...@@ -16,7 +16,6 @@ depending on type of storages being used): ...@@ -16,7 +16,6 @@ depending on type of storages being used):
<script src="jio.js"></script> <script src="jio.js"></script>
<!-- jio storage libraries --> <!-- jio storage libraries -->
<script src="complex-queries.js"></script>
<script src="localstorage.js"></script> <script src="localstorage.js"></script>
<script ...> <script ...>
...@@ -309,13 +308,12 @@ var jio_instance = jIO.createJIO({ ...@@ -309,13 +308,12 @@ var jio_instance = jIO.createJIO({
For more information on the specific storages including guidelines on how to For more information on the specific storages including guidelines on how to
create your own connector, please also refer to the [documentation](https://www.j-io.org/documentation/jio-documentation). create your own connector, please also refer to the [documentation](https://www.j-io.org/documentation/jio-documentation).
### Complex Queries ### jIO Query
jIO uses complex-queries manager, which can be run on top of the allDocs() jIO can use queries, which can be run in the allDocs() method to query document
method to query documents in the storage tree. A sample query would look like lists. A sample query would look like this (note that not all storages support
this (note that not all storages support allDocs and complex queries, and allDocs and jio queries, and that pre-querying of documents on distant storages
that pre-querying of documents on distant storages should best be done should best be done server-side):
server-side):
```javascript ```javascript
// run allDocs with query option on an existing jIO // run allDocs with query option on an existing jIO
...@@ -342,7 +340,7 @@ jio_instance.allDocs({ ...@@ -342,7 +340,7 @@ jio_instance.allDocs({
}); });
``` ```
To find out more about complex queries, please refer to the documentation. To find out more about queries, please refer to the documentation.
### Task Management ### Task Management
......
...@@ -5,7 +5,7 @@ Quick start ...@@ -5,7 +5,7 @@ Quick start
----------- -----------
The source repository includes ready-to-use files, so in case you do The source repository includes ready-to-use files, so in case you do
not want to build jIO yourself, just use *jio.js* as well as *complex_queries.js* not want to build jIO yourself, just use *sha256.amd.js*, *rsvp.js*, *jio.js*
plus the storages and dependencies you need and you will be good to go. plus the storages and dependencies you need and you will be good to go.
If you want to modify or build jIO yourself, you need to If you want to modify or build jIO yourself, you need to
...@@ -21,15 +21,15 @@ If you want to modify or build jIO yourself, you need to ...@@ -21,15 +21,15 @@ If you want to modify or build jIO yourself, you need to
``# npm -g install grunt-cli`` ``# npm -g install grunt-cli``
* Install the dependencies. * Install the dependencies.
``$ npm install`` ``$ npm install``
* Compile the JS/CC parser. * Compile the JS/CC parser.
``$ make`` (until we find out how to compile it with grunt) ``$ make`` (until we find out how to compile it with grunt)
* Run build. * Run build.
``$ grunt`` ``$ grunt``
...@@ -311,4 +311,3 @@ Or you can just clear all rules before adding new ones: ...@@ -311,4 +311,3 @@ Or you can just clear all rules before adding new ones:
// ... // ...
}] }]
}); });
...@@ -15,7 +15,6 @@ Getting started ...@@ -15,7 +15,6 @@ Getting started
<script src="jio.js"></script> <script src="jio.js"></script>
<!-- storages + dependencies --> <!-- storages + dependencies -->
<script src="complex_queries.js"></script>
<script src="localstorage.js"></script> <script src="localstorage.js"></script>
<script src="davstorage.js"></script> <script src="davstorage.js"></script>
...@@ -33,7 +32,6 @@ Getting started ...@@ -33,7 +32,6 @@ Getting started
rsvp: 'rsvp-custom', rsvp: 'rsvp-custom',
jio: 'jio', jio: 'jio',
// storages + dependencies // storages + dependencies
complex_queries: 'complex_queries',
localstorage: 'localstorage', localstorage: 'localstorage',
davstorage: 'davstorage' davstorage: 'davstorage'
} }
...@@ -110,7 +108,6 @@ Core ...@@ -110,7 +108,6 @@ Core
* sha256.amd.js * sha256.amd.js
* rsvp-custom.js, AMD only version: rsvp-custom.amd.js * rsvp-custom.js, AMD only version: rsvp-custom.amd.js
* jio.js * jio.js
* complex_queries.js
Storage dependencies Storage dependencies
^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^
......
...@@ -9,7 +9,8 @@ A storage to enable interoperability between all kind of storages. ...@@ -9,7 +9,8 @@ A storage to enable interoperability between all kind of storages.
A global ID (GID) is a document id which represents a unique document. This ID A global ID (GID) is a document id which represents a unique document. This ID
is then used to find this unique document on all types of backends. is then used to find this unique document on all types of backends.
This storage uses sub storage ``.allDocs()`` and complex queries to find unique documents, and converts their ids to gids. This storage uses sub storage ``.allDocs()`` and queries to find unique
documents, and converts their ids to gids.
Where it can be used Where it can be used
-------------------- --------------------
...@@ -125,7 +126,7 @@ Storage Requirements ...@@ -125,7 +126,7 @@ Storage Requirements
-------------------- --------------------
* This storage is not compatible with *RevisionStorage* and *ReplicateRevisionStorage*. * This storage is not compatible with *RevisionStorage* and *ReplicateRevisionStorage*.
* Sub storages have to support options for ``complex queries`` and ``include_docs``. * Sub storages have to support options for queries and ``include_docs``.
Dependencies Dependencies
...@@ -158,5 +159,3 @@ Offline application usage:: ...@@ -158,5 +159,3 @@ Offline application usage::
`-- Local Storage `-- Local Storage
**CAUTION: All gid storage must have the same description!** **CAUTION: All gid storage must have the same description!**
...@@ -41,10 +41,9 @@ jIO documentation ...@@ -41,10 +41,9 @@ jIO documentation
revision_storages revision_storages
available_storages available_storages
gid_storage gid_storage
complex_queries query
keys keys
metadata metadata
developers developers
style_guide style_guide
authors authors
...@@ -161,7 +161,7 @@ property, that behaves like the ``compareFunction`` described in ...@@ -161,7 +161,7 @@ property, that behaves like the ``compareFunction`` described in
If the < or > comparison makes no sense for the objects, the function should return ``undefined``. If the < or > comparison makes no sense for the objects, the function should return ``undefined``.
The ``.cmp()`` property is also used, if present, by the sorting feature of complex queries. The ``.cmp()`` property is also used, if present, by the sorting feature of queries.
...@@ -262,7 +262,7 @@ A schema can be used: ...@@ -262,7 +262,7 @@ A schema can be used:
.. code-block:: javascript .. code-block:: javascript
complex_queries.QueryFactory.create({...}, key_schema).exec(...); jIO.QueryFactory.create({...}, key_schema).exec(...);
* In the ``jIO.createJIO()`` method. The same schema will be used * In the ``jIO.createJIO()`` method. The same schema will be used
......
...@@ -400,7 +400,7 @@ Posting a job announcement ...@@ -400,7 +400,7 @@ Posting a job announcement
Getting a list of document created by someone Getting a list of document created by someone
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With complex query: With query:
.. code-block:: javascript .. code-block:: javascript
...@@ -410,7 +410,7 @@ With complex query: ...@@ -410,7 +410,7 @@ With complex query:
Getting all documents about jIO in the resilience project Getting all documents about jIO in the resilience project
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With complex query: With query:
.. code-block:: javascript .. code-block:: javascript
......
jIO Complex Queries jIO Query
=================== =========
What are Complex Queries? What are Queries?
------------------------- -----------------
In jIO, a complex query can ask a storage server to select, filter, sort, or In jIO, a query can ask a storage server to select, filter, sort, or limit a
limit a document list before sending it back. If the server is not able to do document list before sending it back. If the server is not able to do so, the
so, the complex query tool can do the filtering by itself on the client. Only the jio query tool can do the filtering by itself on the client. Only the
``.allDocs()`` method can use complex queries. ``.allDocs()`` method can use jio queries.
A query can either be a string (using a specific language useful for writing A query can either be a string (using a specific language useful for writing
queries), or it can be a tree of objects (useful to browse queries). To handle queries), or it can be a tree of objects (useful to browse queries). To handle
complex queries, jIO uses a parsed grammar file which is compiled using `JSCC <http://jscc.phorward-software.com/>`_. queries, jIO uses a parsed grammar file which is compiled using `JSCC
<http://jscc.phorward-software.com/>`_.
Why use Complex Queries? Why use JIO Queries?
------------------------ --------------------
Complex queries can be used like database queries, for tasks such as: JIO queries can be used like database queries, for tasks such as:
* search a specific document * search a specific document
* sort a list of documents in a certain order * sort a list of documents in a certain order
* avoid retrieving a list of ten thousand documents * avoid retrieving a list of ten thousand documents
* limit the list to show only N documents per page * limit the list to show only N documents per page
For some storages (like localStorage), complex queries can be a powerful tool For some storages (like localStorage), jio queries can be a powerful tool to
to query accessible documents. When querying documents on a distant storage, query accessible documents. When querying documents on a distant storage, some
some server-side logic should be run to avoid returning too many documents server-side logic should be run to avoid returning too many documents to the
to the client. If distant storages are static, an alternative would be to use client. If distant storages are static, an alternative would be to use an
an indexStorage with appropriate indices as complex queries will always try indexStorage with appropriate indices as jio queries will always try to run the
to run the query on the index before querying documents itself. query on the index before querying documents itself.
How to use Complex Queries with jIO? How to use Queries with jIO?
------------------------------------ ----------------------------
Complex queries can be triggered by including the option named **query** in the ``.allDocs()`` method call. Queries can be triggered by including the option named **query** in the ``.allDocs()`` method call.
Example: Example:
...@@ -75,31 +76,29 @@ Example: ...@@ -75,31 +76,29 @@ Example:
jio_instance.allDocs(options, callback); jio_instance.allDocs(options, callback);
How to use Complex Queries outside jIO? How to use Queries outside jIO?
--------------------------------------- -------------------------------
.. XXX 404 page missing on complex_example.html
Complex Queries provides an API - which namespace is complex_queries. Refer to the `JIO Query sample page <http://git.erp5.org/gitweb/jio.git/blob/HEAD:/examples/example-queries.html?js=1>`_
Refer to the `Complex Queries sample page <http://git.erp5.org/gitweb/jio.git/blob/HEAD:/examples/complex_example.html?js=1>`_
for how to use these methods, in and outside jIO. The module provides: for how to use these methods, in and outside jIO. The module provides:
.. code-block:: javascript .. code-block:: javascript
{ jIO: {
parseStringToObject: [Function: parseStringToObject],
stringEscapeRegexpCharacters: [Function: stringEscapeRegexpCharacters],
select: [Function: select],
sortOn: [Function: sortOn],
limit: [Function: limit],
searchTextToRegExp: [Function: searchTextToRegExp],
QueryFactory: { [Function: QueryFactory] create: [Function] }, QueryFactory: { [Function: QueryFactory] create: [Function] },
Query: [Function: Query], Query: { [Function: Query],
parseStringToObject: [Function],
stringEscapeRegexpCharacters: [Function],
select: [Function],
sortOn: [Function],
limit: [Function],
searchTextToRegExp: [Function],
}
SimpleQuery: { SimpleQuery: {
[Function: SimpleQuery] super_: [Function: Query] [Function: SimpleQuery] super_: [Function: Query]
}, },
ComplexQuery: { ComplexQuery: {
[Function: ComplexQuery] super_: [Function: Query] [Function: ComplexQuery] super_: [Function: Query]
} }
} }
...@@ -119,7 +118,7 @@ Basic example: ...@@ -119,7 +118,7 @@ Basic example:
var query = 'title: "Document number 1"'; var query = 'title: "Document number 1"';
// running the query // running the query
var result = complex_queries.QueryFactory.create(query).exec(object_list); var result = jIO.QueryFactory.create(query).exec(object_list);
// console.log(result); // console.log(result);
// [ { "title": "Document number 1", "creator": "John Doe"} ] // [ { "title": "Document number 1", "creator": "John Doe"} ]
...@@ -128,7 +127,7 @@ Other example: ...@@ -128,7 +127,7 @@ Other example:
.. code-block:: javascript .. code-block:: javascript
var result = complex_queries.QueryFactory.create(query).exec( var result = jIO.QueryFactory.create(query).exec(
object_list, object_list,
{ {
"select": ['title', 'year'], "select": ['title', 'year'],
...@@ -138,18 +137,18 @@ Other example: ...@@ -138,18 +137,18 @@ Other example:
} }
); );
// this case is equal to: // this case is equal to:
var result = complex_queries.QueryFactory. var result = jIO.QueryFactory.
create(query).exec(object_list); create(query).exec(object_list);
complex_queries.sortOn([ jIO.Query.sortOn([
['title', 'ascending'], ['title', 'ascending'],
['year', 'descending'] ['year', 'descending']
], result); ], result);
complex_queries.limit([20, 20], result); jIO.Query.limit([20, 20], result);
complex_queries.select(['title', 'year'], result); jIO.Query.select(['title', 'year'], result);
Complex Queries in storage connectors Query in storage connectors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
The query exec method must only be used if the server is not able to pre-select The query exec method must only be used if the server is not able to pre-select
documents. As mentioned before, you could use an indexStorage to maintain documents. As mentioned before, you could use an indexStorage to maintain
...@@ -160,7 +159,7 @@ are available in the index. ...@@ -160,7 +159,7 @@ are available in the index.
Matching properties Matching properties
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
Complex Queries select items which exactly match the value given in the query Queries select items which exactly match the value given in the query
but you can also use wildcards (``%``). If you don't want to use a wildcard, but you can also use wildcards (``%``). If you don't want to use a wildcard,
just set the operator to ``=``. just set the operator to ``=``.
...@@ -184,14 +183,14 @@ component (change ``limit: [0, 10]`` to ``limit: [10, 10]`` or ``sort_on: [['tit ...@@ -184,14 +183,14 @@ component (change ``limit: [0, 10]`` to ``limit: [10, 10]`` or ``sort_on: [['tit
'ascending']]`` to ``sort_on: [['creator', 'ascending']]``) and each component must 'ascending']]`` to ``sort_on: [['creator', 'ascending']]``) and each component must
have its own default properties to keep their own behavior. have its own default properties to keep their own behavior.
Convert Complex Queries into another type Query into another type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
Example, convert Query object into a human readable string: Example, convert Query object into a human readable string:
.. code-block:: javascript .. code-block:: javascript
var query = complex_queries.QueryFactory. var query = jIO.QueryFactory.
create('year: < 2000 OR title: "%a"'), create('year: < 2000 OR title: "%a"'),
option = { option = {
limit: [0, 10] limit: [0, 10]
...@@ -240,7 +239,7 @@ JSON Schemas and Grammar ...@@ -240,7 +239,7 @@ JSON Schemas and Grammar
Below you can find schemas for constructing queries. Below you can find schemas for constructing queries.
* Complex Queries JSON Schema: * Complex Query JSON Schema:
.. code-block:: javascript .. code-block:: javascript
...@@ -274,7 +273,7 @@ Below you can find schemas for constructing queries. ...@@ -274,7 +273,7 @@ Below you can find schemas for constructing queries.
} }
* Simple Queries JSON Schema: * Simple Query JSON Schema:
.. code-block:: javascript .. code-block:: javascript
...@@ -308,7 +307,7 @@ Below you can find schemas for constructing queries. ...@@ -308,7 +307,7 @@ Below you can find schemas for constructing queries.
* Complex Queries Grammar:: * JIO Query Grammar::
search_text search_text
: and_expression : and_expression
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Complex Queries Example</title> <title>JIO Query Example</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
table, textarea, input { table, textarea, input {
width: 100%; width: 100%;
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
<button onclick="jsonToSearchText()">JSON to Search text</button> <button onclick="jsonToSearchText()">JSON to Search text</button>
<button onclick="query()">Query</button> <button onclick="query()">Query</button>
<script type="text/javascript" src="../lib/rsvp/rsvp-custom.js"></script> <script type="text/javascript" src="../lib/rsvp/rsvp-custom.js"></script>
<script type="text/javascript" src="../complex_queries.js"></script>
<script type="text/javascript" <script type="text/javascript"
src="http://code.jquery.com/jquery-1.8.2.min.js"></script> src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
...@@ -48,7 +47,7 @@ function searchTextToJson() { ...@@ -48,7 +47,7 @@ function searchTextToJson() {
$("#obj").attr( $("#obj").attr(
"value", "value",
JSON.stringify( JSON.stringify(
complex_queries.QueryFactory.create( jIO.QueryFactory.create(
$("#str").attr("value") $("#str").attr("value")
).serialized() ).serialized()
) )
...@@ -57,7 +56,7 @@ function searchTextToJson() { ...@@ -57,7 +56,7 @@ function searchTextToJson() {
function jsonToSearchText() { function jsonToSearchText() {
$("#str").attr( $("#str").attr(
"value", "value",
complex_queries.QueryFactory.create( jIO.QueryFactory.create(
JSON.parse( JSON.parse(
$("#obj").attr("value") $("#obj").attr("value")
) )
...@@ -66,7 +65,7 @@ function jsonToSearchText() { ...@@ -66,7 +65,7 @@ function jsonToSearchText() {
} }
function query() { function query() {
var list = JSON.parse($("#list").attr("value")); var list = JSON.parse($("#list").attr("value"));
complex_queries.QueryFactory.create( jIO.QueryFactory.create(
JSON.parse( JSON.parse(
$("#obj").attr("value") $("#obj").attr("value")
) )
......
...@@ -19,7 +19,6 @@ var log = function (o) { ...@@ -19,7 +19,6 @@ var log = function (o) {
<script src="../src/sha256.amd.js"></script> <script src="../src/sha256.amd.js"></script>
<script src="../lib/rsvp/rsvp-custom.js"></script> <script src="../lib/rsvp/rsvp-custom.js"></script>
<script src="../jio.js"></script> <script src="../jio.js"></script>
<script src="../complex_queries.js"></script>
<script src="../src/jio.storage/localstorage.js"></script> <script src="../src/jio.storage/localstorage.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
......
...@@ -130,7 +130,6 @@ document.addEventListener("keypress", function (event) { ...@@ -130,7 +130,6 @@ document.addEventListener("keypress", function (event) {
<script src="../lib/rsvp/rsvp-custom.js"></script> <script src="../lib/rsvp/rsvp-custom.js"></script>
<script src="../src/sha256.amd.js"></script> <script src="../src/sha256.amd.js"></script>
<script src="../jio.js"></script> <script src="../jio.js"></script>
<script src="../complex_queries.js"></script>
<script src="../src/jio.storage/localstorage.js"></script> <script src="../src/jio.storage/localstorage.js"></script>
<script src="http://git.erp5.org/gitweb/uritemplate-js.git/blob_plain/HEAD:/bin/uritemplate-min.js"></script> <script src="http://git.erp5.org/gitweb/uritemplate-js.git/blob_plain/HEAD:/bin/uritemplate-min.js"></script>
<script src="../lib/uri/URI.js"></script> <script src="../lib/uri/URI.js"></script>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
// } // }
/*jslint indent: 2, nomen: true, unparam: true */ /*jslint indent: 2, nomen: true, unparam: true */
/*global jIO, complex_queries, console, UriTemplate, FormData, RSVP, URI, /*global jIO, console, UriTemplate, FormData, RSVP, URI,
ProgressEvent, define */ ProgressEvent, define */
(function (dependencies, module) { (function (dependencies, module) {
...@@ -18,13 +18,12 @@ ...@@ -18,13 +18,12 @@
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
return define(dependencies, module); return define(dependencies, module);
} }
module(RSVP, jIO, complex_queries, URI); module(RSVP, jIO, URI);
}([ }([
'rsvp', 'rsvp',
'jio', 'jio',
'complex_queries',
'uri' 'uri'
], function (RSVP, jIO, complex_queries, URI) { ], function (RSVP, jIO, URI) {
"use strict"; "use strict";
function ERP5Storage(spec) { function ERP5Storage(spec) {
...@@ -176,7 +175,7 @@ ...@@ -176,7 +175,7 @@
ERP5Storage.prototype.allDocs = function (command, param, options) { ERP5Storage.prototype.allDocs = function (command, param, options) {
if (typeof options.query !== "string") { if (typeof options.query !== "string") {
options.query = (options.query ? options.query = (options.query ?
complex_queries.objectToSearchText(options.query) : jIO.Query.objectToSearchText(options.query) :
undefined); undefined);
} }
return this._getSiteDocument() return this._getSiteDocument()
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* JIO GID Storage. Type = 'gid'. * JIO GID Storage. Type = 'gid'.
* Identifies document with their global identifier representation * Identifies document with their global identifier representation
* *
* Sub storages must support complex queries and include_docs options. * Sub storages must support queries and include_docs options.
* *
* Storage Description: * Storage Description:
* *
...@@ -216,12 +216,12 @@ ...@@ -216,12 +216,12 @@
} }
/** /**
* Convert a gid to a complex query. * Convert a gid to a jio query.
* *
* @param {Object,String} gid The gid * @param {Object,String} gid The gid
* @return {Object} A complex serialized object * @return {Object} A jio serialized query
*/ */
function gidToComplexQuery(gid) { function gidToJIOQuery(gid) {
var k, i, result = [], meta, content; var k, i, result = [], meta, content;
if (typeof gid === 'string') { if (typeof gid === 'string') {
gid = JSON.parse(gid); gid = JSON.parse(gid);
...@@ -300,7 +300,7 @@ ...@@ -300,7 +300,7 @@
* Generic command for post or put one. * Generic command for post or put one.
* *
* This command will check if the document already exist with an allDocs * This command will check if the document already exist with an allDocs
* and a complex query. If exist, then post will fail. Put will update the * and a jio query. If exist, then post will fail. Put will update the
* retrieved document thanks to its real id. If no documents are found, post * retrieved document thanks to its real id. If no documents are found, post
* and put will create a new document with the sub storage id generator. * and put will create a new document with the sub storage id generator.
* *
...@@ -310,7 +310,7 @@ ...@@ -310,7 +310,7 @@
* @param {String} method The command method * @param {String} method The command method
*/ */
priv.putOrPost = function (command, metadata, method) { priv.putOrPost = function (command, metadata, method) {
var gid, complex_query, doc = tool.deepClone(metadata); var gid, jio_query, doc = tool.deepClone(metadata);
gid = gidFormat(doc, priv.constraints); gid = gidFormat(doc, priv.constraints);
if (gid === undefined || (doc._id && gid !== doc._id)) { if (gid === undefined || (doc._id && gid !== doc._id)) {
return command.error( return command.error(
...@@ -319,9 +319,9 @@ ...@@ -319,9 +319,9 @@
"Cannot " + method + " document" "Cannot " + method + " document"
); );
} }
complex_query = gidToComplexQuery(gid); jio_query = gidToJIOQuery(gid);
command.storage(priv.sub_storage).allDocs({ command.storage(priv.sub_storage).allDocs({
"query": complex_query "query": jio_query
}).then(function (response) { }).then(function (response) {
var update_method = method; var update_method = method;
response = response.data; response = response.data;
...@@ -359,7 +359,7 @@ ...@@ -359,7 +359,7 @@
* Generic command for putAttachment, getAttachment or removeAttachment. * Generic command for putAttachment, getAttachment or removeAttachment.
* *
* This command will check if the document exist with an allDocs and a * This command will check if the document exist with an allDocs and a
* complex query. If not exist, then it returns 404. Otherwise the * jio query. If not exist, then it returns 404. Otherwise the
* action will be done on the attachment of the found document. * action will be done on the attachment of the found document.
* *
* @method putGetOrRemoveAttachment * @method putGetOrRemoveAttachment
...@@ -369,7 +369,7 @@ ...@@ -369,7 +369,7 @@
* @param {String} method The command method * @param {String} method The command method
*/ */
priv.putGetOrRemoveAttachment = function (command, doc, method) { priv.putGetOrRemoveAttachment = function (command, doc, method) {
var gid_object, complex_query; var gid_object, jio_query;
gid_object = gidParse(doc._id, priv.constraints); gid_object = gidParse(doc._id, priv.constraints);
if (gid_object === undefined) { if (gid_object === undefined) {
return command.error( return command.error(
...@@ -378,9 +378,9 @@ ...@@ -378,9 +378,9 @@
"Cannot " + method + " attachment" "Cannot " + method + " attachment"
); );
} }
complex_query = gidToComplexQuery(gid_object); jio_query = gidToJIOQuery(gid_object);
command.storage(priv.sub_storage).allDocs({ command.storage(priv.sub_storage).allDocs({
"query": complex_query "query": jio_query
}).then(function (response) { }).then(function (response) {
response = response.data; response = response.data;
if (response.total_rows === 0) { if (response.total_rows === 0) {
...@@ -429,7 +429,7 @@ ...@@ -429,7 +429,7 @@
/** /**
* Puts an attachment to a document thank to its gid, a sub allDocs and a * Puts an attachment to a document thank to its gid, a sub allDocs and a
* complex query. * jio query.
* *
* @method putAttachment * @method putAttachment
* @param {Command} command The JIO command * @param {Command} command The JIO command
...@@ -439,13 +439,13 @@ ...@@ -439,13 +439,13 @@
}; };
/** /**
* Gets a document thank to its gid, a sub allDocs and a complex query. * Gets a document thank to its gid, a sub allDocs and a jio query.
* *
* @method get * @method get
* @param {Object} command The JIO command * @param {Object} command The JIO command
*/ */
that.get = function (command, param) { that.get = function (command, param) {
var gid_object, complex_query; var gid_object, jio_query;
gid_object = gidParse(param._id, priv.constraints); gid_object = gidParse(param._id, priv.constraints);
if (gid_object === undefined) { if (gid_object === undefined) {
return command.error( return command.error(
...@@ -454,9 +454,9 @@ ...@@ -454,9 +454,9 @@
"Cannot get document" "Cannot get document"
); );
} }
complex_query = gidToComplexQuery(gid_object); jio_query = gidToJIOQuery(gid_object);
command.storage(priv.sub_storage).allDocs({ command.storage(priv.sub_storage).allDocs({
"query": complex_query, "query": jio_query,
"include_docs": true "include_docs": true
}).then(function (response) { }).then(function (response) {
response = response.data; response = response.data;
...@@ -477,7 +477,7 @@ ...@@ -477,7 +477,7 @@
/** /**
* Gets an attachment from a document thank to its gid, a sub allDocs and a * Gets an attachment from a document thank to its gid, a sub allDocs and a
* complex query. * jio query.
* *
* @method getAttachment * @method getAttachment
* @param {Command} command The JIO command * @param {Command} command The JIO command
...@@ -487,13 +487,13 @@ ...@@ -487,13 +487,13 @@
}; };
/** /**
* Remove a document thank to its gid, sub allDocs and a complex query. * Remove a document thank to its gid, sub allDocs and a jio query.
* *
* @method remove * @method remove
* @param {Command} command The JIO command. * @param {Command} command The JIO command.
*/ */
that.remove = function (command, doc) { that.remove = function (command, doc) {
var gid_object, complex_query; var gid_object, jio_query;
gid_object = gidParse(doc._id, priv.constraints); gid_object = gidParse(doc._id, priv.constraints);
if (gid_object === undefined) { if (gid_object === undefined) {
return command.error( return command.error(
...@@ -502,9 +502,9 @@ ...@@ -502,9 +502,9 @@
"Cannot remove document" "Cannot remove document"
); );
} }
complex_query = gidToComplexQuery(gid_object); jio_query = gidToJIOQuery(gid_object);
command.storage(priv.sub_storage).allDocs({ command.storage(priv.sub_storage).allDocs({
"query": complex_query "query": jio_query
}).then(function (response) { }).then(function (response) {
response = response.data; response = response.data;
if (response.total_rows === 0) { if (response.total_rows === 0) {
...@@ -533,7 +533,7 @@ ...@@ -533,7 +533,7 @@
/** /**
* Removes an attachment to a document thank to its gid, a sub allDocs and a * Removes an attachment to a document thank to its gid, a sub allDocs and a
* complex query. * jio query.
* *
* @method removeAttachment * @method removeAttachment
* @param {Command} command The JIO command * @param {Command} command The JIO command
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
*/ */
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, regexp: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, regexp: true */
/*global window, exports, require, define, jIO, RSVP, complex_queries */ /*global window, exports, require, define, jIO, RSVP */
/** /**
* JIO Index Storage. * JIO Index Storage.
...@@ -122,18 +122,16 @@ ...@@ -122,18 +122,16 @@
return module( return module(
exports, exports,
require('jio'), require('jio'),
require('rsvp'), require('rsvp')
require('complex_queries')
); );
} }
window.index_storage = {}; window.index_storage = {};
module(window.index_storage, jIO, RSVP, complex_queries); module(window.index_storage, jIO, RSVP);
}([ }([
'exports', 'exports',
'jio', 'jio',
'rsvp', 'rsvp'
'complex_queries' ], function (exports, jIO, RSVP) {
], function (exports, jIO, RSVP, complex_queries) {
"use strict"; "use strict";
/** /**
...@@ -747,7 +745,7 @@ ...@@ -747,7 +745,7 @@
db[i]["_" + now] = db[i]; db[i]["_" + now] = db[i];
} }
} }
complex_queries.QueryFactory.create(option.query || ''). jIO.QueryFactory.create(option.query || '').
exec(db, option).then(function () { exec(db, option).then(function () {
for (i = 0; i < db.length; i += 1) { for (i = 0; i < db.length; i += 1) {
id = db[i]._id; id = db[i]._id;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
*/ */
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, regexp: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true, regexp: true */
/*global jIO, localStorage, setTimeout, complex_queries, window, define, /*global jIO, localStorage, setTimeout, window, define,
exports, require */ exports, require */
/** /**
...@@ -54,15 +54,14 @@ ...@@ -54,15 +54,14 @@
return define(dependencies, module); return define(dependencies, module);
} }
if (typeof exports === 'object') { if (typeof exports === 'object') {
return module(exports, require('jio'), require('complex_queries')); return module(exports, require('jio'));
} }
window.local_storage = {}; window.local_storage = {};
module(window.local_storage, jIO, complex_queries); module(window.local_storage, jIO);
}([ }([
'exports', 'exports',
'jio', 'jio'
'complex_queries' ], function (exports, jIO) {
], function (exports, jIO, complex_queries) {
"use strict"; "use strict";
/** /**
...@@ -403,7 +402,7 @@ ...@@ -403,7 +402,7 @@
rows = []; rows = [];
document_list = []; document_list = [];
path_re = new RegExp( path_re = new RegExp(
"^" + complex_queries.stringEscapeRegexpCharacters(this._localpath) + "^" + jIO.Query.stringEscapeRegexpCharacters(this._localpath) +
"/[^/]+$" "/[^/]+$"
); );
if (options.query === undefined && options.sort_on === undefined && if (options.query === undefined && options.sort_on === undefined &&
...@@ -426,7 +425,7 @@ ...@@ -426,7 +425,7 @@
} }
command.success({"data": {"rows": rows, "total_rows": rows.length}}); command.success({"data": {"rows": rows, "total_rows": rows.length}});
} else { } else {
// create complex query object from returned results // create jio query object from returned results
for (i in this._database) { for (i in this._database) {
if (this._database.hasOwnProperty(i)) { if (this._database.hasOwnProperty(i)) {
if (path_re.test(i)) { if (path_re.test(i)) {
...@@ -445,8 +444,8 @@ ...@@ -445,8 +444,8 @@
document_object[meta._id] = meta; document_object[meta._id] = meta;
}); });
} }
complex_queries.QueryFactory.create(options.query || "", jIO.QueryFactory.create(options.query || "",
this._key_schema). this._key_schema).
exec(document_list, options).then(function () { exec(document_list, options).then(function () {
document_list = document_list.map(function (value) { document_list = document_list.map(function (value) {
var o = { var o = {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
return define(dependencies, module); return define(dependencies, module);
} }
// if (typeof exports === 'object') { // if (typeof exports === 'object') {
// return module(exports, require('jio'), require('complex_queries')); // return module(exports, require('jio'));
// } // }
module(jIO); module(jIO);
}([ }([
......
/*jslint indent: 2, maxlen: 80, nomen: true, regexp: true, unparam: true */ /*jslint indent: 2, maxlen: 80, nomen: true, regexp: true, unparam: true */
/*global define, RSVP, jIO, complex_queries */ /*global define, RSVP, jIO */
(function (dependencies, module) { (function (dependencies, module) {
"use strict"; "use strict";
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
return define(dependencies, module); return define(dependencies, module);
} }
module(RSVP, complex_queries, jIO); module(RSVP, jIO);
}(['rsvp', 'complex_queries', 'jio'], function (RSVP, complex_queries, jIO) { }(['rsvp', 'jio'], function (RSVP, jIO) {
"use strict"; "use strict";
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
/** /**
* Retrieve documents. * Retrieve documents.
* This method performs an .allDocs() call on the substorage, * This method performs an .allDocs() call on the substorage,
* retrieving everything, then runs a complex query on the result. * retrieving everything, then runs a query on the result.
* *
* @method allDocs * @method allDocs
* @param {Object} command The given parameters * @param {Object} command The given parameters
...@@ -157,8 +157,8 @@ ...@@ -157,8 +157,8 @@
rows_map[row.id] = row; rows_map[row.id] = row;
}); });
return complex_queries.QueryFactory.create(options.query, return jIO.QueryFactory.create(options.query,
that._key_schema). that._key_schema).
exec(docs, options). exec(docs, options).
then(function (filtered_docs) { then(function (filtered_docs) {
// reconstruct filtered rows, preserving the order from docs // reconstruct filtered rows, preserving the order from docs
......
/*
* Copyright 2013, Nexedi SA
* Released under the LGPL license.
* http://www.gnu.org/licenses/lgpl.html
*/
/**
* Provides some function to use complex queries with item list
*
* @module complex_queries
*/
// define([module_name], [dependencies], module);
(function (dependencies, module) {
"use strict";
if (typeof define === 'function' && define.amd) {
return define(dependencies, module);
}
if (typeof exports === 'object') {
return module(exports);
}
window.complex_queries = {};
module(window.complex_queries, RSVP);
}(['exports', 'rsvp'], function (to_export, RSVP) {
"use strict";
/**
* Add a secured (write permission denied) property to an object.
*
* @param {Object} object The object to fill
* @param {String} key The object key where to store the property
* @param {Any} value The value to store
*/
function _export(key, value) {
Object.defineProperty(to_export, key, {
"configurable": false,
"enumerable": true,
"writable": false,
"value": value
});
}
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global Query: true, query_class_dict: true, inherits: true, /*global Query: true, query_class_dict: true, inherits: true,
_export, QueryFactory, RSVP, sequence */ exports, QueryFactory, RSVP, sequence */
/** /**
* The ComplexQuery inherits from Query, and compares one or several metadata * The ComplexQuery inherits from Query, and compares one or several metadata
...@@ -195,4 +195,4 @@ ComplexQuery.prototype.NOT = function (item) { ...@@ -195,4 +195,4 @@ ComplexQuery.prototype.NOT = function (item) {
query_class_dict.complex = ComplexQuery; query_class_dict.complex = ComplexQuery;
_export("ComplexQuery", ComplexQuery); exports.ComplexQuery = ComplexQuery;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global parseStringToObject: true, emptyFunction: true, sortOn: true, limit: /*global parseStringToObject: true, emptyFunction: true, sortOn: true, limit:
true, select: true, _export: true, stringEscapeRegexpCharacters: true, true, select: true, exports, stringEscapeRegexpCharacters: true,
deepClone, RSVP, sequence */ deepClone, RSVP, sequence */
/** /**
...@@ -194,4 +194,4 @@ Query.prototype.serialized = function () { ...@@ -194,4 +194,4 @@ Query.prototype.serialized = function () {
return undefined; return undefined;
}; };
_export("Query", Query); exports.Query = Query;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global _export, ComplexQuery, SimpleQuery, Query, parseStringToObject, /*global exports, ComplexQuery, SimpleQuery, Query, parseStringToObject,
query_class_dict */ query_class_dict */
/** /**
...@@ -36,4 +36,4 @@ QueryFactory.create = function (object, key_schema) { ...@@ -36,4 +36,4 @@ QueryFactory.create = function (object, key_schema) {
"Argument 1 is not a search text or a parsable object"); "Argument 1 is not a search text or a parsable object");
}; };
_export("QueryFactory", QueryFactory); exports.QueryFactory = QueryFactory;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global _export: true */ /*global Query, exports */
function objectToSearchText(query) { function objectToSearchText(query) {
var str_list = []; var str_list = [];
...@@ -19,4 +19,4 @@ function objectToSearchText(query) { ...@@ -19,4 +19,4 @@ function objectToSearchText(query) {
} }
throw new TypeError("This object is not a query"); throw new TypeError("This object is not a query");
} }
_export("objectToSearchText", objectToSearchText); Query.objectToSearchText = objectToSearchText;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global Query: true, inherits: true, query_class_dict: true, _export: true, /*global Query, inherits, query_class_dict, exports,
searchTextToRegExp, RSVP */ searchTextToRegExp, RSVP */
var checkKeySchema = function (key_schema) { var checkKeySchema = function (key_schema) {
...@@ -384,4 +384,4 @@ SimpleQuery.prototype[">="] = function (object_value, comparison_value) { ...@@ -384,4 +384,4 @@ SimpleQuery.prototype[">="] = function (object_value, comparison_value) {
query_class_dict.simple = SimpleQuery; query_class_dict.simple = SimpleQuery;
_export("SimpleQuery", SimpleQuery); exports.SimpleQuery = SimpleQuery;
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */ /*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global _export, RSVP */ /*global Query, RSVP, deepClone */
/** /**
* Escapes regexp special chars from a string. * Escapes regexp special chars from a string.
...@@ -11,11 +11,11 @@ function stringEscapeRegexpCharacters(string) { ...@@ -11,11 +11,11 @@ function stringEscapeRegexpCharacters(string) {
if (typeof string === "string") { if (typeof string === "string") {
return string.replace(/([\\\.\$\[\]\(\)\{\}\^\?\*\+\-])/g, "\\$1"); return string.replace(/([\\\.\$\[\]\(\)\{\}\^\?\*\+\-])/g, "\\$1");
} }
throw new TypeError("complex_queries.stringEscapeRegexpCharacters(): " + throw new TypeError("Query.stringEscapeRegexpCharacters(): " +
"Argument no 1 is not of type 'string'"); "Argument no 1 is not of type 'string'");
} }
_export("stringEscapeRegexpCharacters", stringEscapeRegexpCharacters); Query.stringEscapeRegexpCharacters = stringEscapeRegexpCharacters;
/** /**
* Convert metadata values to array of strings. ex: * Convert metadata values to array of strings. ex:
...@@ -100,38 +100,10 @@ function sortFunction(key, way) { ...@@ -100,38 +100,10 @@ function sortFunction(key, way) {
return 0; return 0;
}; };
} }
throw new TypeError("complex_queries.sortFunction(): " + throw new TypeError("Query.sortFunction(): " +
"Argument 2 must be 'ascending' or 'descending'"); "Argument 2 must be 'ascending' or 'descending'");
} }
/**
* Clones all native object in deep. Managed types: Object, Array, String,
* Number, Boolean, null.
*
* @param {A} object The object to clone
* @return {A} The cloned object
*/
function deepClone(object) {
var i, cloned;
if (Array.isArray(object)) {
cloned = [];
for (i = 0; i < object.length; i += 1) {
cloned[i] = deepClone(object[i]);
}
return cloned;
}
if (typeof object === "object") {
cloned = {};
for (i in object) {
if (object.hasOwnProperty(i)) {
cloned[i] = deepClone(object[i]);
}
}
return cloned;
}
return object;
}
/** /**
* Inherits the prototype methods from one constructor into another. The * Inherits the prototype methods from one constructor into another. The
* prototype of `constructor` will be set to a new object created from * prototype of `constructor` will be set to a new object created from
...@@ -171,11 +143,11 @@ function emptyFunction() { ...@@ -171,11 +143,11 @@ function emptyFunction() {
function select(select_option, list, clone) { function select(select_option, list, clone) {
var i, j, new_item; var i, j, new_item;
if (!Array.isArray(select_option)) { if (!Array.isArray(select_option)) {
throw new TypeError("complex_queries.select(): " + throw new TypeError("jioquery.select(): " +
"Argument 1 is not of type Array"); "Argument 1 is not of type Array");
} }
if (!Array.isArray(list)) { if (!Array.isArray(list)) {
throw new TypeError("complex_queries.select(): " + throw new TypeError("jioquery.select(): " +
"Argument 2 is not of type Array"); "Argument 2 is not of type Array");
} }
if (clone === true) { if (clone === true) {
...@@ -198,7 +170,7 @@ function select(select_option, list, clone) { ...@@ -198,7 +170,7 @@ function select(select_option, list, clone) {
return list; return list;
} }
_export('select', select); Query.select = select;
/** /**
* Sort a list of items, according to keys and directions. If `clone` is true, * Sort a list of items, according to keys and directions. If `clone` is true,
...@@ -212,7 +184,7 @@ _export('select', select); ...@@ -212,7 +184,7 @@ _export('select', select);
function sortOn(sort_on_option, list, clone) { function sortOn(sort_on_option, list, clone) {
var sort_index; var sort_index;
if (!Array.isArray(sort_on_option)) { if (!Array.isArray(sort_on_option)) {
throw new TypeError("complex_queries.sortOn(): " + throw new TypeError("jioquery.sortOn(): " +
"Argument 1 is not of type 'array'"); "Argument 1 is not of type 'array'");
} }
if (clone) { if (clone) {
...@@ -228,7 +200,7 @@ function sortOn(sort_on_option, list, clone) { ...@@ -228,7 +200,7 @@ function sortOn(sort_on_option, list, clone) {
return list; return list;
} }
_export('sortOn', sortOn); Query.sortOn = sortOn;
/** /**
* Limit a list of items, according to index and length. If `clone` is true, * Limit a list of items, according to index and length. If `clone` is true,
...@@ -241,11 +213,11 @@ _export('sortOn', sortOn); ...@@ -241,11 +213,11 @@ _export('sortOn', sortOn);
*/ */
function limit(limit_option, list, clone) { function limit(limit_option, list, clone) {
if (!Array.isArray(limit_option)) { if (!Array.isArray(limit_option)) {
throw new TypeError("complex_queries.limit(): " + throw new TypeError("jioquery.limit(): " +
"Argument 1 is not of type 'array'"); "Argument 1 is not of type 'array'");
} }
if (!Array.isArray(list)) { if (!Array.isArray(list)) {
throw new TypeError("complex_queries.limit(): " + throw new TypeError("jioquery.limit(): " +
"Argument 2 is not of type 'array'"); "Argument 2 is not of type 'array'");
} }
if (clone) { if (clone) {
...@@ -258,7 +230,7 @@ function limit(limit_option, list, clone) { ...@@ -258,7 +230,7 @@ function limit(limit_option, list, clone) {
return list; return list;
} }
_export('limit', limit); Query.limit = limit;
/** /**
* Convert a search text to a regexp. * Convert a search text to a regexp.
...@@ -269,7 +241,7 @@ _export('limit', limit); ...@@ -269,7 +241,7 @@ _export('limit', limit);
*/ */
function searchTextToRegExp(string, use_wildcard_characters) { function searchTextToRegExp(string, use_wildcard_characters) {
if (typeof string !== 'string') { if (typeof string !== 'string') {
throw new TypeError("complex_queries.searchTextToRegExp(): " + throw new TypeError("jioquery.searchTextToRegExp(): " +
"Argument 1 is not of type 'string'"); "Argument 1 is not of type 'string'");
} }
if (use_wildcard_characters === false) { if (use_wildcard_characters === false) {
...@@ -284,7 +256,7 @@ function searchTextToRegExp(string, use_wildcard_characters) { ...@@ -284,7 +256,7 @@ function searchTextToRegExp(string, use_wildcard_characters) {
) + "$"); ) + "$");
} }
_export("searchTextToRegExp", searchTextToRegExp); Query.searchTextToRegExp = searchTextToRegExp;
/** /**
* sequence(thens): Promise * sequence(thens): Promise
......
return to_export;
}));
return result; return result;
} // parseStringToObject } // parseStringToObject
_export('parseStringToObject', parseStringToObject); Query.parseStringToObject = parseStringToObject;
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
<script src="../../lib/rsvp/rsvp-custom.js"></script> <script src="../../lib/rsvp/rsvp-custom.js"></script>
<script src="../../src/sha256.amd.js"></script> <script src="../../src/sha256.amd.js"></script>
<script src="../../jio.js"></script> <script src="../../jio.js"></script>
<script src="../../complex_queries.js"></script>
<script src="../../src/jio.storage/davstorage.js"></script> <script src="../../src/jio.storage/davstorage.js"></script>
<script src="../jio/util.js"></script> <script src="../jio/util.js"></script>
</head> </head>
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<script src="../../lib/jquery/jquery.min.js"></script> <script src="../../lib/jquery/jquery.min.js"></script>
<script src="../../src/sha256.amd.js"></script> <script src="../../src/sha256.amd.js"></script>
<script src="../../jio.js"></script> <script src="../../jio.js"></script>
<script src="../../complex_queries.js"></script>
<script src="../../src/sha1.amd.js"></script> <script src="../../src/sha1.amd.js"></script>
<script src="../../src/jio.storage/gidstorage.js"></script> <script src="../../src/jio.storage/gidstorage.js"></script>
<script src="../../src/jio.storage/s3storage.js"></script> <script src="../../src/jio.storage/s3storage.js"></script>
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<script src="../../lib/jquery/jquery.min.js"></script> <script src="../../lib/jquery/jquery.min.js"></script>
<script src="../../src/sha256.amd.js"></script> <script src="../../src/sha256.amd.js"></script>
<script src="../../jio.js"></script> <script src="../../jio.js"></script>
<script src="../../complex_queries.js"></script>
<script src="../../src/sha1.amd.js"></script> <script src="../../src/sha1.amd.js"></script>
<script src="../../src/jio.storage/s3storage.js"></script> <script src="../../src/jio.storage/s3storage.js"></script>
<script src="../../src/jio.storage/splitstorage.js"></script> <script src="../../src/jio.storage/splitstorage.js"></script>
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<script src="../../lib/jquery/jquery.min.js"></script> <script src="../../lib/jquery/jquery.min.js"></script>
<script src="../../src/sha256.amd.js"></script> <script src="../../src/sha256.amd.js"></script>
<script src="../../jio.js"></script> <script src="../../jio.js"></script>
<script src="../../complex_queries.js"></script>
<script src="../../src/sha1.amd.js"></script> <script src="../../src/sha1.amd.js"></script>
<script src="../../src/jio.storage/s3storage.js"></script> <script src="../../src/jio.storage/s3storage.js"></script>
<script src="../jio/util.js"></script> <script src="../jio/util.js"></script>
......
/*jslint indent: 2, maxlen: 120, nomen: true, vars: true */ /*jslint indent: 2, maxlen: 120, nomen: true, vars: true */
/*global define, exports, require, module, complex_queries, jiodate, window, test, ok, /*global define, exports, require, module, jIO, jiodate, window, test,
equal, deepEqual, sinon, start, stop, RSVP */ ok, equal, deepEqual, sinon, start, stop, RSVP */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
(function (dependencies, module) { (function (dependencies, module) {
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
return define(dependencies, module); return define(dependencies, module);
} }
if (typeof exports === 'object') { if (typeof exports === 'object') {
return module(require('complex_queries'), require('jiodate')); return module(require('jio'), require('jiodate'));
} }
module(complex_queries, jiodate); module(jIO, jiodate);
}(['complex_queries', 'jiodate', 'qunit'], function (complex_queries, jiodate) { }(['jio', 'jiodate', 'qunit'], function (jIO, jiodate) {
"use strict"; "use strict";
module('Custom Key Queries with JIODate'); module('Custom Key Queries with JIODate');
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date', key: 'date',
value: '2011' value: '2011'
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date', key: 'date',
operator: '!=', operator: '!=',
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date', key: 'date',
operator: '<', operator: '<',
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date', key: 'date',
operator: '<=', operator: '<=',
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date', key: 'date',
operator: '>', operator: '>',
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date', key: 'date',
operator: '>=', operator: '>=',
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
query_list.forEach(function (o) { query_list.forEach(function (o) {
var qs = o[0], expected = o[1]; var qs = o[0], expected = o[1];
promise.push( promise.push(
complex_queries.QueryFactory.create(qs, key_schema). jIO.QueryFactory.create(qs, key_schema).
exec(docList()). exec(docList()).
then(function (dl) { then(function (dl) {
deepEqual(dl, expected, "Match with '" + qs + "' (parsed query string)"); deepEqual(dl, expected, "Match with '" + qs + "' (parsed query string)");
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
query_list.forEach(function (qs) { query_list.forEach(function (qs) {
promise.push( promise.push(
complex_queries.QueryFactory.create(qs, key_schema). jIO.QueryFactory.create(qs, key_schema).
exec(docList()). exec(docList()).
then(function (dl) { then(function (dl) {
deepEqual(dl, [ deepEqual(dl, [
......
/*jslint indent: 2, maxlen: 100, nomen: true, vars: true */ /*jslint indent: 2, maxlen: 100, nomen: true, vars: true */
/*global define, exports, require, module, complex_queries, window, test, ok, /*global define, exports, require, module, jIO, window, test, ok,
deepEqual, sinon, start, stop, RSVP */ deepEqual, sinon, start, stop, RSVP */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
return define(dependencies, module); return define(dependencies, module);
} }
if (typeof exports === 'object') { if (typeof exports === 'object') {
return module(require('complex_queries')); return module(require('jio'));
} }
module(complex_queries); module(jIO);
}(['complex_queries', 'qunit'], function (complex_queries) { }(['jio', 'qunit'], function (jIO) {
"use strict"; "use strict";
module('Custom Key Queries with Schema'); module('Custom Key Queries with Schema');
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'case_insensitive_identifier', key: 'case_insensitive_identifier',
value: 'A' value: 'A'
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date_day', key: 'date_day',
value: '2013-02-02' value: '2013-02-02'
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date_month', key: 'date_month',
value: '2013-02-10' value: '2013-02-10'
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'date_year', key: 'date_year',
value: '2013-02-10' value: '2013-02-10'
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
}); });
test('Test key schema + complex queries', function () { test('Test key schema + jio query', function () {
var docList = function () { var docList = function () {
return [ return [
{'identifier': '10', 'number': '10'}, {'identifier': '10', 'number': '10'},
...@@ -209,7 +209,7 @@ ...@@ -209,7 +209,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'complex', type: 'complex',
operator: 'OR', operator: 'OR',
query_list: [{ query_list: [{
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'translated_state', key: 'translated_state',
value: 'ouvert' value: 'ouvert'
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: 'translated_state', key: 'translated_state',
operator: '=', operator: '=',
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
// XXX not implemented yet // XXX not implemented yet
// doc_list = docList(); // doc_list = docList();
// complex_queries.QueryFactory.create({ // jIO.QueryFactory.create({
// type: 'simple', // type: 'simple',
// key: 'translated_state', // key: 'translated_state',
// operator: '!=', // operator: '!=',
......
/*jslint indent: 2, maxlen: 90, nomen: true */ /*jslint indent: 2, maxlen: 90, nomen: true */
/*global define, exports, require, module, complex_queries, window, test, /*global define, exports, require, module, jIO, window, test,
raises, ok, equal, deepEqual, sinon */ raises, ok, equal, deepEqual, sinon */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
...@@ -9,17 +9,17 @@ ...@@ -9,17 +9,17 @@
return define(dependencies, module); return define(dependencies, module);
} }
if (typeof exports === 'object') { if (typeof exports === 'object') {
return module(require('complex_queries')); return module(require('jio'));
} }
module(complex_queries); module(jIO);
}(['complex_queries', 'qunit'], function (complex_queries) { }(['jio', 'qunit'], function (jIO) {
"use strict"; "use strict";
module('Key and key_schema objects validation'); module('Key and key_schema objects validation');
test('Check the parameters passed to exec() and create()', function () { test('Check the parameters passed to exec() and create()', function () {
try { try {
complex_queries.QueryFactory.create('').exec('gnegne'); jIO.QueryFactory.create('').exec('gnegne');
ok(false, 'argument 1 not checked'); ok(false, 'argument 1 not checked');
} catch (e) { } catch (e) {
equal(e.name, 'TypeError', 'wrong exception type'); equal(e.name, 'TypeError', 'wrong exception type');
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
} }
try { try {
complex_queries.QueryFactory.create({}); jIO.QueryFactory.create({});
ok(false, 'argument 1 not checked'); ok(false, 'argument 1 not checked');
} catch (e) { } catch (e) {
equal(e.name, 'TypeError', 'wrong exception type'); equal(e.name, 'TypeError', 'wrong exception type');
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
} }
try { try {
complex_queries.QueryFactory.create('').exec([], 1); jIO.QueryFactory.create('').exec([], 1);
ok(false, 'argument 2 not checked'); ok(false, 'argument 2 not checked');
} catch (e) { } catch (e) {
equal(e.name, 'TypeError', 'wrong exception type'); equal(e.name, 'TypeError', 'wrong exception type');
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
} }
try { try {
complex_queries.QueryFactory.create({type: 'simple'}, ''); jIO.QueryFactory.create({type: 'simple'}, '');
ok(false, 'key_schema type is not checked'); ok(false, 'key_schema type is not checked');
} catch (e) { } catch (e) {
equal(e.name, 'TypeError', 'wrong exception type'); equal(e.name, 'TypeError', 'wrong exception type');
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
} }
try { try {
complex_queries.QueryFactory.create({type: 'simple'}, {}); jIO.QueryFactory.create({type: 'simple'}, {});
ok(false, 'key_schema.key_set is not checked'); ok(false, 'key_schema.key_set is not checked');
} catch (e) { } catch (e) {
equal(e.name, 'TypeError', 'wrong exception type'); equal(e.name, 'TypeError', 'wrong exception type');
...@@ -69,7 +69,9 @@ ...@@ -69,7 +69,9 @@
} }
try { try {
complex_queries.QueryFactory.create({type: 'simple'}, {key_set: {}, foobar: {}}); jIO.QueryFactory.create({
type: 'simple'
}, {key_set: {}, foobar: {}});
ok(false, 'unknown key_schema properties are not checked'); ok(false, 'unknown key_schema properties are not checked');
} catch (e) { } catch (e) {
equal(e.name, 'TypeError', 'wrong exception type'); equal(e.name, 'TypeError', 'wrong exception type');
...@@ -87,7 +89,7 @@ ...@@ -87,7 +89,7 @@
]; ];
try { try {
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: {}, key: {},
value: 'a' value: 'a'
...@@ -101,7 +103,7 @@ ...@@ -101,7 +103,7 @@
} }
try { try {
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: { key: {
read_from: 'identifier', read_from: 'identifier',
......
/*jslint indent: 2, maxlen: 120, nomen: true, vars: true */ /*jslint indent: 2, maxlen: 120, nomen: true, vars: true */
/*global define, exports, require, module, complex_queries, window, test, ok, /*global define, exports, require, module, jIO, window, test, ok,
equal, deepEqual, sinon, stop, start, RSVP */ equal, deepEqual, sinon, stop, start, RSVP */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
return define(dependencies, module); return define(dependencies, module);
} }
if (typeof exports === 'object') { if (typeof exports === 'object') {
return module(require('complex_queries')); return module(require('jio'));
} }
module(complex_queries); module(jIO);
}(['complex_queries', 'qunit'], function (complex_queries) { }(['jio', 'qunit'], function (jIO) {
"use strict"; "use strict";
module('Custom Key Queries'); module('Custom Key Queries');
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.title, key: keys.title,
value: 'a' value: 'a'
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.case_insensitive_identifier, key: keys.case_insensitive_identifier,
value: 'A' value: 'A'
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.day, key: keys.day,
value: '2013-02-02' value: '2013-02-02'
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.month, key: keys.month,
value: '2013-02-10' value: '2013-02-10'
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.year, key: keys.year,
value: '2013-02-10' value: '2013-02-10'
...@@ -199,7 +199,7 @@ ...@@ -199,7 +199,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
operator: '=', operator: '=',
...@@ -214,7 +214,7 @@ ...@@ -214,7 +214,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
operator: '!=', operator: '!=',
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
operator: '<=', operator: '<=',
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
operator: '<', operator: '<',
...@@ -261,7 +261,7 @@ ...@@ -261,7 +261,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
operator: '>', operator: '>',
...@@ -276,7 +276,7 @@ ...@@ -276,7 +276,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
operator: '>=', operator: '>=',
...@@ -315,7 +315,7 @@ ...@@ -315,7 +315,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
value: '2013-02-02' value: '2013-02-02'
...@@ -329,7 +329,7 @@ ...@@ -329,7 +329,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
operator: '=', operator: '=',
...@@ -344,7 +344,7 @@ ...@@ -344,7 +344,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.mydate, key: keys.mydate,
operator: '>=', operator: '>=',
...@@ -381,7 +381,7 @@ ...@@ -381,7 +381,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: { key: {
read_from: 'number', read_from: 'number',
...@@ -399,7 +399,7 @@ ...@@ -399,7 +399,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: { key: {
read_from: 'number', read_from: 'number',
...@@ -417,7 +417,7 @@ ...@@ -417,7 +417,7 @@
); );
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'complex', type: 'complex',
operator: 'OR', operator: 'OR',
query_list: [{ query_list: [{
...@@ -477,7 +477,7 @@ ...@@ -477,7 +477,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.translated_state, key: keys.translated_state,
value: 'ouvert' value: 'ouvert'
...@@ -492,7 +492,7 @@ ...@@ -492,7 +492,7 @@
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.translated_state, key: keys.translated_state,
operator: '=', operator: '=',
...@@ -508,7 +508,7 @@ ...@@ -508,7 +508,7 @@
// XXX not implemented yet // XXX not implemented yet
// doc_list = docList(); // doc_list = docList();
// complex_queries.QueryFactory.create({ // jIO.QueryFactory.create({
// type: 'simple', // type: 'simple',
// key: keys.translated_state, // key: keys.translated_state,
// operator: '!=', // operator: '!=',
...@@ -579,7 +579,7 @@ ...@@ -579,7 +579,7 @@
stop(); stop();
promise.push( promise.push(
complex_queries.QueryFactory.create({ jIO.QueryFactory.create({
type: 'simple', type: 'simple',
key: keys.identifier, key: keys.identifier,
value: 'aei%' value: 'aei%'
......
/*jslint indent: 2, maxlen: 80, nomen: true */ /*jslint indent: 2, maxlen: 80, nomen: true */
/*global define, exports, require, module, complex_queries, window, test, ok, /*global define, exports, require, module, jIO, window, test, ok,
deepEqual, stop, start */ deepEqual, stop, start */
// define([module_name], [dependencies], module); // define([module_name], [dependencies], module);
...@@ -9,13 +9,13 @@ ...@@ -9,13 +9,13 @@
return define(dependencies, module); return define(dependencies, module);
} }
if (typeof exports === 'object') { if (typeof exports === 'object') {
return module(require('complex_queries')); return module(require('jio'));
} }
module(complex_queries); module(jIO);
}(['complex_queries', 'qunit'], function (complex_queries) { }(['jio', 'qunit'], function (jIO) {
"use strict"; "use strict";
module('Complex Queries'); module('Query');
// XXX test documentation // XXX test documentation
test('Empty Query', function () { test('Empty Query', function () {
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
{"identifier": ["b", "c"]} {"identifier": ["b", "c"]}
]; ];
stop(); stop();
complex_queries.QueryFactory.create('').exec(doc_list). jIO.QueryFactory.create('').exec(doc_list).
then(function (doc_list) { then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
{"identifier": "a"}, {"identifier": "a"},
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
{"identifier": ["b", "c"]} {"identifier": ["b", "c"]}
]; ];
stop(); stop();
complex_queries.QueryFactory.create('identifier: "a"').exec(doc_list). jIO.QueryFactory.create('identifier: "a"').exec(doc_list).
then(function (doc_list) { then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
{"identifier": "a"} {"identifier": "a"}
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
{"identifier": ["a", "b"]} {"identifier": ["a", "b"]}
]; ];
return complex_queries.QueryFactory.create('identifier: "a"'). return jIO.QueryFactory.create('identifier: "a"').
exec(doc_list); exec(doc_list);
}).then(function (doc_list) { }).then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
{"identifier": ["b", "c"]} {"identifier": ["b", "c"]}
]; ];
stop(); stop();
complex_queries.QueryFactory.create( jIO.QueryFactory.create(
'identifier: "b" AND identifier: "c"' 'identifier: "b" AND identifier: "c"'
).exec(doc_list).then(function (doc_list) { ).exec(doc_list).then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
{"identifier": "a"}, {"identifier": "a"},
{"identifier": ["b", "c"]} {"identifier": ["b", "c"]}
]; ];
return complex_queries.QueryFactory.create( return jIO.QueryFactory.create(
'identifier: "a" OR identifier: "c"' 'identifier: "a" OR identifier: "c"'
).exec(doc_list); ).exec(doc_list);
}).then(function (doc_list) { }).then(function (doc_list) {
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
{"identifier": ["b", "c"]} {"identifier": ["b", "c"]}
]; ];
return complex_queries.QueryFactory.create( return jIO.QueryFactory.create(
'(identifier: "a" OR identifier: "b") AND title: "o"' '(identifier: "a" OR identifier: "b") AND title: "o"'
).exec(doc_list); ).exec(doc_list);
}).then(function (doc_list) { }).then(function (doc_list) {
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
{"identifier": ["ab", "b"]} {"identifier": ["ab", "b"]}
]; ];
stop(); stop();
complex_queries.QueryFactory.create('identifier: "a%"').exec( jIO.QueryFactory.create('identifier: "a%"').exec(
doc_list doc_list
).then(function (doc_list) { ).then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
{"identifier": ["ab", "b"]} {"identifier": ["ab", "b"]}
]; ];
return complex_queries.QueryFactory.create('identifier: "a\\%"'). return jIO.QueryFactory.create('identifier: "a\\%"').
exec(doc_list); exec(doc_list);
}).then(function (doc_list) { }).then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
...@@ -142,7 +142,7 @@ ...@@ -142,7 +142,7 @@
{"identifier": ["ab", "b"]} {"identifier": ["ab", "b"]}
]; ];
return complex_queries.QueryFactory.create('identifier: "__"'). return jIO.QueryFactory.create('identifier: "__"').
exec(doc_list); exec(doc_list);
}).then(function (doc_list) { }).then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
...@@ -155,7 +155,7 @@ ...@@ -155,7 +155,7 @@
{"identifier": ["ab", "b"]} {"identifier": ["ab", "b"]}
]; ];
return complex_queries.QueryFactory.create('identifier: "__%"'). return jIO.QueryFactory.create('identifier: "__%"').
exec(doc_list); exec(doc_list);
}).then(function (doc_list) { }).then(function (doc_list) {
deepEqual(doc_list, [ deepEqual(doc_list, [
...@@ -175,7 +175,7 @@ ...@@ -175,7 +175,7 @@
{"identifier": "b", "title": "d"} {"identifier": "b", "title": "d"}
]; ];
stop(); stop();
complex_queries.QueryFactory.create('').exec(doc_list, { jIO.QueryFactory.create('').exec(doc_list, {
"select_list": ["title"], "select_list": ["title"],
"limit": [2, 1], "limit": [2, 1],
"sort_on": [["identifier", "ascending"], ["title", "descending"]] "sort_on": [["identifier", "ascending"], ["title", "descending"]]
...@@ -187,7 +187,7 @@ ...@@ -187,7 +187,7 @@
}); });
test("JSON query", function () { test("JSON query", function () {
var jsoned = complex_queries.QueryFactory.create( var jsoned = jIO.QueryFactory.create(
"NOT(a:=b OR c:% AND d:<2)" "NOT(a:=b OR c:% AND d:<2)"
).toJSON(); ).toJSON();
deepEqual( deepEqual(
...@@ -222,7 +222,7 @@ ...@@ -222,7 +222,7 @@
"\"NOT(a:=b OR c:% AND d:<2)\".toJSON()" "\"NOT(a:=b OR c:% AND d:<2)\".toJSON()"
); );
deepEqual( deepEqual(
complex_queries.parseStringToObject("NOT(a:=b OR c:% AND d:<2)"), jIO.Query.parseStringToObject("NOT(a:=b OR c:% AND d:<2)"),
jsoned, jsoned,
"parseStringToObject(\"NOT(a:=b OR c:% AND d:<2)\");" "parseStringToObject(\"NOT(a:=b OR c:% AND d:<2)\");"
); );
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<link rel="stylesheet" href="../lib/qunit/qunit.css" /> <link rel="stylesheet" href="../lib/qunit/qunit.css" />
<title>JIO, Storage and ComplexQueries Qunit/Sinon Unit Tests</title> <title>JIO Qunit/Sinon Unit Tests</title>
</head> </head>
<body> <body>
<div id="qunit"></div> <div id="qunit"></div>
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
<script src="jio/fakestorage.js"></script> <script src="jio/fakestorage.js"></script>
<script src="jio/tests.js"></script> <script src="jio/tests.js"></script>
<script src="../complex_queries.js"></script>
<script src="queries/key.tests.js"></script> <script src="queries/key.tests.js"></script>
<script src="queries/key-schema.tests.js"></script> <script src="queries/key-schema.tests.js"></script>
<script src="queries/tests.js"></script> <script src="queries/tests.js"></script>
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
"test_util": "jio/util", "test_util": "jio/util",
"fakestorage": "jio/fakestorage", "fakestorage": "jio/fakestorage",
"complex_queries": "../complex_queries", "jioquery_tests": "queries/tests",
"complex_queries_tests": "queries/tests",
"localstorage": "../src/jio.storage/localstorage", "localstorage": "../src/jio.storage/localstorage",
"localstorage_tests": "jio.storage/localstorage.tests", "localstorage_tests": "jio.storage/localstorage.tests",
...@@ -53,7 +52,7 @@ ...@@ -53,7 +52,7 @@
require([ require([
"sinon_qunit", "sinon_qunit",
"jio_tests", "jio_tests",
"complex_queries_tests", "jioquery_tests",
"localstorage_tests", "localstorage_tests",
"davstorage_tests", "davstorage_tests",
"indexstorage_tests", "indexstorage_tests",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment