diff --git a/process/AttributeFilter_lib/process.js b/process/AttributeFilter_lib/process.js index e5c3eac4d08c416de8c35768bc3c3add7c32d7c6..9c667f3770c0aeab7853b9d8ad6bfae02981b5b1 100644 --- a/process/AttributeFilter_lib/process.js +++ b/process/AttributeFilter_lib/process.js @@ -9,10 +9,27 @@ import("Attribute_lib"); import("system.entities"); import("system.util"); -//TODO: comment lib - +/** + * Procides static methods for en- or decoding attributeFilter names + * AttributeFilter names are shared over several processes and contain therefore various information + * The infomration needs to be encoded to be able to transfer it over the different processes + * + * @class + * + */ function AttributeSearchNameCoder(){} +/** + * encodes several parameters into one string that can be used as AttributeFilter-name + * + * @param {String} pUid <p/> attribute uid of the attribute that has to be encoded + * @param {String} pAttributeType <p/> attribute type of the attribute that has to be encoded + * <br /> while you may able to specify any string, only values of $AttributeTypes.*** are useful + * + * @return {String} <p/> an encoded string of the given parametervalues + * <br/> this is basically a serialized object which is base64 encoded + * @static + */ AttributeSearchNameCoder.encode = function (pUid, pAttributeType) { var res = { @@ -24,6 +41,15 @@ AttributeSearchNameCoder.encode = function (pUid, pAttributeType) return res }; +/** + * decodes a string that was encoded with AttributeSearchNameCoder.encode + * + * + * @param {String} pEncodedString <p/> string that shall be decoded; the origin of the name has to be a filter-object + * + * @return {Object} <p/> an object that contains all keys and values that have been encoded with AttributeSearchNameCoder.encode + * @static + */ AttributeSearchNameCoder.decode = function (pEncodedString) { var res = pEncodedString.substr(pEncodedString.lastIndexOf(".") + 1); @@ -32,8 +58,31 @@ AttributeSearchNameCoder.decode = function (pEncodedString) return res }; + +/** + * Provides static methods for hanlding AttriubteFilterExtensions + * The methods are used to fill the processes that need to be specified within a FilterExtension of a RecrodContainer + * + * @class + * + */ function AttributeFilterExtensionMaker() {} +/** + * fetches attributes that are filterable and transforms them into filter fields + * + * @param {String} pObjectType <p/> contextId of the context whoes attributes are used for providing the filter fields + * + * @return {String} <p/> field-definitions (array of objects) that are ready to use for a filterExtensionSet in a stringified form + * <br/> The object within the array contains the following properties: + * <ul> + * <li>name - internal name for an attribut filter field; has several data encoded</li> + * <li>title - string of a human readable name for the end user (translated)</li> + * <li>contentType - string of the neon-contentType (e.g. TEXT)</li> + * <li>hasDropDownValues - boolean if possible values have to be calculated or not</li> + * </ul> + * @static + */ AttributeFilterExtensionMaker.getFilterFields = function(pObjectType) { var res = []; @@ -70,6 +119,12 @@ AttributeFilterExtensionMaker.getFilterFields = function(pObjectType) return res; }; +/** + * fetches attributes that are filterable and transforms them into filter fields for the current context + * + * @see AttributeFilterExtensionMaker.getFilterFields for more details + * @static + */ AttributeFilterExtensionMaker.makeFilterFields = function() { var objectType = ContextUtils.getCurrentContextId(); @@ -77,6 +132,19 @@ AttributeFilterExtensionMaker.makeFilterFields = function() return res; }; +/** + * Returns possible values to choose from within a attributeFilterExtension. <br/> + * Depending on the attribute-type and the attribute(id) itself, different values will be returned. <br/> + * For some attirbute types there are returned static possible values, e.g. a Boolean-attribute has always the values "Yes [true] and No [false] + * + * @param {String} pFilter <p/> stringified form of the filter-object that contains the filter-name + * <br/>The filter-name contains various data of the attribute as encoded string + * + * @return {Array} <p/> list of the values of an attribute if the attribute has chooseable values or an empty array if not + * <br/>This is a 2D-Array where each element is an array that contains the ID and the title: + * <br/> [[id1, title1], [idN, titleN]] + * @static + */ AttributeFilterExtensionMaker.getFilterValues = function(pFilter) { var filter = JSON.parse(pFilter); @@ -92,6 +160,13 @@ AttributeFilterExtensionMaker.getFilterValues = function(pFilter) return res; }; +/** + * fetches pssible chooseable attribute values for a current filter + * This process is useful for a process within the filter extension for attributes + * + * @see AttributeFilterExtensionMaker.getFilterValues for more details + * @static + */ AttributeFilterExtensionMaker.makeFilterValues = function() { var filter = vars.getString("$local.filter"); @@ -99,6 +174,22 @@ AttributeFilterExtensionMaker.makeFilterValues = function() return res; }; +/** + * Builds a Sql-condition that may be used in a filter extension set and allows to filter for attributes within a db-table + * + * @param {String} pObjectType <p/> contextId of the objects thats records + * @param {String} pFilterName <p/> name of the filter that was prior encoded and contains various information + * @param {String} pCondition <p/> a SQL-condition like it is given in the "$local.condition"-variable in filter extension sets + * @param {String} pRawValue <p/> the raw input value that the user has entered for a filter operation + * @param {String} pOperatorName <p/> the operator of the condition (equals, smaller, greater, etc.) as a resolved name; e.g. "IS NOT NULL" + * @param {String} pIdTableName <p/> name of the db-table where the data shall be filtered + * @param {String} pIdColumnName <p/> name of the primarykey-column of the table that was given via pIdTablename + * @param {String} pColumnPlaceholder <p/> name of the placeholder where the columnname should be like it is given in the + * "$local.columnPlaceholder"-variable in filter extension sets + * + * @return {SqlBuilder} <p/> a SqlBuilder-condition that contains a sub-select and may be used for filtering data + * @static + */ AttributeFilterExtensionMaker.getFilterCondition = function(pObjectType, pFilterName, pCondition, pRawValue, pOperatorName, pIdTableName, pIdColumnName, pColumnPlaceholder) { @@ -147,6 +238,12 @@ AttributeFilterExtensionMaker.getFilterCondition = function(pObjectType, pFilter return resSql; }; +/** + * Builds a Sql-condition for a attribute filter extension set. This allows to filter for attributes within a db-table + * + * @see AttributeFilterExtensionMaker.getFilterCondition for more details + * @static + */ AttributeFilterExtensionMaker.makeFilterConditionSql = function() { var objectType = ContextUtils.getCurrentContextId();