Skip to content

Commit e372232

Browse files
committed
getApplicationsWithNumbers orders by date_created,sid instead of only date_created.
Also simplified getApplications() interface. Refers #2517, PR #2550
1 parent 647bcfd commit e372232

File tree

11 files changed

+12
-15
lines changed

11 files changed

+12
-15
lines changed

Diff for: restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/applications.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
OR num.ussd_application_sid = app.sid
4343
OR num.refer_application_sid = app.sid
4444
WHERE (app.account_sid=#{account_sid} or app.account_sid is null)
45-
ORDER BY app.date_created;
45+
ORDER BY app.date_created, app.sid;
4646
</select>
4747

4848
<delete id="removeApplication" parameterType="string">

Diff for: restcomm/restcomm.application/src/main/webapp/WEB-INF/sql/applications.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
OR "num"."ussd_application_sid" = "app"."sid"
6363
OR "num"."refer_application_sid" = "app"."sid"
6464
WHERE ("app"."account_sid"=#{account_sid} or "app"."account_sid" is null)
65-
ORDER BY "app"."date_created";
65+
ORDER BY "app"."date_created", "app"."sid";
6666
</select>
6767

6868

Diff for: restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/ApplicationsDao.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface ApplicationsDao {
3737
List<Application> getApplications(Sid accountSid);
3838

3939
// this may optionally return related numbers as part of an Application
40-
List<Application> getApplications(Sid accountSid, boolean includeNumbers);
40+
List<Application> getApplicationsWithNumbers(Sid accountSid);
4141

4242
void removeApplication(Sid sid);
4343

Diff for: restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/mybatis/MybatisApplicationsDao.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ private Application getApplication(final String selector, final String parameter
9595
}
9696

9797
@Override
98-
public List<Application> getApplications(Sid accountSid, boolean includeNumbers) {
99-
if (!includeNumbers)
100-
return getApplications(accountSid);
101-
98+
public List<Application> getApplicationsWithNumbers(Sid accountSid) {
10299
final SqlSession session = sessions.openSession();
103100
try {
104101
final List<Map<String, Object>> results = session.selectList(namespace + "getApplicationsAndNumbers", accountSid.toString());

Diff for: restcomm/restcomm.dao/src/test/java/org/restcomm/connect/dao/mybatis/ApplicationRetrievalTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ public void retrieveApplications() {
8080
@Test
8181
public void retrieveApplicationsAndTheirNumbers() {
8282
ApplicationsDao dao = manager.getApplicationsDao();
83-
List<Application> apps = dao.getApplications(new Sid("ACae6e420f425248d6a26948c17a9e2acf"), true);
83+
List<Application> apps = dao.getApplicationsWithNumbers(new Sid("ACae6e420f425248d6a26948c17a9e2acf"));
8484

8585
Assert.assertEquals(5, apps.size());
8686
Assert.assertNotNull(searchApplicationBySid(new Sid("AP73926e7113fa4d95981aa96b76eca854"),apps).getNumbers());
8787
// applications bound with many numbers are property returned
88-
Assert.assertEquals("Three (3) numbers should be bound to this application", searchApplicationBySid(new Sid("AP73926e7113fa4d95981aa96b76eca854"),apps).getNumbers().size(), 3);
88+
Assert.assertEquals("Three (3) numbers should be bound to this application", 3, searchApplicationBySid(new Sid("AP73926e7113fa4d95981aa96b76eca854"),apps).getNumbers().size());
8989
// applications bound with no numbers are properly returned
9090
Assert.assertNull(searchApplicationBySid(new Sid("AP00000000000000000000000000000004"),apps).getNumbers());
9191
// applications bound to numbers that belong to different account should not be returned (for now at least)

Diff for: restcomm/restcomm.dao/src/test/resources/applications.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
OR "num"."ussd_application_sid" = "app"."sid"
6363
OR "num"."refer_application_sid" = "app"."sid"
6464
WHERE ("app"."account_sid"=#{account_sid} or "app"."account_sid" is null)
65-
ORDER BY "app"."date_created";
65+
ORDER BY "app"."date_created", "app"."sid";
6666
</select>
6767

6868

Diff for: restcomm/restcomm.dao/src/test/resources/applicationsDao/applications.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
OR "num"."ussd_application_sid" = "app"."sid"
6363
OR "num"."refer_application_sid" = "app"."sid"
6464
WHERE ("app"."account_sid"=#{account_sid} or "app"."account_sid" is null)
65-
ORDER BY "app"."date_created";
65+
ORDER BY "app"."date_created", "app"."sid";
6666
</select>
6767

6868

Diff for: restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/ApplicationsEndpoint.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected Response getApplications(final String accountSid, final MediaType resp
161161
if (tmp != null && tmp.equalsIgnoreCase("true"))
162162
includeNumbers = true;
163163

164-
final List<Application> applications = dao.getApplications(account.getSid(), includeNumbers);
164+
final List<Application> applications = dao.getApplicationsWithNumbers(account.getSid());
165165
if (APPLICATION_XML_TYPE == responseType) {
166166
final RestCommResponse response = new RestCommResponse(new ApplicationList(applications));
167167
return ok(xstream.toXML(response), APPLICATION_XML).build();

Diff for: restcomm/restcomm.mrb/src/test/resources/mappers/applications.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
OR "num"."ussd_application_sid" = "app"."sid"
6363
OR "num"."refer_application_sid" = "app"."sid"
6464
WHERE ("app"."account_sid"=#{account_sid} or "app"."account_sid" is null)
65-
ORDER BY "app"."date_created";
65+
ORDER BY "app"."date_created", "app"."sid";
6666
</select>
6767

6868

Diff for: restcomm/restcomm.telephony/resources/mappers/applications.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
OR "num"."ussd_application_sid" = "app"."sid"
6363
OR "num"."refer_application_sid" = "app"."sid"
6464
WHERE ("app"."account_sid"=#{account_sid} or "app"."account_sid" is null)
65-
ORDER BY "app"."date_created";
65+
ORDER BY "app"."date_created", "app"."sid";
6666
</select>
6767

6868

Diff for: restcomm/restcomm.telephony/src/test/resources/mappers/applications.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
OR "num"."ussd_application_sid" = "app"."sid"
6363
OR "num"."refer_application_sid" = "app"."sid"
6464
WHERE ("app"."account_sid"=#{account_sid} or "app"."account_sid" is null)
65-
ORDER BY "app"."date_created";
65+
ORDER BY "app"."date_created", "app"."sid";
6666
</select>
6767

6868

0 commit comments

Comments
 (0)