Skip to content
Snippets Groups Projects
Commit 48acf017 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

rename functions: relation to contact

parent f832c5bb
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 40 deletions
...@@ -2,4 +2,4 @@ import("system.result"); ...@@ -2,4 +2,4 @@ import("system.result");
import("system.vars"); import("system.vars");
import("Contact_lib") import("Contact_lib")
result.object(ContactUtils.getRelationType(vars.get("$field.CONTACTID"), vars.get("$field.PERSON_ID"), vars.get("$field.ORGANISATION_ID"))); result.object(ContactUtils.getContactType(vars.get("$field.CONTACTID"), vars.get("$field.PERSON_ID"), vars.get("$field.ORGANISATION_ID")));
\ No newline at end of file \ No newline at end of file
import("system.result"); import("system.result");
import("Contact_lib") import("Contact_lib")
result.string(ContactUtils.getFullRelationString()); result.string(ContactUtils.getFullContactString());
\ No newline at end of file \ No newline at end of file
...@@ -2,4 +2,4 @@ import("system.vars"); ...@@ -2,4 +2,4 @@ import("system.vars");
import("system.result"); import("system.result");
import("Contact_lib"); import("Contact_lib");
result.string(ContactUtils.getContextByRelationId(vars.getString("$field.CONTACT_ID"))); result.string(ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID")));
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,7 @@ var links = []; ...@@ -7,7 +7,7 @@ var links = [];
if (contactId) if (contactId)
{ {
links.push([ContactUtils.getContextByRelationId(contactId), contactId]); links.push([ContactUtils.getContextByContactId(contactId), contactId]);
} }
if (vars.get("$field.SALESPROJECT_ID")) if (vars.get("$field.SALESPROJECT_ID"))
......
...@@ -2,4 +2,4 @@ import("system.vars"); ...@@ -2,4 +2,4 @@ import("system.vars");
import("system.result"); import("system.result");
import("Contact_lib"); import("Contact_lib");
result.string(ContactUtils.getContextByRelationId(vars.getString("$field.CONTACT_ID"))); result.string(ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID")));
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,7 @@ var links = []; ...@@ -7,7 +7,7 @@ var links = [];
if (contactId) if (contactId)
{ {
links.push([ContactUtils.getContextByRelationId(contactId), contactId]); links.push([ContactUtils.getContextByContactId(contactId), contactId]);
} }
if (vars.get("$field.SALESPROJECT_ID")) if (vars.get("$field.SALESPROJECT_ID"))
......
...@@ -7,7 +7,7 @@ var links = []; ...@@ -7,7 +7,7 @@ var links = [];
if (contactId) if (contactId)
{ {
links.push([ContactUtils.getContextByRelationId(contactId), contactId]); links.push([ContactUtils.getContextByContactId(contactId), contactId]);
} }
if (vars.get("$field.SALESPROJECT_ID")) if (vars.get("$field.SALESPROJECT_ID"))
......
...@@ -2,7 +2,7 @@ import("system.vars"); ...@@ -2,7 +2,7 @@ import("system.vars");
import("system.result"); import("system.result");
import("Contact_lib"); import("Contact_lib");
var type = ContactUtils.getRelationType(vars.get("$field.CONTACT_ID"), vars.get("$field.CONTACT_PERSON_ID"), vars.get("$field.CONTACT_ORG_ID")); var type = ContactUtils.getContactType(vars.get("$field.CONTACT_ID"), vars.get("$field.CONTACT_PERSON_ID"), vars.get("$field.CONTACT_ORG_ID"));
result.string(type != 2); result.string(type != 2);
......
...@@ -7,7 +7,7 @@ var links = []; ...@@ -7,7 +7,7 @@ var links = [];
if (contactId) if (contactId)
{ {
links.push([ContactUtils.getContextByRelationId(contactId), contactId]); links.push([ContactUtils.getContextByContactId(contactId), contactId]);
} }
if (vars.get("$field.SALESPROJECT_ID")) if (vars.get("$field.SALESPROJECT_ID"))
......
...@@ -7,7 +7,7 @@ var links = []; ...@@ -7,7 +7,7 @@ var links = [];
if (contactId) if (contactId)
{ {
links.push([ContactUtils.getContextByRelationId(contactId), contactId]); links.push([ContactUtils.getContextByContactId(contactId), contactId]);
} }
if (vars.get("$field.SALESPROJECT_ID")) if (vars.get("$field.SALESPROJECT_ID"))
......
...@@ -2,4 +2,4 @@ import("system.vars"); ...@@ -2,4 +2,4 @@ import("system.vars");
import("system.result"); import("system.result");
import("Contact_lib"); import("Contact_lib");
result.string(ContactUtils.getContextByRelationId(vars.getString("$field.CONTACT_ID"))); result.string(ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID")));
\ No newline at end of file \ No newline at end of file
...@@ -7,7 +7,7 @@ var links = []; ...@@ -7,7 +7,7 @@ var links = [];
if (contactId) if (contactId)
{ {
links.push([ContactUtils.getContextByRelationId(contactId), contactId]); links.push([ContactUtils.getContextByContactId(contactId), contactId]);
} }
if (vars.get("$field.SALESPROJECT_ID")) if (vars.get("$field.SALESPROJECT_ID"))
......
...@@ -7,7 +7,7 @@ var links = []; ...@@ -7,7 +7,7 @@ var links = [];
if (contactId) if (contactId)
{ {
links.push([ContactUtils.getContextByRelationId(contactId), contactId]); links.push([ContactUtils.getContextByContactId(contactId), contactId]);
} }
if (vars.get("$field.SALESPROJECT_ID")) if (vars.get("$field.SALESPROJECT_ID"))
......
...@@ -7,7 +7,7 @@ var links = []; ...@@ -7,7 +7,7 @@ var links = [];
if (contactId) if (contactId)
{ {
links.push([ContactUtils.getContextByRelationId(contactId), contactId]); links.push([ContactUtils.getContextByContactId(contactId), contactId]);
} }
if (vars.get("$field.SALESPROJECT_ID")) if (vars.get("$field.SALESPROJECT_ID"))
......
...@@ -187,6 +187,7 @@ ...@@ -187,6 +187,7 @@
<consumer>Addresses</consumer> <consumer>Addresses</consumer>
<searchable v="false" /> <searchable v="false" />
<state>AUTO</state> <state>AUTO</state>
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/address_id/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/Organisation_entity/entityfields/address_id/displayValueProcess.js</displayValueProcess> <displayValueProcess>%aditoprj%/entity/Organisation_entity/entityfields/address_id/displayValueProcess.js</displayValueProcess>
</entityField> </entityField>
<entityConsumer> <entityConsumer>
...@@ -639,6 +640,7 @@ ...@@ -639,6 +640,7 @@
<alias>Data_alias</alias> <alias>Data_alias</alias>
<fromClauseProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess> <fromClauseProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess>
<conditionProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/conditionProcess.js</conditionProcess> <conditionProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
<onDBInsert>%aditoprj%/entity/Organisation_entity/recordcontainers/db/onDBInsert.js</onDBInsert>
<onDBUpdate>%aditoprj%/entity/Organisation_entity/recordcontainers/db/onDBUpdate.js</onDBUpdate> <onDBUpdate>%aditoprj%/entity/Organisation_entity/recordcontainers/db/onDBUpdate.js</onDBUpdate>
<linkInformation> <linkInformation>
<linkInformation> <linkInformation>
......
import("system.logging");
import("system.vars");
...@@ -50,7 +50,7 @@ function ContactUtils() {} ...@@ -50,7 +50,7 @@ function ContactUtils() {}
* This saves an extra select from CONTACT. <br> * This saves an extra select from CONTACT. <br>
* <br> * <br>
* <br> * <br>
* @param {String} pRelationId * @param {String} pContactId
* @param {String} pPersId selected from the CONTACT table * @param {String} pPersId selected from the CONTACT table
* @param {String} pOrgId selected from the CONTACT table * @param {String} pOrgId selected from the CONTACT table
* <br> * <br>
...@@ -59,34 +59,34 @@ function ContactUtils() {} ...@@ -59,34 +59,34 @@ function ContactUtils() {}
* 2 if privat person <br> * 2 if privat person <br>
* 3 if person of an organisation <br> * 3 if person of an organisation <br>
*/ */
ContactUtils.getRelationType = function(pRelationId, pPersId, pOrgId) ContactUtils.getContactType = function(pContactId, pPersId, pOrgId)
{ {
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{ {
return ContactUtils.getRelationTypeByRelation(pRelationId); return ContactUtils.getContactTypeByContact(pContactId);
} }
else else
{ {
return ContactUtils.getRelationTypeByPersOrg(pPersId, pOrgId); return ContactUtils.getContactTypeByPersOrg(pPersId, pOrgId);
} }
} }
/** /**
* get the type of contact for a relationId <br> * get the type of contact for a relationId <br>
* If you already have persId and orgId from the CONTACT table, use getRelationTypeByPersOrg() <br> * If you already have persId and orgId from the CONTACT table, use getContactTypeByPersOrg() <br>
* @param {String} pRelationId * @param {String} pContactId
* <br> * <br>
* @return {Integer} 0 if relationId not found <br> * @return {Integer} 0 if relationId not found <br>
* 1 if organisation <br> * 1 if organisation <br>
* 2 if privat person <br> * 2 if privat person <br>
* 3 if person of an organisation <br> * 3 if person of an organisation <br>
*/ */
ContactUtils.getRelationTypeByRelation = function(pRelationId) ContactUtils.getContactTypeByContact = function(pContactId)
{ {
var relationData = ContactUtils.getPersOrgIds(pRelationId); var relationData = ContactUtils.getPersOrgIds(pContactId);
if (relationData[0]) if (relationData[0])
{ {
return this.getRelationTypeByPersOrg(relationData[1], relationData[2]); return this.getContactTypeByPersOrg(relationData[1], relationData[2]);
} }
else else
{ {
...@@ -102,7 +102,7 @@ ContactUtils.getRelationTypeByRelation = function(pRelationId) ...@@ -102,7 +102,7 @@ ContactUtils.getRelationTypeByRelation = function(pRelationId)
* !!It does not check if the person / org ids really exist!! <br> * !!It does not check if the person / org ids really exist!! <br>
* !!And it does not check if really any contact with this person / org ids exist!! <br> * !!And it does not check if really any contact with this person / org ids exist!! <br>
* <br> * <br>
* This function is more performant than getRelationTypeByRelation, <br> * This function is more performant than getContactTypeByContact, <br>
* because it doesn't load something from the db. <br> * because it doesn't load something from the db. <br>
* <br> * <br>
* It is meant to be used by entitys, where you can load person and org with the DataRecord. <br> * It is meant to be used by entitys, where you can load person and org with the DataRecord. <br>
...@@ -116,7 +116,7 @@ ContactUtils.getRelationTypeByRelation = function(pRelationId) ...@@ -116,7 +116,7 @@ ContactUtils.getRelationTypeByRelation = function(pRelationId)
* 2 if privat person <br> * 2 if privat person <br>
* 3 if person of an organisation <br> * 3 if person of an organisation <br>
*/ */
ContactUtils.getRelationTypeByPersOrg = function(pPersId, pOrgId) ContactUtils.getContactTypeByPersOrg = function(pPersId, pOrgId)
{ {
if (!pPersId) if (!pPersId)
{ {
...@@ -147,7 +147,7 @@ ContactUtils.getRelationTypeByPersOrg = function(pPersId, pOrgId) ...@@ -147,7 +147,7 @@ ContactUtils.getRelationTypeByPersOrg = function(pPersId, pOrgId)
* !!It does not check if the person / org ids really exist!! <br> * !!It does not check if the person / org ids really exist!! <br>
* !!And it does not check if really any contact with this person / org ids exist!! <br> * !!And it does not check if really any contact with this person / org ids exist!! <br>
* <br> * <br>
* This function is more performant than getContextByRelationId, <br> * This function is more performant than getContextByContactId, <br>
* because it doesn't load something from the db. <br> * because it doesn't load something from the db. <br>
* <br> * <br>
* It is meant to be used by entitys, where you can load person and org with the DataRecord. <br> * It is meant to be used by entitys, where you can load person and org with the DataRecord. <br>
...@@ -161,7 +161,7 @@ ContactUtils.getRelationTypeByPersOrg = function(pPersId, pOrgId) ...@@ -161,7 +161,7 @@ ContactUtils.getRelationTypeByPersOrg = function(pPersId, pOrgId)
*/ */
ContactUtils.getContextByPersOrg = function(pPersId, pOrgId) ContactUtils.getContextByPersOrg = function(pPersId, pOrgId)
{ {
switch (ContactUtils.getRelationTypeByPersOrg(pPersId, pOrgId)) switch (ContactUtils.getContactTypeByPersOrg(pPersId, pOrgId))
{ {
case 1: // Org case 1: // Org
return ContextUtils.getContextName("Organisation"); return ContextUtils.getContextName("Organisation");
...@@ -177,27 +177,27 @@ ContactUtils.getContextByPersOrg = function(pPersId, pOrgId) ...@@ -177,27 +177,27 @@ ContactUtils.getContextByPersOrg = function(pPersId, pOrgId)
* return the corresponding context of the contact <br> * return the corresponding context of the contact <br>
* If you already have persId and orgId from the CONTACT table, use getContextByPersOrg() <br> * If you already have persId and orgId from the CONTACT table, use getContextByPersOrg() <br>
* *
* @param {String} pRelationId * @param {String} pContactId
* @return {String} contextname or "" if contact not found * @return {String} contextname or "" if contact not found
*/ */
ContactUtils.getContextByRelationId = function(pRelationId) ContactUtils.getContextByContactId = function(pContactId)
{ {
var relationData = ContactUtils.getPersOrgIds(pRelationId); var relationData = ContactUtils.getPersOrgIds(pContactId);
return ContactUtils.getContextByPersOrg(relationData[1], relationData[2]) return ContactUtils.getContextByPersOrg(relationData[1], relationData[2])
} }
/** /**
* get the person- and org-id from a contact as array * get the person- and org-id from a contact as array
* *
* @param {String} pRelationId * @param {String} pContactId
* @return {String[]} result as [persid, orgid] if one of them is null in the db, "" will be returned as the id. * @return {String[]} result as [persid, orgid] if one of them is null in the db, "" will be returned as the id.
*/ */
ContactUtils.getPersOrgIds = function(pRelationId) ContactUtils.getPersOrgIds = function(pContactId)
{ {
if (pRelationId) { if (pContactId) {
return db.array(db.ROW, return db.array(db.ROW,
SqlCondition.begin() SqlCondition.begin()
.andPrepare("CONTACT.CONTACTID", pRelationId) .andPrepare("CONTACT.CONTACTID", pContactId)
.buildSql("select CONTACTID, PERSON_ID, ORGANISATION_ID from CONTACT", "1=0")); .buildSql("select CONTACTID, PERSON_ID, ORGANISATION_ID from CONTACT", "1=0"));
} }
...@@ -264,14 +264,13 @@ ContactUtils.getTitleByPersonId = function(pPersonId) ...@@ -264,14 +264,13 @@ ContactUtils.getTitleByPersonId = function(pPersonId)
* *
* @return {String} * @return {String}
*/ */
ContactUtils.getFullRelationString = function() ContactUtils.getFullContactString = function()
{ {
return " CONTACT join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID" return " CONTACT join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID"
+ " left join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID" + " left join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID"
+ " left join ADDRESS on ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID"; + " left join ADDRESS on ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID";
} }
/** /**
* object for handling of a single contact * object for handling of a single contact
* provides static- and instance-functions * provides static- and instance-functions
......
...@@ -63,8 +63,8 @@ AddressUtils.getFormattedOnlineAddressById = function(pAddressId) ...@@ -63,8 +63,8 @@ AddressUtils.getFormattedOnlineAddressById = function(pAddressId)
* *
* @return {String} * @return {String}
*/ */
AddressUtils.getAddress = function(pRelationId) { AddressUtils.getAddress = function(pContactId) {
var address = db.array(db.ROW, SqlCondition.begin().andPrepare("CONTACT.CONTACTID", pRelationId).buildSql('select CONTACTID, ADDRESS, BUILDINGNO, ZIP, CITY, "NAME", FIRSTNAME, LASTNAME, TITLE from' + ContactUtils.getFullRelationString(), "1=0")); var address = db.array(db.ROW, SqlCondition.begin().andPrepare("CONTACT.CONTACTID", pContactId).buildSql('select CONTACTID, ADDRESS, BUILDINGNO, ZIP, CITY, "NAME", FIRSTNAME, LASTNAME, TITLE from' + ContactUtils.getFullContactString(), "1=0"));
// TODO: currently there are some relations without standard address. Use Hardcoded one. // TODO: currently there are some relations without standard address. Use Hardcoded one.
if (!address[1]) { if (!address[1]) {
...@@ -75,7 +75,7 @@ AddressUtils.getAddress = function(pRelationId) { ...@@ -75,7 +75,7 @@ AddressUtils.getAddress = function(pRelationId) {
address[4] = dummyAddress[3]; address[4] = dummyAddress[3];
} }
var type = ContactUtils.getRelationTypeByRelation(pRelationId); var type = ContactUtils.getContactTypeByContact(pContactId);
return AddressUtils.formatAddress(type, address[1], address[2], address[3], address[4], address[5], address[6], address[7], address[8]); return AddressUtils.formatAddress(type, address[1], address[2], address[3], address[4], address[5], address[6], address[7], address[8]);
} }
...@@ -103,7 +103,7 @@ AddressUtils.getAddressById = function(pAddressId) { ...@@ -103,7 +103,7 @@ AddressUtils.getAddressById = function(pAddressId) {
address[4] = dummyAddress[4]; address[4] = dummyAddress[4];
} }
var type = ContactUtils.getRelationTypeByRelation(address[0]); var type = ContactUtils.getContactTypeByContact(address[0]);
var names = db.array(db.ROW, SqlCondition.begin() var names = db.array(db.ROW, SqlCondition.begin()
.andPrepare("CONTACT.CONTACTID", address[0]) .andPrepare("CONTACT.CONTACTID", address[0])
......
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