diff --git a/entity/Contact_entity/Contact_entity.aod b/entity/Contact_entity/Contact_entity.aod index ecdd154429d1d6248908268b47143771936d6612..4ce8a38fd6962ba6b14bf4479779995fc6f191c2 100644 --- a/entity/Contact_entity/Contact_entity.aod +++ b/entity/Contact_entity/Contact_entity.aod @@ -48,13 +48,17 @@ <dependency> <name>dependency</name> <entityName>Organisation_entity</entityName> - <fieldName>Organisations</fieldName> + <fieldName>WithPersonIdFilter</fieldName> </dependency> <children> <entityParameter> <name>WithPrivate_param</name> <valueProcess>%aditoprj%/entity/Contact_entity/entityfields/organisations/children/withprivate_param/valueProcess.js</valueProcess> </entityParameter> + <entityParameter> + <name>ExcludeOrganisationsByPersonId</name> + <valueProcess>%aditoprj%/entity/Contact_entity/entityfields/organisations/children/excludeorganisationsbypersonid/valueProcess.js</valueProcess> + </entityParameter> </children> </entityConsumer> <entityParameter> diff --git a/entity/Contact_entity/entityfields/organisations/children/excludeorganisationsbypersonid/valueProcess.js b/entity/Contact_entity/entityfields/organisations/children/excludeorganisationsbypersonid/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..b273dc66b2666ffe2198c68cf38f00e4b7817cc2 --- /dev/null +++ b/entity/Contact_entity/entityfields/organisations/children/excludeorganisationsbypersonid/valueProcess.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("system.result"); + +var personId = vars.get("$field.PERSON_ID"); +result.string(personId); \ No newline at end of file diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index ea7df11cc5e14ae0284e09a69f3f0f3d96648c43..64f7d41a88060b949915c7b4b3414ff21ab22103 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -140,12 +140,6 @@ <fieldName>Organisations</fieldName> <isConsumer v="false" /> </entityDependency> - <entityDependency> - <name>7aa5f9b4-6986-4593-a6d8-c4fb03da9c68</name> - <entityName>Contact_entity</entityName> - <fieldName>Organisations</fieldName> - <isConsumer v="false" /> - </entityDependency> </dependencies> <children> <entityParameter> @@ -156,6 +150,10 @@ <name>WithPrivate_param</name> <expose v="true" /> </entityParameter> + <entityParameter> + <name>ExcludeOrganisationsByPersonId</name> + <expose v="false" /> + </entityParameter> </children> </entityProvider> <entityConsumer> @@ -591,6 +589,7 @@ <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/withprivate_param/valueProcess.js</valueProcess> <expose v="true" /> <triggerRecalculation v="true" /> + <documentation>%aditoprj%/entity/Organisation_entity/entityfields/withprivate_param/documentation.adoc</documentation> <description>PARAMETER</description> </entityParameter> <entityConsumer> @@ -633,6 +632,41 @@ </entityParameter> </children> </entityConsumer> + <entityParameter> + <name>ExcludeOrganisationsByPersonId</name> + <expose v="true" /> + <documentation>%aditoprj%/entity/Organisation_entity/entityfields/excludeorganisationsbypersonid/documentation.adoc</documentation> + <description>PARAMETER</description> + </entityParameter> + <entityProvider> + <name>WithPersonIdFilter</name> + <fieldType>DEPENDENCY_IN</fieldType> + <documentation>%aditoprj%/entity/Organisation_entity/entityfields/withpersonidfilter/documentation.adoc</documentation> + <dependencies> + <entityDependency> + <name>5a456b04-f0ca-4a45-9c1f-bdfdf074434a</name> + <entityName>Contact_entity</entityName> + <fieldName>Organisations</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> + <children> + <entityParameter> + <name>ContactId_param</name> + <expose v="false" /> + </entityParameter> + <entityParameter> + <name>ExcludeOrganisationsByPersonId</name> + <title></title> + <expose v="true" /> + <mandatory v="true" /> + </entityParameter> + <entityParameter> + <name>WithPrivate_param</name> + <expose v="true" /> + </entityParameter> + </children> + </entityProvider> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Organisation_entity/entityfields/excludeorganisationsbypersonid/documentation.adoc b/entity/Organisation_entity/entityfields/excludeorganisationsbypersonid/documentation.adoc new file mode 100644 index 0000000000000000000000000000000000000000..df350126c674f699847049d6e70d2147c0e61432 --- /dev/null +++ b/entity/Organisation_entity/entityfields/excludeorganisationsbypersonid/documentation.adoc @@ -0,0 +1,2 @@ +A param used to filter Organisations where a specific PersonId does already exist as contact-entry. +In other words: The list of orgs is reduced by those where a Contact-entry does exist for the given Personid \ No newline at end of file diff --git a/entity/Organisation_entity/entityfields/withpersonidfilter/documentation.adoc b/entity/Organisation_entity/entityfields/withpersonidfilter/documentation.adoc new file mode 100644 index 0000000000000000000000000000000000000000..417ca5b40f81dfc38a15d5f7c48274d962d942c1 --- /dev/null +++ b/entity/Organisation_entity/entityfields/withpersonidfilter/documentation.adoc @@ -0,0 +1,2 @@ +Provides Organisations where a filter is applied: +The list of Organisations is reduced by those where a Contact-entry does exist for a given PersonId. \ No newline at end of file diff --git a/entity/Organisation_entity/entityfields/withprivate_param/documentation.adoc b/entity/Organisation_entity/entityfields/withprivate_param/documentation.adoc new file mode 100644 index 0000000000000000000000000000000000000000..6465a654b7694320706cbe5bd8aa25e300133642 --- /dev/null +++ b/entity/Organisation_entity/entityfields/withprivate_param/documentation.adoc @@ -0,0 +1,9 @@ +Param that describes if the "private"-dummy-Organisation shall be returned or not. +Possible values are: + +- `true` +- `false` + +The Default value is `false`. + +If the value `true` is passed the "private"-dummy-Organisation will be returned. Otherwise the "private"-dummy-Organisation is filtered. \ No newline at end of file diff --git a/entity/Organisation_entity/recordcontainers/db/conditionProcess.js b/entity/Organisation_entity/recordcontainers/db/conditionProcess.js index d8bc46d7f92c21bcc1cb6ac79ddbebc74ecac7a9..d8f6c2d5a839058a05dd2dc58d9c128a39398c12 100644 --- a/entity/Organisation_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Organisation_entity/recordcontainers/db/conditionProcess.js @@ -10,7 +10,11 @@ var cond = SqlCondition.begin() if (vars.getString("$param.WithPrivate_param") != "true") cond.andPrepare("ORGANISATION.ORGANISATIONID", "0", "# <> ?"); -//TODO: exclude already used (or validation of already used combinations) +var excludeOrgsWithPersonId = vars.get("$param.ExcludeOrganisationsByPersonId") +if (excludeOrgsWithPersonId) + cond.andAttachPrepared(SqlCondition.begin() + .andPrepare("CONTACT.PERSON_ID", excludeOrgsWithPersonId) + .buildSql("ORGANISATION.ORGANISATIONID not in (select CONTACT.ORGANISATION_ID from CONTACT", null, ")")); //TODO: use a preparedCondition when available #1030812 #1034026 result.string(db.translateCondition(cond.build("1 = 1"))); \ No newline at end of file