cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
969
Views
5
Helpful
1
Replies

Retrieving primary line DN on a Device

Mamdouh Elgamal
Level 1
Level 1

Hello,

i'm working on a java tool that accomplishes the following:

loop through a string array of CUCM end user userIds ---> check if enduser is associated with a device ---> get device name and run following SQL Query

String sqlQuery = "select numplan.dnorpattern, devicenumplanmap.e164mask from device, numplan, devicenumplanmap "

                + "where device.pkid = devicenumplanmap.fkdevice and "

                + "numplan.pkid = devicenumplanmap.fknumplan and device.name="+"'"+deviceName+"'";

Make a ExecuteSQLQueryReq

                ExecuteSQLQueryReq sqlReq = new ExecuteSQLQueryReq();

                sqlReq.setSql(sqlQuery);

                ExecuteSQLQueryRes sqlRes = axlPortReq().executeSQLQuery(sqlReq);

                sqlReturn = sqlRes.getReturn().getRow();

                Element returnValue = (Element)sqlReturn.get(1);

                dNumber = returnValue.getElementsByTagName("dnorpattern").item(0).getFirstChild().getTextContent();

                e164Mask = returnValue.getElementsByTagName("dnorpattern").item(0).getNextSibling().getTextContent();

                if(!e164Mask.toLowerCase().equals("null")) line = phoneDescription+","+dNumber+","+e164Mask;

                else if(e164Mask.toLowerCase().equals("null")) line = phoneDescription+","+dNumber+",No Mask";

print string line:

System.out.println(line);

The problem i'm runing into is the following:

if the device has a secondary(Line 2) shared line(shared with other devices) on it, the sql query request returns the shared line and not the primary line DN

I'm able to retrive the primary line dn only when i do the following:

change

dNumber = returnValue.getElementsByTagName("dnorpattern").item(0).getFirstChild().getTextContent();

to

dNumber = returnValue.getElementsByTagName("dnorpattern").item(1).getFirstChild().getTextContent();

my question is, why is it returning the shared secondary line DN vs the primary line DN ?

I also tried to make a GetPhoneReq vs the SQL query to obtain the primary line DN, but still same issue.

CUCM version is 10.5.1.10000-7

i can share more code if needed. Thanks

1 Reply 1

Mamdouh Elgamal
Level 1
Level 1

figured it out

changed the query to the following: String sqlQuery = "select numplan.dnorpattern, devicenumplanmap.e164mask from device, numplan, devicenumplanmap "+ "where device.pkid = devicenumplanmap.fkdevice and " + "numplan.pkid = devicenumplanmap.fknumplan and numplanindex = 1"+ "and device.name="+"'"+deviceName+"'";