예제 #1
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    logger.info("******Inside ProductDisplayAction...........");
    ProductDisplayForm theform = null;
    Collection colln = new ArrayList();

    String ndc = request.getParameter("NDC");
    System.out.println("NDC : " + ndc);
    String lotNumber = request.getParameter("lotnum");
    String pedId = request.getParameter("PedigreeId");
    String envId = (String) request.getAttribute("envId");
    logger.info(" NDC =" + ndc);
    logger.info("lotnumber =" + lotNumber);

    try {

      HttpSession sess = request.getSession();
      Helper helper = new Helper();
      clientIP = request.getRemoteAddr();

      Conn = helper.ConnectTL();
      stmt = helper.getStatement(Conn);
      logger.info("Validating The Session");

      // Validating Session
      String sessionID = (String) sess.getAttribute("sessionID");
      logger.info("sessionID in ProductDisplayAction :" + sessionID);
      String validateResult = helper.ValidateUserSession(stmt, sessionID, clientIP);

      if (!validateResult.equals("VALID")) {
        // return a forward to invalid .
        return mapping.findForward("loginPage");
      }

      StringBuffer buf = new StringBuffer();
      // buf.append("tlsp:GetProductId('','')");
      buf.append("for $i in collection('tig:///ePharma/ShippedPedigree')/PedigreeEnvelope ");
      buf.append("where $i/pedigree/shippedPedigree/documentInfo/serialNumber = '" + pedId + "' ");
      buf.append(
          "return <output> <ProductName>{data($i/pedigree/shippedPedigree/initialPedigree/productInfo/drugName)}</ProductName></output> ");
      System.out.println("Query in product display action : " + buf.toString());
      Statement Stmt = helper.getStatement(Conn);

      Enumeration enu = request.getParameterNames();
      while (enu.hasMoreElements()) {
        String str = (String) enu.nextElement();
        logger.info("Str =" + str + "=" + request.getParameter(str));
      }

      List list = (List) queryRunner.executeQuery(buf.toString());

      if (list.size() > 1) {

        return mapping.findForward("successddd");

      } else {
        Node node = XMLUtil.parse((ByteArrayInputStream) list.get(0));
        if (node != null) {

          String productName = XMLUtil.getValue(node, "ProductName");
          System.out.println("Product Name in action : " + productName);
          StringBuffer bfr = new StringBuffer();
          bfr.append(
              " declare namespace bin='http://www.rainingdata.com/TigerLogic/binary-support'; declare binary-encoding none; ");
          /* bfr.append(" for $k in collection('tig:///EAGRFID/Products')[ProductName =  "+productName+"]");
             bfr.append(" for $k in collection ('tig:///EAGRFID/Products')/Product");
          bfr.append(" for $D in collection('tig:///EAGRFID/ProductImage')/Location");
             bfr.append(" where data($D/ID) = data($k/genId) and data($k/ProductName) = '"+productName+"'");
             bfr.append(" return $D/LocIMG/binary() ");
            */

          bfr.append(
              "for $K in collection('tig:///EAGRFID/Products')/Product[ProductName = '"
                  + productName
                  + "' ] ");
          bfr.append(
              " for $D in collection('tig:///EAGRFID/ProductImage')/Product[ID = $K/ProductID]");
          bfr.append(
              " return  if( exists($D/ProdIMG/binary()) ) then $D/ProdIMG/binary() else   bin:base64-decode( $D/ProdIMG ) ");
          System.out.println("Query for getting image: " + bfr.toString());
          logger.info(" Query " + bfr.toString());
          logger.info("query =" + bfr);

          byte[] xmlResults = helper.ReadTL(Stmt, bfr.toString());
          if (xmlResults != null) {
            String str = sess.getServletContext().getRealPath(request.getContextPath());
            logger.info(str + "\\..");
            File file = new File(str + "\\..\\images\\" + productName);
            logger.info("Path =" + file.getAbsolutePath());
            System.out.println("Path : " + file.getAbsolutePath());
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(xmlResults);
            Thread.sleep(2000);
            fos.flush();
            fos.close();
          }
          request.setAttribute("imagefile", "..\\..\\images\\" + productName);
        }
        request.setAttribute("productlists", node);
        StringBuffer buffer = new StringBuffer();
        buffer.append("tlsp:GetProductId('" + pedId + "')");
        System.out.println("Query for getting product id: " + buffer.toString());
        List result = queryRunner.returnExecuteQueryStrings(buffer.toString());
        if (result.size() > 0) {
          String prodId = (String) result.get(0).toString();
          System.out.println("Product Id in action: " + prodId);
          request.setAttribute("ProdId", prodId);
        }
        StringBuffer buff = new StringBuffer();
        buff.append("tlsp:GetProductDetails('" + envId + "','" + pedId + "','" + ndc + "')");
        System.out.println("Query for getting product details: " + buff.toString());
        List res = queryRunner.executeQuery(buff.toString());

        colln = new ArrayList();
        for (int i = 0; i < res.size(); i++) {

          theform = new ProductDisplayForm();
          Node listNode = XMLUtil.parse((InputStream) res.get(i));
          System.out.println("listNode :" + listNode);

          theform.setDosageForm(CommonUtil.jspDisplayValue(listNode, "Product/DosageForm"));
          System.out.println("Dosage form: " + theform.getDosageForm());
          theform.setDosageStrength(CommonUtil.jspDisplayValue(listNode, "Product/DosageStrength"));
          theform.setEpc(CommonUtil.jspDisplayValue(listNode, "Product/EPC"));
          theform.setMfrDate(CommonUtil.jspDisplayValue(listNode, "Product/DosageForm"));
          theform.setMfrName(CommonUtil.jspDisplayValue(listNode, "Product/ManufacturerName"));
          theform.setNdc(CommonUtil.jspDisplayValue(listNode, "Product/NDC"));
          theform.setPbc(CommonUtil.jspDisplayValue(listNode, "Product/BarCode"));
          theform.setProdName(CommonUtil.jspDisplayValue(listNode, "Product/ProductName"));
          theform.setUpc(CommonUtil.jspDisplayValue(listNode, "Product/PackageUPC"));
          colln.add(theform);
          request.setAttribute("Result", listNode);
        }

        request.setAttribute(Constants.PRODUCTDISPLAY_DETAILS, colln);

        return mapping.findForward("success");
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      logger.error("Error in ProductDisplayAction  execute()" + ex);
      return mapping.findForward("exception");
    }
  }
