Skip to content
Snippets Groups Projects
Commit 8b89a8c9 authored by S.Listl's avatar S.Listl
Browse files

#1063319 Address fields for lat and lon, location added to Organisation index

parent ad84517f
No related branches found
No related tags found
No related merge requests found
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<changeSet author="s.listl" id="2f2d806c-8aab-42f0-91c2-c7d15322d89f">
<addColumn tableName="ADDRESS">
<column name="LAT" type="DECIMAL(10,8)"/>
<column name="LON" type="DECIMAL(11,8)"/>
</addColumn>
</changeSet>
</databaseChangeLog>
......@@ -2,6 +2,7 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<include file="AlterButtonLabelTitles/AlterButtonLabelTitles.xml" relativeToChangelogFile="true" />
<include file="add_Address_LatLon.xml" relativeToChangelogFile="true"/>
<!-- disabled the following script since it is WIP-->
<!--<include file="VisitPlanEntry/rename_VisitPlanEntry_ORGANISATION_ID.xml" relativeToChangelogFile="true" />-->
</databaseChangeLog>
......@@ -50,5 +50,5 @@
<include file="generatedData/exporttemplatefield.xml" relativeToChangelogFile="true"/>
<include file="generatedData/exporttemplateplaceofuse.xml" relativeToChangelogFile="true"/>
<include file="generatedData/documenttemplateplaceofuse.xml" relativeToChangelogFile="true"/>
<include file="generatedData/visitplan.xml" relativeToChangelogFile="true"/>
<!--<include file="generatedData/visitplan.xml" relativeToChangelogFile="true"/>-->
</databaseChangeLog>
\ No newline at end of file
......@@ -14,6 +14,7 @@
<include relativeToChangelogFile="true" file="basic/2020.1.0/changelog.xml"/>
<include relativeToChangelogFile="true" file="basic/2020.1.1/changelog.xml"/>
<include relativeToChangelogFile="true" file="basic/2020.1.2/changelog.xml"/>
<include relativeToChangelogFile="true" file="basic/2020.1.3/changelog.xml"/>
<!--enable this only when you definetly want to overwrite the existing data with demo records:-->
<!--<include relativeToChangelogFile="true" file="basic/_demoData/changelog.xml" context="example"/>-->
......
......@@ -1143,6 +1143,34 @@
<title>Creation user</title>
<description></description>
</entityFieldDb>
<entityFieldDb>
<name>LON</name>
<dbName></dbName>
<primaryKey v="false" />
<columnType v="3" />
<size v="11" />
<scale v="8" />
<notNull v="false" />
<isUnique v="false" />
<index v="false" />
<documentation></documentation>
<title></title>
<description></description>
</entityFieldDb>
<entityFieldDb>
<name>LAT</name>
<dbName></dbName>
<primaryKey v="false" />
<columnType v="3" />
<size v="10" />
<scale v="8" />
<notNull v="false" />
<isUnique v="false" />
<index v="false" />
<documentation></documentation>
<title></title>
<description></description>
</entityFieldDb>
</entityFields>
</entityDb>
<entityDb>
......
......@@ -469,6 +469,16 @@
<name>ReplaceStandardAddress_param</name>
<expose v="true" />
</entityParameter>
<entityField>
<name>LAT</name>
<title>Latitude</title>
<contentType>NUMBER</contentType>
</entityField>
<entityField>
<name>LON</name>
<title>Longitude</title>
<contentType>NUMBER</contentType>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......@@ -577,6 +587,14 @@
<name>COUNTRY.displayValue</name>
<expression>%aditoprj%/entity/Address_entity/recordcontainers/db/recordfieldmappings/country.displayvalue/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>LAT.value</name>
<recordfield>ADDRESS.LAT</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>LON.value</name>
<recordfield>ADDRESS.LON</recordfield>
</dbRecordFieldMapping>
</recordFieldMappings>
</dbRecordContainer>
</recordContainers>
......
......@@ -1353,6 +1353,12 @@
</affectedTables>
<affectedIds>%aditoprj%/entity/Organisation_entity/recordcontainers/index/affectedIds.js</affectedIds>
<indexFieldMappings>
<indexRecordFieldMapping>
<name>#LOCATION</name>
<systemField>LOCATION</systemField>
<isFilterable v="false" />
<isLookupFilter v="false" />
</indexRecordFieldMapping>
<indexRecordFieldMapping>
<name>NAME.value</name>
<indexFieldType>PROPER_NAME</indexFieldType>
......
......@@ -5,6 +5,7 @@ import("system.calendars");
import("system.db");
import("Sql_lib");
import("Communication_lib");
import("system.SQLTYPES");
/*
Before changing the results that are returned here:
......@@ -12,40 +13,39 @@ Please keep in mind that some of the indexfields are used in other modules (like
You may want to check out if your change affects other modules. However adding more fields should not be a problem therefor.
*/
var sqlQuery, sqlHelper, queryCondition, affectedIds;
var CommMediumPhoneIds = db.array( db.COLUMN, "select KEYID from AB_KEYWORD_ENTRY join ab_keyword_attributerelation on AB_KEYWORD_ENTRYID = AB_KEYWORD_ENTRY_ID "
+ " join ab_keyword_attribute on AB_KEYWORD_ATTRIBUTEID = AB_KEYWORD_ATTRIBUTE_ID and CHAR_VALUE = 'TELEPHONE' and AB_KEYWORD_ATTRIBUTE.CONTAINER = 'CommunicationMedium'");
sqlHelper = new SqlMaskingUtils();
var querySelect = newSelect("CONTACT.CONTACTID "
+ ", " + sqlHelper.concat(["ORGANISATION.NAME", "'|'", "ORGANISATION.CUSTOMERCODE"])
+ ", " + sqlHelper.concat([
sqlHelper.concat(["defaultAddress.ADDRESS", "defaultAddress.BUILDINGNO", "'-'"
,"defaultAddress.COUNTRY", "defaultAddress.ZIP", "defaultAddress.CITY"])
,sqlHelper.concat(["'" + translate.text("Phone") + ":'", "(" + CommUtil.getStandardSubSqlPhone() + ")"])
,sqlHelper.concat(["'" + translate.text("Email") + ":'", "(" + CommUtil.getStandardSubSqlMail() + ")"])
], " | ")
//additional indexed fields
+ ", ORGANISATION.NAME"
+ ", ORGANISATION.ORGANISATIONID"
+ ", CONTACT.CONTACTID"
+ ", ORGANISATION.CUSTOMERCODE"
+ ", ADDRESS.ADDRESS "
+ ", ADDRESS.COUNTRY "
+ ", ADDRESS.ZIP "
+ ", ADDRESS.CITY "
+ ", COMMUNICATION.ADDR "
+ ", PHONE.ADDR "
)
.from("ORGANISATION")
.join("CONTACT", "CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID and CONTACT.PERSON_ID is null")
.leftJoin("ADDRESS", "defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID", "defaultAddress")
.leftJoin("ADDRESS", "ADDRESS.CONTACT_ID = CONTACT.CONTACTID")
.leftJoin("COMMUNICATION", "COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID")
.leftJoin("COMMUNICATION", "PHONE.CONTACT_ID = CONTACT.CONTACTID and PHONE.MEDIUM_ID in ('" + CommMediumPhoneIds.join("', '") + "')", "PHONE")//TODO: refactor to new SqlBuilder
var commMediumPhoneIds = CommUtil.getMediumIdsByCategory("PHONE");
var sqlHelper = new SqlMaskingUtils();
var querySelect = newSelect([
"CONTACT.CONTACTID",
sqlHelper.concat(["ORGANISATION.NAME", "'|'", "ORGANISATION.CUSTOMERCODE"]),
sqlHelper.concat([
sqlHelper.concat(["defaultAddress.ADDRESS", "defaultAddress.BUILDINGNO", "'-'"
,"defaultAddress.COUNTRY", "defaultAddress.ZIP", "defaultAddress.CITY"]),
sqlHelper.concat(["'" + translate.text("Phone") + ":'", "(" + CommUtil.getStandardSubSqlPhone() + ")"]),
sqlHelper.concat(["'" + translate.text("Email") + ":'", "(" + CommUtil.getStandardSubSqlMail() + ")"])
], " | "),
sqlHelper.concat([sqlHelper.cast("ADDRESS.LAT", SQLTYPES.VARCHAR, 16), sqlHelper.cast("ADDRESS.LON", SQLTYPES.VARCHAR, 16)], ","),
//additional indexed fields
"ORGANISATION.NAME",
"ORGANISATION.ORGANISATIONID",
"CONTACT.CONTACTID",
"ORGANISATION.CUSTOMERCODE",
"ADDRESS.ADDRESS",
"ADDRESS.COUNTRY",
"ADDRESS.ZIP",
"ADDRESS.CITY",
"COMMUNICATION.ADDR",
"PHONE.ADDR"
])
.from("ORGANISATION")
.join("CONTACT", "CONTACT.ORGANISATION_ID = ORGANISATION.ORGANISATIONID and CONTACT.PERSON_ID is null")
.leftJoin("ADDRESS", "defaultAddress.ADDRESSID = CONTACT.ADDRESS_ID", "defaultAddress")
.leftJoin("ADDRESS", "ADDRESS.CONTACT_ID = CONTACT.CONTACTID")
.leftJoin("COMMUNICATION", "COMMUNICATION.CONTACT_ID = CONTACT.CONTACTID")
.leftJoin("COMMUNICATION", newWhere("phone.CONTACT_ID = CONTACT.CONTACTID")
.and(["COMMUNICATION", "MEDIUM_ID", "phone"], commMediumPhoneIds, SqlBuilder.IN()), "phone");
if (vars.exists("$local.idvalue") && vars.get("$local.idvalue") && vars.get("$local.idvalue").length > 0)
{
querySelect.where("CONTACT.CONTACTID", vars.get("$local.idvalue"), SqlBuilder.IN());
}
querySelect.where("CONTACT.CONTACTID", "$local.idvalue", SqlBuilder.IN());
result.string(querySelect.toString());
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