From 48acf017479a35204ac688314ebbe63b2c596a13 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Mon, 25 Mar 2019 15:25:24 +0100 Subject: [PATCH] rename functions: relation to contact --- .../entityfields/contacttype/valueProcess.js | 2 +- .../recordcontainers/db/fromClauseProcess.js | 2 +- .../contact_id/linkedContextProcess.js | 2 +- .../presetlinks_param/valueProcess.js | 2 +- .../contact_id/linkedContextProcess.js | 2 +- .../newactivity/onActionProcess.js | 2 +- .../entityfields/newtask/onActionProcess.js | 2 +- .../salesproject_id/mandatoryProcess.js | 2 +- .../presetlinks_param/valueProcess.js | 2 +- .../presetlinks_param/valueProcess.js | 2 +- .../contact_id/linkedContextProcess.js | 2 +- .../newactivity/onActionProcess.js | 2 +- .../entityfields/newtask/onActionProcess.js | 2 +- .../presetlinks_param/valueProcess.js | 2 +- .../Organisation_entity.aod | 2 + .../recordcontainers/db/onDBInsert.js | 3 ++ process/Contact_lib/process.js | 43 +++++++++---------- process/PostalAddress_lib/process.js | 8 ++-- 18 files changed, 44 insertions(+), 40 deletions(-) create mode 100644 entity/Organisation_entity/recordcontainers/db/onDBInsert.js diff --git a/entity/AnyContact_entity/entityfields/contacttype/valueProcess.js b/entity/AnyContact_entity/entityfields/contacttype/valueProcess.js index 32bb8ca197..1974bb4d5a 100644 --- a/entity/AnyContact_entity/entityfields/contacttype/valueProcess.js +++ b/entity/AnyContact_entity/entityfields/contacttype/valueProcess.js @@ -2,4 +2,4 @@ import("system.result"); import("system.vars"); import("Contact_lib") -result.object(ContactUtils.getRelationType(vars.get("$field.CONTACTID"), vars.get("$field.PERSON_ID"), vars.get("$field.ORGANISATION_ID"))); \ No newline at end of file +result.object(ContactUtils.getContactType(vars.get("$field.CONTACTID"), vars.get("$field.PERSON_ID"), vars.get("$field.ORGANISATION_ID"))); \ No newline at end of file diff --git a/entity/AnyContact_entity/recordcontainers/db/fromClauseProcess.js b/entity/AnyContact_entity/recordcontainers/db/fromClauseProcess.js index c2008fc0d1..7dc4c1aa3f 100644 --- a/entity/AnyContact_entity/recordcontainers/db/fromClauseProcess.js +++ b/entity/AnyContact_entity/recordcontainers/db/fromClauseProcess.js @@ -1,4 +1,4 @@ import("system.result"); import("Contact_lib") -result.string(ContactUtils.getFullRelationString()); \ No newline at end of file +result.string(ContactUtils.getFullContactString()); \ No newline at end of file diff --git a/entity/Contract_entity/entityfields/contact_id/linkedContextProcess.js b/entity/Contract_entity/entityfields/contact_id/linkedContextProcess.js index e678b842c5..2e504d63e3 100644 --- a/entity/Contract_entity/entityfields/contact_id/linkedContextProcess.js +++ b/entity/Contract_entity/entityfields/contact_id/linkedContextProcess.js @@ -2,4 +2,4 @@ import("system.vars"); import("system.result"); import("Contact_lib"); -result.string(ContactUtils.getContextByRelationId(vars.getString("$field.CONTACT_ID"))); \ No newline at end of file +result.string(ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID"))); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/activities/children/presetlinks_param/valueProcess.js b/entity/Offer_entity/entityfields/activities/children/presetlinks_param/valueProcess.js index db35a547ac..e4c6c134df 100644 --- a/entity/Offer_entity/entityfields/activities/children/presetlinks_param/valueProcess.js +++ b/entity/Offer_entity/entityfields/activities/children/presetlinks_param/valueProcess.js @@ -7,7 +7,7 @@ var links = []; if (contactId) { - links.push([ContactUtils.getContextByRelationId(contactId), contactId]); + links.push([ContactUtils.getContextByContactId(contactId), contactId]); } if (vars.get("$field.SALESPROJECT_ID")) diff --git a/entity/Offer_entity/entityfields/contact_id/linkedContextProcess.js b/entity/Offer_entity/entityfields/contact_id/linkedContextProcess.js index e678b842c5..2e504d63e3 100644 --- a/entity/Offer_entity/entityfields/contact_id/linkedContextProcess.js +++ b/entity/Offer_entity/entityfields/contact_id/linkedContextProcess.js @@ -2,4 +2,4 @@ import("system.vars"); import("system.result"); import("Contact_lib"); -result.string(ContactUtils.getContextByRelationId(vars.getString("$field.CONTACT_ID"))); \ No newline at end of file +result.string(ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID"))); \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/newactivity/onActionProcess.js b/entity/Offer_entity/entityfields/newactivity/onActionProcess.js index d0e6ebcf2b..4be677edd5 100644 --- a/entity/Offer_entity/entityfields/newactivity/onActionProcess.js +++ b/entity/Offer_entity/entityfields/newactivity/onActionProcess.js @@ -7,7 +7,7 @@ var links = []; if (contactId) { - links.push([ContactUtils.getContextByRelationId(contactId), contactId]); + links.push([ContactUtils.getContextByContactId(contactId), contactId]); } if (vars.get("$field.SALESPROJECT_ID")) diff --git a/entity/Offer_entity/entityfields/newtask/onActionProcess.js b/entity/Offer_entity/entityfields/newtask/onActionProcess.js index b77c8343aa..f0165851ed 100644 --- a/entity/Offer_entity/entityfields/newtask/onActionProcess.js +++ b/entity/Offer_entity/entityfields/newtask/onActionProcess.js @@ -7,7 +7,7 @@ var links = []; if (contactId) { - links.push([ContactUtils.getContextByRelationId(contactId), contactId]); + links.push([ContactUtils.getContextByContactId(contactId), contactId]); } if (vars.get("$field.SALESPROJECT_ID")) diff --git a/entity/Offer_entity/entityfields/salesproject_id/mandatoryProcess.js b/entity/Offer_entity/entityfields/salesproject_id/mandatoryProcess.js index 05b1f9bd5c..3bd7da35b2 100644 --- a/entity/Offer_entity/entityfields/salesproject_id/mandatoryProcess.js +++ b/entity/Offer_entity/entityfields/salesproject_id/mandatoryProcess.js @@ -2,7 +2,7 @@ import("system.vars"); import("system.result"); 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); diff --git a/entity/Offer_entity/entityfields/tasks/children/presetlinks_param/valueProcess.js b/entity/Offer_entity/entityfields/tasks/children/presetlinks_param/valueProcess.js index db35a547ac..e4c6c134df 100644 --- a/entity/Offer_entity/entityfields/tasks/children/presetlinks_param/valueProcess.js +++ b/entity/Offer_entity/entityfields/tasks/children/presetlinks_param/valueProcess.js @@ -7,7 +7,7 @@ var links = []; if (contactId) { - links.push([ContactUtils.getContextByRelationId(contactId), contactId]); + links.push([ContactUtils.getContextByContactId(contactId), contactId]); } if (vars.get("$field.SALESPROJECT_ID")) diff --git a/entity/Order_entity/entityfields/activities/children/presetlinks_param/valueProcess.js b/entity/Order_entity/entityfields/activities/children/presetlinks_param/valueProcess.js index db35a547ac..e4c6c134df 100644 --- a/entity/Order_entity/entityfields/activities/children/presetlinks_param/valueProcess.js +++ b/entity/Order_entity/entityfields/activities/children/presetlinks_param/valueProcess.js @@ -7,7 +7,7 @@ var links = []; if (contactId) { - links.push([ContactUtils.getContextByRelationId(contactId), contactId]); + links.push([ContactUtils.getContextByContactId(contactId), contactId]); } if (vars.get("$field.SALESPROJECT_ID")) diff --git a/entity/Order_entity/entityfields/contact_id/linkedContextProcess.js b/entity/Order_entity/entityfields/contact_id/linkedContextProcess.js index e678b842c5..2e504d63e3 100644 --- a/entity/Order_entity/entityfields/contact_id/linkedContextProcess.js +++ b/entity/Order_entity/entityfields/contact_id/linkedContextProcess.js @@ -2,4 +2,4 @@ import("system.vars"); import("system.result"); import("Contact_lib"); -result.string(ContactUtils.getContextByRelationId(vars.getString("$field.CONTACT_ID"))); \ No newline at end of file +result.string(ContactUtils.getContextByContactId(vars.getString("$field.CONTACT_ID"))); \ No newline at end of file diff --git a/entity/Order_entity/entityfields/newactivity/onActionProcess.js b/entity/Order_entity/entityfields/newactivity/onActionProcess.js index 52c2254f6f..1a27d3d454 100644 --- a/entity/Order_entity/entityfields/newactivity/onActionProcess.js +++ b/entity/Order_entity/entityfields/newactivity/onActionProcess.js @@ -7,7 +7,7 @@ var links = []; if (contactId) { - links.push([ContactUtils.getContextByRelationId(contactId), contactId]); + links.push([ContactUtils.getContextByContactId(contactId), contactId]); } if (vars.get("$field.SALESPROJECT_ID")) diff --git a/entity/Order_entity/entityfields/newtask/onActionProcess.js b/entity/Order_entity/entityfields/newtask/onActionProcess.js index a2fb8e983a..3d0aeaf0be 100644 --- a/entity/Order_entity/entityfields/newtask/onActionProcess.js +++ b/entity/Order_entity/entityfields/newtask/onActionProcess.js @@ -7,7 +7,7 @@ var links = []; if (contactId) { - links.push([ContactUtils.getContextByRelationId(contactId), contactId]); + links.push([ContactUtils.getContextByContactId(contactId), contactId]); } if (vars.get("$field.SALESPROJECT_ID")) diff --git a/entity/Order_entity/entityfields/tasks/children/presetlinks_param/valueProcess.js b/entity/Order_entity/entityfields/tasks/children/presetlinks_param/valueProcess.js index db35a547ac..e4c6c134df 100644 --- a/entity/Order_entity/entityfields/tasks/children/presetlinks_param/valueProcess.js +++ b/entity/Order_entity/entityfields/tasks/children/presetlinks_param/valueProcess.js @@ -7,7 +7,7 @@ var links = []; if (contactId) { - links.push([ContactUtils.getContextByRelationId(contactId), contactId]); + links.push([ContactUtils.getContextByContactId(contactId), contactId]); } if (vars.get("$field.SALESPROJECT_ID")) diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 1c9253f9ce..ea7df11cc5 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -187,6 +187,7 @@ <consumer>Addresses</consumer> <searchable v="false" /> <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> </entityField> <entityConsumer> @@ -639,6 +640,7 @@ <alias>Data_alias</alias> <fromClauseProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess> <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> <linkInformation> <linkInformation> diff --git a/entity/Organisation_entity/recordcontainers/db/onDBInsert.js b/entity/Organisation_entity/recordcontainers/db/onDBInsert.js new file mode 100644 index 0000000000..ba0e67422c --- /dev/null +++ b/entity/Organisation_entity/recordcontainers/db/onDBInsert.js @@ -0,0 +1,3 @@ +import("system.logging"); +import("system.vars"); + diff --git a/process/Contact_lib/process.js b/process/Contact_lib/process.js index b3e659f848..c3b389da09 100644 --- a/process/Contact_lib/process.js +++ b/process/Contact_lib/process.js @@ -50,7 +50,7 @@ function ContactUtils() {} * This saves an extra select from CONTACT. <br> * <br> * <br> - * @param {String} pRelationId + * @param {String} pContactId * @param {String} pPersId selected from the CONTACT table * @param {String} pOrgId selected from the CONTACT table * <br> @@ -59,34 +59,34 @@ function ContactUtils() {} * 2 if privat person <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) { - return ContactUtils.getRelationTypeByRelation(pRelationId); + return ContactUtils.getContactTypeByContact(pContactId); } else { - return ContactUtils.getRelationTypeByPersOrg(pPersId, pOrgId); + return ContactUtils.getContactTypeByPersOrg(pPersId, pOrgId); } } /** * get the type of contact for a relationId <br> - * If you already have persId and orgId from the CONTACT table, use getRelationTypeByPersOrg() <br> - * @param {String} pRelationId + * If you already have persId and orgId from the CONTACT table, use getContactTypeByPersOrg() <br> + * @param {String} pContactId * <br> * @return {Integer} 0 if relationId not found <br> * 1 if organisation <br> * 2 if privat person <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]) { - return this.getRelationTypeByPersOrg(relationData[1], relationData[2]); + return this.getContactTypeByPersOrg(relationData[1], relationData[2]); } else { @@ -102,7 +102,7 @@ ContactUtils.getRelationTypeByRelation = function(pRelationId) * !!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> * <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> * <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) * 2 if privat person <br> * 3 if person of an organisation <br> */ -ContactUtils.getRelationTypeByPersOrg = function(pPersId, pOrgId) +ContactUtils.getContactTypeByPersOrg = function(pPersId, pOrgId) { if (!pPersId) { @@ -147,7 +147,7 @@ ContactUtils.getRelationTypeByPersOrg = function(pPersId, pOrgId) * !!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> * <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> * <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) */ ContactUtils.getContextByPersOrg = function(pPersId, pOrgId) { - switch (ContactUtils.getRelationTypeByPersOrg(pPersId, pOrgId)) + switch (ContactUtils.getContactTypeByPersOrg(pPersId, pOrgId)) { case 1: // Org return ContextUtils.getContextName("Organisation"); @@ -177,27 +177,27 @@ ContactUtils.getContextByPersOrg = function(pPersId, pOrgId) * return the corresponding context of the contact <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 */ -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]) } /** * 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. */ -ContactUtils.getPersOrgIds = function(pRelationId) +ContactUtils.getPersOrgIds = function(pContactId) { - if (pRelationId) { + if (pContactId) { return db.array(db.ROW, SqlCondition.begin() - .andPrepare("CONTACT.CONTACTID", pRelationId) + .andPrepare("CONTACT.CONTACTID", pContactId) .buildSql("select CONTACTID, PERSON_ID, ORGANISATION_ID from CONTACT", "1=0")); } @@ -264,14 +264,13 @@ ContactUtils.getTitleByPersonId = function(pPersonId) * * @return {String} */ -ContactUtils.getFullRelationString = function() +ContactUtils.getFullContactString = function() { 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"; } - /** * object for handling of a single contact * provides static- and instance-functions diff --git a/process/PostalAddress_lib/process.js b/process/PostalAddress_lib/process.js index 40445e11ec..7c96f2e623 100644 --- a/process/PostalAddress_lib/process.js +++ b/process/PostalAddress_lib/process.js @@ -63,8 +63,8 @@ AddressUtils.getFormattedOnlineAddressById = function(pAddressId) * * @return {String} */ -AddressUtils.getAddress = function(pRelationId) { - 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")); +AddressUtils.getAddress = function(pContactId) { + 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. if (!address[1]) { @@ -75,7 +75,7 @@ AddressUtils.getAddress = function(pRelationId) { 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]); } @@ -103,7 +103,7 @@ AddressUtils.getAddressById = function(pAddressId) { address[4] = dummyAddress[4]; } - var type = ContactUtils.getRelationTypeByRelation(address[0]); + var type = ContactUtils.getContactTypeByContact(address[0]); var names = db.array(db.ROW, SqlCondition.begin() .andPrepare("CONTACT.CONTACTID", address[0]) -- GitLab