예제 #1
0
  public static void insertDocument(Node theNode, String colletionName)
      throws PersistanceException {

    StringBuffer xQuery = new StringBuffer();
    xQuery.append("tig:insert-document('tig:///" + Constants.CATALOG_DB + "/" + colletionName);
    xQuery.append("',");
    xQuery.append(XMLUtil.convertToString(theNode, true) + ")");
    queryRunner.executeQuery(xQuery.toString());
  }
  public ActionForward listTrdgPartners(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    log.info("hai.........");
    Collection colIn = new ArrayList();
    StringBuffer buff = new StringBuffer();
    buff.append("<root> { ");
    buff.append("for $l in collection('tig:///CatalogManager/TradingPartner')/TradingPartner");
    buff.append(" order by $l/genId return <output> {");
    buff.append("<GenId>{data($l/genId)}</GenId>,");
    buff.append("<Name>{data($l/name)}</Name> } </output>");
    buff.append("}</root>");
    List result = queryRunner.returnExecuteQueryStrings(buff.toString());
    log.info("Out put node" + result.get(0));
    // TradingPartner 	tradingPartner = new TradingPartner(request);
    // Node n =(Node) TradingPartner.getTradingPartnerList();
    // log.info("Out put node"+n);
    Node n = XMLUtil.parse((String) result.get(0));
    List list = XMLUtil.executeQuery(n, "output");
    log.info("/////********" + list);
    for (int i = 0; i < list.size(); i++) {
      MapTradingPartnerForm trdPrtFrm = new MapTradingPartnerForm();
      trdPrtFrm.setTrdPId(XMLUtil.getValue((Node) list.get(i), "GenId"));
      log.info("\\\\\\\\\\\\\\" + trdPrtFrm.getTrdPId());
      trdPrtFrm.setTrdPName(XMLUtil.getValue((Node) list.get(i), "Name"));
      colIn.add(trdPrtFrm);
    }

    /*	String XQuery = "<root> { ";
    XQuery = XQuery + "for $l in collection('tig:///CatalogManager/TradingPartner')/TradingPartner";
    XQuery = XQuery + " order by $l/genId return <output> {";
    XQuery =XQuery + " <GenId>{data($l/genId)}</GenId>,";
    XQuery =XQuery + " <Name>{data($l/name)}</Name> } </output>";
    XQuery =XQuery + " } </root>";

    log.info("***************"+XQuery);
    String tlRows = new String(helper.ReadTL(Stmt, XQuery));
    log.info("//////////"+tlRows);
    Node n = XMLUtil.parse(tlRows);
    //Node  rt = XMLUtil.getNode(n, "root");
    List list = XMLUtil.executeQuery(n,"output");
    log.info("/////********"+list);
    for (int i=0; i< list.size(); i++ ) {
    	MapTradingPartnerForm trdPrtFrm=new MapTradingPartnerForm();
    	trdPrtFrm.setTrdPId(XMLUtil.getValue((Node)list.get(i),"GenId"));
    	log.info("\\\\\\\\\\\\\\"+trdPrtFrm.getTrdPId());
    	trdPrtFrm.setTrdPName(XMLUtil.getValue((Node)list.get(i),"Name"));
    	colIn.add(trdPrtFrm);
    }*/
    request.setAttribute(Constants.MAP_TRD_PTNR_KEY, colIn.toArray());

    return mapping.findForward("listTrdPartners");
  }
예제 #3
0
  public static List findDocument(String colletionName, String condition)
      throws PersistanceException {

    StringBuffer xQuery = new StringBuffer();
    xQuery.append(
        " for $a in collection('tig:///" + Constants.CATALOG_DB + "/" + colletionName + "/')");
    xQuery.append(" where " + condition);
    xQuery.append(" return $a/*");

    return (List) queryRunner.executeQuery(xQuery.toString());
  }
예제 #4
0
  public String getdocIDForFaxName(String faxName) throws PersistanceException {
    String id = "";
    StringBuffer buffer = new StringBuffer();
    buffer.append("for $i in collection('tig:///ePharma_MD/ReceivedFax')/InboundPostRequest");
    buffer.append(" where $i/FaxControl/FaxName = '" + faxName + "'");
    buffer.append(" return data( $i/InitialPedigreeId)");
    log.info("query is" + buffer.toString());
    id = queryRunner.returnExecuteQueryStringsAsString(buffer.toString());
    log.info("Pedigree ID" + id);

    return id;
  }
예제 #5
0
  public String getParentCodeList() throws Exception {
    String ret = "";

    List al = qrun.returnExecuteQueryStrings("tlsp:listCategoriesProc()");

    for (Iterator itr = al.iterator(); itr.hasNext(); ) {
      String s1 = (String) itr.next();
      ret = ret + s1;
    }

    return ret;
  }
