diff --git a/entity/AddressValidation_entity/AddressValidation_entity.aod b/entity/AddressValidation_entity/AddressValidation_entity.aod new file mode 100644 index 0000000000000000000000000000000000000000..75146c9d6496bb87302dcdb8792d9568afa83445 --- /dev/null +++ b/entity/AddressValidation_entity/AddressValidation_entity.aod @@ -0,0 +1,115 @@ +<?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.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.1"> + <name>AddressValidation_entity</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <titleProcess>%aditoprj%/entity/AddressValidation_entity/titleProcess.js</titleProcess> + <recordContainer>jdito</recordContainer> + <entityFields> + <entityProvider> + <name>#PROVIDER</name> + </entityProvider> + <entityField> + <name>UID</name> + <title>Address</title> + </entityField> + <entityProvider> + <name>ZipValidaton</name> + <fieldType>DEPENDENCY_IN</fieldType> + <dependencies> + <entityDependency> + <name>1b2e3be5-b3be-42c5-a55f-b892fdfbf21f</name> + <entityName>Communication_entity</entityName> + <fieldName>AddressValidator</fieldName> + <isConsumer v="false" /> + </entityDependency> + <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>State</title> + </entityField> + <entityField> + <name>VALUE</name> + </entityField> + <entityProvider> + <name>CityValidation</name> + <fieldType>DEPENDENCY_IN</fieldType> + <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> + </entityFields> + <recordContainers> + <jDitoRecordContainer> + <name>jdito</name> + <contentProcess>%aditoprj%/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js</contentProcess> + <recordFields> + <element>UID.value</element> + <element>UID.displayValue</element> + <element>ZIP.value</element> + <element>CITY.value</element> + <element>COUNTRY.value</element> + <element>DISTRICT.value</element> + <element>REGION.value</element> + <element>STATE.value</element> + <element>VALUE.value</element> + </recordFields> + </jDitoRecordContainer> + </recordContainers> +</entity> diff --git a/entity/AddressValidation_entity/entityfields/cityvalidation/children/type_param/valueProcess.js b/entity/AddressValidation_entity/entityfields/cityvalidation/children/type_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..605d65eb517e3f51c7d9a129c17c0d6e46b79452 --- /dev/null +++ b/entity/AddressValidation_entity/entityfields/cityvalidation/children/type_param/valueProcess.js @@ -0,0 +1,4 @@ +import("AddressValidation_lib"); +import("system.result"); + +result.string(AddressValidationType.get().TYPE_CITY.key); \ No newline at end of file diff --git a/entity/AddressValidation_entity/entityfields/cityvalidatior/children/type_param/valueProcess.js b/entity/AddressValidation_entity/entityfields/cityvalidatior/children/type_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..605d65eb517e3f51c7d9a129c17c0d6e46b79452 --- /dev/null +++ b/entity/AddressValidation_entity/entityfields/cityvalidatior/children/type_param/valueProcess.js @@ -0,0 +1,4 @@ +import("AddressValidation_lib"); +import("system.result"); + +result.string(AddressValidationType.get().TYPE_CITY.key); \ No newline at end of file diff --git a/entity/AddressValidation_entity/entityfields/validate/children/zip_param/valueProcess.js b/entity/AddressValidation_entity/entityfields/validate/children/zip_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..212bdd0b1df7e31a5b3c126f1d0b58926f924dda --- /dev/null +++ b/entity/AddressValidation_entity/entityfields/validate/children/zip_param/valueProcess.js @@ -0,0 +1 @@ +result.object(tr) \ No newline at end of file diff --git a/entity/AddressValidation_entity/entityfields/zipvalidaton/children/type_param/valueProcess.js b/entity/AddressValidation_entity/entityfields/zipvalidaton/children/type_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e980e6dd0b82b651a1025901c43d74fc6be1632d --- /dev/null +++ b/entity/AddressValidation_entity/entityfields/zipvalidaton/children/type_param/valueProcess.js @@ -0,0 +1,4 @@ +import("AddressValidation_lib"); +import("system.result"); + +result.string(AddressValidationType.get().TYPE_ZIP.key); \ No newline at end of file diff --git a/entity/AddressValidation_entity/entityfields/zipvalidator/children/type_param/valueProcess.js b/entity/AddressValidation_entity/entityfields/zipvalidator/children/type_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..e980e6dd0b82b651a1025901c43d74fc6be1632d --- /dev/null +++ b/entity/AddressValidation_entity/entityfields/zipvalidator/children/type_param/valueProcess.js @@ -0,0 +1,4 @@ +import("AddressValidation_lib"); +import("system.result"); + +result.string(AddressValidationType.get().TYPE_ZIP.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 new file mode 100644 index 0000000000000000000000000000000000000000..8bfa900b0b8f2fbe9ccf2e5d1191a143085b607c --- /dev/null +++ b/entity/AddressValidation_entity/recordcontainers/jdito/contentProcess.js @@ -0,0 +1,26 @@ +import("system.result"); +import("system.logging"); +import("AddressValidation_lib"); +import("system.vars"); + +var type = ""; +if (vars.exists("$param.Type_param") && vars.get("$param.Type_param")) + type = vars.get("$param.Type_param"); + +var country = ""; +if (vars.exists("$param.Country_param") && vars.get("$param.Country_param")) + country = vars.get("$param.Country_param"); + + +var filter = ""; +var sysFilter = vars.get("$sys.filter"); +if(sysFilter.filter != null) { + filter = JSON.parse(sysFilter.filter).childs[0].value; +} + +var foundAddresses = AddressValidationUtils.validate(filter, type, country); + +if (filter) + foundAddresses.push([filter, filter, filter, "", "", "", "", "", filter]); + +result.object(foundAddresses); \ No newline at end of file diff --git a/entity/AddressValidation_entity/titleProcess.js b/entity/AddressValidation_entity/titleProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..137427fc9c938b9d7ad105818377943e2c1a8e0a --- /dev/null +++ b/entity/AddressValidation_entity/titleProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$field.VALUE")); \ No newline at end of file diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index df8385fa8fbe6b6e32f925fcf2bba765e0d03d3d..cf8f5b77c530176b0dcb06a5db6f52259dab8ddd 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -37,7 +37,13 @@ <entityField> <name>CITY</name> <title>City</title> + <consumer>CityValidation</consumer> <mandatoryProcess>%aditoprj%/entity/Address_entity/entityfields/city/mandatoryProcess.js</mandatoryProcess> + <displayValueProcess>%aditoprj%/entity/Address_entity/entityfields/city/displayValueProcess.js</displayValueProcess> + <onValueChange>%aditoprj%/entity/Address_entity/entityfields/city/onValueChange.js</onValueChange> + <onValueChangeTypes> + <element>MASK</element> + </onValueChangeTypes> </entityField> <entityField> <name>COUNTRY</name> @@ -68,8 +74,14 @@ <entityField> <name>ZIP</name> <title>postcode</title> + <consumer>ZipValidation</consumer> <mandatoryProcess>%aditoprj%/entity/Address_entity/entityfields/zip/mandatoryProcess.js</mandatoryProcess> + <displayValueProcess>%aditoprj%/entity/Address_entity/entityfields/zip/displayValueProcess.js</displayValueProcess> <onValidation>%aditoprj%/entity/Address_entity/entityfields/zip/onValidation.js</onValidation> + <onValueChange>%aditoprj%/entity/Address_entity/entityfields/zip/onValueChange.js</onValueChange> + <onValueChangeTypes> + <element>MASK</element> + </onValueChangeTypes> </entityField> <entityProvider> <name>OrganisationAddresses</name> @@ -288,6 +300,30 @@ <contentTypeProcess>%aditoprj%/entity/Address_entity/entityfields/is_standard_icon/contentTypeProcess.js</contentTypeProcess> <valueProcess>%aditoprj%/entity/Address_entity/entityfields/is_standard_icon/valueProcess.js</valueProcess> </entityField> + <entityConsumer> + <name>ZipValidation</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <dependency> + <name>dependency</name> + <entityName>AddressValidation_entity</entityName> + <fieldName>ZipValidaton</fieldName> + </dependency> + <children> + <entityParameter> + <name>Country_param</name> + <valueProcess>%aditoprj%/entity/Address_entity/entityfields/zipvalidation/children/country_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> + <entityConsumer> + <name>CityValidation</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <dependency> + <name>dependency</name> + <entityName>AddressValidation_entity</entityName> + <fieldName>CityValidation</fieldName> + </dependency> + </entityConsumer> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Address_entity/entityfields/city/displayValueProcess.js b/entity/Address_entity/entityfields/city/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..de2c5e835eaf4fe6dd8b3521b3e17a39c9ac23c1 --- /dev/null +++ b/entity/Address_entity/entityfields/city/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/city/onValueChange.js b/entity/Address_entity/entityfields/city/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..29bde9d486834bcd1fcd747d5ded932d2fe60196 --- /dev/null +++ b/entity/Address_entity/entityfields/city/onValueChange.js @@ -0,0 +1,3 @@ +import("AddressValidation_lib"); + +AddressValidationUtils.setFields(); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/zip/displayValueProcess.js b/entity/Address_entity/entityfields/zip/displayValueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..de2c5e835eaf4fe6dd8b3521b3e17a39c9ac23c1 --- /dev/null +++ b/entity/Address_entity/entityfields/zip/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/zip/onValueChange.js b/entity/Address_entity/entityfields/zip/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..29bde9d486834bcd1fcd747d5ded932d2fe60196 --- /dev/null +++ b/entity/Address_entity/entityfields/zip/onValueChange.js @@ -0,0 +1,3 @@ +import("AddressValidation_lib"); + +AddressValidationUtils.setFields(); \ No newline at end of file diff --git a/entity/Address_entity/entityfields/zipvalidation/children/country_param/valueProcess.js b/entity/Address_entity/entityfields/zipvalidation/children/country_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..bece889b8e3ca6d6141ac5a750d0d068b23dc85a --- /dev/null +++ b/entity/Address_entity/entityfields/zipvalidation/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/Communication_entity/Communication_entity.aod b/entity/Communication_entity/Communication_entity.aod index 8c7e0e773a9a474fae34ce2b9438a725009f5c7f..dc93aa2b68f3689d6028ecb7131f699660e22b52 100644 --- a/entity/Communication_entity/Communication_entity.aod +++ b/entity/Communication_entity/Communication_entity.aod @@ -14,6 +14,11 @@ <mandatory v="true" /> <valueProcess>%aditoprj%/entity/Communication_entity/entityfields/addr/valueProcess.js</valueProcess> <onValidation>%aditoprj%/entity/Communication_entity/entityfields/addr/onValidation.js</onValidation> + <onValueChange>%aditoprj%/entity/Communication_entity/entityfields/addr/onValueChange.js</onValueChange> + <onValueChangeTypes> + <element>MASK</element> + <element>PROCESS</element> + </onValueChangeTypes> </entityField> <entityField> <name>COMMUNICATIONID</name> @@ -203,6 +208,15 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <name>DATE_EDIT</name> <valueProcess>%aditoprj%/entity/Communication_entity/entityfields/date_edit/valueProcess.js</valueProcess> </entityField> + <entityConsumer> + <name>AddressValidator</name> + <fieldType>DEPENDENCY_OUT</fieldType> + <dependency> + <name>dependency</name> + <entityName>AddressValidation_entity</entityName> + <fieldName>ZipValidaton</fieldName> + </dependency> + </entityConsumer> </entityFields> <recordContainers> <dbRecordContainer> diff --git a/entity/Communication_entity/entityfields/addr/onValueChange.js b/entity/Communication_entity/entityfields/addr/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..c6bc6676a2735c9892523a68b9719a4949cbf414 --- /dev/null +++ b/entity/Communication_entity/entityfields/addr/onValueChange.js @@ -0,0 +1,40 @@ +import("system.util"); +import("system.net"); +import("system.vars"); +import("Keyword_lib"); +import("KeywordRegistry_basic"); +import("system.neon"); +import("PostalAddress_lib"); + +var addr = vars.get("$this.value"); + +if (addr) +{ + var commMedium = vars.get("$field.MEDIUM_ID"); + var keywordAttributes = KeywordUtils.getAttributeRelationsByKey(commMedium, $KeywordRegistry.communicationMedium()); + var commCategory = keywordAttributes.contentType || "TEXT"; + + switch (commCategory) + { + case "TELEPHONE": // Phone + if(addr.length > 5) // https://services.aditosoftware.local/services/rest/ws_checkPhoneNumber?Number=017666862716&Country=DE + { + var url = "https://services.aditosoftware.local/services/rest/ws_checkPhoneNumber"; + var actionType = "GET"; + + var ret = JSON.parse(net.callRestWebserviceBasicAuth(url, actionType, {Number:addr, Country:vars.get("$param.ContactsMainCountry_param")}, null, null, "text/plain", "text/plain", util.DATA_TEXT, util.DATA_TEXT, "Admin", "a", true)); + if (ret.hasHttpSuccessStatusCode) + { + neon.setFieldValue("$field.ADDR", ret.body); + } + else + { + // error handling + } + } + break; + default: + + } + +} \ No newline at end of file diff --git a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js index ce4db7ef998d69e0ce250494359be8039a890003..ecccde702a88fb72646dd5d94ffd3917a22bec48 100644 --- a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js @@ -5,7 +5,6 @@ import("system.tools"); import("Util_lib"); import("Contact_lib"); import("JditoFilter_lib"); - var users; if (vars.exists("$local.idvalues") && vars.get("$local.idvalues")) users = [tools.getUser(vars.get("$local.idvalues"), tools.PROFILE_FULL)]; @@ -43,4 +42,4 @@ users = JditoFilterUtils.filterRecords(["UID", "TITLE", "TITLE_ORIGINAL", "ISACT ArrayUtils.sort2d(users, 0, true, false); //sort by username -result.object(users); \ No newline at end of file +result.object(users); diff --git a/neonContext/AddressValidation/AddressValidation.aod b/neonContext/AddressValidation/AddressValidation.aod new file mode 100644 index 0000000000000000000000000000000000000000..7542f8466fc2c7dbfbf84c32253d970b121a2517 --- /dev/null +++ b/neonContext/AddressValidation/AddressValidation.aod @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> + <name>AddressValidation</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <lookupview>AddressValidationLookup_view</lookupview> + <entity>AddressValidation_entity</entity> + <references> + <neonViewReference> + <name>a093b522-3dc9-4c77-85f1-46ed07bd4be7</name> + <view>AddressValidationLookup_view</view> + </neonViewReference> + </references> +</neonContext> diff --git a/neonView/AddressList_view/AddressList_view.aod b/neonView/AddressList_view/AddressList_view.aod index 0baa8a57551446a1b41fc43aff6da1974c8a0425..787f7afcf8b268f16dec05baa865904ded63beb9 100644 --- a/neonView/AddressList_view/AddressList_view.aod +++ b/neonView/AddressList_view/AddressList_view.aod @@ -42,6 +42,18 @@ <name>6af52273-25bf-4286-83cc-217aea94ad09</name> <entityField>ADDRIDENTIFIER</entityField> </neonTableColumn> + <neonTableColumn> + <name>af515eed-da89-49dc-ba3a-30958bd4fedd</name> + <entityField>DISTRICT</entityField> + </neonTableColumn> + <neonTableColumn> + <name>29dbb3f5-6f80-4100-aed3-334ac0b9cc48</name> + <entityField>REGION</entityField> + </neonTableColumn> + <neonTableColumn> + <name>aafc58cf-7dbb-42cb-b04c-d0869e58d09a</name> + <entityField>STATE</entityField> + </neonTableColumn> </columns> </titledListViewTemplate> </children> diff --git a/neonView/AddressValidationLookup_view/AddressValidationLookup_view.aod b/neonView/AddressValidationLookup_view/AddressValidationLookup_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..a0bf44af7ce2d5e9e872e1025e207d724ec1d3b6 --- /dev/null +++ b/neonView/AddressValidationLookup_view/AddressValidationLookup_view.aod @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.1"> + <name>AddressValidationLookup_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + </boxLayout> + </layout> + <children> + <tableViewTemplate> + <name>DataTable</name> + <entityField>#ENTITY</entityField> + <columns> + <neonTableColumn> + <name>a8787cc8-57a2-4cd5-903e-da14924a9052</name> + <entityField>ZIP</entityField> + </neonTableColumn> + <neonTableColumn> + <name>fb715731-9162-405e-b2e2-6c20921f026f</name> + <entityField>CITY</entityField> + </neonTableColumn> + <neonTableColumn> + <name>d32d92bf-db7d-443f-b911-6731ea89cf3b</name> + <entityField>COUNTRY</entityField> + </neonTableColumn> + <neonTableColumn> + <name>4035d833-ece7-4562-8acf-51c7a01b8497</name> + <entityField>DISTRICT</entityField> + </neonTableColumn> + <neonTableColumn> + <name>05bb9d3b-0e90-4a1a-bfe8-03b7dab6ed01</name> + <entityField>REGION</entityField> + </neonTableColumn> + <neonTableColumn> + <name>22779be5-4111-49c2-8821-0ec02cca40bb</name> + <entityField>STATE</entityField> + </neonTableColumn> + </columns> + </tableViewTemplate> + </children> +</neonView> diff --git a/process/AddressValidation_lib/AddressValidation_lib.aod b/process/AddressValidation_lib/AddressValidation_lib.aod new file mode 100644 index 0000000000000000000000000000000000000000..d9b312c9ea010874d7543ac38a170160ad71c158 --- /dev/null +++ b/process/AddressValidation_lib/AddressValidation_lib.aod @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<process xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.2.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/process/1.2.1"> + <name>AddressValidation_lib</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <process>%aditoprj%/process/AddressValidation_lib/process.js</process> + <variants> + <element>LIBRARY</element> + </variants> +</process> diff --git a/process/AddressValidation_lib/process.js b/process/AddressValidation_lib/process.js new file mode 100644 index 0000000000000000000000000000000000000000..af396923f550141fe170c0242dc7e9dcb430aa31 --- /dev/null +++ b/process/AddressValidation_lib/process.js @@ -0,0 +1,104 @@ +import("system.vars"); +import("system.neon"); +import("system.net"); +import("system.util"); +import("system.logging"); + +function AddressValidationType(pKey, pParamName) +{ + this.key = pKey; + this.paramName = pParamName; +} + +AddressValidationType.get = function(pKey) +{ + if (!this._cache) + this._cache = { + TYPE_ZIP: new AddressValidationType("TYPE_ZIP", "zip"), + TYPE_CITY: new AddressValidationType("TYPE_CITY", "city") + } + + if (pKey) + return this._cache[pKey]; + + return this._cache; +} + +/** + * Class containing utility functions for address validation + * do not create an instance of this + * + * @class + */ +function AddressValidationUtils() {} + +AddressValidationUtils.validate = function(pValue, pType, pCountry) +{ + // TODO: Options for url, user, pw + var userName = "Admin"; + var pw = "a"; + + // get AddressValidationType-Object if it is only the key + if (typeof pType == "string") + pType = AddressValidationType.get(pType); + + if (pValue && pType) + { + var parameters = {}; + + if (pCountry) + { + parameters.country = pCountry; + } + + parameters[pType.paramName] = pValue; + + var url = "https://services.aditosoftware.local/services/rest/ws_checkAddress"; + var actionType = "GET"; + + var ret = JSON.parse(net.callRestWebserviceBasicAuth(url, actionType, parameters, null, null, "text/plain", "text/plain", util.DATA_TEXT, util.DATA_TEXT, userName, pw, true)); + if (ret.hasHttpSuccessStatusCode) + { + return JSON.parse(ret.body).map(function(pAddress) + { + var data = pAddress[0]; + return [ + JSON.stringify(data), + pAddress[1], + data.zip, + data.city, + data.country, + data.district, + data.region, + data.state, + data[pType.paramName] + ] + }); + } + else + { + + // error handling + } + } + + return []; +} + +AddressValidationUtils.setFields = function() +{ + var data = JSON.parse(vars.get("$this.value")); + + _setField("$field.ZIP", data.zip); + _setField("$field.COUNTRY", data.country); + _setField("$field.CITY", data.city); + _setField("$field.DISTRICT", data.district); + _setField("$field.REGION", data.region); + _setField("$field.STATE", data.state); + + function _setField(pField, pValue) + { + if (pValue) + neon.setFieldValue(pField, pValue); + } +} \ No newline at end of file