Package org.mobicents.seam

Examples of org.mobicents.seam.Order


    System.out.println("The Dtmf is " + dtmf);

    int cause = Integer.parseInt(dtmf);

    EntityManager mgr = null;
    Order order = null;
    boolean successful = false;
    String audioFile = null;

    String destinationName = "/queue/B";

    InitialContext ic = null;
    ConnectionFactory cf = null;
    Connection jmsConnection = null;

    switch (cause) {
    case Basic.CAUSE_DIGIT_1:
      audioFile = pathToAudioDirectory + "OrderApproved.wav";
      if (this.getSfDemo()) {
        System.out.println("Lookup the Queue and put value");
        try {
          ic = new InitialContext();

          cf = (ConnectionFactory) ic.lookup("/ConnectionFactory");
          Queue queue = (Queue) ic.lookup(destinationName);
          logger.info("Queue " + destinationName + " exists");

          jmsConnection = cf.createConnection();
          javax.jms.Session jmsSession = jmsConnection.createSession(
              false, javax.jms.Session.AUTO_ACKNOWLEDGE);
          MessageProducer sender = jmsSession.createProducer(queue);

          TextMessage message = jmsSession.createTextMessage(this
              .getCustomEvent().getOrderId()
              + ",1");
          sender.send(message);
          logger.info("The message was successfully sent to the "
              + queue.getQueueName() + " queue");

        } catch (Exception e) {
          logger.error("Exception while trying to send message", e);
        } finally {
          if (ic != null) {
            try {
              ic.close();
            } catch (Exception e) {
              logger.error("Exception while closing the IC", e);
            }
          }
          try {
            if (jmsConnection != null) {
              jmsConnection.close();
            }
          } catch (JMSException jmse) {
            logger.error("Could not close connection "
                + jmsConnection + " exception was " + jmse,
                jmse);
          }
        }

      } else {
        mgr = this.persistenceResourceAdaptorSbbInterface
            .createEntityManager(new HashMap(), "custom-pu");

        order = (Order) mgr.createQuery(
            "select o from Order o where o.orderId = :orderId")
            .setParameter("orderId",
                this.getCustomEvent().getOrderId())
            .getSingleResult();

        order.setStatus(Order.Status.PROCESSING);

        mgr.flush();
        mgr.close();
      }
      successful = true;
      break;
    case Basic.CAUSE_DIGIT_2:
      audioFile = pathToAudioDirectory + "OrderCancelled.wav";
      if (this.getSfDemo()) {
        System.out.println("Lookup the Queue and put value");
        try {
          ic = new InitialContext();

          cf = (ConnectionFactory) ic.lookup("/ConnectionFactory");
          Queue queue = (Queue) ic.lookup(destinationName);
          logger.info("Queue " + destinationName + " exists");

          jmsConnection = cf.createConnection();
          javax.jms.Session jmsSession = jmsConnection.createSession(
              false, javax.jms.Session.AUTO_ACKNOWLEDGE);
          MessageProducer sender = jmsSession.createProducer(queue);

          TextMessage message = jmsSession.createTextMessage(this
              .getCustomEvent().getOrderId()
              + ",2");
          sender.send(message);
          logger.info("The message was successfully sent to the "
              + queue.getQueueName() + " queue");

        } catch (Exception e) {
          logger.error("Exception while trying to send message", e);
        } finally {
          if (ic != null) {
            try {
              ic.close();
            } catch (Exception e) {
              logger.error("Exception while closing the IC", e);
            }
          }
          try {
            if (jmsConnection != null) {
              jmsConnection.close();
            }
          } catch (JMSException jmse) {
            logger.error("Could not close connection "
                + jmsConnection + " exception was " + jmse,
                jmse);
          }
        }

      } else {
        mgr = this.persistenceResourceAdaptorSbbInterface
            .createEntityManager(new HashMap(), "custom-pu");

        order = (Order) mgr.createQuery(
            "select o from Order o where o.orderId = :orderId")
            .setParameter("orderId",
                this.getCustomEvent().getOrderId())
            .getSingleResult();

        order.setStatus(Order.Status.CANCELLED);

        mgr.flush();
        mgr.close();
      }
      successful = true;
View Full Code Here


  }

  public void handleDtmf(int cause) {

    EntityManager mgr = null;
    Order order = null;
    boolean successful = false;

    switch (cause) {
    case Basic.CAUSE_DIGIT_1:
      String orderConfirmed = pathToAudioDirectory + "OrderConfirmed.wav";
      this.setAudioFile(orderConfirmed);

      mgr = this.persistenceResourceAdaptorSbbInterface
          .createEntityManager(new HashMap(), "custom-pu");

      order = (Order) mgr
          .createQuery(
              "select o from Order o where o.orderId = :orderId")
          .setParameter("orderId", this.getCustomEvent().getOrderId())
          .getSingleResult();

      order.setStatus(Order.Status.OPEN);

      mgr.flush();
      mgr.close();

      successful = true;

      break;
    case Basic.CAUSE_DIGIT_2:
      String orderCancelled = pathToAudioDirectory + "OrderCancelled.wav";
      this.setAudioFile(orderCancelled);

      mgr = this.persistenceResourceAdaptorSbbInterface
          .createEntityManager(new HashMap(), "custom-pu");

      order = (Order) mgr
          .createQuery(
              "select o from Order o where o.orderId = :orderId")
          .setParameter("orderId", this.getCustomEvent().getOrderId())
          .getSingleResult();

      order.setStatus(Order.Status.CANCELLED);

      mgr.flush();
      mgr.close();

      successful = true;
View Full Code Here

  }

  private void makeCall(CustomEvent event, ActivityContextInterface ac) {

    EntityManager mgr = null;
    Order order = null;

    this.setCustomEvent(event);
    this.setDateAndTime("");

    mgr = this.persistenceResourceAdaptorSbbInterface.createEntityManager(
        new HashMap(), "custom-pu");

    order = (Order) mgr.createQuery(
        "select o from Order o where o.orderId = :orderId")
        .setParameter("orderId", this.getCustomEvent().getOrderId())
        .getSingleResult();

    Timestamp orderDate = order.getDeliveryDate();

    mgr.close();

    TTSSession ttsSession = getTTSProvider().getNewTTSSession(
        audioFilePath, "kevin16");
View Full Code Here

    // user is well educated and will always punch right date and time

    if (dateAndTime.length() == 10) {

      EntityManager mgr = null;
      Order order = null;

      TTSSession ttsSession = getTTSProvider().getNewTTSSession(
          audioFilePath, "kevin16");

      char[] c = dateAndTime.toCharArray();

      StringBuffer stringBuffer = new StringBuffer();
      stringBuffer.append("You have selected delivery date to be ");

      String date = "" + c[0] + c[1];
      int iDate = (new Integer(date)).intValue();
      stringBuffer.append(iDate);

      String month = "" + c[2] + c[3];
      int iMonth = (new Integer(month)).intValue();

      String year = "" + c[4] + c[5];
      int iYear = (new Integer(year)).intValue();

      String hour = "" + c[6] + c[7];
      int iHour = (new Integer(hour)).intValue();

      String min = "" + c[8] + c[9];
      int iMin = (new Integer(min)).intValue();

      switch (iMonth) {
      case 1:
        month = "January";
        break;
      case 2:
        month = "February";
        break;
      case 3:
        month = "March";
        break;
      case 4:
        month = "April";
        break;
      case 5:
        month = "May";
        break;
      case 6:
        month = "June";
        break;
      case 7:
        month = "July";
        break;
      case 8:
        month = "August";
        break;
      case 9:
        month = "September";
        break;
      case 10:
        month = "October";
        break;
      case 11:
        month = "November";
        break;
      case 12:
        month = "December";
        break;
      default:
        break;
      }
      stringBuffer.append(" of ");
      stringBuffer.append(month);
      stringBuffer.append(" ");
      stringBuffer.append(2000 + iYear);
      stringBuffer.append(" at ");
      stringBuffer.append(iHour);
      stringBuffer.append(" hour and ");
      stringBuffer.append(iMin);
      stringBuffer.append(" minute. Thank you. Bye.");

      java.sql.Timestamp timeStamp = new java.sql.Timestamp(
          (iYear + 100), iMonth - 1, iDate, iHour, iMin, 0, 0);

      mgr = this.persistenceResourceAdaptorSbbInterface
          .createEntityManager(new HashMap(), "custom-pu");

      order = (Order) mgr
          .createQuery(
              "select o from Order o where o.orderId = :orderId")
          .setParameter("orderId", this.getCustomEvent().getOrderId())
          .getSingleResult();

      order.setDeliveryDate(timeStamp);

      mgr.flush();
      mgr.close();

      ttsSession.textToAudioFile(stringBuffer.toString());
View Full Code Here

TOP

Related Classes of org.mobicents.seam.Order

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.