예제 #6
0
  public static void updateDocument(Node theNode, String colletionName, String condition)
      throws PersistanceException {

    StringBuffer xQuery = new StringBuffer();
    xQuery.append(
        " for $a in collection('tig:///" + Constants.CATALOG_DB + "/" + colletionName + "/')");
    xQuery.append(" where " + condition);
    xQuery.append(
        " return tig:replace-document(document-uri( $a ), "
            + XMLUtil.convertToString(theNode, true)
            + ")");
    queryRunner.executeQuery(xQuery.toString());
  }
예제 #7
0
 public void createCategory(
     String parent,
     String child,
     String desc,
     String createdBy,
     String createdOn,
     String updatedBy,
     String updatedOn)
     throws Exception {
   String input =
       "'" + parent + AD + child + AD + desc + AD + createdBy + AD + createdOn + AD + updatedBy
           + AD + updatedOn + "'";
   List lt = qrun.executeQuery("tlsp:addCategoryProc(" + input + ")");
 }
예제 #8
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    try {
      HttpSession sess = request.getSession();
      Helper helper = new Helper();
      String sessionID = (String) sess.getAttribute("sessionID");
      log.info("sessionID in Action :" + sessionID);
      String validateResult = helper.ValidateUserSession(stmt, sessionID, clientIP);
      Collection colln = new ArrayList();
      Collection products = new ArrayList();
      clientIP = request.getRemoteAddr();

      log.info("Validating The Session");

      RepackedForm theForm = (RepackedForm) form;
      PreviousProductForm productForm = null;

      // String envId = request.getParameter("envId");
      // Validating Session

      String pedId = request.getParameter("PedigreeId");
      String collection = request.getParameter("collection");
      String strProc = "tlsp:getPreviousProducts('" + collection + "','" + pedId + "')";

      System.out.println("Query for getting Previous products :" + strProc);
      List list2 = queryRunner.returnExecuteQueryStrings(strProc);
      ;

      System.out.println("Output from Query :" + (String) list2.get(0));
      Node repackedNode = (Node) XMLUtil.parse((String) list2.get(0));
      Node previousProducts = XMLUtil.getNode(repackedNode, "previousProducts");
      Node productInfo = XMLUtil.getNode(repackedNode, "productInfo/productInfo");
      Node ItemInfo = XMLUtil.getNode(repackedNode, "itemInfo");
      NodeList prList = previousProducts.getChildNodes();
      int length = prList.getLength();
      for (int i = 0; i < length; i++) {
        Node preProductInf = prList.item(i);
        productForm = new PreviousProductForm();
        System.out.println(
            "Maunfacture" + XMLUtil.getValue(preProductInf, "previousProductInfo/manufacturer"));
        productForm.setManuFacture(
            XMLUtil.getValue(preProductInf, "previousProductInfo/manufacturer"));

        System.out.println("Manf name test :" + productForm.getManuFacture());

        productForm.setPreviousExpDate(XMLUtil.getValue(preProductInf, "itemInfo/expirationDate"));
        productForm.setQuantity(XMLUtil.getValue(preProductInf, "itemInfo/quantity"));
        productForm.setPreviousLot(XMLUtil.getValue(preProductInf, "itemInfo/lot"));
        productForm.setProductCode(
            XMLUtil.getValue(preProductInf, "previousProductInfo/productCode"));
        colln.add(productForm);
      }
      System.out.println("Size of collection::::" + colln.size());

      request.setAttribute("previousProducts11", colln);
      theForm.setCurrentManufacture(XMLUtil.getValue(productInfo, "manufacturer"));
      theForm.setDosageForm(XMLUtil.getValue(productInfo, "dosageForm"));
      theForm.setDrugName(XMLUtil.getValue(productInfo, "drugName"));
      theForm.setNewNDC(XMLUtil.getValue(productInfo, "productCode"));
      theForm.setStrength(XMLUtil.getValue(productInfo, "strength"));
      theForm.setContainerSize(XMLUtil.getValue(productInfo, "containerSize"));
      theForm.setLotNo(XMLUtil.getValue(ItemInfo, "itemInfo/lot"));
      theForm.setQuantity(XMLUtil.getValue(ItemInfo, "itemInfo/quantity"));
      theForm.setExpDate(XMLUtil.getValue(ItemInfo, "itemInfo/expirationDate"));
      products.add(theForm);

      request.setAttribute("productInfo", products);

      return mapping.findForward("success");

    } catch (Exception ex) {

      log.error("Error in execute()" + ex);
      throw new PersistanceException(ex);
    }
  }
