Skip to content
Snippets Groups Projects
Commit 76e50707 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

[Projekt: Entwicklung - Neon][TicketNr.: 1041584][Filter - Attribute]

parent 3f992dd1
No related branches found
No related tags found
No related merge requests found
import("system.vars");
import("Context_lib");
import("system.result");
import("AttributeFilter_lib");
var objectType = ContextUtils.getCurrentContextId();
var filterName = vars.get("$local.name");
var filterCond = vars.get("$local.condition");
var resSql = AttributeFilterExtensionMaker.getFilterCondition(objectType, filterName, filterCond);
result.string(resSql);
\ No newline at end of file
var sqlCond = AttributeFilterExtensionMaker.makeFilterConditionSql();
result.string(sqlCond);
\ No newline at end of file
import("Context_lib");
import("AttributeFilter_lib");
import("system.result");
var objectType = ContextUtils.getCurrentContextId();
var res = AttributeFilterExtensionMaker.getFilterFields(objectType);
result.string(res);
var fields = AttributeFilterExtensionMaker.makeFilterFields();
result.string(fields);
\ No newline at end of file
import("system.vars");
import("system.result");
import("AttributeFilter_lib");
var filter = vars.getString("$local.filter");
var values = AttributeFilterExtensionMaker.getFilterValues(filter);
var values = AttributeFilterExtensionMaker.makeFilterValues();
result.object(values);
\ No newline at end of file
import("Entity_lib");
import("system.vars");
import("Context_lib");
import("system.db");
import("Sql_lib");
import("Attribute_lib");
......@@ -48,9 +51,9 @@ AttributeFilterExtensionMaker.getFilterFields = function(pObjectType)
res.push({
name: name,
title: row["FULL_ATTRIBUTE_NAME"],
//TODO: comment why this workaround is necessary
//workaround since we do not have a "UNKNOWN"-contentType in the filter-definition
contentType: contentType == "UNKNOWN" ? "TEXT" : contentType,
hasDropDownValues: contentType == "UNKNOWN" || contentType == "BOOLEAN" ? true : false
hasDropDownValues: contentType == "UNKNOWN" || contentType == "BOOLEAN" ? true : false//TODO: determine this somehow else
});
}
});
......@@ -59,6 +62,13 @@ AttributeFilterExtensionMaker.getFilterFields = function(pObjectType)
return res;
};
AttributeFilterExtensionMaker.makeFilterFields = function()
{
var objectType = ContextUtils.getCurrentContextId();
var res = AttributeFilterExtensionMaker.getFilterFields(objectType);
return res;
};
AttributeFilterExtensionMaker.getFilterValues = function(pFilter)
{
var filter = JSON.parse(pFilter);
......@@ -73,7 +83,14 @@ AttributeFilterExtensionMaker.getFilterValues = function(pFilter)
return res;
};
AttributeFilterExtensionMaker.getFilterCondition = function(pObjectType, pFilterName, pCondition)
AttributeFilterExtensionMaker.makeFilterValues = function()
{
var filter = vars.getString("$local.filter");
var res = AttributeFilterExtensionMaker.getFilterValues(filter);
return res;
};
AttributeFilterExtensionMaker.getFilterCondition = function(pObjectType, pFilterName, pCondition, pIdTableName, pIdColumnName)
{
var name = pFilterName;
name = AttributeSearchNameCoder.decode(name);
......@@ -87,14 +104,23 @@ AttributeFilterExtensionMaker.getFilterCondition = function(pObjectType, pFilter
[pObjectType, SqlUtils.getSingleColumnType("AB_ATTRIBUTERELATION.OBJECT_TYPE")],
[attributeId, SqlUtils.getSingleColumnType("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID")]
];
//TODO: dynmic mapping of UID and TABLE -> sys.uidcolumn
var resSql = "CONTACTID in (select CONTACT.CONTACTID \n\
from CONTACT \n\
left join AB_ATTRIBUTERELATION on (AB_ATTRIBUTERELATION.OBJECT_ROWID = CONTACT.CONTACTID \n\
var resSql = pIdColumnName + " in (select " + pIdTableName + "." + pIdColumnName + " \n\
from " + pIdTableName + " \n\
left join AB_ATTRIBUTERELATION on (AB_ATTRIBUTERELATION.OBJECT_ROWID = " + pIdTableName + "." + pIdColumnName + " \n\
and AB_ATTRIBUTERELATION.OBJECT_TYPE = ? \n\
and AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = ?) \n\
where " + condition + " )";
resSql = db.translateCondition([resSql, preparedValues]);
return resSql;
};
AttributeFilterExtensionMaker.makeFilterConditionSql = function()
{
var objectType = ContextUtils.getCurrentContextId();
var filterName = vars.get("$local.name");
var filterCond = vars.get("$local.condition");
var uidInfo = EntityUtils.parseUidColumn(vars.get("$sys.uidcolumn"));
var res = AttributeFilterExtensionMaker.getFilterCondition(objectType, filterName, filterCond, uidInfo.table, uidInfo.column);
return res;
};
\ No newline at end of file
import("KeywordData_lib");
import("KeywordData_lib");
import("Context_lib");
import("system.util");
import("system.datetime");
......@@ -74,7 +75,18 @@ AttributeUtil.getPossibleAttributes = function (pObjectType, pIncludeGroups, pFi
return attributes;
}
//TODO: comment function
/**
* searches for possiblevalues for a atttribute and returns these. The values depend on the attributeType
*
* @param {String} pAttributeId the id of the attribute
* @param {Boolean} pAttributeType type of the attribute that is specified with pAttributeId;
* The type needs to be passed to the function for better performance
* (loading the type via attribute several times would be too slow)
* @param {Boolean} [pIncludeInactives=false] specifies if only active attributevalues or actives + inactives shall be returned,
* this is important when you want to search for attributevalues
*
* @return {Array} 2D-array with [ID, value] als elements if the given attributeType has possible items. if not null is returned
*/
AttributeUtil.getPossibleListValues = function (pAttributeId, pAttributeType, pIncludeInactives)
{
var attributeId = pAttributeId;
......
......@@ -2,6 +2,30 @@ import("system.result");
import("system.neon");
import("system.vars");
/**
* provides static methods for special handling of entities in JDito-Processes
* do not create an instance of this
*
* @class
*/
function EntityUtils(){}
/**
* parses a full-databnase-uid-name into a table and a column identifier
*
* @param {String} pFullUidName full-databnase-uid-name like "ORGANISATION.ORGANISATIONID", the variable "$sys.uidcolumn" returns this for example
*
* @return {Object} new object with 2 properties: - table: contains the tablename, - column: contains the columnname
*/
EntityUtils.parseUidColumn = function(pFullUidName)
{
var pos = pFullUidName.lastIndexOf(".");
return {
table: pFullUidName.substring(0, pos),
column: pFullUidName.substring(++pos)
};
};
/**
* provides static methods for special handling of entities in JDito-Processes
* do not create an instance of this
......
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