diff --git a/Order Processor/.classpath b/Order Processor/.classpath
index 0286c00..60d0773 100644
--- a/Order Processor/.classpath
+++ b/Order Processor/.classpath
@@ -1,9 +1,11 @@
+
+
diff --git a/Order Processor/lib/ostermillerutils_1_07_00.jar b/Order Processor/lib/ostermillerutils_1_07_00.jar
new file mode 100644
index 0000000..a993150
Binary files /dev/null and b/Order Processor/lib/ostermillerutils_1_07_00.jar differ
diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/DB/OrderDB.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/DB/OrderDB.java
index cc7b588..e554709 100644
--- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/DB/OrderDB.java
+++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/DB/OrderDB.java
@@ -9,9 +9,8 @@ package com.TwentyCodes.java.OrderProcessor.DB;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileReader;
+import java.io.FileInputStream;
import java.io.IOException;
-import java.io.LineNumberReader;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.sql.Connection;
@@ -23,8 +22,8 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
-import java.util.Scanner;
+import com.Ostermiller.util.CSVParser;
import com.TwentyCodes.java.OrderProcessor.Date;
import com.TwentyCodes.java.OrderProcessor.InvalidDateFormatException;
import com.TwentyCodes.java.OrderProcessor.Main;
@@ -72,18 +71,21 @@ public class OrderDB {
}
/**
- * counts the number of lines in a file
+ * counts the number of lines in a csv file
* @param file to be read
* @return number of lines in a file
* @throws IOException
* @author ricky barrette
*/
public int countLines(File file) throws IOException {
- LineNumberReader reader = new LineNumberReader(new FileReader(file));
- int cnt = 0;
- while ((reader.readLine()) != null) ;
- cnt = reader.getLineNumber();
- reader.close();
+// LineNumberReader reader = new LineNumberReader(new FileReader(file));
+ int cnt = 1;
+// while ((reader.readLine()) != null) ;
+// cnt = reader.getLineNumber();
+// reader.close();
+ CSVParser csvParser = new CSVParser(new FileInputStream(file));
+ while(csvParser.getLine() != null)
+ cnt++;
return cnt;
}
@@ -177,7 +179,11 @@ public class OrderDB {
* @throws OrderExistsException
*/
public void load(File file) throws SQLException, IOException, ClassNotFoundException{
- Scanner scan = new Scanner(file);
+
+// Scanner scan = new Scanner(file);
+
+ CSVParser csvParser = new CSVParser(new FileInputStream(file));
+
int line = 1;
int lineCount = countLines(file);
isLoadingFile = true;
@@ -186,7 +192,7 @@ public class OrderDB {
prep = conn.prepareStatement(INSERT);
conn.setAutoCommit(true);
- while(scan.hasNextLine()){
+ while(csvParser.lastLineNumber() < lineCount){
if(mListener != null)
mListener.onProgressUpdate(line++, lineCount);
@@ -195,7 +201,7 @@ public class OrderDB {
System.out.println("\non line: "+ line);
try {
- addOrder(new Order(scan.nextLine()));
+ addOrder(new Order(csvParser.getLine()));
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (InvalidDateFormatException e) {
diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Main.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Main.java
index 4cf7eb3..59a4d34 100644
--- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Main.java
+++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Main.java
@@ -15,7 +15,7 @@ import com.TwentyCodes.java.OrderProcessor.UI.MainWindow;
public class Main {
- public static final boolean DEBUG = false;
+ public static final boolean DEBUG = true;
/**
* called when the application first starts
diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java
index fbb9e2c..75ad287 100644
--- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java
+++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Order.java
@@ -6,7 +6,11 @@
package com.TwentyCodes.java.OrderProcessor;
+import java.io.IOException;
import java.io.Serializable;
+import java.io.StringReader;
+
+import com.Ostermiller.util.CSVParser;
/**
@@ -34,48 +38,76 @@ public class Order implements Comparable, Serializable{
* @param order
* @author ricky barrette
* @throws InvalidDateFormatException
+ * @throws IOException
*/
- public Order(String order) throws NumberFormatException, InvalidDateFormatException{
+ public Order(String order) throws NumberFormatException, InvalidDateFormatException, IOException{
if(Main.DEBUG)
System.out.println("parsing in order: "+ order);
- String [] lineParts;
- lineParts = order.split(",");
+ CSVParser parsedOrder = new CSVParser(new StringReader(order));
+ String[] lineParts = parsedOrder.getLine();
+ parsedOrder.close();
- this.mGoogleOrderNumber = Long.parseLong(removeLastChar(lineParts[0].split(" ")[1]));
- this.mOrderCreationDate = new Date(lineParts[2].substring(1, (lineParts[2].length() -1) ));
+ this.mGoogleOrderNumber = Long.parseLong(lineParts[0].split(" ")[1]);
+ this.mOrderCreationDate = new Date(lineParts[2]);
this.mOrderAmount = Float.parseFloat(lineParts[4]);
this.mAmountCharged = Float.parseFloat(lineParts[5]);
this.mFinancialStatus = Status.parseStatus(lineParts[6]);
this.mFulfillmentStatus = Status.parseStatus(lineParts[7]);
- this.mCustomerEmail = removeFistAndLastChar(lineParts[16]);
- this.mCustomerName = removeFistAndLastChar(lineParts[17]);
- this.mItemName = removeFistAndLastChar(lineParts[27]);
+ this.mCustomerEmail = lineParts[16];
+ this.mCustomerName = lineParts[17];
+ this.mItemName = lineParts[27];
+
+// String [] lineParts;
+// lineParts = order.split(",");
+// System.out.println(lineParts[0].split(" ")[1]);
+// this.mGoogleOrderNumber = Long.parseLong(lineParts[0].split(" ")[1]);
+// this.mOrderCreationDate = new Date(lineParts[2].substring(1));
+// this.mOrderAmount = Float.parseFloat(lineParts[4]);
+// this.mAmountCharged = Float.parseFloat(lineParts[5]);
+// this.mFinancialStatus = Status.parseStatus(lineParts[6]);
+// this.mFulfillmentStatus = Status.parseStatus(lineParts[7]);
+// this.mCustomerEmail = removeFistAndLastChar(lineParts[16]);
+// this.mCustomerName = removeFistAndLastChar(lineParts[17]);
+// this.mItemName = removeFistAndLastChar(lineParts[27]);
if (Main.DEBUG)
System.out.println(this.toString());
}
- /**
- * removes the last char from a string
- * @param s
- * @return
- * @author ricky barrette
- */
- private String removeLastChar(String s) {
- return s.substring(0, s.length() - 1);
- }
+// /**
+// * removes the last char from a string
+// * @param s
+// * @return
+// * @author ricky barrette
+// */
+// private String removeLastChar(String s) {
+// return s.substring(0, s.length() - 1);
+// }
+//
+// /**
+// * removes the first and last chars from a string
+// * @param s
+// * @return
+// * @author ricky barrette
+// */
+// private String removeFistAndLastChar(String s){
+// return s.substring(1, s.length()-1);
+// }
- /**
- * removes the first and last chars from a string
- * @param s
- * @return
- * @author ricky barrette
- */
- private String removeFistAndLastChar(String s){
- return s.substring(1, s.length()-1);
- }
+ public Order(String[] lineParts) throws InvalidDateFormatException, NumberFormatException {
+ this.mGoogleOrderNumber = Long.parseLong(lineParts[0].split(" ")[1]);
+ this.mOrderCreationDate = new Date(lineParts[2]);
+ this.mOrderAmount = Float.parseFloat(lineParts[4]);
+ this.mAmountCharged = Float.parseFloat(lineParts[5]);
+ this.mFinancialStatus = Status.parseStatus(lineParts[6]);
+ this.mFulfillmentStatus = Status.parseStatus(lineParts[7]);
+ this.mCustomerEmail = lineParts[16];
+ this.mCustomerName = lineParts[17];
+ this.mItemName = lineParts[27];
+ }
+
/**
* returns a human readable string that represnets this object
* (non-Javadoc)
diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Status.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Status.java
index 40d1745..1a47266 100644
--- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Status.java
+++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/Status.java
@@ -50,19 +50,19 @@ public enum Status {
if(Main.DEBUG)
System.out.println("parsing status: "+ s);
- if(s.equals("\""+ CHARGED.toString()+"\""))
+ if(s.equals(CHARGED.toString()))
return CHARGED;
- if(s.equals("\""+ CANCELLED.toString()+"\""))
+ if(s.equals(CANCELLED.toString()))
return CANCELLED;
- if(s.equals("\""+ CANCELLED_BY_GOOGLE.toString()+"\""))
+ if(s.equals(CANCELLED_BY_GOOGLE.toString()))
return CANCELLED_BY_GOOGLE;
- if(s.equals("\""+ DELIVERED.toString()+"\""))
+ if(s.equals(DELIVERED.toString()))
return DELIVERED;
- if(s.equals("\""+ WILL_NOT_DELIVER.toString()+"\""))
+ if(s.equals(WILL_NOT_DELIVER.toString()))
return WILL_NOT_DELIVER;
return null;
diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/TransactionType.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/TransactionType.java
deleted file mode 100644
index abb5824..0000000
--- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/TransactionType.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * @author Twenty Codes, LLC
- * @author ricky barrette
- * @date Dec 22, 2010
- */
-
-package com.TwentyCodes.java.OrderProcessor;
-
-/**
- * this enum will represent trantions types
- * @author ricky barrette
- */
-public enum TransactionType {
-
- DEPOSIT, WITHDRAW, CHARGE_FEE
-
-}
diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/GetStatsDialog.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/GetStatsDialog.java
deleted file mode 100644
index d4e29bc..0000000
--- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/GetStatsDialog.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/**
- * GetStatsDialog.java
- * @date Jan 2, 2010
- * @author ricky barrette
- * @author Twenty Codes, LLC
- */
-package com.TwentyCodes.java.OrderProcessor.UI;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.ButtonGroup;
-import javax.swing.GroupLayout;
-import javax.swing.GroupLayout.Alignment;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.JTextField;
-import javax.swing.LayoutStyle.ComponentPlacement;
-import javax.swing.border.EmptyBorder;
-
-import com.TwentyCodes.java.OrderProcessor.Date;
-import com.TwentyCodes.java.OrderProcessor.Months;
-
-/**
- * this will be a dialog for getting information about the stats the user is looking for
- * @author ricky barrette
- */
-public class GetStatsDialog extends JFrame implements ActionListener {
-
-
- private static final long serialVersionUID = -8681149469926405790L;
- private JPanel contentPane;
- private JRadioButton mJan;
- private JRadioButton mFeb;
- private JRadioButton mMar;
- private JRadioButton mApr;
- private JRadioButton mJun;
- private JRadioButton mJul;
- private JRadioButton mAug;
- private JRadioButton mSep;
- private JRadioButton mNov;
- private JRadioButton mDec;
- private JRadioButton mYear;
- private JRadioButton mMay;
- private JRadioButton mOct;
- private JTextField textField;
- private JButton mOkButton;
- @SuppressWarnings("unused")
- private Months mTimeFrame = Months.JAN;
- @SuppressWarnings("unused")
- private Date mStartDate;
- @SuppressWarnings("unused")
- private Date mEndDate;
-
- /**
- * Create the frame.
- */
- public GetStatsDialog() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 260, 371);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
-
- ButtonGroup group = new ButtonGroup();
- mJan = new JRadioButton("Jan");
- mFeb = new JRadioButton("Feb");
- mMar = new JRadioButton("Mar");
- mApr = new JRadioButton("Apr");
- mMay = new JRadioButton("May");
- mJun = new JRadioButton("Jun");
- mJul = new JRadioButton("Jul");
- mAug = new JRadioButton("Aug");
- mSep = new JRadioButton("Sep");
- mOct = new JRadioButton("Oct");
- mNov = new JRadioButton("Nov");
- mDec = new JRadioButton("Dec");
- mYear = new JRadioButton("Year");
-
- group.add(mJan);
- group.add(mFeb);
- group.add(mMar);
- group.add(mApr);
- group.add(mMay);
- group.add(mJun);
- group.add(mJul);
- group.add(mAug);
- group.add(mSep);
- group.add(mOct);
- group.add(mNov);
- group.add(mDec);
- group.add(mYear);
-
- mJan.setSelected(true);
-
- //Put the radio buttons in a column in a panel.
- JPanel radioPanel = new JPanel();
-
- mJan.addActionListener(this);
- mFeb.addActionListener(this);
- mMar.addActionListener(this);
- mApr.addActionListener(this);
- mMay.addActionListener(this);
- mJun.addActionListener(this);
- mJul.addActionListener(this);
- mAug.addActionListener(this);
- mSep.addActionListener(this);
- mOct.addActionListener(this);
- mNov.addActionListener(this);
- mDec.addActionListener(this);
- mYear.addActionListener(this);
- setContentPane(contentPane);
-
- JLabel lblTimeFrame = new JLabel("Time Frame");
-
- JLabel lblApplicationName = new JLabel("Application Name");
-
- textField = new JTextField();
- textField.setColumns(10);
-
- mOkButton = new JButton("Ok");
- GroupLayout gl_contentPane = new GroupLayout(contentPane);
- gl_contentPane.setHorizontalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addContainerGap()
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addComponent(mOkButton, GroupLayout.PREFERRED_SIZE, 135, GroupLayout.PREFERRED_SIZE)
- .addComponent(lblApplicationName))
- .addPreferredGap(ComponentPlacement.RELATED))
- .addComponent(textField))
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addComponent(lblTimeFrame)
- .addComponent(radioPanel, GroupLayout.PREFERRED_SIZE, 96, GroupLayout.PREFERRED_SIZE))
- .addGap(164))
- );
- gl_contentPane.setVerticalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
- .addComponent(lblTimeFrame)
- .addComponent(lblApplicationName))
- .addPreferredGap(ComponentPlacement.RELATED)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
- .addComponent(radioPanel, GroupLayout.PREFERRED_SIZE, 306, GroupLayout.PREFERRED_SIZE)
- .addGroup(Alignment.TRAILING, gl_contentPane.createSequentialGroup()
- .addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(mOkButton)))
- .addContainerGap())
- );
- GroupLayout gl_radioPanel = new GroupLayout(radioPanel);
- gl_radioPanel.setHorizontalGroup(
- gl_radioPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_radioPanel.createSequentialGroup()
- .addContainerGap()
- .addComponent(mDec)
- .addContainerGap(45, Short.MAX_VALUE))
- .addGroup(gl_radioPanel.createSequentialGroup()
- .addGroup(gl_radioPanel.createParallelGroup(Alignment.TRAILING)
- .addGroup(Alignment.LEADING, gl_radioPanel.createSequentialGroup()
- .addContainerGap()
- .addGroup(gl_radioPanel.createParallelGroup(Alignment.LEADING)
- .addComponent(mJan)
- .addComponent(mFeb)
- .addComponent(mMar)
- .addComponent(mApr)
- .addComponent(mMay)
- .addComponent(mJun)
- .addComponent(mJul)
- .addComponent(mAug)
- .addComponent(mSep)
- .addComponent(mOct)
- .addComponent(mNov, GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)))
- .addGroup(Alignment.LEADING, gl_radioPanel.createSequentialGroup()
- .addContainerGap()
- .addComponent(mYear)))
- .addGap(39))
- );
- gl_radioPanel.setVerticalGroup(
- gl_radioPanel.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_radioPanel.createSequentialGroup()
- .addComponent(mJan)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mFeb)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mMar)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mApr)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mMay)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mJun)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mJul)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mAug)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mSep)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mOct)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mNov)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mDec)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(mYear)
- .addGap(167))
- );
- radioPanel.setLayout(gl_radioPanel);
- contentPane.setLayout(gl_contentPane);
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == mJan){
- mTimeFrame = Months.JAN;
- }
-
- if(e.getSource() == mFeb){
- mTimeFrame = Months.FEB;
- }
-
- if(e.getSource() == mMar){
- mTimeFrame = Months.MAR;
- }
-
- if(e.getSource() == mApr){
- mTimeFrame = Months.APR;
- }
-
- if(e.getSource() == mMay){
- mTimeFrame = Months.MAY;
- }
-
- if(e.getSource() == mJun){
- mTimeFrame = Months.JUN;
- }
-
- if(e.getSource() == mJul){
- mTimeFrame = Months.JUL;
- }
-
- if(e.getSource() == mAug){
- mTimeFrame = Months.AUG;
- }
-
- if(e.getSource() == mSep){
- mTimeFrame = Months.SEP;
- }
-
- if(e.getSource() == mOct){
- mTimeFrame = Months.OCT;
- }
-
- if(e.getSource() == mNov){
- mTimeFrame = Months.NOV;
- }
-
- if(e.getSource() == mDec){
- mTimeFrame = Months.DEC;
- }
-
- if(e.getSource() == mYear){
- mTimeFrame = Months.YEAR;
- }
-
- if(e.getSource() == mOkButton){
-
- }
-
- }
-}
diff --git a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/MainWindow.java b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/MainWindow.java
index 6828992..83299e2 100644
--- a/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/MainWindow.java
+++ b/Order Processor/src/com/TwentyCodes/java/OrderProcessor/UI/MainWindow.java
@@ -151,7 +151,7 @@ public class MainWindow extends JFrame implements ActionListener, ProgressListen
*/
@Override
public void onProgressUpdate(int progress, int max) {
- progress++;
+// progress++;
mProgressBar.setMaximum(max);
mProgressBar.setValue(progress);
mProgressBar.setString(" "+mCurrentFile + " ~ Parsing Order: "+ progress +" of "+mProgressBar.getMaximum()+" ");
diff --git a/Order Processor/version infomation/changelog b/Order Processor/version infomation/changelog
new file mode 100644
index 0000000..e69de29
diff --git a/Order Processor/version infomation/version b/Order Processor/version infomation/version
new file mode 100644
index 0000000..073ca47
--- /dev/null
+++ b/Order Processor/version infomation/version
@@ -0,0 +1 @@
+0.12.0 b 27
\ No newline at end of file