예제 #9
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    logger.info("***Inside ShipStatusAction class.......");

    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 GenerateAlertAction :" + sessionID);
      String validateResult = helper.ValidateUserSession(stmt, sessionID, clientIP);

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

      ShipStatusFormBean formbean = (ShipStatusFormBean) form;

      SimpleDateFormat df = new SimpleDateFormat();

      df.applyPattern("yyyy-MM-dd");
      String tmDate = df.format(new java.util.Date());
      df.applyPattern("hh:mm:ss");
      String tmTime = df.format(new java.util.Date());
      logger.info("Time:" + tmTime);
      String Shipstatus1 = (String) formbean.getShipstatus1();
      String APNID = (String) formbean.getAPNID();
      APNID = request.getParameter("pedid");
      Shipstatus1 = request.getParameter("Shipstatus1");
      logger.info("WE ARE know HERE" + Shipstatus1);

      String xQuery = "replace doc(for $b in collection('tig:///ePharma/PedigreeStatus') ";

      xQuery =
          xQuery
              + "return document-uri($b))//PedigreeStatus with <PedigreeStatus><PedigreeDocID>"
              + APNID;
      xQuery =
          xQuery
              + "</PedigreeDocID><StatusType>"
              + Shipstatus1
              + "</StatusType><StatusDescription></StatusDescription><CreatedBy>System</CreatedBy><CreatedOn>{current-dateTime()}</CreatedOn></PedigreeStatus>";

      List list1 = queryRunner.executeQuery(xQuery);
    } catch (Exception ex) {
      ex.printStackTrace();
      logger.error("Error inside ProductList Class........." + ex);
      return mapping.findForward("exception");
    }

    return mapping.findForward("success");
  }
예제 #10
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");
  }
  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");
  }
