Beispiel #1
0
  private void createCallDetailRecord(
      FrontLineWorker flw, CallDetailRecordRequest callDetailRecordRequest, Service service) {
    CallDetailRecord cdr = new CallDetailRecord();
    cdr.setFrontLineWorker(flw);
    cdr.setCallingNumber(callDetailRecordRequest.getCallingNumber());
    cdr.setCallId(callDetailRecordRequest.getCallId());
    cdr.setOperator(callDetailRecordRequest.getOperator());
    cdr.setCircle(callDetailRecordRequest.getCircle());
    cdr.setCallStartTime(
        new DateTime(callDetailRecordRequest.getCallStartTime() * MILLISECONDS_PER_SECOND));
    cdr.setCallEndTime(
        new DateTime(callDetailRecordRequest.getCallEndTime() * MILLISECONDS_PER_SECOND));
    cdr.setCallDurationInPulses(callDetailRecordRequest.getCallDurationInPulses());
    cdr.setEndOfUsagePromptCounter(callDetailRecordRequest.getEndOfUsagePromptCounter());
    cdr.setCallStatus(callDetailRecordRequest.getCallStatus());
    cdr.setCallDisconnectReason(callDetailRecordRequest.getCallDisconnectReason());

    if (service == Service.MOBILE_KUNJI) {
      cdr.setWelcomePrompt(callDetailRecordRequest.getWelcomeMessagePromptFlag());
    }

    callDetailRecordService.add(cdr);

    for (CallContentRequest callContentRequest : callDetailRecordRequest.getContent()) {
      CallContent content = new CallContent();

      content.setContentName(callContentRequest.getContentName());
      content.setContentFile(callContentRequest.getContentFileName());
      content.setStartTime(
          new DateTime(callContentRequest.getStartTime() * MILLISECONDS_PER_SECOND));
      content.setEndTime(new DateTime(callContentRequest.getEndTime() * MILLISECONDS_PER_SECOND));

      if (service == Service.MOBILE_KUNJI) {
        content.setMobileKunjiCardCode(callContentRequest.getMkCardCode());
      }

      if (service == Service.MOBILE_ACADEMY) {
        content.setType(callContentRequest.getType());
        content.setCompletionFlag(callContentRequest.getCompletionFlag());
      }

      content.setCallDetailRecord(cdr);

      callContentService.add(content);
    }
  }
Beispiel #2
0
  private String validateCallContentRequest(
      Service service, CallContentRequest callContentRequest) {
    StringBuilder failureReasons = new StringBuilder();

    // Common elements (contentName, contentFile, startTime, endTime)
    if (null == callContentRequest.getContentName()) {
      failureReasons.append(String.format(NOT_PRESENT, "contentName"));
    }

    if (null == callContentRequest.getContentFileName()) {
      failureReasons.append(String.format(NOT_PRESENT, "contentFile"));
    }

    if (null == callContentRequest.getStartTime()) {
      failureReasons.append(String.format(NOT_PRESENT, "startTime"));
    }

    if (null == callContentRequest.getEndTime()) {
      failureReasons.append(String.format(NOT_PRESENT, "endTime"));
    }

    // MK elements (mkCardCode)
    if (service == Service.MOBILE_KUNJI) {
      if (null == callContentRequest.getMkCardCode()) {
        failureReasons.append(String.format(NOT_PRESENT, "mkCardCode"));
      }
    }

    // MA elements (type, completionFlag)
    if (service == Service.MOBILE_ACADEMY) {
      if (null == callContentRequest.getType()) {
        failureReasons.append(String.format(NOT_PRESENT, "type"));
      }

      if (null == callContentRequest.getCompletionFlag()) {
        failureReasons.append(String.format(NOT_PRESENT, "completionFlag"));
      }
    }

    return failureReasons.toString();
  }