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

add street to webservice validation

parent 09116733
No related branches found
No related tags found
No related merge requests found
Showing
with 283 additions and 197 deletions
<?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>
import("WsValidation_lib");
import("system.result");
result.string(WsValidationType.get().TYPE_STREET_NOMINATIM.key);
\ No newline at end of file
......@@ -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
......@@ -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>
......
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
import("WsValidation_lib");
WsValidationUtils.setAddressFields();
\ No newline at end of file
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
import("system.vars");
import("system.result");
result.string(vars.get("$field.CITY"))
\ No newline at end of file
import("system.result");
import("system.vars");
result.string(vars.get("$field.COUNTRY"));
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$this.value"))
\ No newline at end of file
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
......@@ -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)
}
/**
......
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