예제 #12
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    System.out.println("InitialPedigreeAction");
    HttpSession ses = request.getSession();
    String opr = request.getParameter("operationType");

    if (opr == null) opr = "";
    if (opr.equalsIgnoreCase("processedFax")) {

      InitialPedigreeForm formbean = (InitialPedigreeForm) form;
      String faxName = request.getParameter("faxName");
      String docId = getdocIDForFaxName(faxName);
      System.out.println("InitialPedigree ID" + docId);

      if (docId != null || !docId.equalsIgnoreCase("")) {
        StringBuffer buf = new StringBuffer();
        buf.append("for $i in collection('tig:///ePharma_MD/PaperPedigree')/initialPedigree");
        buf.append(" where $i/DocumentInfo/serialNumber='" + docId + "' return $i");

        String result = queryRunner.returnExecuteQueryStringsAsString(buf.toString());
        if (result != null) {
          Node n1 = XMLUtil.parse(result);
          Node n2 = XMLUtil.getNode(n1, "/initialPedigree");

          formbean.setTpName(
              XMLUtil.getValue(n2, "transactionInfo/senderInfo/businessAddress/businessName"));
          formbean.setAddress1(
              XMLUtil.getValue(n2, "transactionInfo/senderInfo/businessAddress/street1"));
          formbean.setAddress2(
              XMLUtil.getValue(n2, "transactionInfo/senderInfo/businessAddress/street2"));
          formbean.setCity(XMLUtil.getValue(n2, "transactionInfo/senderInfo/businessAddress/city"));
          formbean.setZipCode(
              XMLUtil.getValue(n2, "transactionInfo/senderInfo/businessAddress/postalCode"));

          formbean.setState(
              XMLUtil.getValue(n2, "transactionInfo/senderInfo/businessAddress/stateOrRegion"));
          formbean.setContactName(
              XMLUtil.getValue(n2, "transactionInfo/senderInfo/contactInfo/name"));
          formbean.setContainerSize(XMLUtil.getValue(n2, "productInfo/containerSize"));
          formbean.setCountry(
              XMLUtil.getValue(n2, "transactionInfo/senderInfo/businessAddress/country"));
          formbean.setDosageForm(XMLUtil.getValue(n2, "productInfo/dosageForm"));

          List item = XMLUtil.executeQuery(n2, "itemInfo");
          String[] lotNos = new String[item.size()];
          String[] quantity = new String[item.size()];
          ;
          String[] itemSerialNumber = new String[item.size()];
          ;
          String[] expirationDate = new String[item.size()];
          ;
          for (int i = 0; i < item.size(); i++) {
            Node itemInfo = (Node) item.get(i);
            System.out.println(XMLUtil.convertToString(itemInfo));

            if (i == 0) {
              formbean.setLotNumber(XMLUtil.getValue(itemInfo, "lot"));
              formbean.setQuantity(XMLUtil.getValue(itemInfo, "quantity"));
              formbean.setItemSerialNumber(XMLUtil.getValue(itemInfo, "itemSerialNumber"));

              formbean.setExpirationDate(XMLUtil.getValue(itemInfo, "expirationDate"));

              lotNos[i] = XMLUtil.getValue(itemInfo, "lot");

              quantity[i] = XMLUtil.getValue(itemInfo, "quantity");
              itemSerialNumber[i] = XMLUtil.getValue(itemInfo, "itemSerialNumber");
              expirationDate[i] = XMLUtil.getValue(itemInfo, "expirationDate");
            } else {

              lotNos[i] = XMLUtil.getValue(itemInfo, "lot");
              quantity[i] = XMLUtil.getValue(itemInfo, "quantity");
              itemSerialNumber[i] = XMLUtil.getValue(itemInfo, "itemSerialNumber");
              expirationDate[i] = XMLUtil.getValue(itemInfo, "expirationDate");
            }
          }

          ses.setAttribute("lotNos", lotNos);
          ses.setAttribute("quantity", quantity);
          ses.setAttribute("itemSerialNumber", itemSerialNumber);
          ses.setAttribute("expirationDate", expirationDate);
          ses.setAttribute("operationType", "processed");
          formbean.setManufacturer(XMLUtil.getValue(n2, "productInfo/manufacturer"));
          formbean.setName(XMLUtil.getValue(n2, "productInfo/drugName"));
          formbean.setProductCode(XMLUtil.getValue(n2, "productInfo/productCode"));
          formbean.setStrength(XMLUtil.getValue(n2, "productInfo/strength"));

          formbean.setTransactionDate(XMLUtil.getValue(n2, "transactionInfo/transactionDate"));
          formbean.setTransactionId(
              XMLUtil.getValue(n2, "transactionInfo/transactionIdentifier/identifier"));
          formbean.setTransactionType(
              XMLUtil.getValue(n2, "transactionInfo/transactionIdentifier/identifierType"));
          formbean.setDocumentID(docId);
          ses.setAttribute("InitialPedigreeForm", formbean);
          ses.setAttribute("DocId", docId);
        }
      }

      return mapping.findForward("success");
    }
    if (opr.equalsIgnoreCase("Save")) {
      String docId = "";
      System.out.println(request.getParameter("receivedFax"));
      String rcv = request.getParameter("receivedFax");

      if (!rcv.equals("null")) {
        docId = (String) ses.getAttribute("DocId");
      } else {
        docId = com.rdta.commons.PedigreeUtil.createPedId();
      }
      InitialPedigreeForm formbean = (InitialPedigreeForm) form;
      formbean.setDocumentID(docId);
      String str = createDocument(formbean, request, docId);
      String pedDataxml = createPedINString(formbean, request, docId);
      System.out.println(pedDataxml);
      if (((String) ses.getAttribute("TPNameNotValid")).equals("true")) {

        return mapping.findForward("frame1");
      }

      StringBuffer xQuery = new StringBuffer();
      xQuery.append("tig:insert-document('tig:///" + "ePharma_MD" + "/" + "PaperPedigree");
      xQuery.append("',");
      xQuery.append(str + ")");
      queryRunner.executeQuery(xQuery.toString());

      xQuery = new StringBuffer("");
      xQuery.append("tlsp:ChangeFaxStatus_MD('" + docId + "')");
      queryRunner.executeQuery(xQuery.toString());

      ses.setAttribute("DocId", docId);

      String check = request.getParameter("check");
      System.out.println("Check value" + check);
      boolean flag = true;
      if (check != null) {
        InputStream stream = formbean.getAttachment().getInputStream();

        String query =
            "declare binary-encoding none; declare namespace bin ='http://www.rainingdata.com/TigerLogic/binary-support';";

        query = query + "update let $binData := binary{$1} ";
        query = query + "replace doc( for $i in collection('tig:///ePharma_MD/PaperPedigree') ";
        query = query + "where $i/initialPedigree/DocumentInfo/serialNumber = '" + docId + "' ";
        query =
            query
                + "return  document-uri($i))//altPedigree with <altPedigree><mimeType>application/pdf</mimeType><encoding>base64binary</encoding><data>{bin:base64-encode($binData)}</data></altPedigree>";
        System.out.println("Query for updating altPedigree : " + query);

        queryRunner.executeQueryWithStream(query, stream);
        flag = false;
      }
      if (!rcv.equals("null") && flag == true) {

        StringBuffer buf = new StringBuffer();

        buf.append(
            "for $i in collection('tig:///ePharma_MD/ReceivedFax')//InboundPostRequest[InitialPedigreeId='"
                + docId
                + "']");
        buf.append("  return tlsp:repnode(data($i/FaxControl/FileContents),'" + docId + "')");
        System.out.println("bufer" + buf.toString());
        queryRunner.executeQuery(buf.toString());
      }

      // callPEDIN(pedDataxml);
      return mapping.findForward("frame1");
    }

    if (opr.equals("Update")) {

      InitialPedigreeForm formbean = (InitialPedigreeForm) form;
      String docId = "";
      String flag = "true";
      String altString = "false";
      String binaryString = "";
      String rcv = request.getParameter("receivedFax");
      if (formbean.getDocumentID() != null) {
        docId = formbean.getDocumentID();
      }

      String pedDataxml = createPedINString(formbean, request, docId);
      if (((String) ses.getAttribute("TPNameNotValid")).equals("true")) {

        return mapping.findForward("frame1");
      }

      StringBuffer b = new StringBuffer();
      b.append(
          "for $i in collection('tig:///ePharma_MD/PaperPedigree')/initialPedigree[DocumentInfo/serialNumber='"
              + docId
              + "']");
      b.append(" return $i/altPedigree/data/binary()");

      List alt = queryRunner.executeQuery(b.toString());
      System.out.println("altttt" + alt.size());

      InputStream altPedigree = null;
      if (alt.size() > 0 && alt.get(0) != null) {
        altPedigree = (InputStream) alt.get(0);
      }

      if (alt.size() == 0) {
        StringBuffer b1 = new StringBuffer();
        b1.append(
            "for $i in collection('tig:///ePharma_MD/PaperPedigree')/initialPedigree[DocumentInfo/serialNumber='"
                + docId
                + "']");
        b1.append(" return $i/altPedigree/data");
        binaryString = queryRunner.returnExecuteQueryStringsAsString(b1.toString());
        List list = queryRunner.executeQuery(b1.toString());

        System.out.println("ranesgsgsg " + list.get(0).getClass().getName());
        InputStream stream = (ByteArrayInputStream) list.get(0);
        byte[] data = new byte[128];
        File file = new File("c:\\temp\\abc.xml");
        file.createNewFile();
        FileOutputStream fos = new FileOutputStream(file);

        DataOutputStream dos = new DataOutputStream(fos);
        int x = stream.read();
        while (x != -1) {

          dos.write(x);
          // data= new byte[128];
          x = stream.read();
        }
        stream.close();
        dos.close();

        altString = "true";
      }

      String str = createDocument(formbean, request, docId);

      Node theNode = XMLUtil.parse(str);
      StringBuffer buff = new StringBuffer("$a//DocumentInfo/serialNumber='");
      buff.append(docId);
      buff.append("'");
      StringBuffer xQuery = new StringBuffer();
      xQuery.append(" for $a in collection('tig:///ePharma_MD/PaperPedigree/')");
      xQuery.append(" where " + buff.toString());
      xQuery.append(" return tig:replace-document(document-uri( $a ), " + str + ")");

      queryRunner.executeQuery(xQuery.toString());

      String check = request.getParameter("check");
      System.out.println("Check value" + check);
      if (check != null) {
        InputStream stream = formbean.getAttachment().getInputStream();

        String query =
            " declare namespace bin ='http://www.rainingdata.com/TigerLogic/binary-support';declare binary-encoding none;";

        query = query + "update let $binData := binary{$1} ";
        query = query + "replace doc( for $i in collection('tig:///ePharma_MD/PaperPedigree') ";
        query = query + "where $i/initialPedigree/DocumentInfo/serialNumber = '" + docId + "' ";
        query =
            query
                + "return  document-uri($i))//altPedigree with <altPedigree><mimeType>application/pdf</mimeType><encoding>base64binary</encoding><data>{bin:base64-encode($binData)}</data></altPedigree>";
        System.out.println("Query for updating altPedigree : " + query);

        queryRunner.executeQueryWithStream(query, stream);
        flag = "false";
      }

      /*
       * if(rcv.equals("processed")&& flag.equalsIgnoreCase("true")){
       * String cid=(String)ses.getAttribute("DocId"); StringBuffer buf=
       * new StringBuffer(); buf.append("for $i in
       * collection('tig:///ePharma/ReceivedFax')//InboundPostRequest[InitialPedigreeId='"+cid+"']");
       * buf.append(" return
       * tlsp:repnode($i/FaxControl/FileContents/string(),'"+docId+"')");
       * queryRunner.executeQuery(buf.toString());
       * ses.setAttribute("operationType","processed"); flag="false"; }
       */
      if (flag.equalsIgnoreCase("true") && altString.equals("true")) {

        String query = " tlsp:repEncoding_MD('" + docId + "')";

        System.out.println("Query for updating altPedigree : " + query);

        // queryRunner.executeQueryWithStream(query, new FileInputStream
        // (new File("c:\\temp\\abc.xml")));
        queryRunner.executeQuery(query);
        flag = "false";
      }
      if (flag.equalsIgnoreCase("true")) {

        String query =
            "declare binary-encoding none; declare namespace bin ='http://www.rainingdata.com/TigerLogic/binary-support';";

        query = query + "update let $binData := binary{$1} ";
        query = query + "replace doc( for $i in collection('tig:///ePharma_MD/PaperPedigree') ";
        query = query + "where $i/initialPedigree/DocumentInfo/serialNumber = '" + docId + "' ";
        query =
            query
                + "return  document-uri($i))//altPedigree with <altPedigree><mimeType>application/pdf</mimeType><encoding>base64binary</encoding><data>{bin:base64-encode($binData)}</data></altPedigree>";
        System.out.println("Query for updating altPedigree : " + query);

        queryRunner.executeQueryWithStream(query, altPedigree);
      }
      // callPEDIN(pedDataxml);
      return mapping.findForward("frame1");
    }
    if (opr.equalsIgnoreCase("receivedFax")) {

      ses.removeAttribute("InitialPedigreeForm");

      ses.removeAttribute("lotNos");
      ses.removeAttribute("quantity");
      ses.removeAttribute("itemSerialNumber");
      ses.removeAttribute("expirationDate");

      String faxName = request.getParameter("faxName");
      String docId = getdocIDForFaxName(faxName);
      System.out.println("InitialPedigree ID" + docId);

      InitialPedigreeForm formbean = (InitialPedigreeForm) form;
      System.out.println("FFF" + formbean);

      formbean.setAddress1("");
      formbean.setAddress2("");
      formbean.setCity("");
      formbean.setContactName("");
      formbean.setContainerSize("");
      formbean.setCountry("");
      formbean.setDosageForm("");
      formbean.setDosageForm("");
      formbean.setExpirationDate("");
      formbean.setItemSerialNumber("");
      formbean.setLotNumber("");
      formbean.setManufacturer("");
      formbean.setName("");
      formbean.setProductCode("");
      formbean.setQuantity("");
      formbean.setTpName("");
      formbean.setTransactionDate("");
      formbean.setTransactionId("");
      formbean.setTransactionType("");
      formbean.setZipCode("");
      formbean.setStrength("");
      formbean.setState("");

      formbean.setDocumentID(null);

      ses.setAttribute("DocId", docId);
      ses.setAttribute("test", "test");
      ses.setAttribute("InitialPedigreeForm", formbean);
      ses.setAttribute("operationType", "received");
      /*
       * StringBuffer sb=new StringBuffer(); sb.append("for $i in
       * collection('tig:///ePharma/ReceivedFax')//InboundPostRequest[FaxControl/CSID='"+csid+"']");
       * sb.append("return data( $i/InitialPedigreeId)"); String
       * docId=queryRunner.returnExecuteQueryStringsAsString(sb.toString());
       */

      /*
       * String str= createDocument(formbean, request,docId); String
       * pedDataxml=createPedINString(formbean,request,docId);
       * callPEDIN(pedDataxml); StringBuffer xQuery = new StringBuffer();
       * xQuery.append("tig:insert-document('tig:///" + "ePharma" + "/" +
       * "PaperPedigree"); xQuery.append("',"); xQuery.append(str + ")");
       * queryRunner.executeQuery(xQuery.toString());
       *
       * StringBuffer buf= new StringBuffer();
       *
       * buf.append("for $i in
       * collection('tig:///ePharma/ReceivedFax')//InboundPostRequest[FaxControl/CSID='"+csid+"']");
       * buf.append(" return
       * tlsp:repnode($i/FaxControl/FileContents/string(),'"+docId+"')");
       * queryRunner.executeQuery(buf.toString());
       */

      return mapping.findForward("success");
    }
    ses.removeAttribute("TPNameNotValid");
    ses.removeAttribute("InitialPedigreeForm");
    ses.removeAttribute("DocId");
    ses.removeAttribute("operationType");
    ses.removeAttribute("lotNos");
    ses.removeAttribute("quantity");
    ses.removeAttribute("itemSerialNumber");
    ses.removeAttribute("expirationDate");
    return mapping.findForward("success");
  };
