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

Context_lib: exclude private-dummy organisation

parent e4342917
No related branches found
No related tags found
No related merge requests found
......@@ -183,6 +183,7 @@ function ContextSelector(pTableName, pIdField, pTitleExpression)
* @property
*/
this.activeStates = null; ProtoPropertyUtils.makeSemiReadOnly(this, "activeStates");
this.condition = null; ProtoPropertyUtils.makeSemiReadOnly(this, "condition");
}
/**
* creates a new instance of a ContextSelector and returns it
......@@ -252,6 +253,15 @@ ContextSelector.prototype.setActiveStates = function(pValue)
this._activeStates = pValue;
return this;
};
/**
* sets the condition property of a ContextSelector-object
* @param {Object} pSqlCondition condition as SqlCondition-object
*/
ContextSelector.prototype.setCondition = function(pSqlCondition)
{
this._condition = pSqlCondition;
return this;
};
/**
* TODO: !!!temporary function until you can get fields from another Entity!!!
......@@ -261,6 +271,7 @@ ContextUtils.getSelectMap = function()
var maskingUtils = new SqlMaskingUtils();
return {
"Organisation": ContextSelector.create("ORGANISATION", "ORGANISATIONID", "NAME")
.setCondition(SqlCondition.begin().and("ORGANISATION.ORGANISATIONID != '0'"))
,"Person": ContextSelector.create("CONTACT", "CONTACTID")
.setTitleExpression(maskingUtils.concat([
new ContactTitleRenderer(Contact.createWithColumnPreset()).asSql()
......@@ -365,37 +376,39 @@ ContextUtils.getNameSql = function(pContextId, pRowId)
*/
ContextUtils.getContextDataSql = function(pContextId, pRowId, pWithDate, pActive, pWithState)
{
var selectMap = ContextUtils.getSelectMap ();
var selectMap = ContextUtils.getSelectMap();
var ownContextSelector = selectMap[pContextId];
var cond = SqlCondition.begin();
if (pRowId)
{
cond.andPrepare(selectMap[pContextId].tableName + "." + selectMap[pContextId].contactIdField, pRowId)
cond.andPrepare(ownContextSelector.tableName + "." + ownContextSelector.contactIdField, pRowId)
}
if (pActive != undefined)
{
var activeStates = selectMap[pContextId].activeStates;
var activeStates = ownContextSelector.activeStates;
if(activeStates != null && activeStates.length > 0)
{
var condSub = SqlCondition.begin();
activeStates.forEach(function (state)
{
if(pActive)
condSub.orPrepare(selectMap[pContextId].tableName + "." + selectMap[pContextId].stateField, state)
condSub.orPrepare(ownContextSelector.tableName + "." + ownContextSelector.stateField, state)
else
condSub.andPrepare(selectMap[pContextId].tableName + "." + selectMap[pContextId].stateField, state, "# != ?")
condSub.andPrepare(ownContextSelector.tableName + "." + ownContextSelector.stateField, state, "# != ?")
});
cond.andSqlCondition(condSub);
}
}
var dateColumn = "";
if (pWithDate === true)
dateColumn = ", " + (selectMap[pContextId].creationDateField || "''");
dateColumn = ", " + (ownContextSelector.creationDateField || "''");
var stateColumn = "";
if (pWithState === true)
stateColumn = ", " + (selectMap[pContextId].stateField || "''");
return cond.buildSql("select " + selectMap[pContextId].getFullIdField() + ", " + selectMap[pContextId].titleExpression + dateColumn + stateColumn
+ " from " + selectMap[pContextId].getFullFromClause(), "1=1");
stateColumn = ", " + (ownContextSelector.stateField || "''");
if (ownContextSelector.condition)
cond.andSqlCondition(ownContextSelector.condition);
var res = cond.buildSql("select " + ownContextSelector.getFullIdField() + ", " + ownContextSelector.titleExpression + dateColumn + stateColumn
+ " from " + ownContextSelector.getFullFromClause(), "1=1");
return res;
}
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