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 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()); }
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()); }
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 + ")"); }
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"); } }
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"); }
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"); }
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"); };
public void callPEDIN(String xmlString) throws PersistanceException { String callPedin = "tlsp:Ped-In_MD(" + xmlString + ")"; List li = queryRunner.executeQuery(callPedin); }