<commit_before>package org.motechproject.ivr.kookoo;

import org.apache.commons.lang.StringUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.motechproject.server.service.ivr.IVREvent;
import org.motechproject.server.service.ivr.IVRRequest;
import org.motechproject.server.service.ivr.IVRSession;

import java.util.HashMap;
import java.util.Map;

public class KookooRequest implements IVRRequest {

    private static final String POUND_SYMBOL = "%23";
    private String sid;
    private String cid;
    private String event;
    private String data;
    private String callId;
    private Map<String, String> dataMap = new HashMap<String, String>();

    @Override
    public String getCallerId() {
        return callId;
    }

    @Override
    public String getParameter(String key) {
        return dataMap.get(key);
    }

    @Override
    public void setParameter(String key, String value) {
        dataMap.put(key, value);
    }

    @Override
    public String getEvent() {
        return event;
    }

    public KookooRequest() {
    }

    public KookooRequest(String sid, String cid, String event, String data) {
        this.sid = sid;
        this.cid = cid;
        this.event = event;
        this.data = data;
    }

    public String getSessionId() {
        return sid;
    }

    @Override
    public String getCallId() {
        return callId;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getCid() {
        return cid;
    }

    public void setCid(String cid) {
        this.cid = cid;
    }


    public void setEvent(String event) {
        this.event = event;
    }

    public String getData() {
        return data;
    }

    public String getInput() {
        return data.replace(POUND_SYMBOL, "");
    }

    public void setData(String data) {
        this.data = data;
    }

    public IVREvent callEvent() {
        return IVREvent.keyOf(this.event);
    }

    public boolean hasNoData() {
        return StringUtils.isBlank(this.data);
    }

    public String getPayloadJson() {
        JSONObject object = new JSONObject();
        for (String key : dataMap.keySet()) {
            try {
                object.put(key, dataMap.get(key));
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        return object.toString();
    }

    public Map getPayloadParams() {
        return dataMap;
    }

    public CallDirection getCallDirection() {
        return dataMap!=null && "true".equals(dataMap.get(IVRSession.IVRCallAttribute.IS_OUTBOUND_CALL)) ? CallDirection.Outbound: CallDirection.Inbound;
    }

}
<commit_msg>#266 | fixed callerId defect <mano/vijay><commit_after>package org.motechproject.ivr.kookoo;

import org.apache.commons.lang.StringUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.motechproject.server.service.ivr.IVREvent;
import org.motechproject.server.service.ivr.IVRRequest;
import org.motechproject.server.service.ivr.IVRSession;

import java.util.HashMap;
import java.util.Map;

public class KookooRequest implements IVRRequest {

    private static final String POUND_SYMBOL = "%23";
    private String sid;
    private String cid;
    private String event;
    private String data;
    private String callId;
    private Map<String, String> dataMap = new HashMap<String, String>();

    public KookooRequest() {
    }

    public KookooRequest(String sid, String cid, String event, String data) {
        this.sid = sid;
        this.cid = cid;
        this.event = event;
        this.data = data;
    }

    @Override
    public String getCallId() {
        return callId;
    }

    @Override
    public String getCallerId() {
        return cid;
    }

    @Override
    public String getParameter(String key) {
        return dataMap.get(key);
    }

    @Override
    public void setParameter(String key, String value) {
        dataMap.put(key, value);
    }

    @Override
    public String getEvent() {
        return event;
    }

    public String getSessionId() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getCid() {
        return cid;
    }

    public void setCid(String cid) {
        this.cid = cid;
    }


    public void setEvent(String event) {
        this.event = event;
    }

    public String getData() {
        return data;
    }

    public String getInput() {
        return data.replace(POUND_SYMBOL, "");
    }

    public void setData(String data) {
        this.data = data;
    }

    public IVREvent callEvent() {
        return IVREvent.keyOf(this.event);
    }

    public boolean hasNoData() {
        return StringUtils.isBlank(this.data);
    }

    public String getPayloadJson() {
        JSONObject object = new JSONObject();
        for (String key : dataMap.keySet()) {
            try {
                object.put(key, dataMap.get(key));
            } catch (JSONException e) {
                throw new RuntimeException(e);
            }
        }
        return object.toString();
    }

    public Map getPayloadParams() {
        return dataMap;
    }

    public CallDirection getCallDirection() {
        return dataMap!=null && "true".equals(dataMap.get(IVRSession.IVRCallAttribute.IS_OUTBOUND_CALL)) ? CallDirection.Outbound: CallDirection.Inbound;
    }

}

{'fraction_non_alphanumeric': 0.0976915974145891, 'fraction_numerical': 0.0012927054478301017, 'mean_word_length': 2.316595223515003, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4444712', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1603, 'n_words': 390}