define([], function () {
'use strict';
/**
* General representation of condition useable for data restriction.
*
* <p>
* Conditon is basically filtering rule which can be applied by the client to fetch only records matching some restriction. {@link operation/js/api/Condition Conditon} is always
* either simple (represented by a single filtering rule) or composite (represented by multiple filtering rules combined using AND/OR operators) object.
* </p>
*
* <p>
* <ul>
* <li>
* To see how to create certain {@link operation/js/api/Condition Conditon} instance, please check {@link module:operation/js/api/Conditions Conditions} factory methods.
* </li>
* <li>
* To see how to apply certain {@link operation/js/api/Condition Conditon} to filter records, please check {@link module:api/js/Operations.read Operations.read(..)} method.
* </li>
* </ul>
* </p>
*
* @AbcsAPI stable
* @version 15.4.5
* @exports operation/js/api/Condition
*
* @constructor
* @private
* @class
*
* @see {@link module:operation/js/api/Conditions.SIMPLE Conditions.SIMPLE(..)} to create {@link operation/js/api/Condition Condition} with a single filtering restriction.
* @see {@link module:operation/js/api/Conditions.OR Conditions.OR(..)} to create composite {@link operation/js/api/Condition Condition} which consist of multiple filtering restrictions joining them using an OR operator.
* @see {@link module:operation/js/api/Conditions.AND Conditions.AND(..)} to create composite {@link operation/js/api/Condition Condition} which consist of multiple filtering restrictions joining them using an AND operator.
* @see {@link module:api/js/Operations.read Operations.read(..)} to fetch data programmatically filtered using the given {@link operation/js/api/Condition Condition} instance.
*/
var Condition = function() {
AbcsLib.checkThis(this);
};
/**
* Interpret this {@link operation/js/api/Condition Condition} by the given {@link bop/js/spi/operation/ConditionVisitor ConditionVisitor}.
*
* <p>
* Allows author of the {@link bop/js/spi/BOP BOP} to interpret incoming {@link operation/js/api/Condition Condition}s and transform them into proper URL query or generally process them any way (s)he need.
* </p>
*
* @AbcsExtension stable
* @version 17.1.1
*
* @param {bop/js/spi/operation/ConditionVisitor} conditionVisitor - {@link bop/js/spi/operation/ConditionVisitor ConditionVisitor} to interpret this {@link operation/js/api/Condition Condition}
*
* @see {@link bop/js/spi/operation/ConditionVisitor ConditionVisitor}
* @see {@link bop/js/spi/operation/ConditionVisitor#visitEmptyCondition ConditionVisitor.visitEmptyCondition()}
* @see {@link bop/js/spi/operation/ConditionVisitor#visitSimpleCondition ConditionVisitor.visitSimpleCondition(..)}
* @see {@link bop/js/spi/operation/ConditionVisitor#visitCompositeCondition ConditionVisitor.visitCompositeCondition(..)}
*
* @example
* <caption>
* Using {@link bop/js/spi/operation/ConditionVisitor ConditionVisitor} instance in {@link operation/js/api/Operation#perform Operation.perform(..)} method implementation to turn incoming {@link operation/js/api/Condition Condition}
* instance into proper URL querying resulted data.<br/><br/>
*
* Let's assume MyConditionVisitor is implemented so that the query is always appended at the end of the URL. For example if the {@link operation/js/api/Condition Condition} is declared to "Find all employees where
* Firstname equals 'Martin' AND Lastname equals 'Janicek'", the resulted URL can look like this: 'http://example.com/employee?q= Firstname EQ Martin & Lastname EQ Janicek'
* </caption>
*
* define([
* 'operation/js/api/OperationResult',
* '{{package}}/js/MyConditionVisitor'
* ], function (
* OperationResult,
* MyConditionVisitor
* ) {
*
* var Employee = function() {
* };
*
* Employee.find = function(operationData) {
* var results = [];
* var baseURL = 'http://example.com/employee';
* var condition = operationData.getQuery().getCondition();
*
* // The visitor is there to turn Condition abstraction into
* // whatever shape data provider expects on it's input
* var resultURL = condition.visit(new MyConditionVisitor(baseURL));
*
* $.ajax({
* url: resultURL,
* type: 'GET'
* }).done(function(response) {
* // Because the URL was change by the visitor, we should have filtered results here
* fulfil(OperationResult.success(response));
* });
* };
*
* return Employee;
* });
*/
Condition.prototype.visit = function(/*conditionVisitor*/) {};
/**
* Appends the given condition.
*
* <p>
* Behavior depends on what the instance of 'this' condition is. If the instance of the object on which is
* this method called is:
* <ul>
* <li>
* {@link module:bop/js/EmptyCondition EmptyCondition} - It will return the given condition itself.
* <li>
* <li>
* {@link module:bop/js/api/operation/SimpleCondition SimpleCondition} - It will return an instance of {@link module:bop/js/api/operation/CompositeCondition CompositeCondition}
* and use the given {@link module:bop/js/api/operation/RelationOperator RelationOperator} as an operator between original and the given condition.
* <li>
* <li>
* {@link module:bop/js/api/operation/CompositeCondition CompositeCondition} - It will return the same composite instance
* and appends the given condition instance using already existing relation operator.
* <li>
* <ul>
* <p>
*
* @param {Condition} condition
* @param {RelationOperator} relationOperator
* @returns {Condition}
*
* @see {@link module:bop/js/EmptyCondition EmptyCondition}
* @see {@link module:bop/js/api/operation/SimpleCondition SimpleCondition}
* @see {@link module:bop/js/api/operation/CompositeCondition CompositeCondition}
* @see {@link module:bop/js/api/operation/RelationOperator RelationOperator}
*/
Condition.prototype.append = function(/*condition, relationOperator*/) {};
/**
* Gets an array of all sub-conditions if this condition has any.
*
* @returns {Condition[]}
*/
Condition.prototype.getSubConditions = function() {};
/**
* Gets the JSON definition of this {@link query/js/api/Condition Condition} object.
*
* @returns {Object[]}
*/
Condition.prototype.getDefinition = function() {};
/**
* Clones this condition.
*
* @returns {@link query/js/api/Condition}
*/
Condition.prototype.clone = function() {};
/**
* Checks whether the given data matches this condition or not.
*
* @param {Map<Property, Object>} recordData
* @returns {Boolean}
*/
Condition.prototype.match = function(/*recordData*/) {};
return Condition;
});