Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
jio
Commits
d814b55c
Commit
d814b55c
authored
Feb 26, 2019
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5storage] Allow to query the catalog with the group_by parameter
parent
2f890873
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
5 deletions
+54
-5
src/jio.js
src/jio.js
+1
-0
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+8
-2
test/jio.storage/erp5storage.tests.js
test/jio.storage/erp5storage.tests.js
+7
-3
test/jio.storage/querystorage.tests.js
test/jio.storage/querystorage.tests.js
+38
-0
No files found.
src/jio.js
View file @
d814b55c
...
...
@@ -474,6 +474,7 @@
if
(
context
.
hasCapacity
(
"
list
"
)
&&
((
options
.
query
===
undefined
)
||
context
.
hasCapacity
(
"
query
"
))
&&
((
options
.
sort_on
===
undefined
)
||
context
.
hasCapacity
(
"
sort
"
))
&&
((
options
.
group_by
===
undefined
)
||
context
.
hasCapacity
(
"
group
"
))
&&
((
options
.
select_list
===
undefined
)
||
context
.
hasCapacity
(
"
select
"
))
&&
((
options
.
include_docs
===
undefined
)
||
...
...
src/jio.storage/erp5storage.js
View file @
d814b55c
...
...
@@ -419,7 +419,7 @@
ERP5Storage
.
prototype
.
hasCapacity
=
function
(
name
)
{
return
((
name
===
"
list
"
)
||
(
name
===
"
query
"
)
||
(
name
===
"
select
"
)
||
(
name
===
"
limit
"
)
||
(
name
===
"
sort
"
));
(
name
===
"
sort
"
)
||
(
name
===
"
group
"
)
);
};
function
isSingleLocalRoles
(
parsed_query
)
{
...
...
@@ -487,7 +487,8 @@
local_roles
,
local_role_found
=
false
,
selection_domain
,
sort_list
=
[];
sort_list
=
[],
group_list
=
[];
if
(
options
.
query
)
{
parsed_query
=
jIO
.
QueryFactory
.
create
(
options
.
query
);
result_list
=
isSingleLocalRoles
(
parsed_query
);
...
...
@@ -559,6 +560,10 @@
}
}
if
(
options
.
group_by
)
{
group_list
=
options
.
group_by
;
}
if
(
selection_domain
)
{
selection_domain
=
JSON
.
stringify
(
selection_domain
);
}
...
...
@@ -572,6 +577,7 @@
select_list
:
options
.
select_list
||
[
"
title
"
,
"
reference
"
],
limit
:
options
.
limit
,
sort_on
:
sort_list
,
group_by
:
group_list
,
local_roles
:
local_roles
,
selection_domain
:
selection_domain
})
...
...
test/jio.storage/erp5storage.tests.js
View file @
d814b55c
...
...
@@ -32,7 +32,7 @@
domain
=
"
https://example.org
"
,
traverse_template
=
domain
+
"
?mode=traverse{&relative_url,view}
"
,
search_template
=
domain
+
"
?mode=search{&query,select_list*,limit*,
"
+
"
sort_on*,local_roles*,selection_domain*}
"
,
"
sort_on*,
group_by*,
local_roles*,selection_domain*}
"
,
add_url
=
domain
+
"
lets?add=somedocument
"
,
root_hateoas
=
JSON
.
stringify
({
"
_links
"
:
{
...
...
@@ -1289,6 +1289,7 @@
ok
(
this
.
jio
.
hasCapacity
(
"
query
"
));
ok
(
this
.
jio
.
hasCapacity
(
"
select
"
));
ok
(
this
.
jio
.
hasCapacity
(
"
limit
"
));
ok
(
this
.
jio
.
hasCapacity
(
"
group
"
));
});
/////////////////////////////////////////////////////////////////
...
...
@@ -1481,7 +1482,9 @@
var
search_url
=
domain
+
"
?mode=search&query=title%3A%20%22two%22&
"
+
"
select_list=destination&select_list=source&limit=5&
"
+
"
sort_on=%5B%22title%22%2C%22descending%22%5D&
"
+
"
sort_on=%5B%22id%22%2C%22descending%22%5D
"
,
"
sort_on=%5B%22id%22%2C%22descending%22%5D&
"
+
"
group_by=a_foo_grouping&
"
+
"
group_by=a_bar_grouping
"
,
search_hateoas
=
JSON
.
stringify
({
"
_embedded
"
:
{
...
...
@@ -1522,7 +1525,8 @@
limit
:
[
5
],
select_list
:
[
"
destination
"
,
"
source
"
],
query
:
'
title: "two"
'
,
sort_on
:
[[
"
title
"
,
"
descending
"
],
[
"
id
"
,
"
descending
"
]]
sort_on
:
[[
"
title
"
,
"
descending
"
],
[
"
id
"
,
"
descending
"
]],
group_by
:
[
"
a_foo_grouping
"
,
"
a_bar_grouping
"
]
})
.
then
(
function
(
result
)
{
deepEqual
(
result
,
{
...
...
test/jio.storage/querystorage.tests.js
View file @
d814b55c
...
...
@@ -964,6 +964,44 @@
start
();
});
});
test
(
"
group_by is not handled
"
,
function
()
{
stop
();
expect
(
3
);
function
StorageGroupCapacity
()
{
return
this
;
}
StorageGroupCapacity
.
prototype
.
hasCapacity
=
function
(
capacity
)
{
return
((
capacity
===
"
list
"
)
||
(
capacity
===
"
group
"
));
};
jIO
.
addStorage
(
'
querystoragegroupcapacity
'
,
StorageGroupCapacity
);
var
jio
=
jIO
.
createJIO
({
type
:
"
query
"
,
sub_storage
:
{
type
:
"
querystoragegroupcapacity
"
}
});
jio
.
allDocs
({
group_by
:
[
"
title
"
]
})
.
then
(
function
()
{
ok
(
false
,
'
Must fail as group is not handled
'
);
})
.
fail
(
function
(
error
)
{
ok
(
error
instanceof
jIO
.
util
.
jIOError
);
equal
(
error
.
status_code
,
501
);
equal
(
error
.
message
,
"
Capacity 'group' is not implemented on 'query'
"
);
})
.
always
(
function
()
{
start
();
});
});
/////////////////////////////////////////////////////////////////
// queryStorage.repair
/////////////////////////////////////////////////////////////////
...
...
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