diff --git a/restcomm/restcomm.application/src/main/webapp/WEB-INF/data/hsql/restcomm.script b/restcomm/restcomm.application/src/main/webapp/WEB-INF/data/hsql/restcomm.script index 78c626a0f0..8419f5c7ac 100644 --- a/restcomm/restcomm.application/src/main/webapp/WEB-INF/data/hsql/restcomm.script +++ b/restcomm/restcomm.application/src/main/webapp/WEB-INF/data/hsql/restcomm.script @@ -8,7 +8,7 @@ CREATE MEMORY TABLE "restcomm_outgoing_caller_ids"("sid" VARCHAR(34) NOT NULL PR CREATE MEMORY TABLE "restcomm_http_cookies"("sid" VARCHAR(34) NOT NULL PRIMARY KEY,"comment" LONGVARCHAR,"domain" LONGVARCHAR,"expiration_date" DATETIME,"name" LONGVARCHAR NOT NULL,"path" LONGVARCHAR,"value" LONGVARCHAR,"version" INT) CREATE MEMORY TABLE "restcomm_incoming_phone_numbers"("sid" VARCHAR(34) NOT NULL PRIMARY KEY,"date_created" DATETIME NOT NULL,"date_updated" DATETIME NOT NULL,"friendly_name" VARCHAR(64) NOT NULL,"account_sid" VARCHAR(34) NOT NULL,"phone_number" VARCHAR(30) NOT NULL,"api_version" VARCHAR(10) NOT NULL,"voice_caller_id_lookup" BOOLEAN NOT NULL,"voice_url" LONGVARCHAR,"voice_method" VARCHAR(4),"voice_fallback_url" LONGVARCHAR,"voice_fallback_method" VARCHAR(4),"status_callback" LONGVARCHAR,"status_callback_method" VARCHAR(4),"voice_application_sid" VARCHAR(34),"sms_url" LONGVARCHAR,"sms_method" VARCHAR(4),"sms_fallback_url" LONGVARCHAR,"sms_fallback_method" VARCHAR(4),"sms_application_sid" VARCHAR(34),"uri" LONGVARCHAR NOT NULL, "voice_capable" BOOLEAN, "sms_capable" BOOLEAN, "mms_capable" BOOLEAN, "fax_capable" BOOLEAN, "pure_sip" BOOLEAN,"cost" VARCHAR(10), "ussd_url" LONGVARCHAR, "ussd_method" VARCHAR(4), "ussd_fallback_url" LONGVARCHAR, "ussd_fallback_method" VARCHAR(4), "ussd_application_sid" VARCHAR(34), "refer_url" LONGVARCHAR, "refer_method" VARCHAR(4), "refer_application_sid" VARCHAR(34), "organization_sid" VARCHAR(34) NOT NULL) CREATE MEMORY TABLE "restcomm_applications"("sid" VARCHAR(34) NOT NULL PRIMARY KEY,"date_created" DATETIME NOT NULL,"date_updated" DATETIME NOT NULL,"friendly_name" VARCHAR(64) NOT NULL,"account_sid" VARCHAR(34) NOT NULL,"api_version" VARCHAR(10) NOT NULL,"voice_caller_id_lookup" BOOLEAN NOT NULL,"uri" LONGVARCHAR NOT NULL,"rcml_url" LONGVARCHAR, "kind" VARCHAR(5)) -CREATE MEMORY TABLE "restcomm_call_detail_records"("sid" VARCHAR(1000) NOT NULL PRIMARY KEY,"parent_call_sid" VARCHAR(1000),"date_created" DATETIME NOT NULL,"date_updated" DATETIME NOT NULL,"account_sid" VARCHAR(34) NOT NULL,"sender" VARCHAR(255) NOT NULL,"recipient" VARCHAR(64) NOT NULL,"phone_number_sid" VARCHAR(34),"status" VARCHAR(20) NOT NULL,"start_time" DATETIME,"end_time" DATETIME,"duration" INTEGER,"price" VARCHAR(8),"direction" VARCHAR(20) NOT NULL,"answered_by" VARCHAR(64),"api_version" VARCHAR(10) NOT NULL,"forwarded_from" VARCHAR(30),"caller_name" VARCHAR(50),"uri" LONGVARCHAR NOT NULL, "call_path" VARCHAR(255),"ring_duration" INTEGER, "instanceid" VARCHAR(255) NOT NULL, "conference_sid" VARCHAR(34),"muted" BOOLEAN, "start_conference_on_enter" BOOLEAN, "end_conference_on_exit" BOOLEAN, "on_hold" BOOLEAN, "ms_id" VARCHAR(34)) +CREATE MEMORY TABLE "restcomm_call_detail_records"("sid" VARCHAR(1000) NOT NULL PRIMARY KEY,"parent_call_sid" VARCHAR(1000),"date_created" DATETIME NOT NULL,"date_updated" DATETIME NOT NULL,"account_sid" VARCHAR(34) NOT NULL,"sender" VARCHAR(255) NOT NULL,"recipient" VARCHAR(64) NOT NULL,"phone_number_sid" VARCHAR(34),"status" VARCHAR(20) NOT NULL,"start_time" DATETIME,"end_time" DATETIME,"duration" INTEGER,"price" VARCHAR(8),"direction" VARCHAR(20) NOT NULL,"answered_by" VARCHAR(64),"api_version" VARCHAR(10) NOT NULL,"forwarded_from" VARCHAR(30),"caller_name" VARCHAR(50),"uri" LONGVARCHAR NOT NULL, "call_path" VARCHAR(255),"ring_duration" INTEGER, "instanceid" VARCHAR(255) NOT NULL, "conference_sid" VARCHAR(34),"muted" BOOLEAN, "start_conference_on_enter" BOOLEAN, "end_conference_on_exit" BOOLEAN, "on_hold" BOOLEAN, "ms_id" VARCHAR(34), "call_type" VARCHAR(34)) CREATE MEMORY TABLE "restcomm_conference_detail_records" ( "sid" VARCHAR(34) NOT NULL PRIMARY KEY, "date_created" DATETIME NOT NULL, "date_updated" DATETIME NOT NULL, "account_sid" VARCHAR(34) NOT NULL, "status" VARCHAR(100) NOT NULL, "friendly_name" VARCHAR(60), "api_version" VARCHAR(10) NOT NULL, "uri" LONGVARCHAR NOT NULL, "master_ms_id" VARCHAR(34),"master_conference_endpoint_id" VARCHAR(20),"master_present" BOOLEAN DEFAULT TRUE, "master_ivr_endpoint_id" VARCHAR(20),"master_ivr_endpoint_session_id" VARCHAR(200),"master_bridge_endpoint_id" VARCHAR(20),"master_bridge_endpoint_session_id" VARCHAR(200),"master_bridge_conn_id" VARCHAR(200),"master_ivr_conn_id" VARCHAR(200)) CREATE MEMORY TABLE "restcomm_clients"("sid" VARCHAR(34) NOT NULL PRIMARY KEY,"date_created" DATETIME NOT NULL,"date_updated" DATETIME NOT NULL,"account_sid" VARCHAR(34) NOT NULL,"api_version" VARCHAR(10) NOT NULL,"friendly_name" VARCHAR(64) NOT NULL,"login" VARCHAR(64) NOT NULL,"password" VARCHAR(64) NOT NULL,"status" INTEGER NOT NULL,"voice_url" LONGVARCHAR,"voice_method" VARCHAR(4),"voice_fallback_url" LONGVARCHAR,"voice_fallback_method" VARCHAR(4),"voice_application_sid" VARCHAR(34),"uri" LONGVARCHAR NOT NULL, "push_client_identity" VARCHAR(34)) CREATE MEMORY TABLE "restcomm_registrations"("sid" VARCHAR(34) NOT NULL PRIMARY KEY,"date_created" DATETIME NOT NULL,"date_updated" DATETIME NOT NULL,"date_expires" DATETIME NOT NULL,"address_of_record" LONGVARCHAR NOT NULL,"display_name" VARCHAR(255),"user_name" VARCHAR(64) NOT NULL,"user_agent" LONGVARCHAR,"ttl" INTEGER NOT NULL,"location" LONGVARCHAR NOT NULL, "webrtc" BOOLEAN DEFAULT FALSE, "instanceid" VARCHAR(255), "isLBPresent" BOOLEAN DEFAULT FALSE, "organization_sid" VARCHAR(34)) diff --git a/restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/init.sql b/restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/init.sql index 75520403c9..7fe051ab7f 100644 --- a/restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/init.sql +++ b/restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/init.sql @@ -159,7 +159,8 @@ muted BOOLEAN, start_conference_on_enter BOOLEAN, end_conference_on_exit BOOLEAN, on_hold BOOLEAN, -ms_id VARCHAR(34) +ms_id VARCHAR(34), +call_type VARCHAR(34) ); CREATE TABLE restcomm_conference_detail_records ( diff --git a/restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/call-detail-records.xml b/restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/call-detail-records.xml index f6dd3f38be..d05a33923b 100644 --- a/restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/call-detail-records.xml +++ b/restcomm/restcomm.application/src/main/webapp/WEB-INF/scripts/mariadb/sql/call-detail-records.xml @@ -6,9 +6,9 @@ INSERT INTO restcomm_call_detail_records (sid, instanceid, parent_call_sid, date_created, date_updated, account_sid, recipient, sender, phone_number_sid, status, - start_time, end_time, duration, price, direction, answered_by, api_version, forwarded_from, caller_name, uri, call_path, ring_duration, conference_sid, muted, start_conference_on_enter, end_conference_on_exit, on_hold, ms_id) VALUES (#{sid}, #{instanceid}, #{parent_call_sid}, + start_time, end_time, duration, price, direction, answered_by, api_version, forwarded_from, caller_name, uri, call_path, ring_duration, conference_sid, muted, start_conference_on_enter, end_conference_on_exit, on_hold, ms_id, call_type) VALUES (#{sid}, #{instanceid}, #{parent_call_sid}, #{date_created}, #{date_updated}, #{account_sid}, #{to}, #{from}, #{phone_number_sid}, #{status}, #{start_time}, #{end_time}, #{duration}, #{price}, - #{direction}, #{answered_by}, #{api_version}, #{forwarded_from}, #{caller_name}, #{uri}, #{call_path}, #{ring_duration}, #{conference_sid}, #{muted}, #{start_conference_on_enter}, #{end_conference_on_exit}, #{on_hold}, #{ms_id}); + #{direction}, #{answered_by}, #{api_version}, #{forwarded_from}, #{caller_name}, #{uri}, #{call_path}, #{ring_duration}, #{conference_sid}, #{muted}, #{start_conference_on_enter}, #{end_conference_on_exit}, #{on_hold}, #{ms_id}, #{call_type}); @@ -118,7 +121,9 @@ AND end_time <= DATE_ADD(#{endTime},INTERVAL 1 DAY) - + + AND call_type = #{callType} + order by start_time LIMIT #{limit} OFFSET #{offset} diff --git a/restcomm/restcomm.application/src/main/webapp/WEB-INF/sql/call-detail-records.xml b/restcomm/restcomm.application/src/main/webapp/WEB-INF/sql/call-detail-records.xml index 294a2ce9a4..8e6527bf07 100644 --- a/restcomm/restcomm.application/src/main/webapp/WEB-INF/sql/call-detail-records.xml +++ b/restcomm/restcomm.application/src/main/webapp/WEB-INF/sql/call-detail-records.xml @@ -6,10 +6,10 @@ INSERT INTO "restcomm_call_detail_records" ("sid", "instanceid", "parent_call_sid", "date_created", "date_updated", "account_sid", "recipient", "sender", "phone_number_sid", "status", - "start_time", "end_time", "duration", "price", "direction", "answered_by", "api_version", "forwarded_from", "caller_name", "uri", "call_path", "ring_duration", "conference_sid", "muted", "start_conference_on_enter", "end_conference_on_exit", "on_hold", "ms_id") + "start_time", "end_time", "duration", "price", "direction", "answered_by", "api_version", "forwarded_from", "caller_name", "uri", "call_path", "ring_duration", "conference_sid", "muted", "start_conference_on_enter", "end_conference_on_exit", "on_hold", "ms_id", "call_type") VALUES (#{sid}, #{instanceid}, #{parent_call_sid}, #{date_created}, #{date_updated}, #{account_sid}, #{to}, #{from}, #{phone_number_sid}, #{status}, #{start_time}, #{end_time}, #{duration}, #{price}, #{direction}, - #{answered_by}, #{api_version}, #{forwarded_from}, #{caller_name}, #{uri}, #{call_path}, #{ring_duration}, #{conference_sid}, #{muted}, #{start_conference_on_enter}, #{end_conference_on_exit}, #{on_hold}, #{ms_id}); + #{answered_by}, #{api_version}, #{forwarded_from}, #{caller_name}, #{uri}, #{call_path}, #{ring_duration}, #{conference_sid}, #{muted}, #{start_conference_on_enter}, #{end_conference_on_exit}, #{on_hold}, #{ms_id}, #{call_type}); @@ -119,6 +121,9 @@ AND "end_time" <= DATE_ADD(#{endTime},INTERVAL 1 DAY) + + AND "call_type" = #{callType} + order by "start_time" LIMIT #{limit} OFFSET #{offset} diff --git a/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/entities/CallDetailRecord.java b/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/entities/CallDetailRecord.java index b41dc9e5dd..d9332277de 100644 --- a/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/entities/CallDetailRecord.java +++ b/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/entities/CallDetailRecord.java @@ -27,6 +27,7 @@ import org.restcomm.connect.commons.annotations.concurrency.Immutable; import org.restcomm.connect.commons.annotations.concurrency.NotThreadSafe; import org.restcomm.connect.commons.dao.Sid; +import org.restcomm.connect.commons.telephony.CreateCallType; /** * @author quintana.thomas@gmail.com (Thomas Quintana) @@ -63,13 +64,14 @@ public final class CallDetailRecord { private final Boolean endConferenceOnExit; private final Boolean onHold; private final String msId; + private final CreateCallType type; public CallDetailRecord(final Sid sid, final String instanceId, final Sid parentCallSid, final Sid conferenceSid, final DateTime dateCreated, final DateTime dateUpdated, final Sid accountSid, final String to, final String from, final Sid phoneNumberSid, final String status, final DateTime startTime, final DateTime endTime, final Integer duration, final BigDecimal price, final Currency priceUnit, final String direction, final String answeredBy, final String apiVersion, final String forwardedFrom, final String callerName, final URI uri, final String callPath,final Integer ringDuration, - final Boolean muted, final Boolean startConferenceOnEnter, final Boolean endConferenceOnExit, final Boolean onHold, final String msId) { + final Boolean muted, final Boolean startConferenceOnEnter, final Boolean endConferenceOnExit, final Boolean onHold, final String msId, CreateCallType type) { super(); this.sid = sid; this.instanceId = instanceId; @@ -100,6 +102,7 @@ public CallDetailRecord(final Sid sid, final String instanceId, final Sid parent this.endConferenceOnExit = endConferenceOnExit; this.onHold = onHold; this.msId = msId; + this.type = type; } public static Builder builder() { @@ -223,92 +226,97 @@ public String getMsId() { public CallDetailRecord setStatus(final String status) { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setStartTime(final DateTime startTime) { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setEndTime(final DateTime endTime) { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setDuration(final Integer duration) { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setRingDuration(final Integer ringDuration) { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setPrice(final BigDecimal price) { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setAnsweredBy(final String answeredBy) { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setConferenceSid(final Sid conferenceSid) { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setMuted(final Boolean muted){ return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setStartConferenceOnEnter(final Boolean startConferenceOnEnter){ return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setEndConferenceOnExit(final Boolean endConferenceOnExit){ return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setOnHold(final Boolean onHold){ return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setMsId(final String msId){ return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public CallDetailRecord setForwardedFrom(final String forwardedFrom){ return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, DateTime.now(), accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } + + public CreateCallType getType() { + return type; + } + @Override public String toString() { return "CDR SID: "+getSid()+" | InstanceId: "+getInstanceId()+" | ParentCallSid: "+getParentCallSid()+" | ConferenceSid: "+getConferenceSid()+" | DateCreated: "+getDateCreated()+" | DateUpdated: "+getDateUpdated()+" | AccountSid: "+getAccountSid()+" | To: "+getTo()+" | From: "+getFrom() +" | PhoneNumberSid: "+getPhoneNumberSid()+" | Status: "+getStatus()+" | StartTime: "+getStartTime()+" | EndTime: "+getEndTime()+" | Duration: "+getDuration()+" | Price: "+getPrice()+" | PriceUnit: "+getPriceUnit()+" | Direction: "+getDirection()+" | AnsweredBy: "+getAnsweredBy() +" | ApiVersion: "+getApiVersion()+" | ForwaredFrom: "+getForwardedFrom()+" | CallerName: "+getCallerName()+" | Uri: "+getUri()+" | CallPath: "+getCallPath()+" | RingDuration: "+getRingDuration()+" | Muted: "+isMuted()+" | StartConferenceOnEnter: "+isStartConferenceOnEnter() - +" | isEndConferenceOnExit: "+ isEndConferenceOnExit()+" | isOnHold: "+isOnHold(); + +" | isEndConferenceOnExit: "+ isEndConferenceOnExit()+" | isOnHold: "+isOnHold()+" | CreateCallType: "+getType(); } @NotThreadSafe @@ -342,6 +350,7 @@ public static final class Builder { private Boolean endConferenceOnExit; private Boolean onHold; private String msId; + private CreateCallType type; private Builder() { super(); @@ -373,12 +382,13 @@ private Builder() { endConferenceOnExit = null; onHold = null; msId = null; + type = null; } public CallDetailRecord build() { return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, dateUpdated, accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, - callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + callerName, uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } public void setSid(final Sid sid) { @@ -486,5 +496,9 @@ public void setOnHold(final Boolean onHold) { public void setMsId(final String msId) { this.msId = msId; } + + public void setType(final CreateCallType type) { + this.type = type; + } } } diff --git a/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/entities/CallDetailRecordFilter.java b/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/entities/CallDetailRecordFilter.java index c12e7edec1..6117fe7fa4 100644 --- a/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/entities/CallDetailRecordFilter.java +++ b/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/entities/CallDetailRecordFilter.java @@ -25,6 +25,7 @@ import java.util.List; import org.restcomm.connect.commons.annotations.concurrency.Immutable; +import org.restcomm.connect.commons.telephony.CreateCallType; /** * @author gvagenas @@ -45,14 +46,15 @@ public class CallDetailRecordFilter { private final Integer limit; private final Integer offset; private final String instanceid; + private final CreateCallType callType; public CallDetailRecordFilter(String accountSid, List accountSidSet, String recipient, String sender, String status, String startTime, String endTime, - String parentCallSid, String conferenceSid, Integer limit, Integer offset) throws ParseException { - this(accountSid, accountSidSet, recipient,sender,status,startTime,endTime,parentCallSid, conferenceSid, limit,offset,null); + String parentCallSid, String conferenceSid, Integer limit, Integer offset, CreateCallType type) throws ParseException { + this(accountSid, accountSidSet, recipient,sender,status,startTime,endTime,parentCallSid, conferenceSid, limit, offset, type, null); } public CallDetailRecordFilter(String accountSid, List accountSidSet, String recipient, String sender, String status, String startTime, String endTime, - String parentCallSid, String conferenceSid, Integer limit, Integer offset, String instanceId) throws ParseException { + String parentCallSid, String conferenceSid, Integer limit, Integer offset, CreateCallType type, String instanceId) throws ParseException { this.accountSid = accountSid; this.accountSidSet = accountSidSet; @@ -89,6 +91,11 @@ public CallDetailRecordFilter(String accountSid, List accountSidSet, Str } else { this.instanceid = null; } + if (type != null) { + this.callType = type; + } else { + this.callType = null; + } } public String getSid() { @@ -135,5 +142,9 @@ public int getOffset() { return offset; } + public CreateCallType getType() { + return callType; + } + public String getInstanceid() { return instanceid; } } diff --git a/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/mybatis/MybatisCallDetailRecordsDao.java b/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/mybatis/MybatisCallDetailRecordsDao.java index 45e5085ce8..82d2fd1afb 100644 --- a/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/mybatis/MybatisCallDetailRecordsDao.java +++ b/restcomm/restcomm.dao/src/main/java/org/restcomm/connect/dao/mybatis/MybatisCallDetailRecordsDao.java @@ -38,6 +38,7 @@ import org.joda.time.format.DateTimeFormatter; import org.restcomm.connect.commons.annotations.concurrency.ThreadSafe; import org.restcomm.connect.commons.dao.Sid; +import org.restcomm.connect.commons.telephony.CreateCallType; import org.restcomm.connect.dao.CallDetailRecordsDao; import org.restcomm.connect.dao.DaoUtils; import org.restcomm.connect.dao.entities.CallDetailRecord; @@ -344,9 +345,10 @@ private CallDetailRecord toCallDetailRecord(final Map map) { final Boolean startConferenceOnEnter = DaoUtils.readBoolean(map.get("start_conference_on_enter")); final Boolean endConferenceOnExit = DaoUtils.readBoolean(map.get("end_conference_on_exit")); final Boolean onHold = DaoUtils.readBoolean(map.get("on_hold")); + final CreateCallType type = CreateCallType.valueOf((String)map.get("call_type")); return new CallDetailRecord(sid, instanceId, parentCallSid, conferenceSid, dateCreated, dateUpdated, accountSid, to, from, phoneNumberSid, status, startTime, endTime, duration, price, priceUnit, direction, answeredBy, apiVersion, forwardedFrom, callerName, - uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId); + uri, callPath, ringDuration, muted, startConferenceOnEnter, endConferenceOnExit, onHold, msId, type); } private Map toMap(final CallDetailRecord cdr) { @@ -379,6 +381,7 @@ private Map toMap(final CallDetailRecord cdr) { map.put("end_conference_on_exit", cdr.isEndConferenceOnExit()); map.put("on_hold", cdr.isOnHold()); map.put("ms_id", cdr.getMsId()); + map.put("call_type", cdr.getType()); return map; } } diff --git a/restcomm/restcomm.dao/src/test/java/org/restcomm/connect/dao/mybatis/CallDetailRecordsDaoTest.java b/restcomm/restcomm.dao/src/test/java/org/restcomm/connect/dao/mybatis/CallDetailRecordsDaoTest.java index 96956b2577..e2cff0d6da 100644 --- a/restcomm/restcomm.dao/src/test/java/org/restcomm/connect/dao/mybatis/CallDetailRecordsDaoTest.java +++ b/restcomm/restcomm.dao/src/test/java/org/restcomm/connect/dao/mybatis/CallDetailRecordsDaoTest.java @@ -38,6 +38,7 @@ import org.junit.Before; import org.junit.Test; import org.restcomm.connect.commons.dao.Sid; +import org.restcomm.connect.commons.telephony.CreateCallType; import org.restcomm.connect.dao.CallDetailRecordsDao; import org.restcomm.connect.dao.entities.CallDetailRecord; import org.restcomm.connect.dao.entities.CallDetailRecordFilter; @@ -105,6 +106,7 @@ public void createReadUpdateDelete() { builder.setApiVersion("2012-04-24"); builder.setCallerName("Alice"); builder.setUri(url); + builder.setType(CreateCallType.PSTN); CallDetailRecord cdr = builder.build(); final CallDetailRecordsDao cdrs = manager.getCallDetailRecordsDao(); // Create a new CDR in the data store. @@ -129,6 +131,7 @@ public void createReadUpdateDelete() { assertTrue(result.getApiVersion().equals(cdr.getApiVersion())); assertTrue(result.getCallerName().equals(cdr.getCallerName())); assertTrue(result.getUri().equals(cdr.getUri())); + assertTrue(result.getType().equals(cdr.getType())); // Update the CDR. cdr = cdr.setDuration(2); cdr = cdr.setPrice(new BigDecimal("1.00")); @@ -147,6 +150,31 @@ public void createReadUpdateDelete() { assertTrue(cdrs.getCallDetailRecord(sid) == null); } + @Test + public void testReadByType() { + Sid accountSid = new Sid("AC00000000000000000000000000000001"); + CallDetailRecordsDao dao = manager.getCallDetailRecordsDao(); + try { + CallDetailRecordFilter filterPSTN = new CallDetailRecordFilter(accountSid.toString(), null, null, null, null, null, null, null, null, 0, 0, CreateCallType.PSTN); + CallDetailRecordFilter filterUSSD = new CallDetailRecordFilter(accountSid.toString(), null, null, null, null, null, null, null, null, 0, 0, CreateCallType.USSD); + CallDetailRecordFilter filterSIP = new CallDetailRecordFilter(accountSid.toString(), null, null, null, null, null, null, null, null, 0, 0, CreateCallType.SIP); + CallDetailRecordFilter filterCLIENT = new CallDetailRecordFilter(accountSid.toString(), null, null, null, null, null, null, null, null, 0, 0, CreateCallType.CLIENT); + List callsPstn = dao.getCallDetailRecords(filterPSTN); + List callsUssd = dao.getCallDetailRecords(filterUSSD); + List callsSip = dao.getCallDetailRecords(filterSIP); + List callsClient = dao.getCallDetailRecords(filterCLIENT); + Assert.assertEquals(4, callsPstn.size()); + Assert.assertEquals(3, callsUssd.size()); + Assert.assertEquals(2, callsSip.size()); + Assert.assertEquals(1, callsClient.size()); + Assert.assertEquals(4, dao.getTotalCallDetailRecords(filterPSTN).intValue()); + Assert.assertEquals(3, dao.getTotalCallDetailRecords(filterUSSD).intValue()); + Assert.assertEquals(2, dao.getTotalCallDetailRecords(filterSIP).intValue()); + Assert.assertEquals(1, dao.getTotalCallDetailRecords(filterCLIENT).intValue()); + } catch (ParseException e) { + } + } + @Test public void testReadDeleteByAccount() { final Sid sid = Sid.generate(Sid.Type.CALL); @@ -435,7 +463,7 @@ public void retrieveAccountCdrsRecursively() throws ParseException { // read from a single account but using the 'accountSidSet' interface List accountSidSet = new ArrayList(); accountSidSet.add("AC00000000000000000000000000000000"); - CallDetailRecordFilter filter = new CallDetailRecordFilter(null, accountSidSet, null, null, null, null, null, null, null, null, null); + CallDetailRecordFilter filter = new CallDetailRecordFilter(null, accountSidSet, null, null, null, null, null, null, null, null, null, null); Assert.assertEquals(12, dao.getTotalCallDetailRecords(filter).intValue()); // read cdrs of three accounts accountSidSet.add("AC00000000000000000000000000000000"); @@ -446,13 +474,13 @@ public void retrieveAccountCdrsRecursively() throws ParseException { accountSidSet.clear(); Assert.assertEquals(0, dao.getTotalCallDetailRecords(filter).intValue()); // if both an accountSid and a accountSid set are passed, only accountSidSet is taken into account - filter = new CallDetailRecordFilter("ACae6e420f425248d6a26948c17a9e2acf", accountSidSet, null, null, null, null, null, null, null, null, null); + filter = new CallDetailRecordFilter("ACae6e420f425248d6a26948c17a9e2acf", accountSidSet, null, null, null, null, null, null, null, null, null, null); accountSidSet.add("AC00000000000000000000000000000000"); accountSidSet.add("AC11111111111111111111111111111111"); accountSidSet.add("AC22222222222222222222222222222222"); Assert.assertEquals(25, dao.getTotalCallDetailRecords(filter).intValue()); // if no (null) accountSidSet is passed the method still works - filter = new CallDetailRecordFilter("AC00000000000000000000000000000000", null, null, null, null, null, null, null, null, null, null); + filter = new CallDetailRecordFilter("AC00000000000000000000000000000000", null, null, null, null, null, null, null, null, null, null, null); Assert.assertEquals(12, dao.getTotalCallDetailRecords(filter).intValue()); } } diff --git a/restcomm/restcomm.dao/src/test/resources/callDetailRecordsDao/call-detail-records.xml b/restcomm/restcomm.dao/src/test/resources/callDetailRecordsDao/call-detail-records.xml index c7a7129620..1e00bf2cd9 100644 --- a/restcomm/restcomm.dao/src/test/resources/callDetailRecordsDao/call-detail-records.xml +++ b/restcomm/restcomm.dao/src/test/resources/callDetailRecordsDao/call-detail-records.xml @@ -6,16 +6,24 @@ INSERT INTO "restcomm_call_detail_records" ("sid", "instanceid", "parent_call_sid", "date_created", "date_updated", "account_sid", "recipient", "sender", "phone_number_sid", "status", - "start_time", "end_time", "duration", "price", "direction", "answered_by", "api_version", "forwarded_from", "caller_name", "uri", "call_path", "ring_duration", "conference_sid", "muted", "start_conference_on_enter", "end_conference_on_exit", "on_hold") + "start_time", "end_time", "duration", "price", "direction", "answered_by", "api_version", "forwarded_from", "caller_name", "uri", "call_path", "ring_duration", "conference_sid", "muted", "start_conference_on_enter", "end_conference_on_exit", "on_hold", "ms_id", "call_type") VALUES (#{sid}, #{instanceid}, #{parent_call_sid}, #{date_created}, #{date_updated}, #{account_sid}, #{to}, #{from}, #{phone_number_sid}, #{status}, #{start_time}, #{end_time}, #{duration}, #{price}, #{direction}, - #{answered_by}, #{api_version}, #{forwarded_from}, #{caller_name}, #{uri}, #{call_path}, #{ring_duration}, #{conference_sid}, #{muted}, #{start_conference_on_enter}, #{end_conference_on_exit}, #{on_hold}); + #{answered_by}, #{api_version}, #{forwarded_from}, #{caller_name}, #{uri}, #{call_path}, #{ring_duration}, #{conference_sid}, #{muted}, #{start_conference_on_enter}, #{end_conference_on_exit}, #{on_hold}, #{ms_id}, #{call_type}); - + + + + + @@ -111,8 +121,12 @@ AND "end_time" <= DATE_ADD(#{endTime},INTERVAL 1 DAY) + + AND "call_type" = #{callType} + order by "start_time" LIMIT #{limit} OFFSET #{offset} + diff --git a/restcomm/restcomm.dao/src/test/resources/callDetailRecordsDao/restcomm.script b/restcomm/restcomm.dao/src/test/resources/callDetailRecordsDao/restcomm.script index 06b01a3b52..96b208563e 100644 --- a/restcomm/restcomm.dao/src/test/resources/callDetailRecordsDao/restcomm.script +++ b/restcomm/restcomm.dao/src/test/resources/callDetailRecordsDao/restcomm.script @@ -32,7 +32,7 @@ SET FILES LOG SIZE 200 CREATE USER SA PASSWORD DIGEST 'd41d8cd98f00b204e9800998ecf8427e' CREATE SCHEMA PUBLIC AUTHORIZATION DBA SET SCHEMA PUBLIC -CREATE MEMORY TABLE "restcomm_call_detail_records"("sid" VARCHAR(1000) NOT NULL PRIMARY KEY,"parent_call_sid" VARCHAR(1000),"date_created" DATETIME NOT NULL,"date_updated" DATETIME NOT NULL,"account_sid" VARCHAR(34) NOT NULL,"sender" VARCHAR(30) NOT NULL,"recipient" VARCHAR(64) NOT NULL,"phone_number_sid" VARCHAR(34),"status" VARCHAR(20) NOT NULL,"start_time" DATETIME,"end_time" DATETIME,"duration" INTEGER,"price" VARCHAR(8),"direction" VARCHAR(20) NOT NULL,"answered_by" VARCHAR(64),"api_version" VARCHAR(10) NOT NULL,"forwarded_from" VARCHAR(30),"caller_name" VARCHAR(50),"uri" LONGVARCHAR NOT NULL, "call_path" VARCHAR(255),"ring_duration" INTEGER, "instanceid" VARCHAR(255) NOT NULL, "conference_sid" VARCHAR(34),"muted" BOOLEAN, "start_conference_on_enter" BOOLEAN, "end_conference_on_exit" BOOLEAN, "on_hold" BOOLEAN) +CREATE MEMORY TABLE "restcomm_call_detail_records"("sid" VARCHAR(1000) NOT NULL PRIMARY KEY,"parent_call_sid" VARCHAR(1000),"date_created" DATETIME NOT NULL,"date_updated" DATETIME NOT NULL,"account_sid" VARCHAR(34) NOT NULL,"sender" VARCHAR(255) NOT NULL,"recipient" VARCHAR(64) NOT NULL,"phone_number_sid" VARCHAR(34),"status" VARCHAR(20) NOT NULL,"start_time" DATETIME,"end_time" DATETIME,"duration" INTEGER,"price" VARCHAR(8),"direction" VARCHAR(20) NOT NULL,"answered_by" VARCHAR(64),"api_version" VARCHAR(10) NOT NULL,"forwarded_from" VARCHAR(30),"caller_name" VARCHAR(50),"uri" LONGVARCHAR NOT NULL, "call_path" VARCHAR(255),"ring_duration" INTEGER, "instanceid" VARCHAR(255) NOT NULL, "conference_sid" VARCHAR(34),"muted" BOOLEAN, "start_conference_on_enter" BOOLEAN, "end_conference_on_exit" BOOLEAN, "on_hold" BOOLEAN, "ms_id" VARCHAR(34), "call_type" VARCHAR(34)) ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 1 SET DATABASE DEFAULT INITIAL SCHEMA PUBLIC GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.SQL_IDENTIFIER TO PUBLIC @@ -143,3 +143,13 @@ INSERT INTO "restcomm_call_detail_records" VALUES('CA3a28d89482ec4e46a9f1e2ff5c4 INSERT INTO "restcomm_call_detail_records" VALUES('CA3b30eb7cc24f47489f53d9e033385a2a',NULL,'2013-08-22 14:13:30.336000000','2013-08-22 14:13:30.501000000','ACae6e420f425248d6a26948c17a9e2acf','Anonymous','+15126002188',NULL,'in-progress','2013-08-22 14:13:30.501000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA3b30eb7cc24f47489f53d9e033385a2a', NULL,NULL, NULL, NULL, NULL) INSERT INTO "restcomm_call_detail_records" VALUES('CA3c2386d4942f4028b714c24af404c239',NULL,'2013-08-13 14:14:31.402000000','2013-08-13 14:14:32.519000000','ACae6e420f425248d6a26948c17a9e2acf','19549376176','+15126002188',NULL,'in-progress','2013-08-13 14:14:32.519000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA3c2386d4942f4028b714c24af404c239', NULL,NULL, NULL, NULL, NULL) INSERT INTO "restcomm_call_detail_records" VALUES('CA3d386ded326f4aba9e495959b0ac5218',NULL,'2013-07-17 14:55:01.225000000','2013-07-17 14:55:01.361000000','ACae6e420f425248d6a26948c17a9e2acf','19549376176','+15126002188',NULL,'in-progress','2013-07-17 14:55:01.361000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA3d386ded326f4aba9e495959b0ac5218', NULL,NULL, NULL, NULL, NULL) +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000001',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000001', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'PSTN') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000002',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000002', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'PSTN') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000003',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000003', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'PSTN') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000004',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000004', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'PSTN') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000005',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000005', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'USSD') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000006',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000006', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'USSD') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000007',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000007', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'USSD') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000008',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000008', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'SIP') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000009',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000009', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'SIP') +INSERT INTO "restcomm_call_detail_records" VALUES('CA00000000000000000000000000000010',NULL,'2017-11-01 00:00:00.000000000','2017-11-01 00:00:00.000000000','AC00000000000000000000000000000001','19549376176','+15126002188',NULL,'completed','2017-11-01 00:00:00.000000000',NULL,NULL,'0.00','inbound',NULL,'2012-04-24',NULL,NULL,'/2012-04-24/Accounts/ACae6e420f425248d6a26948c17a9e2acf/Calls/CA00000000000000000000000000000010', NULL,NULL, NULL, NULL, NULL, NULL,NULL, NULL, NULL, 'CLIENT') diff --git a/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/CallsEndpoint.java b/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/CallsEndpoint.java index 45cbe8f1fa..cf79d55e90 100644 --- a/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/CallsEndpoint.java +++ b/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/CallsEndpoint.java @@ -245,10 +245,10 @@ protected Response getCalls(final String accountSid, UriInfo info, MediaType res if (localInstanceOnly) { filterForTotal = new CallDetailRecordFilter(accountSid, ownerAccounts, recipient, sender, status, startTime, endTime, - parentCallSid, conferenceSid, null, null); + parentCallSid, conferenceSid, null, null, null); } else { filterForTotal = new CallDetailRecordFilter(accountSid, ownerAccounts, recipient, sender, status, startTime, endTime, - parentCallSid, conferenceSid, null, null, instanceId); + parentCallSid, conferenceSid, null, null, null, instanceId); } } catch (ParseException e) { return status(BAD_REQUEST).build(); @@ -279,10 +279,10 @@ protected Response getCalls(final String accountSid, UriInfo info, MediaType res try { if (localInstanceOnly) { filter = new CallDetailRecordFilter(accountSid, ownerAccounts, recipient, sender, status, startTime, endTime, - parentCallSid, conferenceSid, limit, offset); + parentCallSid, conferenceSid, limit, offset, null); } else { filter = new CallDetailRecordFilter(accountSid, ownerAccounts, recipient, sender, status, startTime, endTime, - parentCallSid, conferenceSid, limit, offset, instanceId); + parentCallSid, conferenceSid, limit, offset, null, instanceId); } } catch (ParseException e) { return status(BAD_REQUEST).build(); diff --git a/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/SupervisorEndpoint.java b/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/SupervisorEndpoint.java index 080a74504f..40a00f4ec5 100644 --- a/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/SupervisorEndpoint.java +++ b/restcomm/restcomm.http/src/main/java/org/restcomm/connect/http/SupervisorEndpoint.java @@ -114,7 +114,7 @@ protected Response pong(final String accountSid, final MediaType responseType) { CallDetailRecordFilter filterForTotal; try { filterForTotal = new CallDetailRecordFilter("", null, null, null, null, null,null, - null, null, null, null); + null, null, null, null, null); } catch (ParseException e) { return status(BAD_REQUEST).build(); } diff --git a/restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/VoiceInterpreter.java b/restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/VoiceInterpreter.java index 01db9a8cb3..351202c58e 100644 --- a/restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/VoiceInterpreter.java +++ b/restcomm/restcomm.interpreter/src/main/java/org/restcomm/connect/interpreter/VoiceInterpreter.java @@ -1786,7 +1786,7 @@ private void createInitialCallRecord(CallResponse message) { builder.setUri(uri); builder.setCallPath(call.path().toString()); - + builder.setType(callInfo.type()); callRecord = builder.build(); records.addCallDetailRecord(callRecord); } diff --git a/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java b/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java index 667d6620f7..25f191a9e9 100644 --- a/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java +++ b/restcomm/restcomm.telephony.api/src/main/java/org/restcomm/connect/telephony/api/util/B2BUAHelper.java @@ -46,6 +46,7 @@ import org.mobicents.javax.servlet.sip.SipSessionExt; import org.restcomm.connect.commons.configuration.RestcommConfiguration; import org.restcomm.connect.commons.dao.Sid; +import org.restcomm.connect.commons.telephony.CreateCallType; import org.restcomm.connect.commons.util.DNSUtils; import org.restcomm.connect.dao.CallDetailRecordsDao; import org.restcomm.connect.dao.DaoManager; @@ -191,6 +192,7 @@ public static boolean redirectToB2BUA(final SipServletRequest request, final Cli builder.setUri(uri); CallDetailRecordsDao records = daoManager.getCallDetailRecordsDao(); + builder.setType(CreateCallType.CLIENT); CallDetailRecord callRecord = builder.build(); records.addCallDetailRecord(callRecord); @@ -348,6 +350,7 @@ public static boolean redirectToB2BUA(final SipServletRequest request, final Cli buffer.append(fromClient.getSid().toString()); final URI uri = URI.create(buffer.toString()); builder.setUri(uri); + builder.setType(CreateCallType.CLIENT); CallDetailRecordsDao records = daoManager.getCallDetailRecordsDao(); CallDetailRecord callRecord = builder.build(); diff --git a/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/Call.java b/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/Call.java index c769d34ad5..824c62d0b1 100644 --- a/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/Call.java +++ b/restcomm/restcomm.telephony/src/main/java/org/restcomm/connect/telephony/Call.java @@ -917,6 +917,7 @@ public void execute(Object message) throws Exception { builder.setCallPath(self().path().toString()); builder.setParentCallSid(parentCallSid); outgoingCallRecord = builder.build(); + builder.setType(type); recordsDao.addCallDetailRecord(outgoingCallRecord); } else { cdr.setStatus(external.name()); diff --git a/restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/interpreter/UssdInterpreter.java b/restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/interpreter/UssdInterpreter.java index fea7fa5483..7b8834bf41 100644 --- a/restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/interpreter/UssdInterpreter.java +++ b/restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/interpreter/UssdInterpreter.java @@ -722,6 +722,7 @@ public void execute(final Object message) throws Exception { final URI uri = URI.create(buffer.toString()); builder.setUri(uri); builder.setCallPath(ussdCall.path().toString()); + builder.setType(callInfo.type()); callRecord = builder.build(); records.addCallDetailRecord(callRecord); } diff --git a/restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/telephony/UssdCall.java b/restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/telephony/UssdCall.java index d9b8634008..7c5b0d8a0d 100644 --- a/restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/telephony/UssdCall.java +++ b/restcomm/restcomm.ussd/src/main/java/org/restcomm/connect/ussd/telephony/UssdCall.java @@ -617,6 +617,7 @@ public void execute(Object message) throws Exception { buffer.append(id.toString()); final URI uri = URI.create(buffer.toString()); builder.setUri(uri); + builder.setType(type); outgoingCallRecord = builder.build(); callDetailrecordsDao.addCallDetailRecord(outgoingCallRecord); }