예제 #2
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws PersistanceException {

    log.info("Inside Action OrderSearchAction class....... ");

    try {

      HttpSession sess = request.getSession();
      clientIP = request.getRemoteAddr();

      conn = helper.ConnectTL();
      stmt = helper.getStatement(conn);
      log.info("Validating The Session");

      // Validating Session
      String sessionID = (String) sess.getAttribute("sessionID");
      log.info("sessionID in Action :" + sessionID);
      String validateResult = helper.ValidateUserSession(stmt, sessionID, clientIP);

      if (!validateResult.equals("VALID")) {
        // return a forward to invalid .
        return mapping.findForward("loginPage");
      }

      StringBuffer buf = new StringBuffer();
      buf.append("for $i in collection('tig:///CatalogManager/TradingPartner')/TradingPartner ");
      buf.append("return data($i/name) ");
      List tpNames = queryRunner.returnExecuteQueryStrings(buf.toString());
      System.out.println("TP Names : " + tpNames.toString());
      sess.setAttribute("tpNames", tpNames);

      String accessLevel = null;
      accessLevel = request.getParameter("accesslevel");
      if (accessLevel.equalsIgnoreCase("ordersearch") || accessLevel != null) {
        List accessList =
            queryRunner.returnExecuteQueryStrings(
                "tlsp:validateAccess('" + sessionID + "','2.07','Read')");
        String readStatus = accessList.get(0).toString();
        log.info("The readStatus is : " + readStatus);
        if (readStatus.equalsIgnoreCase("false")) {
          request.setAttribute("status", "false");
          return mapping.findForward("failure");
        }
      }

      String fromDT = request.getParameter("fromDT");
      String toDT = request.getParameter("toDT");
      String lotNum = request.getParameter("lotNum");
      String prodNDC = request.getParameter("prodNDC");
      String orderNum = request.getParameter("orderNum");
      log.info("ORderNumber entered is :  " + orderNum);
      String apndocId = request.getParameter("apndocId");
      String tpName = request.getParameter("tpName");
      if (tpName == null || tpName.equalsIgnoreCase("SelectOne..")) {
        tpName = "";
      }
      Collection colln = new ArrayList();

      log.info(
          "  -------- fromDT:   " + fromDT + "  ---toDT :  " + toDT + "  ---- lotNum: " + lotNum);
      log.info(
          "  -------- prodNDC:   "
              + prodNDC
              + "  ---orderNum :  "
              + orderNum
              + "  ---- apndocId: "
              + apndocId
              + "---- tpName: "
              + tpName);

      boolean apnQueryFlag = false;

      StringBuffer orderCriteria = new StringBuffer();

      StringBuffer apnCriteria = new StringBuffer();

      // if apn docid entered we need to get the order id from the
      // apn document

      if (apndocId != null && !apndocId.trim().equalsIgnoreCase("")) {
        //			apnQueryFlag = true;

        String buyersId =
            queryRunner.returnExecuteQueryStringsAsString("tlsp:getBuyersId('" + apndocId + "')");
        System.out.println("The transaction Number is :" + buyersId);

        // add to apn criteria
        apnCriteria.append(" $k/DocumentId='");
        apnCriteria.append(apndocId);
        apnCriteria.append("' ");

        // add to order criteria also
        orderCriteria.append("and ");
        orderCriteria.append(" $a/BuyersID = '" + buyersId + "' ");

      } else {

        if (orderNum != null && !orderNum.trim().equalsIgnoreCase("")) {
          orderCriteria.append("and ");
          orderCriteria.append("$a/BuyersID='");
          orderCriteria.append(orderNum);
          orderCriteria.append("' ");
        }
      }

      if (prodNDC != null && !prodNDC.trim().equalsIgnoreCase("")) {
        orderCriteria.append("and ");
        orderCriteria.append(" $a/OrderLine/LineItem/Item/SellersItemIdentification/ID='");
        orderCriteria.append(prodNDC);
        orderCriteria.append("' ");
      }

      if (tpName != null && !tpName.trim().equalsIgnoreCase("")) {
        orderCriteria.append("and ");
        orderCriteria.append(" $a/BuyerParty/PartyName/Name='");
        orderCriteria.append(tpName);
        orderCriteria.append("' ");
      }

      if (toDT != null && !toDT.trim().equalsIgnoreCase("")) {
        orderCriteria.append("and ");

        if (fromDT == null || fromDT.trim().equalsIgnoreCase("")) {
          fromDT = df.format(new java.util.Date());
        }

        orderCriteria.append("  $a/IssueDate >='");
        orderCriteria.append(fromDT + "T00:00:00");
        orderCriteria.append("' ");

        orderCriteria.append(" and $a/IssueDate <='");
        orderCriteria.append(toDT + "T23:59:59");
        orderCriteria.append("' ");
      }

      if (lotNum != null && !lotNum.trim().equalsIgnoreCase("")) {
        orderCriteria.append("and ");
        orderCriteria.append(" $a/OrderLine/LineItem/Item/LotIdentification='");
        orderCriteria.append(lotNum);
        orderCriteria.append("' ");
      }

      String orderCriteriaStr = orderCriteria.toString().trim();

      log.info(" criteriaStr :" + orderCriteriaStr);
      if (orderCriteriaStr.startsWith("and")) {
        // remove 'and'
        orderCriteriaStr = orderCriteriaStr.substring(3, orderCriteriaStr.length());
      }

      // out put XML string
      StringBuffer outputQuery = new StringBuffer();

      outputQuery.append(" return <Output> ");
      outputQuery.append(" <BuyersID> {data($a/BuyersID)}  </BuyersID> ");
      outputQuery.append(" <IssueDate> {data($a/IssueDate)}  </IssueDate> ");
      outputQuery.append(
          " <TradingPartner>{ data($a/BuyerParty/PartyName/Name) } </TradingPartner> ");
      outputQuery.append(
          " <TotalNumOfNDCs> {count(distinct-values($a/OrderLine/LineItem/Item/SellersItemIdentification/ID)) }</TotalNumOfNDCs>");
      outputQuery.append(" <TotalLineItems>{count($a/OrderLine/LineItem)} </TotalLineItems>");
      outputQuery.append(" <OrderAmount> { data($a/LineExtensionTotalAmount)}  </OrderAmount>");
      outputQuery.append(" {$a/BuyerParty/Address }");
      outputQuery.append(" </Output>");

      // construct final query with all part queries
      StringBuffer finalQuery = new StringBuffer();

      //		if(apnQueryFlag) {
      //			finalQuery.append("for $k in collection('tig:///ePharma/APN')/APN");
      //			finalQuery.append(" where ");
      //			finalQuery.append(apnCriteria.toString());
      //			finalQuery.append(" return ");
      //		}

      // constructs Order query
      StringBuffer orderquery = new StringBuffer();
      orderquery.append(" for $a in collection('tig:///ePharma/Orders')/Order ");

      if (orderCriteriaStr.length() > 0) {
        orderquery.append(" where  ");
        orderquery.append(orderCriteriaStr);
      } else {
        orderquery.append("where $a/BuyersID = '' ");
      }

      // add order part of teh query
      finalQuery.append(orderquery.toString());

      // add output query
      finalQuery.append(outputQuery.toString());

      log.info(" Query in OrderSearchAction : " + finalQuery.toString());

      List list = queryRunner.executeQuery(finalQuery.toString());
      log.info("Result in OrderSearchAction.........." + list.size());

      // set the results
      sess.setAttribute("List", list);

      for (int i = 0; i < list.size(); i++) {

        OrderSearchForm theForm = new OrderSearchForm();
        Node listNode = XMLUtil.parse((InputStream) list.get(i));

        theForm.setOrderNum(CommonUtil.jspDisplayValue(listNode, "BuyersID"));
        // theForm.setOrderNum(CommonUtil.jspDisplayValue(listNode,"orderNum"));
        log.info("Order NUmber is:" + theForm.getOrderNum());
        theForm.setIssueDate(CommonUtil.jspDisplayValue(listNode, "IssueDate"));
        log.info("Issue Date is:" + theForm.getIssueDate());
        theForm.setTradingPartner(CommonUtil.jspDisplayValue(listNode, "TradingPartner"));
        log.info("TradingPartner is:" + theForm.getTradingPartner());
        theForm.setNumOfNDCs(CommonUtil.jspDisplayValue(listNode, "TotalNumOfNDCs"));
        log.info("Number of NDCs is:" + theForm.getNumOfNDCs());
        theForm.setNumOfLineItems(CommonUtil.jspDisplayValue(listNode, "TotalLineItems"));
        log.info("Number of LineItems is:" + theForm.getNumOfLineItems());
        theForm.setAmount(CommonUtil.jspDisplayValue(listNode, "OrderAmount"));
        log.info("Order Amount is:" + theForm.getAmount());
        theForm.setAddress(CommonUtil.jspDisplayValue(listNode, "Address"));
        log.info("Address is:" + theForm.getAddress());

        // theForm.setScreenEnteredDate(screenEnteredDate);
        colln.add(theForm);
      }

      log.info("Before returning to success");
      request.setAttribute(Constants.ORDER_DETAILS, colln);

    } catch (Exception ex) {
      ex.printStackTrace();
      log.error("Error in OrderSearchAction execute method........." + ex);
      return mapping.findForward("exception");
    } finally {
      // close the connection
      helper.CloseConnectionTL(conn);
    }
    return mapping.findForward("success");
  }
