public static void processBrRequisitionFile( java.io.File filePortrait2Process, biz.systempartners.claims.ClaimsViewer claimsViewer, java.util.Vector invoiceVector, java.util.Vector filesVector) { biz.systempartners.claims.XMLClaimFile xmlClaimFile = new biz.systempartners.claims.XMLClaimFile(); xmlClaimFile.processFile(filePortrait2Process); javax.swing.JTable tempInvoiceTable; java.util.Vector headerInvoiceVector = new java.util.Vector(1, 1); headerInvoiceVector.addElement("Invoice No."); // claimsTable = new javax.swing.JTable(5,4); // claimsTable = claimsViewer.getInvoiceTable(); claimsTable = xmlClaimFile.xmlClaim.getInvoiceTable(); invoiceTable = claimsViewer.getInvoiceListTable(); javax.swing.JPanel claimsViewerPanel = claimsViewer.getClaimsViewerPanel(); javax.swing.JScrollPane jScrollPane11 = claimsViewer.getScrollPane(); javax.swing.JScrollPane invoiceScrollPane = claimsViewer.getInvoiceListScrollPane(); invoiceVector = claimsViewer.getInvoiceVector(); java.util.Vector invoiceChildVector = new java.util.Vector(1, 1); javax.swing.JTextField patientNo = claimsViewer.getPatientNo(); javax.swing.JTextField patientName = claimsViewer.getPatientName(); javax.swing.JTextField schemeMemberNo = claimsViewer.getSchemeMemberNo(); javax.swing.JTextField schemeName = claimsViewer.getSchemeName(); javax.swing.JTextField schemePayer = claimsViewer.getSchemePayer(); javax.swing.JTextField accountNo = claimsViewer.getAccountNo(); javax.swing.JTextField invoiceNo = claimsViewer.getInvoiceNo(); javax.swing.JTextField healthCareProvider = claimsViewer.getHealthCareProvider(); jScrollPane11.setViewportView(claimsTable); if (claimsViewer.isShowing()) { claimsViewer.validate(); } else { claimsViewer.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH); claimsViewer.setVisible(true); } claimsViewer.invalidate(); // try { // try { // java.io.FileInputStream requisFileIOStream = new // java.io.FileInputStream(filePortrait2Process); // java.io.ObjectInputStream requisObjInStream = new // java.io.ObjectInputStream(requisFileIOStream); // javax.swing.table.JTableHeader claimsTableHeader = // (javax.swing.table.JTableHeader)requisObjInStream.readObject(); // requisTable = (javax.swing.JTable)requisObjInStream.readObject(); // String invoiceNoString = (java.lang.String)requisObjInStream.readObject(); String invoiceNoString = xmlClaimFile.xmlClaim.getInvoiceNumber(); invoiceNo.setText(invoiceNoString); // patientNo.setText((java.lang.String)requisObjInStream.readObject()); patientNo.setText(xmlClaimFile.xmlClaim.getPatientNumber()); System.out.println( "PATIENT NUMBER : " + xmlClaimFile.xmlClaim.getPatientNumber() + " " + xmlClaimFile.xmlClaim.getPatientName() + " " + xmlClaimFile.xmlClaim.getSchemeName()); // patientName.setText((java.lang.String)requisObjInStream.readObject()); patientName.setText(xmlClaimFile.xmlClaim.getPatientName()); // schemeMemberNo.setText((java.lang.String)requisObjInStream.readObject()); schemeMemberNo.setText(xmlClaimFile.xmlClaim.getSchemeMemberNumber()); // schemeName.setText((java.lang.String)requisObjInStream.readObject()); schemeName.setText(xmlClaimFile.xmlClaim.getSchemeName()); // schemePayer.setText((java.lang.String)requisObjInStream.readObject()); schemePayer.setText(xmlClaimFile.xmlClaim.getSchemePayer()); // accountNo.setText((java.lang.String)requisObjInStream.readObject()); accountNo.setText(xmlClaimFile.xmlClaim.getAccountNumber()); healthCareProvider.setText(xmlClaimFile.xmlClaim.getHealthCareProvider()); tempInvoiceTable = new javax.swing.JTable(invoiceVector, headerInvoiceVector); invoiceChildVector.add(invoiceNoString); invoiceChildVector.add(filePortrait2Process.getPath()); if (filesVector == null) { filesVector = new java.util.Vector(1, 1); } filesVector.add(filePortrait2Process.getAbsolutePath()); claimsViewer.filesVector = filesVector; if (invoiceVector == null) { invoiceVector = new java.util.Vector(1, 1); } invoiceVector.add(invoiceChildVector); /* invoiceNo.setText(invoiceNoString); invoiceChildVector.add(invoiceNoString); invoiceChildVector.add(filePortrait2Process.getPath()); filesVector.add(filePortrait2Process.getAbsolutePath()); // System.out.println("Child Cector Size ="+invoiceChildVector.size()); // System.out.println("File saved in child vector ="+filePortrait2Process.getPath()); invoiceVector.add(invoiceChildVector); // for (int j = 0; j < invoiceChildVector.capacity(); j++) { // System.out.println("Child entry ["+invoiceChildVector.elementAt(j)+"]"); // } patientNo.setText((java.lang.String)requisObjInStream.readObject()); patientName.setText((java.lang.String)requisObjInStream.readObject()); schemeMemberNo.setText((java.lang.String)requisObjInStream.readObject()); schemeName.setText((java.lang.String)requisObjInStream.readObject()); schemePayer.setText((java.lang.String)requisObjInStream.readObject()); accountNo.setText((java.lang.String)requisObjInStream.readObject()); */ tempInvoiceTable = new javax.swing.JTable(invoiceVector, headerInvoiceVector); System.out.println("Starting to populate tables ..."); /** * for (int i = 0; i < requisTable.getModel().getRowCount(); i++) { * * <p>for (int j = 0; j < requisTable.getModel().getColumnCount(); j++){ * * <p>if (requisTable.getValueAt(i,0) != null) { * * <p>claimsTable.setValueAt(requisTable.getValueAt(i,j), i, j); * * <p>System.out.println(requisTable.getValueAt(i,j)); } } } */ for (int i = 0; i < tempInvoiceTable.getModel().getRowCount(); i++) { for (int j = 0; j < tempInvoiceTable.getModel().getColumnCount(); j++) { if (tempInvoiceTable.getValueAt(i, 0) != null) { invoiceTable.setValueAt(tempInvoiceTable.getValueAt(i, j), i, j); System.out.println("Invoices : " + tempInvoiceTable.getValueAt(i, j)); System.out.println(tempInvoiceTable.getValueAt(i, j)); } } } // claimsTable.setModel(requisTable.getModel()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 100.0; claimsViewerPanel.removeAll(); claimsViewerPanel.add(jScrollPane11, gridBagConstraints); invoiceScrollPane.setViewportView(invoiceTable); jScrollPane11.setViewportView(claimsTable); claimsViewerPanel.validate(); for (int i = 0; i < invoiceVector.size(); i++) { java.util.Vector childVector = (java.util.Vector) invoiceVector.elementAt(i); for (int j = 0; j < childVector.size(); j++) { // System.out.println("Child entry at ---- !!! ["+j+"] is // ["+childVector.elementAt(j)+"]"); File file2SelectedInvoice; file2SelectedInvoice = new java.io.File(childVector.elementAt(j).toString()); System.out.println("Selected File ---- !!!!! [" + file2SelectedInvoice.getPath() + "]"); } // for (int j = 0; j < childVector.size(); j++) { // if (childVector.elementAt(0).toString().equalsIgnoreCase(invoiceNo)) { // } // } } // } catch(java.lang.ClassNotFoundException cnfExec) { // javax.swing.JOptionPane.showMessageDialog(new java.awt.Frame(), cnfExec.getMessage()); // } // } catch(java.io.IOException ioExec) { // javax.swing.JOptionPane.showMessageDialog(new java.awt.Frame(), ioExec.getMessage()); // } }
public static void dumpPart(Part p, biz.systempartners.claims.ClaimsViewer claimsViewer) throws Exception { if (p instanceof Message) dumpEnvelope((Message) p); /** * Dump input stream .. * * <p>InputStream is = p.getInputStream(); // If "is" is not already buffered, wrap a * BufferedInputStream // around it. if (!(is instanceof BufferedInputStream)) is = new * BufferedInputStream(is); int c; while ((c = is.read()) != -1) System.out.write(c); */ String ct = p.getContentType(); try { pr("CONTENT-TYPE: " + (new ContentType(ct)).toString()); } catch (ParseException pex) { pr("BAD CONTENT-TYPE: " + ct); } String filename = p.getFileName(); if (filename != null) pr("FILENAME: " + filename); /* * Using isMimeType to determine the content type avoids * fetching the actual content data until we need it. */ if (p.isMimeType("text/plain")) { pr("This is plain text"); pr("---------------------------"); if (!showStructure && !saveAttachments) System.out.println((String) p.getContent()); } else if (p.isMimeType("multipart/*")) { pr("This is a Multipart"); pr("---------------------------"); Multipart mp = (Multipart) p.getContent(); level++; int count = mp.getCount(); for (int i = 0; i < count; i++) dumpPart(mp.getBodyPart(i), claimsViewer); level--; } else if (p.isMimeType("message/rfc822")) { pr("This is a Nested Message"); pr("---------------------------"); level++; dumpPart((Part) p.getContent(), claimsViewer); level--; } else { if (!showStructure && !saveAttachments) { /* * If we actually want to see the data, and it's not a * MIME type we know, fetch it and check its Java type. */ Object o = p.getContent(); if (o instanceof String) { pr("This is a string"); pr("---------------------------"); System.out.println((String) o); } else if (o instanceof InputStream) { pr("This is just an input stream"); pr("---------------------------"); InputStream is = (InputStream) o; int c; while ((c = is.read()) != -1) System.out.write(c); } else { pr("This is an unknown type"); pr("---------------------------"); pr(o.toString()); } } else { // just a separator pr("---------------------------"); } } /* * If we're saving attachments, write out anything that * looks like an attachment into an appropriately named * file. Don't overwrite existing files to prevent * mistakes. */ if (saveAttachments && level != 0 && !p.isMimeType("multipart/*")) { String disp = p.getDisposition(); // many mailers don't include a Content-Disposition if (disp == null || disp.equalsIgnoreCase(Part.ATTACHMENT)) { if (filename == null) filename = "Attachment" + attnum++; pr("Saving attachment to file " + filename); try { File f = new File(System.getProperty("user.dir"), filename); /* if (f.exists()) // XXX - could try a series of names throw new IOException("file exists");*/ OutputStream os = new BufferedOutputStream(new FileOutputStream(f)); InputStream is = p.getInputStream(); int c; while ((c = is.read()) != -1) os.write(c); os.close(); if (p.isMimeType("text/xml") || p.isMimeType("application/octet-stream")) { processBrRequisitionFile( f, claimsViewer, claimsViewer.getInvoiceVector(), claimsViewer.getFilesVector()); } System.out.println("I have saved file [" + f.getAbsolutePath() + "]"); } catch (IOException ex) { pr("Failed to save attachment: " + ex); } pr("---------------------------"); } } }