[#58] object/search: Add object-with-children filter
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
624e8cd3cb
commit
16252ad09a
2 changed files with 14 additions and 3 deletions
|
@ -7,12 +7,14 @@ import (
|
||||||
|
|
||||||
// FIXME: this is a temporary solution for object fields filters
|
// FIXME: this is a temporary solution for object fields filters
|
||||||
|
|
||||||
const keyChildrenField = "Object.Header.Split.Children"
|
const keyParentField = "Object.Header.Split.WithChildren"
|
||||||
|
|
||||||
|
const keyNoChildrenField = "Object.Header.Split.NoChildren"
|
||||||
|
|
||||||
const keyParentIDField = "Object.Header.Split.Parent"
|
const keyParentIDField = "Object.Header.Split.Parent"
|
||||||
|
|
||||||
func NewEmptyChildrenFilter() *Filter {
|
func NewEmptyChildrenFilter() *Filter {
|
||||||
return NewFilterEqual(keyChildrenField, "")
|
return NewFilterEqual(keyNoChildrenField, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewParentIDFilter(par *object.ID) *Filter {
|
func NewParentIDFilter(par *object.ID) *Filter {
|
||||||
|
@ -25,3 +27,10 @@ func NewRightChildQuery(par *object.ID) query.Query {
|
||||||
NewEmptyChildrenFilter(),
|
NewEmptyChildrenFilter(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewLinkingQuery(par *object.ID) query.Query {
|
||||||
|
return New(
|
||||||
|
NewParentIDFilter(par),
|
||||||
|
NewFilterEqual(keyParentField, ""),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -97,10 +97,12 @@ func headerEqual(obj *object.Object, key, value string) bool {
|
||||||
return value == cidValue(obj.GetContainerID())
|
return value == cidValue(obj.GetContainerID())
|
||||||
case objectSDK.HdrSysNameOwnerID:
|
case objectSDK.HdrSysNameOwnerID:
|
||||||
return value == ownerIDValue(obj.GetOwnerID())
|
return value == ownerIDValue(obj.GetOwnerID())
|
||||||
case keyChildrenField:
|
case keyNoChildrenField:
|
||||||
return len(obj.GetChildren()) == 0
|
return len(obj.GetChildren()) == 0
|
||||||
case keyParentIDField:
|
case keyParentIDField:
|
||||||
return idValue(obj.GetParent().GetID()) == value
|
return idValue(obj.GetParent().GetID()) == value
|
||||||
|
case keyParentField:
|
||||||
|
return len(obj.GetChildren()) > 0
|
||||||
// TODO: add other headers
|
// TODO: add other headers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue