diff --git a/entity/AddressValidation_entity/AddressValidation_entity.aod b/entity/AddressValidation_entity/AddressValidation_entity.aod index 14071d6da47fb0c8a577e31c7e6bf4cf590a2533..c1e6c8b8b0cd6493d0110595d69a7b43141dd2b6 100644 --- a/entity/AddressValidation_entity/AddressValidation_entity.aod +++ b/entity/AddressValidation_entity/AddressValidation_entity.aod @@ -1,182 +1,204 @@ -<?xml version="1.0" encoding="UTF-8"?> -<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.9" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.9"> - <name>AddressValidation_entity</name> - <majorModelMode>DISTRIBUTED</majorModelMode> - <contentTitleProcess>%aditoprj%/entity/AddressValidation_entity/contentTitleProcess.js</contentTitleProcess> - <recordContainer>jdito</recordContainer> - <entityFields> - <entityProvider> - <name>#PROVIDER</name> - </entityProvider> - <entityField> - <name>UID</name> - <title>Address</title> - <description>UID consists of all fields as JSON. </description> - </entityField> - <entityProvider> - <name>ZipValidaton</name> - <dependencies> - <entityDependency> - <name>fcfcbebe-260a-4773-a874-9791b4887ae2</name> - <entityName>Address_entity</entityName> - <fieldName>ZipValidation</fieldName> - <isConsumer v="false" /> - </entityDependency> - </dependencies> - <children> - <entityParameter> - <name>Type_param</name> - <valueProcess>%aditoprj%/entity/AddressValidation_entity/entityfields/zipvalidaton/children/type_param/valueProcess.js</valueProcess> - <expose v="false" /> - </entityParameter> - </children> - </entityProvider> - <entityParameter> - <name>Type_param</name> - <expose v="true" /> - <mandatory v="true" /> - <description>PARAMETER</description> - </entityParameter> - <entityParameter> - <name>Country_param</name> - <expose v="true" /> - <description>PARAMETER</description> - </entityParameter> - <entityField> - <name>COUNTRY</name> - <title>Country</title> - </entityField> - <entityField> - <name>ZIP</name> - <title>Zip</title> - </entityField> - <entityField> - <name>CITY</name> - <title>City</title> - </entityField> - <entityField> - <name>DISTRICT</name> - <title>District</title> - </entityField> - <entityField> - <name>REGION</name> - <title>Region</title> - </entityField> - <entityField> - <name>STATE</name> - <title>${ADDRESS_STATE}</title> - </entityField> - <entityField> - <name>VALUE</name> - <description>Final value returned</description> - </entityField> - <entityProvider> - <name>CityValidation</name> - <dependencies> - <entityDependency> - <name>27114db7-8562-43b2-87d8-fa605bbf2319</name> - <entityName>Address_entity</entityName> - <fieldName>CityValidation</fieldName> - <isConsumer v="false" /> - </entityDependency> - </dependencies> - <children> - <entityParameter> - <name>Type_param</name> - <valueProcess>%aditoprj%/entity/AddressValidation_entity/entityfields/cityvalidation/children/type_param/valueProcess.js</valueProcess> - <expose v="false" /> - </entityParameter> - </children> - </entityProvider> - <entityParameter> - <name>CurrentValue_param</name> - <expose v="true" /> - <description>PARAMETER</description> - </entityParameter> - <entityProvider> - <name>FullAddressValidation</name> - <dependencies> - <entityDependency> - <name>10f700b5-1ac6-4d50-bcb8-aae55714fb43</name> - <entityName>Address_entity</entityName> - <fieldName>FullAddressValidation</fieldName> - <isConsumer v="false" /> - </entityDependency> - </dependencies> - <children> - <entityParameter> - <name>Type_param</name> - <valueProcess>%aditoprj%/entity/AddressValidation_entity/entityfields/fulladdressvalidation/children/type_param/valueProcess.js</valueProcess> - <expose v="false" /> - </entityParameter> - </children> - </entityProvider> - <entityField> - <name>STREET</name> - <title>Street</title> - </entityField> - <entityField> - <name>LON</name> - </entityField> - <entityField> - <name>LAT</name> - </entityField> - <entityField> - <name>CITYEXT</name> - </entityField> - <entityField> - <name>BUILDINGNO</name> - </entityField> - </entityFields> - <recordContainers> - <jDitoRecordContainer> - <name>jdito</name> - <jDitoRecordAlias></jDitoRecordAlias> - <isFilterable v="true" /> - <isRequireContainerFiltering v="true" /> - <isSortable v="true" /> - <contentProcess>%aditoprj%/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js</contentProcess> - <recordFieldMappings> - <jDitoRecordFieldMapping> - <name>UID.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>UID.displayValue</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>ZIP.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>CITY.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>CITYEXT.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>COUNTRY.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>DISTRICT.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>REGION.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>STATE.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>STREET.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>BUILDINGNO.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>LON.value</name> - </jDitoRecordFieldMapping> - <jDitoRecordFieldMapping> - <name>LAT.value</name> - </jDitoRecordFieldMapping> - </recordFieldMappings> - </jDitoRecordContainer> - </recordContainers> -</entity> +<?xml version="1.0" encoding="UTF-8"?> +<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.9" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.9"> + <name>AddressValidation_entity</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <contentTitleProcess>%aditoprj%/entity/AddressValidation_entity/contentTitleProcess.js</contentTitleProcess> + <recordContainer>jdito</recordContainer> + <entityFields> + <entityProvider> + <name>#PROVIDER</name> + </entityProvider> + <entityField> + <name>UID</name> + <title>Address</title> + <description>UID consists of all fields as JSON. </description> + </entityField> + <entityProvider> + <name>ZipValidaton</name> + <dependencies> + <entityDependency> + <name>fcfcbebe-260a-4773-a874-9791b4887ae2</name> + <entityName>Address_entity</entityName> + <fieldName>ZipValidation</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> + <children> + <entityParameter> + <name>Type_param</name> + <valueProcess>%aditoprj%/entity/AddressValidation_entity/entityfields/zipvalidaton/children/type_param/valueProcess.js</valueProcess> + <expose v="false" /> + </entityParameter> + </children> + </entityProvider> + <entityParameter> + <name>Type_param</name> + <expose v="true" /> + <mandatory v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityParameter> + <name>Country_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityField> + <name>COUNTRY</name> + <title>Country</title> + </entityField> + <entityField> + <name>ZIP</name> + <title>Zip</title> + </entityField> + <entityField> + <name>CITY</name> + <title>City</title> + </entityField> + <entityField> + <name>DISTRICT</name> + <title>District</title> + </entityField> + <entityField> + <name>REGION</name> + <title>Region</title> + </entityField> + <entityField> + <name>STATE</name> + <title>${ADDRESS_STATE}</title> + </entityField> + <entityField> + <name>VALUE</name> + <description>Final value returned</description> + </entityField> + <entityProvider> + <name>CityValidation</name> + <dependencies> + <entityDependency> + <name>27114db7-8562-43b2-87d8-fa605bbf2319</name> + <entityName>Address_entity</entityName> + <fieldName>CityValidation</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> + <children> + <entityParameter> + <name>Type_param</name> + <valueProcess>%aditoprj%/entity/AddressValidation_entity/entityfields/cityvalidation/children/type_param/valueProcess.js</valueProcess> + <expose v="false" /> + </entityParameter> + </children> + </entityProvider> + <entityParameter> + <name>CurrentValue_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityProvider> + <name>FullAddressValidation</name> + <dependencies> + <entityDependency> + <name>10f700b5-1ac6-4d50-bcb8-aae55714fb43</name> + <entityName>Address_entity</entityName> + <fieldName>FullAddressValidation</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> + <children> + <entityParameter> + <name>Type_param</name> + <valueProcess>%aditoprj%/entity/AddressValidation_entity/entityfields/fulladdressvalidation/children/type_param/valueProcess.js</valueProcess> + <expose v="false" /> + </entityParameter> + </children> + </entityProvider> + <entityField> + <name>STREET</name> + <title>Street</title> + </entityField> + <entityField> + <name>LON</name> + </entityField> + <entityField> + <name>LAT</name> + </entityField> + <entityField> + <name>CITYEXT</name> + </entityField> + <entityField> + <name>BUILDINGNO</name> + </entityField> + <entityProvider> + <name>StreetValidation</name> + <dependencies> + <entityDependency> + <name>3211d147-0867-4fc1-8640-34a1b8fdcf18</name> + <entityName>Address_entity</entityName> + <fieldName>StreetValidation</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> + <children> + <entityParameter> + <name>Type_param</name> + <valueProcess>%aditoprj%/entity/AddressValidation_entity/entityfields/streetvalidation/children/type_param/valueProcess.js</valueProcess> + <expose v="false" /> + </entityParameter> + </children> + </entityProvider> + <entityParameter> + <name>City_param</name> + <expose v="true" /> + </entityParameter> + </entityFields> + <recordContainers> + <jDitoRecordContainer> + <name>jdito</name> + <jDitoRecordAlias></jDitoRecordAlias> + <isFilterable v="true" /> + <isRequireContainerFiltering v="true" /> + <isSortable v="true" /> + <contentProcess>%aditoprj%/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js</contentProcess> + <recordFieldMappings> + <jDitoRecordFieldMapping> + <name>UID.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>UID.displayValue</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>ZIP.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>CITY.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>CITYEXT.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>COUNTRY.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>DISTRICT.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>REGION.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>STATE.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>STREET.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>BUILDINGNO.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>LON.value</name> + </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>LAT.value</name> + </jDitoRecordFieldMapping> + </recordFieldMappings> + </jDitoRecordContainer> + </recordContainers> +</entity> diff --git a/entity/AddressValidation_entity/entityfields/streetvalidation/children/type_param/valueProcess.js b/entity/AddressValidation_entity/entityfields/streetvalidation/children/type_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..84ce4d3552f2a616ba448406736d64b2b560825a --- /dev/null +++ b/entity/AddressValidation_entity/entityfields/streetvalidation/children/type_param/valueProcess.js @@ -0,0 +1,4 @@ +import("WsValidation_lib"); +import("system.result"); + +result.string(WsValidationType.get().TYPE_STREET_NOMINATIM.key); \ No newline at end of file diff --git a/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js b/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js index 70bcb62de39fd2d5e04dcdaf5f8bc1689a1342bf..23d093d4cfac35df3f945324673a3718d1f5a2d2 100644 --- a/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js @@ -10,6 +10,10 @@ var country = ""; if (vars.exists("$param.Country_param") && vars.get("$param.Country_param")) country = vars.get("$param.Country_param"); +var city = ""; +if (vars.exists("$param.City_param") && vars.get("$param.City_param")) + city = vars.get("$param.City_param"); + // get the value typed by the user var filter = ""; var localFilter = vars.get("$local.filter"); @@ -21,5 +25,5 @@ if(localFilter.filter != null) { if (!filter && vars.exists("$param.CurrentValue_param") && vars.get("$param.CurrentValue_param")) filter = vars.get("$param.CurrentValue_param"); -var foundAddresses = WsValidationUtils.validate(filter, type, country); +var foundAddresses = WsValidationUtils.validate(filter, type, country, city); result.object(foundAddresses); \ No newline at end of file diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index a792cd32d55c5494cce7b52f26f48e8002e28339..4af02845d6b88a7b1f7554e453cf73a34ff78202 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -12,7 +12,15 @@ <entityField> <name>ADDRESS</name> <title>Street</title> + <consumer>StreetValidation</consumer> <mandatoryProcess>%aditoprj%/entity/Address_entity/entityfields/address/mandatoryProcess.js</mandatoryProcess> + <textInputAllowed v="true" /> + <displayValueProcess>%aditoprj%/entity/Address_entity/entityfields/address/displayValueProcess.js</displayValueProcess> + <onValueChange>%aditoprj%/entity/Address_entity/entityfields/address/onValueChange.js</onValueChange> + <onValueChangeTypes> + <element>MASK</element> + <element>PROCESS</element> + </onValueChangeTypes> </entityField> <entityField> <name>ADDRESSADDITION</name> @@ -367,6 +375,28 @@ </entityParameter> </children> </entityConsumer> + <entityConsumer> + <name>StreetValidation</name> + <dependency> + <name>dependency</name> + <entityName>AddressValidation_entity</entityName> + <fieldName>StreetValidation</fieldName> + </dependency> + <children> + <entityParameter> + <name>City_param</name> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/streetvalidation/children/city_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>Country_param</name> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/streetvalidation/children/country_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>CurrentValue_param</name> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/streetvalidation/children/currentvalue_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Address_entity/entityfields/address/displayValueProcess.js b/entity/Address_entity/entityfields/address/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..de2c5e835eaf4fe6dd8b3521b3e17a39c9ac23c1 --- /dev/null +++ b/entity/Address_entity/entityfields/address/displayValueProcess.js @@ -0,0 +1,5 @@ +import("system.vars"); +import("system.result"); + +// needed for instant display name change if value set by neon.setFieldValue +result.string(vars.get("$this.value")) \ No newline at end of file diff --git a/entity/Address_entity/entityfields/address/onValueChange.js b/entity/Address_entity/entityfields/address/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..5634474c9dabbfeec7a11ee3c23680b765030b4a --- /dev/null +++ b/entity/Address_entity/entityfields/address/onValueChange.js @@ -0,0 +1,3 @@ +import("WsValidation_lib"); + +WsValidationUtils.setAddressFields(); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js b/entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js index b6d717bf6d0a017888c93e57157690f2e1f44f18..210aab5135161a47229a09613e2ed186ebf9528f 100644 --- a/entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js +++ b/entity/Address_entity/entityfields/cityvalidation/children/currentvalue_param/valueProcess.js @@ -1,4 +1,4 @@ -import("system.vars"); -import("system.result"); - -result.string(vars.get("$field.CITY")) \ No newline at end of file +import("system.vars"); +import("system.result"); + +result.string(vars.get("$this.value")) \ No newline at end of file diff --git a/entity/Address_entity/entityfields/streetvalidation/children/city_param/valueProcess.js b/entity/Address_entity/entityfields/streetvalidation/children/city_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..74c070329cde0f8edeabd0e80677b4105b3e256e --- /dev/null +++ b/entity/Address_entity/entityfields/streetvalidation/children/city_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.CITY")) \ No newline at end of file diff --git a/entity/Address_entity/entityfields/streetvalidation/children/country_param/valueProcess.js b/entity/Address_entity/entityfields/streetvalidation/children/country_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..41f3b8dc1a9b50c6ae934a4fae1402d699cc87b8 --- /dev/null +++ b/entity/Address_entity/entityfields/streetvalidation/children/country_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.result"); +import("system.vars"); + +result.string(vars.get("$field.COUNTRY")); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/streetvalidation/children/currentvalue_param/valueProcess.js b/entity/Address_entity/entityfields/streetvalidation/children/currentvalue_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..210aab5135161a47229a09613e2ed186ebf9528f --- /dev/null +++ b/entity/Address_entity/entityfields/streetvalidation/children/currentvalue_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$this.value")) \ No newline at end of file diff --git a/entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js b/entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js index 5b95cc2dbda4676eb8fd41482418b10dcbe6d4e0..210aab5135161a47229a09613e2ed186ebf9528f 100644 --- a/entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js +++ b/entity/Address_entity/entityfields/zipvalidation/children/currentvalue_param/valueProcess.js @@ -1,4 +1,4 @@ -import("system.vars"); -import("system.result"); - -result.string(vars.get("$field.ZIP")) \ No newline at end of file +import("system.vars"); +import("system.result"); + +result.string(vars.get("$this.value")) \ No newline at end of file diff --git a/process/WsValidation_lib/process.js b/process/WsValidation_lib/process.js index 0f34bcf034364414e9877eb649cb7608060926e7..eee133e328fb1e3610d372eb87dfdf1a36d550f6 100644 --- a/process/WsValidation_lib/process.js +++ b/process/WsValidation_lib/process.js @@ -42,6 +42,7 @@ WsValidationType.get = function(pKey) TYPE_ADDRESS_NOMINATIM: new WsValidationType("TYPE_ADDRESS_NOMINATIM", "nominatim", _processNominatimAddressLookup, _nominatimRequest, "q"), TYPE_ZIP_NOMINATIM: new WsValidationType("TYPE_ZIP_NOMINATIM", "nominatim", _processNominatimAddressLookup, _nominatimRequest, "postalcode"), TYPE_CITY_NOMINATIM: new WsValidationType("TYPE_CITY_NOMINATIM", "nominatim", _processNominatimAddressLookup, _nominatimRequest, "city"), + TYPE_STREET_NOMINATIM: new WsValidationType("TYPE_STREET_NOMINATIM", "nominatim", _processNominatimAddressLookup, _nominatimRequest, "street"), // Communication validation TYPE_PHONE: new WsValidationType("TYPE_PHONE", "phoneValidation", _processCommunicationValidation, _customRequest, "Number") @@ -156,7 +157,7 @@ WsValidationType.get = function(pKey) return this.processResultCallback.call(this, null, pValue); } - function _nominatimRequest(pValue, pCountry) + function _nominatimRequest(pValue, pCountry, pCity) { var nominatimCache; if (WsValidationUtils.isWsEnabled(this)) @@ -174,13 +175,13 @@ WsValidationType.get = function(pKey) nominatimCache = JSON.parse(vars.getString("$context.nominatim")); } - if (nominatimCache.last == parameterName + pValue + (pCountry ? pCountry : "")) + if (nominatimCache.last == parameterName + pValue + (pCountry ? pCountry : "") + (pCity ? pCity : "") ) { return nominatimCache.data; } else { - nominatimCache.last = parameterName + pValue + (pCountry ? pCountry : "") + nominatimCache.last = parameterName + pValue + (pCountry ? pCountry : "") + (pCity ? pCity : "") var url = project.getPreferenceValue("custom." + this.webserviceName + ".url"); @@ -206,6 +207,10 @@ WsValidationType.get = function(pKey) { restConf.addQueryParameter("countrycodes", pCountry) } + if (pCity) + { + restConf.addQueryParameter("city", pCity) + } restConf.addQueryParameter(parameterName, pValue) @@ -247,17 +252,18 @@ function WsValidationUtils() {} * validate the value with the webservice * @param {String} pValue to search for * @param {WsValidationType|String} pType type used for the search. Can be an WsValidationType or the key of the WsValidationType - * @param {String} pCountry needed by the webservice e.g. "DE" + * @param {String} pCountry needed by some webservices e.g. "DE" + * @param {String} pCity needed by some webservices e.g. "Landshut" * * @return {object} this is different, based on which webservice-type is used */ -WsValidationUtils.validate = function(pValue, pType, pCountry) +WsValidationUtils.validate = function(pValue, pType, pCountry, pCity) { // get WsValidationType-Object if it is only the key if (typeof pType == "string") pType = WsValidationType.get(pType); - return pType.processRequestCallback.call(pType, pValue, pCountry) + return pType.processRequestCallback.call(pType, pValue, pCountry, pCity) } /**