Refiner
This object is optionally provided as
property of a result set.
A new instance is created every time a discover is performed, and it is maintained with its
chronology, until a new discover is performed.
The Refiner is initialized as follows:
- the
cursorvalue is 0 - the chronology
.lengthis 1 and contains the constraints and the options of the origin discover
The Refiner provides the following main features:
- allows to refine the related result set by merging the given constraints with the constraints of the origin discover (see point 2 above)
- keeps track of the refinements (both constraints and options) in a chronology that can be scrolled back and ahead
Methods
browse
-
onResponse -
who -
[options]
Browses the content of the composed node
having the given who identifier.
The correspondent result set is the same that could be
retrieved by calling the expand method on the
composed node having the given who identifier.
However the Refiner allows to take advantage of the chronology.
If who corresponds to a non existent node or to a
Report/simple:property node, the
correspondent result set is empty.
chronology
()
Object[]
Returns the chronology of the constraints used to refine the related result set
Returns:
array of basic constraints
cursor
()
Integer
Returns the chronology cursor, an integer value indicating the current constraints of the
chronology.
The value satisfies the following statement:
cursor >= 0 && cursor <= history.length
Returns:
an integer value indicating the current constraint of the chronology
forward
-
[onResponse]
Scrolls ahead the chronology:
- increases the cursor by one
- restores the chronology to the current cursor value
.length
and onResponse is provided
Parameters:
-
[onResponse]Function optionalcallback function for receiving asynchronous query response; if omitted the method is only tested but not executed
Returns:
true if the cursor is less than chronology.length,
false otherwise
refine
-
onResponse -
constraints -
[options]
Refines the related result set:
- merges the given
constraintswith the original discover constraints - if cursor is at the end of the chronology (its value is
chronology
.length - 1), it appends the mergedconstraintsto the chronology - if cursor is less than chronology
.length - 1(due to one or more calls to the rewind/forward methods), it overwrites the chronology at indexcursor + 1with the mergedconstraintsand clears the remaining part of the chronology - increases the
cursorby 1 - refines the related result set with the
merged
constraintsand the givenoptions
Only basic constraints are supported. See also mergeConstraints
Parameters:
-
onResponseFunctionCallback function for receiving asynchronous query response
-
constraintsObjectthe constraints to refine the discover. Only basic constraints are supported
-
[options]Object optionalall the options are allowed except
start,termFrequencyandextension
reset
()
Resets the Refiner to its initial state:
- the cursor value is set to 0
- the chronology
.lengthis set to 1 and contains the constraints and the options of the origin discover
restore
-
[onResponse] -
cursor
Refines the the related result set by restoring the constraints and the
options in the chronology at the specified cursor.
The method is executed only if
cursor >= 0 && cursor <= chronology.length and onResponse is provided
Parameters:
-
[onResponse]Function optionalcallback function for receiving asynchronous query response; if omitted the method is only tested but not executed
-
cursorIntegeran integer value indicating the constraints in the chronology to restore
Returns:
true if cursor >= 0 && cursor <= chronology.length ,
false otherwise
rewind
-
[onResponse]
Scrolls back the chronology:
- decreases the cursor by 1
- restores the chronology to the current cursor value
onResponse is provided
Parameters:
-
[onResponse]Function optionalcallback function for receiving asynchronous query response; if omitted the method is only tested but not executed
