Skip to content
Snippets Groups Projects
Commit 98f10e9f authored by Heinz Boesl's avatar Heinz Boesl
Browse files

360 changed

parent 4adfdfcb
No related branches found
No related tags found
No related merge requests found
Showing
with 65 additions and 121 deletions
......@@ -12,7 +12,7 @@
<column name="DUNNINGDATE" type="DATETIME"/>
<column name="DUNNINGLEVEL" type="VARCHAR(36)"/>
<column name="ORDERTYPE" type="VARCHAR(36)"/>
<column name="ORDERSTATUS" type="TINYINT"/>
<column name="ORDERSTATUS" type="VARCHAR(36)"/>
<column name="PAYMENTTERMS" type="VARCHAR(36)"/>
<column name="DELIVERYTERMS" type="VARCHAR(36)"/>
<column name="DELIVERYADDRESS" type="NCLOB"/>
......
......@@ -4568,8 +4568,8 @@
<name>ORDERSTATUS</name>
<dbName></dbName>
<primaryKey v="false" />
<columnType v="5" />
<size v="5" />
<columnType v="12" />
<size v="36" />
<scale v="0" />
<notNull v="false" />
<isUnique v="false" />
......
......@@ -47,11 +47,6 @@
<valueProcess>%aditoprj%/entity/360Degree_entity/entityfields/organisationobjects/children/objecttype_param/valueProcess.js</valueProcess>
<expose v="false" />
</entityParameter>
<entityParameter>
<name>BaseContextId_param</name>
<valueProcess>%aditoprj%/entity/360Degree_entity/entityfields/organisationobjects/children/basecontextid_param/valueProcess.js</valueProcess>
<expose v="false" />
</entityParameter>
</children>
</entityProvider>
<entityField>
......@@ -91,11 +86,6 @@
<valueProcess>%aditoprj%/entity/360Degree_entity/entityfields/personobjects/children/objecttype_param/valueProcess.js</valueProcess>
<expose v="false" />
</entityParameter>
<entityParameter>
<name>BaseContextId_param</name>
<valueProcess>%aditoprj%/entity/360Degree_entity/entityfields/personobjects/children/basecontextid_param/valueProcess.js</valueProcess>
<expose v="false" />
</entityParameter>
</children>
</entityProvider>
<entityField>
......@@ -166,10 +156,6 @@
<groupable v="true" />
<dropDownProcess>%aditoprj%/entity/360Degree_entity/entityfields/active/dropDownProcess.js</dropDownProcess>
</entityField>
<entityParameter>
<name>BaseContextId_param</name>
<expose v="true" />
</entityParameter>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......
import("system.result");
result.string("Organisation");
\ No newline at end of file
import("system.vars");
import("system.result");
result.object(["Salesproject", "Offer", "Order", "Contract", "Campaign", "Order"]);
\ No newline at end of file
result.object(["Salesproject", "Offer", "Order", "Contract", "Campaign", "SupportTicket"]);
\ No newline at end of file
import("system.result");
result.string("Person");
\ No newline at end of file
import("system.logging");
import("system.util");
import("system.db");
import("system.vars");
......@@ -6,12 +7,12 @@ import("Context_lib");
import("system.translate");
if (vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param") && vars.exists("$param.ObjectRowId_param") && vars.get("$param.ObjectRowId_param"))
{
{
var active;
var selectMap = ContextUtils.getSelectMap();
if(vars.exists("$local.filter") && vars.get("$local.filter") )
{
logging.log(JSON.stringify(vars.get("$local.filter")))
var filter = vars.get("$local.filter");
if (filter.filter)
if(filter.filter.childs != null && filter.filter.childs.length > 0)
......@@ -26,10 +27,7 @@ if (vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param"
var contextList = JSON.parse(vars.getString("$param.ObjectType_param"));
var contactId = vars.get("$param.ObjectRowId_param");
var baseContext = vars.exists("$param.BaseContextId_param") ? vars.get("$param.BaseContextId_param") : undefined;
result.object(_get360Data(selectMap, baseContext, contactId, contextList, active, undefined, baseContext != undefined));
result.object(_get360Data(selectMap, contactId, contextList, active));
}
else
{
......@@ -39,23 +37,18 @@ else
/**
* load all data for the 360Degree tree.
* @param {Object} pSelectMap the select map (result of ContextUtils.getSelectMap())
* @param {String} pBaseContextId the ContextId in which this 360 Degree tree is located / for which the data should be loaded
* @param {String[]} pContactId the Contactid the 360 Degree tree should be loaded for
* @param {String[]} pContextList list of contexts to load. Note that subcontexts use their own list, defined in ContextUtils
* @param {Boolean} [pActive=undefined] if not undefined: it select only for active / inactive state
* @param {String[]} [pExcludedObjectIds=undefined] if set: this contextIds are filtered out.
* @param {Boolean} [pAlsoAddFromSubcontexts=false] if true also load data from contexts which are configured as subcontexts.
* A subcontext is for example used by Organisations, which also load the data from all Persons in this organisation into the 360°-view.
* Does not include subcontexts of subcontexts
*
* @return {String[][]} the resulting data
*/
function _get360Data(pSelectMap, pBaseContextId, pContactId, pContextList, pActive, pExcludedObjectIds, pAlsoAddFromSubcontexts)
function _get360Data(pSelectMap, pContactId, pContextList, pActive)
{
var resultList = [];
pContextList.forEach(function (context)
{
var data = db.table(ContextUtils.getContextDataSql(context, pContactId, true, pActive, true, pExcludedObjectIds));
var data = db.table(ContextUtils.getContextDataSql(context, JSON.parse(pContactId), true, pActive, true));
data.forEach(function (row)
{
var active;
......@@ -63,10 +56,10 @@ function _get360Data(pSelectMap, pBaseContextId, pContactId, pContextList, pActi
active = translate.text(pActive);
else
{
if(pSelectMap[context].activeStates && pSelectMap[context].activeStates.indexOf(row[3]) > -1)
active = translate.text("true");
else
active = translate.text("false");
if(pSelectMap[context].activeStates && pSelectMap[context].activeStates.indexOf(row[3]) > -1)
active = translate.text("true");
else
active = translate.text("false");
}
resultList.push([
util.getNewUUID(), // UID
......@@ -76,33 +69,14 @@ function _get360Data(pSelectMap, pBaseContextId, pContactId, pContextList, pActi
row[2], //DATE
active,
ContextUtils.getEntityTitle(context, true)
]);
]);
});
});
});
if (pAlsoAddFromSubcontexts)
{
var baseContextData = pSelectMap[pBaseContextId];
var subContexts = baseContextData.getSubContexts(pContactId);
if (!pExcludedObjectIds)
pExcludedObjectIds = [];
pExcludedObjectIds.push(pBaseContextId);
for (subContextId in subContexts)
{
var subContextSelect = subContexts[subContextId][0];
// select Ids from subcontexts
var subContextContactIds = subContextSelect.arrayColumn();
subContextContactIds.forEach(function(pId) {
// V-- do not add subcontexts deeper than one layer
var subcontextRes = _get360Data(pSelectMap, pBaseContextId, pId, subContexts[subContextId][1], pActive, pExcludedObjectIds, false);
resultList = resultList.concat(subcontextRes);
});
}
}
return resultList;
resultList.sort(function (a,b) {
if (a[4] < b[4]) return 1;
if (a[4] > b[4]) return -1;
return 0;
})
return resultList;
}
\ No newline at end of file
import("Sql_lib");
import("system.vars");
import("system.result");
result.string(vars.getString("$field.CONTACTID"));//TODO: CONTACTID/ORGANISATIONID: review if this should be the CONTACTID or the ORGANISATIONID
\ No newline at end of file
var contactids = newSelect( "CONTACTID" )
.from("CONTACT")
.where("CONTACT.ORGANISATION_ID", vars.getString("$field.ORGANISATIONID"))
.arrayColumn();
result.string( JSON.stringify(contactids) );
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.getString("$field.CONTACTID"));
\ No newline at end of file
result.string(JSON.stringify([vars.getString("$field.CONTACTID")]));
\ No newline at end of file
......@@ -76,10 +76,10 @@ ContactUtils.getResolvingDisplaySubSql = function(pContactIdField)
var selectExpression = renderer.asSql();
//TODO: verify if there is a better solution for the usage of this as a displayValueExpression --> automatic use of #TITLE | waiting vor implementation
return "select " + selectExpression + "from CONTACT \n\
left join PERSON on (PERSON.PERSONID = CONTACT.PERSON_ID) \n\
left join ORGANISATION on (ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID) \n\
where CONTACT.CONTACTID = " + pContactIdField;
return "select " + selectExpression + "from CONTACT "
+ " left join PERSON on (PERSON.PERSONID = CONTACT.PERSON_ID) "
+ " left join ORGANISATION on (ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID) "
+ " where CONTACT.CONTACTID = " + pContactIdField;
}
/*
......@@ -323,9 +323,9 @@ ContactUtils.getOrganisationContactId = function(pAnyContactId)
var idSql = SqlCondition.begin()
.andPrepare("anyContact.CONTACTID", pAnyContactId, null, SqlUtils.getSingleColumnType("CONTACT", "CONTACTID"))
.and("CONTACT.PERSON_ID is null")
.buildSql("select CONTACT.CONTACTID \n\
from CONTACT\n\
join CONTACT anyContact on anyContact.ORGANISATION_ID = CONTACT.ORGANISATION_ID");
.buildSql("select CONTACT.CONTACTID "
+ " from CONTACT"
+ " join CONTACT anyContact on anyContact.ORGANISATION_ID = CONTACT.ORGANISATION_ID");
var id = db.cell(idSql);
return id;
}
......@@ -420,10 +420,10 @@ ContactUtils.getTitleByContactId = function(pContactId)
*/
ContactUtils.getFullContactString = function()
{
return " CONTACT \n\
join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID \n\
left join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID \n\
left join ADDRESS on ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID";
return " CONTACT "
+ " join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID "
+ " left join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID "
+ " left join ADDRESS on ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID";
}
/**
......
......@@ -28,7 +28,7 @@ function ContextUtils() {}
*/
ContextUtils.getCurrentContextId = function()
{
return vars.getString("$sys.currentcontextname");
return vars.getString("$sys.currentcontextname");
}
/**
......@@ -472,9 +472,9 @@ ContextUtils.getSelectMap = function()
,"' - '"
,"defaultAddress.COUNTRY", "defaultAddress.ZIP", "defaultAddress.CITY"
]," "))
.setJoinExpression("join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID \n\
join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID\n\
left join ADDRESS defaultAddress on defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID")
.setJoinExpression("join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID "
+ " join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID "
+ " left join ADDRESS defaultAddress on defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID")
,"PrivatePerson": ContextSelector.create("PERSON", "PERSONID")
.setTitleExpression(maskingUtils.concat([
new ContactTitleRenderer(Contact.createWithColumnPresetForPrivatePerson()).asSql()
......@@ -518,19 +518,16 @@ ContextUtils.getSelectMap = function()
.setContactIdField("CONTACT_ID")
.setCreationDateField("OFFERDATE")
.setStateField("STATUS")
.setActiveStates([$KeywordRegistry.offerStatus$open, $KeywordRegistry.offerStatus$checked, $KeywordRegistry.offerStatus$sent])
.setActiveStates([$KeywordRegistry.offerStatus$open(), $KeywordRegistry.offerStatus$checked(), $KeywordRegistry.offerStatus$sent()])
,"Order": ContextSelector.create("SALESORDER", "SALESORDERID")
.setTitleExpression(maskingUtils.concat([
"'" + translate.text("Order") + "'",
"' '",
maskingUtils.cast("SALESORDERCODE", SQLTYPES.VARCHAR, 10),
"'-'",
maskingUtils.cast("VERSNR", SQLTYPES.VARCHAR, 10)
], "", false))
KeywordUtils.getResolvedTitleSqlPart("OrderType", "ORDERTYPE"),
maskingUtils.cast("SALESORDERCODE", SQLTYPES.VARCHAR, 10)
], " "))
.setContactIdField("CONTACT_ID")
.setCreationDateField("SALESORDERDATE")
.setStateField("ORDERSTATUS")
.setActiveStates([$KeywordRegistry.salesorderState$checked, $KeywordRegistry.salesorderState$sent])
.setActiveStates([$KeywordRegistry.salesorderState$checked(), $KeywordRegistry.salesorderState$sent()])
,"Product": ContextSelector.create("PRODUCT", "PRODUCTID")
.setTitleExpression(maskingUtils.concat([
"PRODUCTCODE",
......@@ -625,34 +622,29 @@ ContextUtils.getContactId = function(pContextId, pRowId)
/**
* TODO: !!!temporary function until you can get fields from another Entity!!!
* nur 360
*
*/
ContextUtils.getContextDataSql = function(pContextId, pContactId, pWithDate, pActive, pWithState, pExcludedObjectIds)
ContextUtils.getContextDataSql = function(pContextId, pContactId, pWithDate, pActive, pWithState )
{
var selectMap = ContextUtils.getSelectMap();
var ownContextSelector = selectMap[pContextId];
var columns = [ownContextSelector.getFullIdField(), ownContextSelector.titleExpression];
var dateColumn = "";
if (pWithDate === true)
dateColumn = ", " + (ownContextSelector.getFullField(ownContextSelector.creationDateField) || "''");
var stateColumn = "";
columns.push(ownContextSelector.getFullField(ownContextSelector.creationDateField) || "''");
if (pWithState === true)
{
if (ownContextSelector.stateField)
stateColumn = ", " + (ownContextSelector.getFullField(ownContextSelector.stateField) || "''");
columns.push(ownContextSelector.getFullField(ownContextSelector.stateField) || "''");
else
stateColumn = ", ''";
columns.push("''");
}
var contextDataSelect = newSelect(ownContextSelector.getFullIdField() + ", " + ownContextSelector.titleExpression + dateColumn + stateColumn)
var contextDataSelect = newSelect( columns.join(", ") )
.from(ownContextSelector.getFullFromClause())
.where();
if (pContactId)
{
contextDataSelect.and(ownContextSelector.getFullField(ownContextSelector.contactIdField), pContactId)
}
.where(ownContextSelector.getFullField(ownContextSelector.contactIdField), pContactId, SqlBuilder.IN());
if (pActive != undefined)
{
......@@ -673,17 +665,9 @@ ContextUtils.getContextDataSql = function(pContextId, pContactId, pWithDate, pAc
});
contextDataSelect.andIfSet(condSub);
}
}
if (pExcludedObjectIds)
{
contextDataSelect.and(ownContextSelector.getFullIdField(), pExcludedObjectIds, SqlBuilder.NOT_IN());
}
contextDataSelect.andIfSet(ownContextSelector.condition);
var res = contextDataSelect.build();
return res;
}
contextDataSelect.andIfSet(ownContextSelector.condition);
return contextDataSelect.build();
}
/**
......
......@@ -1643,7 +1643,7 @@ SqlBuilder.prototype._or = function(pFieldOrCond, pValue, pMandatory, pCondition
* @return {String}
*
* @example
* var cond = newWhere("PERSON.FIRSTNAME", "Fritz", SqlBuilder.NOT_IN())
* var cond = newWhere("PERSON.FIRSTNAME", ["Fritz"], SqlBuilder.NOT_IN())
*/
SqlBuilder.NOT_IN = function()
{
......@@ -1656,7 +1656,7 @@ SqlBuilder.NOT_IN = function()
* @return {String}
*
* @example
* var cond = newWhere("PERSON.FIRSTNAME", "Fritz", SqlBuilder.IN())
* var cond = newWhere("PERSON.FIRSTNAME", ["Fritz"], SqlBuilder.IN())
*/
SqlBuilder.IN = function()
{
......
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