From df15e994f94a8424a555ea6f03389ac29c1b9a5b Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Wed, 27 Mar 2019 10:36:03 +0100 Subject: [PATCH] =?UTF-8?q?Mitbewerber=20&=20Produkt=20Einschr=C3=A4nkung?= =?UTF-8?q?=20auf=20attribut=20Zielgruppe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Organisation_entity.aod | 90 +++++++++++++++---- .../recordcontainers/db/conditionProcess.js | 24 +++++ .../recordcontainers/db/conditionProcess.js | 6 -- entity/Product_entity/Product_entity.aod | 12 ++- .../attributeid_param/valueProcess.js | 4 + .../attributekeyid_param/valueProcess.js | 4 + .../SalesprojectCompetition_entity.aod | 18 +++- .../children/contactid_param/valueProcess.js | 4 - .../attributeid_param/valueProcess.js | 4 + .../attributekeyid_param/valueProcess.js | 4 + .../excludedcontactids_param/valueProcess.js | 8 ++ .../excludedcontactids_param/valueProcess.js | 4 - .../init_AttributeKeyword_target_group.xml | 90 +++++++++++++++++++ .../data_alias/basic/2019.2/changelog.xml | 2 + 14 files changed, 238 insertions(+), 36 deletions(-) create mode 100644 entity/Product_entity/entityfields/organisations/children/attributeid_param/valueProcess.js create mode 100644 entity/Product_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js delete mode 100644 entity/SalesprojectCompetition_entity/entityfields/organisation/children/contactid_param/valueProcess.js create mode 100644 entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributeid_param/valueProcess.js create mode 100644 entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js create mode 100644 entity/SalesprojectCompetition_entity/entityfields/organisations/children/excludedcontactids_param/valueProcess.js create mode 100644 others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeKeyword_target_group.xml diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 64f7d41a88..90e490097c 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -128,12 +128,6 @@ <fieldName>Organisations</fieldName> <isConsumer v="false" /> </entityDependency> - <entityDependency> - <name>120c8bfb-1b03-408d-97e7-88e3b7249c53</name> - <entityName>SalesprojectCompetition_entity</entityName> - <fieldName>Organisation</fieldName> - <isConsumer v="false" /> - </entityDependency> <entityDependency> <name>19a28531-bec6-49e2-b00d-aae3816e6690</name> <entityName>Person_entity</entityName> @@ -154,6 +148,18 @@ <name>ExcludeOrganisationsByPersonId</name> <expose v="false" /> </entityParameter> + <entityParameter> + <name>ExcludedContactIds_param</name> + <expose v="true" /> + </entityParameter> + <entityParameter> + <name>AttributeKeyId_param</name> + <expose v="false" /> + </entityParameter> + <entityParameter> + <name>AttributeId_param</name> + <expose v="false" /> + </entityParameter> </children> </entityProvider> <entityConsumer> @@ -247,18 +253,6 @@ <entityProvider> <name>#PROVIDER</name> <dependencies> - <entityDependency> - <name>f78c0ca6-7939-4a0e-903e-0fbbbf512e76</name> - <entityName>Product_entity</entityName> - <fieldName>Organisations</fieldName> - <isConsumer v="false" /> - </entityDependency> - <entityDependency> - <name>1fa399a8-8c0c-470f-94a8-6c748293d93d</name> - <entityName>SalesprojectCompetition_entity</entityName> - <fieldName>Organisations</fieldName> - <isConsumer v="false" /> - </entityDependency> <entityDependency> <name>c84fdb27-45a1-4dec-b013-af43751f6a7b</name> <entityName>Salesproject_entity</entityName> @@ -667,6 +661,66 @@ </entityParameter> </children> </entityProvider> + <entityParameter> + <name>AttributeId_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityParameter> + <name>AttributeKeyId_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityProvider> + <name>WithAttribute</name> + <fieldType>DEPENDENCY_IN</fieldType> + <dependencies> + <entityDependency> + <name>10480df2-f0b6-4cb6-8bfb-4a468b994996</name> + <entityName>SalesprojectCompetition_entity</entityName> + <fieldName>Organisations</fieldName> + <isConsumer v="false" /> + </entityDependency> + <entityDependency> + <name>f368be61-1a15-449f-b37c-b1343069412c</name> + <entityName>Product_entity</entityName> + <fieldName>Organisations</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> + <children> + <entityParameter> + <name>AttributeId_param</name> + <expose v="true" /> + <mandatory v="true" /> + </entityParameter> + <entityParameter> + <name>AttributeKeyId_param</name> + <expose v="true" /> + </entityParameter> + <entityParameter> + <name>ContactId_param</name> + <expose v="false" /> + </entityParameter> + <entityParameter> + <name>ExcludeOrganisationsByPersonId</name> + <expose v="false" /> + </entityParameter> + <entityParameter> + <name>WithPrivate_param</name> + <expose v="false" /> + </entityParameter> + <entityParameter> + <name>ExcludedContactIds_param</name> + <expose v="true" /> + </entityParameter> + </children> + </entityProvider> + <entityParameter> + <name>ExcludedContactIds_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Organisation_entity/recordcontainers/db/conditionProcess.js b/entity/Organisation_entity/recordcontainers/db/conditionProcess.js index d8f6c2d5a8..a42eafd440 100644 --- a/entity/Organisation_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Organisation_entity/recordcontainers/db/conditionProcess.js @@ -2,6 +2,7 @@ import("system.vars"); import("system.db"); import("system.result"); import("Sql_lib"); +import("Context_lib"); var cond = SqlCondition.begin() .andPrepareVars("ORGANISATION.ORGANISATIONID", "$param.ContactId_param"); @@ -16,5 +17,28 @@ if (excludeOrgsWithPersonId) .andPrepare("CONTACT.PERSON_ID", excludeOrgsWithPersonId) .buildSql("ORGANISATION.ORGANISATIONID not in (select CONTACT.ORGANISATION_ID from CONTACT", null, ")")); +if (vars.exists("$param.AttributeId_param") && vars.get("$param.AttributeId_param")) +{ + var hasAttributeCondition = SqlCondition.begin() + .andPrepare("AB_ATTRIBUTERELATION.OBJECT_TYPE", ContextUtils.getCurrentContextId()) + .andPrepare("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID", vars.get("$param.AttributeId_param")) + .andPrepareVars("AB_ATTRIBUTERELATION.ID_VALUE", "$param.AttributeKeyId_param"); + + cond.andAttachPrepared(hasAttributeCondition.buildSql("ORGANISATION.ORGANISATIONID in (select OBJECT_ROWID from AB_ATTRIBUTERELATION", "1=2", ")")); +} + +if (vars.exists("$param.ExcludedContactIds_param") && vars.get("$param.ExcludedContactIds_param")) +{ + var excludedContacts = JSON.parse(vars.get("$param.ExcludedContactIds_param")); + var excludedCond = SqlCondition.begin(); + + excludedContacts.forEach(function(pContactId) + { + excludedCond.andPrepare("CONTACT.CONTACTID", pContactId, "#<>?"); + }); + + cond.andSqlCondition(excludedCond, "1=1"); +} + //TODO: use a preparedCondition when available #1030812 #1034026 result.string(db.translateCondition(cond.build("1 = 1"))); \ No newline at end of file diff --git a/entity/Person_entity/recordcontainers/db/conditionProcess.js b/entity/Person_entity/recordcontainers/db/conditionProcess.js index 47f1ee3551..d31e4c68e7 100644 --- a/entity/Person_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Person_entity/recordcontainers/db/conditionProcess.js @@ -20,11 +20,5 @@ if (vars.exists("$param.ExcludedContactIds_param") && vars.get("$param.ExcludedC cond.andSqlCondition(excludedCond, "1=1"); } -/* -//in salesprojectMember, only people that aren't already in the salesproject should be selectable -cond.andPrepareVars("PERSON.PERSONID", "$param.SalesprojectId_param", - "# not in (select CONTACT.PERSON_ID from SALESPROJECT_MEMBER join CONTACT on SALESPROJECT_MEMBER.CONTACT_ID = CONTACT.CONTACTID " - + " where SALESPROJECT_MEMBER.SALESPROJECT_ID = ?)"); -*/ //TODO: use a preparedCondition when available #1030812 #1034026 result.string(db.translateCondition(cond.build("1 = 1"))); diff --git a/entity/Product_entity/Product_entity.aod b/entity/Product_entity/Product_entity.aod index 5501274d10..cd11c3d2bc 100644 --- a/entity/Product_entity/Product_entity.aod +++ b/entity/Product_entity/Product_entity.aod @@ -83,8 +83,18 @@ <dependency> <name>dependency</name> <entityName>Organisation_entity</entityName> - <fieldName>#PROVIDER</fieldName> + <fieldName>WithAttribute</fieldName> </dependency> + <children> + <entityParameter> + <name>AttributeId_param</name> + <valueProcess>%aditoprj%/entity/Product_entity/entityfields/organisations/children/attributeid_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>AttributeKeyId_param</name> + <valueProcess>%aditoprj%/entity/Product_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js</valueProcess> + </entityParameter> + </children> </entityConsumer> <entityConsumer> <name>Productprices</name> diff --git a/entity/Product_entity/entityfields/organisations/children/attributeid_param/valueProcess.js b/entity/Product_entity/entityfields/organisations/children/attributeid_param/valueProcess.js new file mode 100644 index 0000000000..645b2d9365 --- /dev/null +++ b/entity/Product_entity/entityfields/organisations/children/attributeid_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); + +// Target Group (Zielgruppe) +result.string("5d1a2b05-f04e-4ad7-9fd0-8efa09a33a53"); \ No newline at end of file diff --git a/entity/Product_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js b/entity/Product_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js new file mode 100644 index 0000000000..4a5bc0b05c --- /dev/null +++ b/entity/Product_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); + +// Manufacturer +result.string("41b0832f-8de2-4ab5-a6e0-9a793c5f80c3"); \ No newline at end of file diff --git a/entity/SalesprojectCompetition_entity/SalesprojectCompetition_entity.aod b/entity/SalesprojectCompetition_entity/SalesprojectCompetition_entity.aod index 0df2e74d7c..e4a89fde11 100644 --- a/entity/SalesprojectCompetition_entity/SalesprojectCompetition_entity.aod +++ b/entity/SalesprojectCompetition_entity/SalesprojectCompetition_entity.aod @@ -91,8 +91,6 @@ <fieldType>DEPENDENCY_OUT</fieldType> <dependency> <name>dependency</name> - <entityName>Organisation_entity</entityName> - <fieldName>Organisations</fieldName> </dependency> <children> <entityParameter> @@ -109,8 +107,22 @@ <dependency> <name>dependency</name> <entityName>Organisation_entity</entityName> - <fieldName>#PROVIDER</fieldName> + <fieldName>WithAttribute</fieldName> </dependency> + <children> + <entityParameter> + <name>AttributeId_param</name> + <valueProcess>%aditoprj%/entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributeid_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>AttributeKeyId_param</name> + <valueProcess>%aditoprj%/entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>ExcludedContactIds_param</name> + <valueProcess>%aditoprj%/entity/SalesprojectCompetition_entity/entityfields/organisations/children/excludedcontactids_param/valueProcess.js</valueProcess> + </entityParameter> + </children> </entityConsumer> <entityConsumer> <name>KeywordWonLost</name> diff --git a/entity/SalesprojectCompetition_entity/entityfields/organisation/children/contactid_param/valueProcess.js b/entity/SalesprojectCompetition_entity/entityfields/organisation/children/contactid_param/valueProcess.js deleted file mode 100644 index 7e0951d02b..0000000000 --- a/entity/SalesprojectCompetition_entity/entityfields/organisation/children/contactid_param/valueProcess.js +++ /dev/null @@ -1,4 +0,0 @@ -import("system.result"); -import("system.vars"); - -result.string(vars.get("$field.CONTACT_ID")); \ No newline at end of file diff --git a/entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributeid_param/valueProcess.js b/entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributeid_param/valueProcess.js new file mode 100644 index 0000000000..645b2d9365 --- /dev/null +++ b/entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributeid_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); + +// Target Group (Zielgruppe) +result.string("5d1a2b05-f04e-4ad7-9fd0-8efa09a33a53"); \ No newline at end of file diff --git a/entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js b/entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js new file mode 100644 index 0000000000..ca41e6e260 --- /dev/null +++ b/entity/SalesprojectCompetition_entity/entityfields/organisations/children/attributekeyid_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); + +// Competitor +result.string("fc09afd5-5f74-4e48-af26-3600bb4c9610"); \ No newline at end of file diff --git a/entity/SalesprojectCompetition_entity/entityfields/organisations/children/excludedcontactids_param/valueProcess.js b/entity/SalesprojectCompetition_entity/entityfields/organisations/children/excludedcontactids_param/valueProcess.js new file mode 100644 index 0000000000..09c14009f3 --- /dev/null +++ b/entity/SalesprojectCompetition_entity/entityfields/organisations/children/excludedcontactids_param/valueProcess.js @@ -0,0 +1,8 @@ +import("system.result"); +import("system.vars"); +import("system.db"); +import("Sql_lib"); + +result.object(db.array(db.COLUMN, SqlCondition.begin() + .andPrepare("SALESPROJECT_COMPETITION.SALESPROJECT_ID", vars.get("$field.SALESPROJECT_ID")) + .buildSql("select CONTACT_ID from SALESPROJECT_COMPETITION", "1=2"))); \ No newline at end of file diff --git a/entity/SalesprojectMember_entity/entityfields/contacts/children/excludedcontactids_param/valueProcess.js b/entity/SalesprojectMember_entity/entityfields/contacts/children/excludedcontactids_param/valueProcess.js index 35ca5d0cce..4f34874adf 100644 --- a/entity/SalesprojectMember_entity/entityfields/contacts/children/excludedcontactids_param/valueProcess.js +++ b/entity/SalesprojectMember_entity/entityfields/contacts/children/excludedcontactids_param/valueProcess.js @@ -1,12 +1,8 @@ -import("system.logging"); import("system.result"); import("system.vars"); import("system.db"); import("Sql_lib"); -logging.log(db.array(db.COLUMN, SqlCondition.begin() - .andPrepare("SALESPROJECT_MEMBER.SALESPROJECT_ID", vars.get("$field.SALESPROJECT_ID")) - .buildSql("select CONTACT_ID from SALESPROJECT_MEMBER", "1=2")).toSource()) result.object(db.array(db.COLUMN, SqlCondition.begin() .andPrepare("SALESPROJECT_MEMBER.SALESPROJECT_ID", vars.get("$field.SALESPROJECT_ID")) .buildSql("select CONTACT_ID from SALESPROJECT_MEMBER", "1=2"))); diff --git a/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeKeyword_target_group.xml b/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeKeyword_target_group.xml new file mode 100644 index 0000000000..5d05350bab --- /dev/null +++ b/others/db_changes/data_alias/basic/2019.2/AditoBasic/init_AttributeKeyword_target_group.xml @@ -0,0 +1,90 @@ +<?xml version="1.1" encoding="UTF-8" standalone="no"?> +<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> + <changeSet author="j.hoermann" id="7401faab-a383-48de-82db-0a869b77445d"> + <insert tableName="AB_ATTRIBUTE"> + <column name="AB_ATTRIBUTEID" value="5d1a2b05-f04e-4ad7-9fd0-8efa09a33a53"/> + <column name="ATTRIBUTE_ACTIVE" valueNumeric="1"/> + <column name="ATTRIBUTE_LEVEL" valueNumeric="0"/> + <column name="ATTRIBUTE_NAME" value="Zielgruppe"/> + <column name="ATTRIBUTE_PARENT_ID"/> + <column name="ATTRIBUTE_TYPE" value="KEYWORD "/> + <column name="KEYWORD_CONTAINER" value="TargetGroup"/> + </insert> + + <insert tableName="AB_ATTRIBUTEUSAGE"> + <column name="AB_ATTRIBUTEUSAGEID" value="d3d71563-cb7a-41a1-80be-148f090dafe1"/> + <column name="AB_ATTRIBUTE_ID" value="5d1a2b05-f04e-4ad7-9fd0-8efa09a33a53"/> + <column name="OBJECT_TYPE" value="Organisation"/> + </insert> + + <insert tableName="AB_KEYWORD_ENTRY"> + <column name="AB_KEYWORD_ENTRYID" value="e9d25ed2-60d6-4512-81e0-f0c234bb099b"/> + <column name="KEYID" value="9ba661a1-82df-46b1-8e9f-79d9c14a2f8c"/> + <column name="TITLE" value="Customer"/> + <column name="CONTAINER" value="TargetGroup"/> + <column name="SORTING" valueNumeric="0"/> + <column name="ISACTIVE" valueNumeric="1"/> + <column name="ISESSENTIAL" valueNumeric="0"/> + </insert> + <insert tableName="AB_KEYWORD_ENTRY"> + <column name="AB_KEYWORD_ENTRYID" value="739898f5-f498-4d55-b384-03d0f2399581"/> + <column name="KEYID" value="765e57ad-964c-47da-91eb-9bcdaa63b6c8"/> + <column name="TITLE" value="Prospective customer"/> + <column name="CONTAINER" value="TargetGroup"/> + <column name="SORTING" valueNumeric="1"/> + <column name="ISACTIVE" valueNumeric="1"/> + <column name="ISESSENTIAL" valueNumeric="0"/> + </insert> + <insert tableName="AB_KEYWORD_ENTRY"> + <column name="AB_KEYWORD_ENTRYID" value="3417041a-11bc-47e6-9ebb-43c82fbb9c05"/> + <column name="KEYID" value="41b0832f-8de2-4ab5-a6e0-9a793c5f80c3"/> + <column name="TITLE" value="Manufacturer"/> + <column name="CONTAINER" value="TargetGroup"/> + <column name="SORTING" valueNumeric="2"/> + <column name="ISACTIVE" valueNumeric="1"/> + <column name="ISESSENTIAL" valueNumeric="0"/> + </insert> + <insert tableName="AB_KEYWORD_ENTRY"> + <column name="AB_KEYWORD_ENTRYID" value="d3e23da8-3551-4d7f-ba8c-da8b6839c3da"/> + <column name="KEYID" value="fc09afd5-5f74-4e48-af26-3600bb4c9610"/> + <column name="TITLE" value="Competitor"/> + <column name="CONTAINER" value="TargetGroup"/> + <column name="SORTING" valueNumeric="3"/> + <column name="ISACTIVE" valueNumeric="1"/> + <column name="ISESSENTIAL" valueNumeric="0"/> + </insert> + <insert tableName="AB_KEYWORD_ENTRY"> + <column name="AB_KEYWORD_ENTRYID" value="aaef93fa-6ca5-46b7-a850-84e02a99de48"/> + <column name="KEYID" value="defe2588-5892-46b2-81d9-00ebde7ca3d7"/> + <column name="TITLE" value="Partner"/> + <column name="CONTAINER" value="TargetGroup"/> + <column name="SORTING" valueNumeric="4"/> + <column name="ISACTIVE" valueNumeric="1"/> + <column name="ISESSENTIAL" valueNumeric="0"/> + </insert> + <rollback> + <delete tableName="AB_ATTRIBUTE"> + <where>AB_ATTRIBUTEID in (?)</where> + <whereParams> + <param value="5d1a2b05-f04e-4ad7-9fd0-8efa09a33a53"/> + </whereParams> + </delete> + <delete tableName="AB_ATTRIBUTEUSAGE"> + <where>AB_ATTRIBUTE_ID in (?)</where> + <whereParams> + <param value="5d1a2b05-f04e-4ad7-9fd0-8efa09a33a53"/> + </whereParams> + </delete> + <delete tableName="AB_KEYWORD_ENTRY"> + <where>AB_KEYWORD_ENTRYID in (?, ?, ?, ?, ?)</where> + <whereParams> + <param value="e9d25ed2-60d6-4512-81e0-f0c234bb099b"/> + <param value="739898f5-f498-4d55-b384-03d0f2399581"/> + <param value="3417041a-11bc-47e6-9ebb-43c82fbb9c05"/> + <param value="d3e23da8-3551-4d7f-ba8c-da8b6839c3da"/> + <param value="aaef93fa-6ca5-46b7-a850-84e02a99de48"/> + </whereParams> + </delete> + </rollback> + </changeSet> +</databaseChangeLog> diff --git a/others/db_changes/data_alias/basic/2019.2/changelog.xml b/others/db_changes/data_alias/basic/2019.2/changelog.xml index 05f9a8b2d4..0020833885 100644 --- a/others/db_changes/data_alias/basic/2019.2/changelog.xml +++ b/others/db_changes/data_alias/basic/2019.2/changelog.xml @@ -108,4 +108,6 @@ <include relativeToChangelogFile="true" file="AditoBasic/init_ContactDepartment.xml"/> <include relativeToChangelogFile="true" file="AditoBasic/init_ContactContactrole.xml"/> <include relativeToChangelogFile="true" file="AditoBasic/init_ContactPosition.xml"/> + + <include relativeToChangelogFile="true" file="AditoBasic/init_AttributeKeyword_target_group.xml"/> </databaseChangeLog> -- GitLab