Skip to content
Snippets Groups Projects
Commit 45f3e8f8 authored by David Büchler's avatar David Büchler
Browse files

Added Utils Lib to support building the subselect statement in a filterConditionStatement

parent c6ac276e
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1">
<name>FilterCondition_lib</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<process>%aditoprj%/process/FilterCondition_lib/process.js</process>
<variants>
<element>LIBRARY</element>
</variants>
</process>
/**
* Methods to help build filterCondition statements.
* Do not create an instance of this!
*
* @class
*/
function FilterConditionUtils() {}
/**
* Builds a filterConditionStatement.
* The values get concatenated as described below:
* [pStatementFirstPart] where [pWhereCondition] group by [pGroupByFields] having [pHavingCondition] [pStatementLastPart]
*
* @param {String} pStatementFirstPart First part of the subselect e.g. "OFFER.OFFERID in (select OFFERITEM.OFFER_ID from OFFERITEM"
* @param {String} pWhereCondition The where conditions e.g. "OFFERITEM.QUANTITY = 2"
* @param {String} pGroupByFields Fields to be grouped by. Only required if there is a pHavingCondition. e.G. "OFFER_ID"
* @param {String} pHavingCondition The having condition e.g. "MIN( OFFERITEM.PRICE ) > 3"
* @param {String} pStatementLastPart The part that gets added in the end. Contains usually ")" to close of the built subselect.
* @return {String} The string concatenated as described above
*/
FilterConditionUtils.buildFilterConditionStatement = function(pStatementFirstPart, pWhereCondition, pGroupByFields, pHavingCondition, pStatementLastPart)
{
let statement = pStatementFirstPart;
if (pWhereCondition != null && pWhereCondition.trim() != "")
statement += " where " + pWhereCondition;
if (pGroupByFields != null && pGroupByFields.trim() != ""
&& pHavingCondition != null && pHavingCondition.trim() != "" )
{
statement += " group by " + pGroupByFields + " having " + pHavingCondition
}
statement += " " + pStatementLastPart;
return statement;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment