Skip to content

Commit 16466de

Browse files
author
Orestis Tsakiridis
committed
Copied changes to numbers mybatis descriptor to all places throughout the codebase (tests, mysql descriptors etc.)
Refers #2608
1 parent a52451b commit 16466de

8 files changed

Lines changed: 139 additions & 46 deletions

File tree

restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/incoming-phone-numbers.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
</if>
6868
<if test="phoneNumber != null">
6969
AND n.phone_number like #{phoneNumber}
70+
</if>
71+
<if test="applicationSid != null">
72+
AND (n.voice_application_sid = #{applicationSid} OR n.sms_application_sid = #{applicationSid} OR n.ussd_application_sid = #{applicationSid} OR n.refer_application_sid = #{applicationSid})
7073
</if>
7174
<choose>
7275
<when test="sortBy == 'phone_number'">
@@ -90,6 +93,9 @@
9093
<if test="phoneNumber != null">
9194
AND phone_number like #{phoneNumber}
9295
</if>
96+
<if test="applicationSid != null">
97+
AND (voice_application_sid = #{applicationSid} OR sms_application_sid = #{applicationSid} OR ussd_application_sid = #{applicationSid} OR refer_application_sid = #{applicationSid})
98+
</if>
9399

94100
</select>
95101

restcomm/restcomm.application/src/main/webapp/WEB-INF/sql/incoming-phone-numbers.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
<if test="phoneNumber != null">
6969
AND "n"."phone_number" like #{phoneNumber}
7070
</if>
71+
<if test="applicationSid != null">
72+
AND ("n"."voice_application_sid" = #{applicationSid} OR "n"."sms_application_sid" = #{applicationSid} OR "n"."ussd_application_sid" = #{applicationSid} OR "n"."refer_application_sid" = #{applicationSid})
73+
</if>
7174
<choose>
7275
<when test="sortBy == 'phone_number'">
7376
order by "n"."phone_number" ${sortDirection}
@@ -92,8 +95,10 @@
9295
<if test="phoneNumber != null">
9396
AND "phone_number" like #{phoneNumber}
9497
</if>
95-
96-
</select>
98+
<if test="applicationSid != null">
99+
AND ("voice_application_sid" = #{applicationSid} OR "sms_application_sid" = #{applicationSid} OR "ussd_application_sid" = #{applicationSid} OR "refer_application_sid" = #{applicationSid})
100+
</if>
101+
</select>
97102

98103

99104
<delete id="removeIncomingPhoneNumber" parameterType="string">

restcomm/restcomm.dao/src/test/resources/applicationsDao/incoming-phone-numbers.xml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
~ TeleStax, Open Source Cloud Communications
4-
~ Copyright 2011-2014, Telestax Inc and individual contributors
5-
~ by the @authors tag.
6-
~
7-
~ This program is free software: you can redistribute it and/or modify
8-
~ under the terms of the GNU Affero General Public License as
9-
~ published by the Free Software Foundation; either version 3 of
10-
~ the License, or (at your option) any later version.
11-
~
12-
~ This program is distributed in the hope that it will be useful,
13-
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
14-
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15-
~ GNU Affero General Public License for more details.
16-
~
17-
~ You should have received a copy of the GNU Affero General Public License
18-
~ along with this program. If not, see <http://www.gnu.org/licenses/>
19-
~
20-
-->
21-
222
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
233
<!--
244
@author thomas.quintana@telestax.com (Thomas Quintana)

restcomm/restcomm.dao/src/test/resources/incoming-phone-numbers.xml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,37 @@
6767
<if test="phoneNumber != null">
6868
AND "n"."phone_number" like #{phoneNumber}
6969
</if>
70+
<if test="applicationSid != null">
71+
AND ("n"."voice_application_sid" = #{applicationSid} OR "n"."sms_application_sid" = #{applicationSid} OR "n"."ussd_application_sid" = #{applicationSid} OR "n"."refer_application_sid" = #{applicationSid})
72+
</if>
7073
<choose>
71-
<when test="sortBy == 'phone_number'">
72-
order by "n"."phone_number" ${sortDirection}
73-
</when>
74-
<when test="sortBy == 'friendly_name'">
75-
order by "n"."friendly_name" ${sortDirection}
76-
</when>
77-
<otherwise>
78-
order by "n"."phone_number" ${sortDirection}
79-
</otherwise>
80-
</choose>
81-
74+
<when test="sortBy == 'phone_number'">
75+
order by "n"."phone_number" ${sortDirection}
76+
</when>
77+
<when test="sortBy == 'friendly_name'">
78+
order by "n"."friendly_name" ${sortDirection}
79+
</when>
80+
<otherwise>
81+
order by "n"."phone_number" ${sortDirection}
82+
</otherwise>
83+
</choose>
84+
8285
LIMIT #{limit} OFFSET #{offset}
8386
</select>
84-
87+
8588
<select id="getTotalIncomingPhoneNumbersByUsingFilters" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="int">
86-
SELECT COUNT(*) FROM "restcomm_incoming_phone_numbers" WHERE "account_sid"=#{accountSid}
89+
SELECT COUNT(*) FROM "restcomm_incoming_phone_numbers" WHERE "account_sid"=#{accountSid}
8790

88-
<if test="friendlyName != null">
91+
<if test="friendlyName != null">
8992
AND "friendly_name"=#{friendlyName}
9093
</if>
9194
<if test="phoneNumber != null">
9295
AND "phone_number" like #{phoneNumber}
9396
</if>
94-
95-
</select>
97+
<if test="applicationSid != null">
98+
AND ("voice_application_sid" = #{applicationSid} OR "sms_application_sid" = #{applicationSid} OR "ussd_application_sid" = #{applicationSid} OR "refer_application_sid" = #{applicationSid})
99+
</if>
100+
</select>
96101

97102

98103
<delete id="removeIncomingPhoneNumber" parameterType="string">

restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/IncomingPhoneNumbersEndpoint.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ protected Response getIncomingPhoneNumbers(final String accountSid, final PhoneN
292292
try{
293293
String phoneNumberFilter = info.getQueryParameters().getFirst("PhoneNumber");
294294
String friendlyNameFilter = info.getQueryParameters().getFirst("FriendlyName");
295+
String applicationSid = info.getQueryParameters().getFirst("ApplicationSid");
295296
String page = info.getQueryParameters().getFirst("Page");
296297
String reverse = info.getQueryParameters().getFirst("Reverse");
297298
String pageSize = info.getQueryParameters().getFirst("PageSize");
@@ -306,14 +307,14 @@ protected Response getIncomingPhoneNumbers(final String accountSid, final PhoneN
306307
int pageAsInt = Integer.parseInt(page);
307308
int offset = (page == "0") ? 0 : (((pageAsInt - 1) * limit) + limit);
308309
IncomingPhoneNumberFilter incomingPhoneNumberFilter = new IncomingPhoneNumberFilter(accountSid, friendlyNameFilter,
309-
phoneNumberFilter);
310+
phoneNumberFilter, applicationSid);
310311
final int total = dao.getTotalIncomingPhoneNumbers(incomingPhoneNumberFilter);
311312

312313
if (pageAsInt > (total / limit)) {
313314
return status(javax.ws.rs.core.Response.Status.BAD_REQUEST).build();
314315
}
315316

316-
incomingPhoneNumberFilter = new IncomingPhoneNumberFilter(accountSid, friendlyNameFilter, phoneNumberFilter, null, sortBy,
317+
incomingPhoneNumberFilter = new IncomingPhoneNumberFilter(accountSid, friendlyNameFilter, phoneNumberFilter, applicationSid, sortBy,
317318
reverse, limit, offset);
318319

319320
final List<IncomingPhoneNumber> incomingPhoneNumbers = dao.getIncomingPhoneNumbersByFilter(incomingPhoneNumberFilter);

restcomm/restcomm.mrb/src/test/resources/mappers/incoming-phone-numbers.xml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,55 @@
4040
-->
4141

4242
<!-- along with the DID it returns the application frien-->
43-
<select id="getIncomingPhoneNumbersByFriendlyName" parameterType="string" resultType="hashmap">
43+
<select id="getIncomingPhoneNumbersByFriendlyName" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="hashmap">
4444
SELECT
4545
"n".*,
4646
"a_voice"."friendly_name" "voice_application_name",
4747
"a_sms"."friendly_name" "sms_application_name",
48-
"a_ussd"."friendly_name" "ussd_application_name"
48+
"a_ussd"."friendly_name" "ussd_application_name",
49+
"a_refer"."friendly_name" "refer_application_name"
4950
FROM "restcomm_incoming_phone_numbers" "n"
5051
LEFT OUTER JOIN "restcomm_applications" "a_voice" ON "n"."voice_application_sid" = "a_voice"."sid"
5152
LEFT OUTER JOIN "restcomm_applications" "a_sms" ON "n"."sms_application_sid" = "a_sms"."sid"
5253
LEFT OUTER JOIN "restcomm_applications" "a_ussd" ON "n"."ussd_application_sid" = "a_ussd"."sid"
54+
LEFT OUTER JOIN "restcomm_applications" "a_refer" ON "n"."refer_application_sid" = "a_refer"."sid"
5355
WHERE "account_sid"=#{accountSid}
5456
<if test="friendlyName != null">
5557
AND "n"."friendly_name"=#{friendlyName}
5658
</if>
5759
<if test="phoneNumber != null">
5860
AND "n"."phone_number" like #{phoneNumber}
5961
</if>
62+
<if test="applicationSid != null">
63+
AND ("n"."voice_application_sid" = #{applicationSid} OR "n"."sms_application_sid" = #{applicationSid} OR "n"."ussd_application_sid" = #{applicationSid} OR "n"."refer_application_sid" = #{applicationSid})
64+
</if>
65+
<choose>
66+
<when test="sortBy == 'phone_number'">
67+
order by "n"."phone_number" ${sortDirection}
68+
</when>
69+
<when test="sortBy == 'friendly_name'">
70+
order by "n"."friendly_name" ${sortDirection}
71+
</when>
72+
<otherwise>
73+
order by "n"."phone_number" ${sortDirection}
74+
</otherwise>
75+
</choose>
76+
77+
LIMIT #{limit} OFFSET #{offset}
78+
</select>
79+
80+
<select id="getTotalIncomingPhoneNumbersByUsingFilters" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="int">
81+
SELECT COUNT(*) FROM "restcomm_incoming_phone_numbers" WHERE "account_sid"=#{accountSid}
82+
83+
<if test="friendlyName != null">
84+
AND "friendly_name"=#{friendlyName}
85+
</if>
86+
<if test="phoneNumber != null">
87+
AND "phone_number" like #{phoneNumber}
88+
</if>
89+
<if test="applicationSid != null">
90+
AND ("voice_application_sid" = #{applicationSid} OR "sms_application_sid" = #{applicationSid} OR "ussd_application_sid" = #{applicationSid} OR "refer_application_sid" = #{applicationSid})
91+
</if>
6092
</select>
6193

6294
<delete id="removeIncomingPhoneNumber" parameterType="string">

restcomm/restcomm.telephony/resources/mappers/incoming-phone-numbers.xml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,55 @@
4040
-->
4141

4242
<!-- along with the DID it returns the application frien-->
43-
<select id="getIncomingPhoneNumbersByFriendlyName" parameterType="string" resultType="hashmap">
43+
<select id="getIncomingPhoneNumbersByFriendlyName" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="hashmap">
4444
SELECT
4545
"n".*,
4646
"a_voice"."friendly_name" "voice_application_name",
4747
"a_sms"."friendly_name" "sms_application_name",
48-
"a_ussd"."friendly_name" "ussd_application_name"
48+
"a_ussd"."friendly_name" "ussd_application_name",
49+
"a_refer"."friendly_name" "refer_application_name"
4950
FROM "restcomm_incoming_phone_numbers" "n"
5051
LEFT OUTER JOIN "restcomm_applications" "a_voice" ON "n"."voice_application_sid" = "a_voice"."sid"
5152
LEFT OUTER JOIN "restcomm_applications" "a_sms" ON "n"."sms_application_sid" = "a_sms"."sid"
5253
LEFT OUTER JOIN "restcomm_applications" "a_ussd" ON "n"."ussd_application_sid" = "a_ussd"."sid"
54+
LEFT OUTER JOIN "restcomm_applications" "a_refer" ON "n"."refer_application_sid" = "a_refer"."sid"
5355
WHERE "account_sid"=#{accountSid}
5456
<if test="friendlyName != null">
5557
AND "n"."friendly_name"=#{friendlyName}
5658
</if>
5759
<if test="phoneNumber != null">
5860
AND "n"."phone_number" like #{phoneNumber}
5961
</if>
62+
<if test="applicationSid != null">
63+
AND ("n"."voice_application_sid" = #{applicationSid} OR "n"."sms_application_sid" = #{applicationSid} OR "n"."ussd_application_sid" = #{applicationSid} OR "n"."refer_application_sid" = #{applicationSid})
64+
</if>
65+
<choose>
66+
<when test="sortBy == 'phone_number'">
67+
order by "n"."phone_number" ${sortDirection}
68+
</when>
69+
<when test="sortBy == 'friendly_name'">
70+
order by "n"."friendly_name" ${sortDirection}
71+
</when>
72+
<otherwise>
73+
order by "n"."phone_number" ${sortDirection}
74+
</otherwise>
75+
</choose>
76+
77+
LIMIT #{limit} OFFSET #{offset}
78+
</select>
79+
80+
<select id="getTotalIncomingPhoneNumbersByUsingFilters" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="int">
81+
SELECT COUNT(*) FROM "restcomm_incoming_phone_numbers" WHERE "account_sid"=#{accountSid}
82+
83+
<if test="friendlyName != null">
84+
AND "friendly_name"=#{friendlyName}
85+
</if>
86+
<if test="phoneNumber != null">
87+
AND "phone_number" like #{phoneNumber}
88+
</if>
89+
<if test="applicationSid != null">
90+
AND ("voice_application_sid" = #{applicationSid} OR "sms_application_sid" = #{applicationSid} OR "ussd_application_sid" = #{applicationSid} OR "refer_application_sid" = #{applicationSid})
91+
</if>
6092
</select>
6193

6294
<delete id="removeIncomingPhoneNumber" parameterType="string">

restcomm/restcomm.telephony/src/test/resources/mappers/incoming-phone-numbers.xml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,55 @@
4040
-->
4141

4242
<!-- along with the DID it returns the application frien-->
43-
<select id="getIncomingPhoneNumbersByFriendlyName" parameterType="string" resultType="hashmap">
43+
<select id="getIncomingPhoneNumbersByFriendlyName" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="hashmap">
4444
SELECT
4545
"n".*,
4646
"a_voice"."friendly_name" "voice_application_name",
4747
"a_sms"."friendly_name" "sms_application_name",
48-
"a_ussd"."friendly_name" "ussd_application_name"
48+
"a_ussd"."friendly_name" "ussd_application_name",
49+
"a_refer"."friendly_name" "refer_application_name"
4950
FROM "restcomm_incoming_phone_numbers" "n"
5051
LEFT OUTER JOIN "restcomm_applications" "a_voice" ON "n"."voice_application_sid" = "a_voice"."sid"
5152
LEFT OUTER JOIN "restcomm_applications" "a_sms" ON "n"."sms_application_sid" = "a_sms"."sid"
5253
LEFT OUTER JOIN "restcomm_applications" "a_ussd" ON "n"."ussd_application_sid" = "a_ussd"."sid"
54+
LEFT OUTER JOIN "restcomm_applications" "a_refer" ON "n"."refer_application_sid" = "a_refer"."sid"
5355
WHERE "account_sid"=#{accountSid}
5456
<if test="friendlyName != null">
5557
AND "n"."friendly_name"=#{friendlyName}
5658
</if>
5759
<if test="phoneNumber != null">
5860
AND "n"."phone_number" like #{phoneNumber}
5961
</if>
62+
<if test="applicationSid != null">
63+
AND ("n"."voice_application_sid" = #{applicationSid} OR "n"."sms_application_sid" = #{applicationSid} OR "n"."ussd_application_sid" = #{applicationSid} OR "n"."refer_application_sid" = #{applicationSid})
64+
</if>
65+
<choose>
66+
<when test="sortBy == 'phone_number'">
67+
order by "n"."phone_number" ${sortDirection}
68+
</when>
69+
<when test="sortBy == 'friendly_name'">
70+
order by "n"."friendly_name" ${sortDirection}
71+
</when>
72+
<otherwise>
73+
order by "n"."phone_number" ${sortDirection}
74+
</otherwise>
75+
</choose>
76+
77+
LIMIT #{limit} OFFSET #{offset}
78+
</select>
79+
80+
<select id="getTotalIncomingPhoneNumbersByUsingFilters" parameterType="org.restcomm.connect.dao.entities.IncomingPhoneNumberFilter" resultType="int">
81+
SELECT COUNT(*) FROM "restcomm_incoming_phone_numbers" WHERE "account_sid"=#{accountSid}
82+
83+
<if test="friendlyName != null">
84+
AND "friendly_name"=#{friendlyName}
85+
</if>
86+
<if test="phoneNumber != null">
87+
AND "phone_number" like #{phoneNumber}
88+
</if>
89+
<if test="applicationSid != null">
90+
AND ("voice_application_sid" = #{applicationSid} OR "sms_application_sid" = #{applicationSid} OR "ussd_application_sid" = #{applicationSid} OR "refer_application_sid" = #{applicationSid})
91+
</if>
6092
</select>
6193

6294
<delete id="removeIncomingPhoneNumber" parameterType="string">

0 commit comments

Comments
 (0)