예제 #13
0
 private static String getUUID() throws PersistanceException {
   StringBuffer buff = new StringBuffer();
   buff.append("import module namespace util = 'xquery:modules:util';");
   buff.append("let $docId := util:create-uuid() return $docId");
   return (queryRunner.returnExecuteQueryStringsAsString(buff.toString()));
 }
예제 #14
0
  public String createPedINString(
      InitialPedigreeForm form, HttpServletRequest request, String docId) {

    String tpName = form.getTpName();

    StringBuffer buffer = new StringBuffer("<PedigreeData>");
    buffer.append("<messageNm>PED_IN</messageNm>");
    buffer.append("<pedigreeId>" + docId + "</pedigreeId>");

    buffer.append("<ProductInfo>");
    buffer.append("<drugName>" + form.getName() + "</drugName>");
    buffer.append("<manufacturer>" + form.getManufacturer() + "</manufacturer>");
    buffer.append("<productCode>" + form.getProductCode() + "</productCode>");
    buffer.append("<dosageForm>" + form.getDosageForm() + "</dosageForm>");
    buffer.append("<strength>" + form.getStrength() + "</strength>");
    buffer.append("<containerSize>" + form.getContainerSize() + "</containerSize>");
    buffer.append("</ProductInfo>");

    // Here need to append iteminfo
    String lotNos[] = request.getParameterValues("lotNumber");
    String quantity[] = request.getParameterValues("quantity");
    String itemSerialNumber[] = request.getParameterValues("itemSerialNumber");
    String expirationDate[] = request.getParameterValues("expirationDate");

    HttpSession session = request.getSession();
    session.setAttribute("lotNos", lotNos);
    session.setAttribute("quantity", quantity);
    session.setAttribute("itemSerialNumber", itemSerialNumber);
    session.setAttribute("expirationDate", expirationDate);
    for (int it = 0; it < lotNos.length; it++) {
      buffer.append("<ItemInfo>");
      buffer.append("<lot>" + lotNos[it] + "</lot><quantity>" + quantity[it] + "</quantity>");
      buffer.append(
          " <expirationDate>" + expirationDate[it] + "T00:00:00" + "</expirationDate></ItemInfo>");
    }

    StringBuffer b = new StringBuffer();

    b.append(
        "for $i in collection('tig:///CatalogManager/TradingPartner')/TradingPartner[name='"
            + form.getTpName()
            + "']");

    b.append(" return data($i/businessId)");
    String businessID = null;
    try {

      businessID = queryRunner.returnExecuteQueryStringsAsString(b.toString());
      if (businessID == null || businessID.equals("")) {
        session.setAttribute("TPNameNotValid", "true");
      } else {
        session.setAttribute("TPNameNotValid", "false");
      }

    } catch (PersistanceException e) {

      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    buffer.append("<TransactionInfo>");

    buffer.append("<Address>");
    buffer.append("<businessId>" + businessID + "</businessId>");
    buffer.append("<businessName>" + form.getTpName() + "</businessName>");
    buffer.append(
        "<street1>"
            + form.getAddress1()
            + "</street1><street2>"
            + form.getAddress2()
            + "</street2>");
    buffer.append(
        "<city>"
            + form.getCity()
            + "</city><stateOrRegion>"
            + form.getState()
            + "</stateOrRegion>");
    buffer.append(
        "<postalCode>"
            + form.getZipCode()
            + "</postalCode><country>"
            + form.getCountry()
            + "</country>");
    buffer.append("</Address>");

    buffer.append("<TransactionId>" + form.getTransactionId() + "</TransactionId>");

    buffer.append("<TransactionType>" + form.getTransactionType() + "</TransactionType>");
    buffer.append(
        "<TransactionDate>" + form.getTransactionDate() + "T00:00:00" + "</TransactionDate>");
    buffer.append("</TransactionInfo>");
    buffer.append("</PedigreeData>");

    return buffer.toString();
  }
예제 #15
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 {

    try {
      log.info("Inside AuthenticatePedigreesReceivingAction execute Method");
      HttpSession sess = request.getSession();
      Helper helper = new Helper();
      clientIP = request.getRemoteAddr();

      conn = helper.ConnectTL();
      stmt = helper.getStatement(conn);
      System.out.println("validating The Session");

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

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

      // envelopeId
      envelopeId = request.getParameter("check");
      System.out.println("The envelopeId from form in Not Authentic is " + envelopeId);

      // For Access Priveleges.
      String validate = "tlsp:validateAccess('" + sessionID + "','8.0','Insert')";
      log.info("Query for getting Access" + validate);
      List accessList = queryRunner.returnExecuteQueryStrings(validate);
      String insertStatus = accessList.get(0).toString();
      System.out.println("The insertStatus is " + insertStatus);

      if (insertStatus.equalsIgnoreCase("false")) {
        return mapping.findForward("failure");
      }

      if (envelopeId != null) {

        boolean authentic = true;
        String statusOfPedigrees = "tlsp:getStatusOfPedigrees('" + envelopeId + "')";
        log.info("Query for getting Status of Pedigrees" + statusOfPedigrees);
        List pedigreesStatus = queryRunner.returnExecuteQueryStrings(statusOfPedigrees);
        System.out.println(
            "Pedigrees status list is "
                + pedigreesStatus
                + " its size is "
                + pedigreesStatus.size());
        if (pedigreesStatus.size() == 0) {

          StringBuffer buff = new StringBuffer();
          buff.append(
              "for $ped in collection ('tig:///ePharma/ReceivedPedigree')"
                  + "/*:pedigreeEnvelope[*:serialNumber = '"
                  + envelopeId
                  + "'] ");
          buff.append(
              "return data($ped/*:pedigree/*:shippedPedigree/*:documentInfo/*:serialNumber)");
          log.info("The query for getting pedigrees is " + buff.toString());
          System.out.println("The query for getting pedigrees is " + buff.toString());
          List pedigrees = queryRunner.returnExecuteQueryStrings(buff.toString());
          System.out.println("The pedigrees list size is " + pedigrees.size());

          for (int i = 0; i < pedigrees.size(); i++) {
            String pedigreeId = (String) pedigrees.get(i);
            String changeStatus =
                "tlsp:InsertAndChangeStatus('"
                    + pedigreeId
                    + "','Authenticated','"
                    + sessionID
                    + "')";
            log.info("The query for InsertAndChangeStatus of pedigrees is " + changeStatus);
            List pedigreestatus = queryRunner.returnExecuteQueryStrings(changeStatus);
            System.out.println("The Document in pedigree status is " + pedigreestatus);
          }
        } else {

          authentic = authenticateStatus(pedigreesStatus);
          System.out.println("Authentic value is: " + authentic);
          if (authentic == true) {
            return mapping.findForward("alreadyAuthenticated");
          } else {
            return mapping.findForward("alreadyAuthenticated");
          }
        }
      }

    } catch (PersistanceException e) {
      log.error("Error in AuthenticatePedigreesReceivingAction execute method........." + e);
      throw new PersistanceException(e);
    } catch (Exception ex) {
      ex.printStackTrace();
      log.error("Error in AuthenticatePedigreesReceivingAction execute method........." + ex);
      throw new Exception(ex);
    }
    return mapping.findForward("success");
  }
  public ActionForward listCatalogs(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    log.info("hai.........");
    String trdId1 = request.getParameter("trdId1");
    String trdId2 = request.getParameter("trdId2");
    Collection colIn = new ArrayList();
    Collection colIn2 = new ArrayList();

    StringBuffer buf = new StringBuffer();
    buf.append("<root> { ");
    buf.append(" for $l in collection('tig:///CatalogManager/Catalog') ");
    buf.append(" where $l/Catalog/keyRef[collectionName='TradingPartner']/tradingPartnerID='");
    System.out.println("*****************" + trdId1);
    buf.append(trdId1);
    buf.append("' return <Catalog> {");
    buf.append("<Name>{data($l/Catalog/catalogName)}</Name>,");
    buf.append("<CatgenId>{data($l/Catalog/catalogID)}</CatgenId>");
    buf.append("}</Catalog>");
    buf.append("}</root>");
    System.out.println("____________________Query" + buf.toString());
    List result = queryRunner.returnExecuteQueryStrings(buf.toString());
    log.info("Out put node" + result.get(0));
    // TradingPartner 	tradingPartner = new TradingPartner(request);
    // Node n =(Node) TradingPartner.getTradingPartnerList();
    // log.info("Out put node"+n);
    Node n = XMLUtil.parse((String) result.get(0));
    List list = XMLUtil.executeQuery(n, "Catalog");
    log.info("/////********" + list);
    log.info("The node Value is   " + XMLUtil.convertToString((Node) list.get(0)));
    for (int i = 0; i < list.size(); i++) {
      MapTradingPartnerForm trdPrtFrm = new MapTradingPartnerForm();
      trdPrtFrm.setCatalogName(XMLUtil.getValue((Node) list.get(i), "Name"));
      trdPrtFrm.setCatalogGenID(XMLUtil.getValue((Node) list.get(i), "CatgenId"));
      log.info("\\\\\\\\\\\\\\" + trdPrtFrm.getCatName());
      log.info("\\\\\\\\\\\\\\" + trdPrtFrm.getCatalogGenId());
      colIn.add(trdPrtFrm);
    }

    // request.setAttribute(Constants.MAP_TRD_PTNR_KEY,colIn.toArray());
    request.setAttribute(Constants.MAP_TRD_CAT_KEY, colIn.toArray());
    log.info("size 1:" + colIn.size());
    StringBuffer buff = new StringBuffer();
    buff.append("<root> { ");
    buff.append("for $l in collection('tig:///CatalogManager/Catalog') ");
    buff.append(" where $l/Catalog/keyRef/tradingPartnerID='");
    System.out.println("*****************" + trdId2);
    buff.append(trdId2);
    buff.append("' return <Catalog> {");
    buff.append("<Name>{data($l/Catalog/catalogName)}</Name>,");
    buff.append("<CatgenId>{data($l/Catalog/catalogID)}</CatgenId>");
    buff.append("}</Catalog>");
    buff.append("}</root>");
    System.out.println("____________________Query :" + buff.toString());
    List result2 = queryRunner.returnExecuteQueryStrings(buff.toString());
    log.info("Out put node" + result2.get(0));
    Node n2 = XMLUtil.parse((String) result2.get(0));
    List list2 = XMLUtil.executeQuery(n2, "Catalog");
    log.info("******" + list2);
    for (int j = 0; j < list2.size(); j++) {
      MapTradingPartnerForm trdPrtFrms = new MapTradingPartnerForm();
      log.info("***66***" + XMLUtil.getValue((Node) list2.get(j), "Name"));
      trdPrtFrms.setCatName(XMLUtil.getValue((Node) list2.get(j), "Name"));
      trdPrtFrms.setCatalogGenId(XMLUtil.getValue((Node) list2.get(j), "CatgenId"));
      log.info("\\\\\\\\\\\\\\" + trdPrtFrms.getCatalogName());
      log.info("ID :" + trdPrtFrms.getCatalogGenID());
      colIn.add(trdPrtFrms);
    }
    log.info("size :" + colIn.size());
    request.setAttribute(Constants.MAP_TRD_CAT_KEY, colIn.toArray());

    return mapping.findForward("listTrdPartCats");
  }
예제 #18
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");
    }
  }
예제 #19
0
  public void callPEDIN(String xmlString) throws PersistanceException {

    String callPedin = "tlsp:Ped-In_MD(" + xmlString + ")";

    List li = queryRunner.executeQuery(callPedin);
  }