예제 #3
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    Collection colln = new ArrayList();
    EnvelopeForm theForm = null;
    try {

      HttpSession sess = request.getSession();
      Helper helper = new Helper();
      clientIP = request.getRemoteAddr();

      conn = helper.ConnectTL();
      stmt = helper.getStatement(conn);
      log.info("Validating The Session");

      // Validating Session
      String sessionID = (String) sess.getAttribute("sessionID");
      log.info("sessionID in Action :" + sessionID);
      String validateResult = helper.ValidateUserSession(stmt, sessionID, clientIP);

      if (!validateResult.equals("VALID")) {
        // return a forward to invalid .
        return mapping.findForward("loginPage");
      }

      String envelopeid = request.getParameter("envelopeId");
      sess.setAttribute("envId", envelopeid);

      String buff1 = "tlsp:ShippingMgnrEnvelopesDisplay_MD('" + envelopeid + "')";
      System.out.println("Query for getting envelope details: " + buff1);
      String enveloped = "tlsp:ShippingMgnrEnvelopeDetails_MD('" + envelopeid + "')";
      System.out.println("Query for getting envelope details: " + enveloped);
      List list1 = queryRunner.returnExecuteQueryStrings(buff1.toString());
      request.setAttribute("envDetails", list1);
      List list2 = queryRunner.returnExecuteQueryStrings(enveloped);
      request.setAttribute("envId", list2);
      colln = new ArrayList();
      theForm = (EnvelopeForm) form;
      Node listNode1 = XMLUtil.parse((String) list2.get(0));

      theForm.setEnvelopeID(CommonUtil.jspDisplayValue(listNode1, "EnvelopeID"));
      theForm.setDate(CommonUtil.jspDisplayValue(listNode1, "Date"));
      String transDateAndTime = CommonUtil.jspDisplayValue(listNode1, "Date");
      String result[] = StringUtils.split(transDateAndTime, "T");
      String date = result[0];
      request.setAttribute("date", date);
      if (result.length > 1) {
        String time = result[1];
        request.setAttribute("time", time);
      } else {
        String time = "N/A";
        request.setAttribute("time", time);
      }

      theForm.setSource(CommonUtil.jspDisplayValue(listNode1, "source"));
      theForm.setDestination(CommonUtil.jspDisplayValue(listNode1, "destination"));

      for (int i = 0; i < list1.size(); i++) {
        theForm = new EnvelopeForm();
        Node listNode = XMLUtil.parse((String) list1.get(i));
        theForm.setContainercode(CommonUtil.jspDisplayValue(listNode, "containerCode"));
        theForm.setPedigreeID(CommonUtil.jspDisplayValue(listNode, "pedigreeid"));
        theForm.setQuantity(CommonUtil.jspDisplayValue(listNode, "Quantity"));
        theForm.setLotnumber(CommonUtil.jspDisplayValue(listNode, "LotNum"));
        theForm.setStatus(CommonUtil.jspDisplayValue(listNode, "status"));
        theForm.setTransactiondate(CommonUtil.jspDisplayValue(listNode, "TransactionDate"));
        String trandate = CommonUtil.jspDisplayValue(listNode, "TransactionDate");
        String trdate[] = StringUtils.split(trandate, "T");
        String trnsdate = trdate[0];
        request.setAttribute("trnsDate", trnsdate);
        if (trdate.length > 1) {
          String trnstime = trdate[1];
          request.setAttribute("transTime", trnstime);
        } else {
          String trnstime = "N/A";
          request.setAttribute("transTime", trnstime);
        }
        theForm.setDrugname(CommonUtil.jspDisplayValue(listNode, "DrugName"));
        theForm.setDrugcode(CommonUtil.jspDisplayValue(listNode, "DrugCode"));
        theForm.setAttachment(CommonUtil.jspDisplayValue(listNode, "Attachement"));
        theForm.setCount(CommonUtil.jspDisplayValue(listNode, "count"));

        colln.add(theForm);
      }

      request.setAttribute(Constants.ENVELOPE_DETAILS, colln);
      sess.setAttribute("envId", envelopeid);

    } catch (Exception ex) {

      ex.printStackTrace();
      log.error("Error in OrderSearchAction execute method........." + ex);
      return mapping.findForward("exception");
    }
    return mapping.findForward("success");
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String faxName[] = request.getParameterValues("check");

    if (faxName != null) {
      int size = faxName.length;
      System.out.println("come into action prasanthi delete size :  " + size);
      String buffer = null;
      for (int i = 0; i < size; i++) {
        buffer = "tlsp:deleteProcessedPedigree('" + faxName[i] + "')";
        queryrunner.executeQuery(buffer);
        System.out.println("Queryyyyyyyyyy: " + buffer);
      }
    }

    ProcessedEnteredPedigreesForm theForm = null;
    Collection colln = new ArrayList();

    log.info("Inside Action ProcessedEnteredPedigreesAction....... ");

    String offset = request.getParameter("offset");
    if (offset != null) {
      int off = Integer.parseInt(offset);
      System.out.println("The value of offset in PedigreeSearchAction is :" + off);
    } else {
      offset = "0";
    }

    request.setAttribute("offset", offset);

    try {

      String query = "tlsp:GetProcessedEnteredPedigrees()";
      log.info("query for FaxDetails is:" + query);
      List enteredPedigrees = queryrunner.executeQuery(query);
      System.out.println("List size after FaxDetails is : " + enteredPedigrees.size());
      request.setAttribute("PedigreeDetails", enteredPedigrees);

      for (int i = 0; i < enteredPedigrees.size(); i++) {

        theForm = new ProcessedEnteredPedigreesForm();
        Node listNode = XMLUtil.parse((InputStream) enteredPedigrees.get(i));
        // Node listNode = XMLUtil.parse((String)res.get(i));

        theForm.setInvoiceNumber(CommonUtil.jspDisplayValue(listNode, "InvoiceNumber"));
        theForm.setPedigreeId(CommonUtil.jspDisplayValue(listNode, "pedigreeId"));
        System.out.println("Invoice Number is:" + theForm.getInvoiceNumber());
        theForm.setVendorName(CommonUtil.jspDisplayValue(listNode, "VendorName"));
        theForm.setDrugName(CommonUtil.jspDisplayValue(listNode, "DrugName"));
        theForm.setNdc(CommonUtil.jspDisplayValue(listNode, "NDC"));
        String lots = XMLUtil.getValue(listNode, "VendorLot");
        System.out.println(lots);
        int l = lots.length();
        lots = lots.substring(0, l - 1);
        theForm.setVendorLot(lots);

        theForm.setProcessedDate(CommonUtil.jspDisplayValue(listNode, "processedDate"));
        colln.add(theForm);
      }

      request.setAttribute(Constants.ENTER_PEDIGREE_DETAILS, colln);

    } catch (PersistanceException e) {
      log.error("Error in ProcessedEnteredPedigreesAction execute method........." + e);
      throw new PersistanceException(e);
    } catch (Exception ex) {
      ex.printStackTrace();
      log.error("Error in ProcessedEnteredPedigreesAction execute method........." + ex);
      throw new Exception(ex);
    }
    return mapping.findForward("success");
  }