package ordering.custom;
import ordering.common.vo.*;
import ordering.common.exceptions.*;
import ordering.common.model.OrderingModel;
import java.util.*;
import ordering.common.vo.POLineItemVO;
import ordering.common.exceptions.NotFoundException;
import java.text.DateFormat;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class OrderingModelImpl implements OrderingModel
{
Connection conn;
public
OrderingModelImpl() throws Exception, SQLException
{
connect();
}
public
void connect() throws Exception, SQLException
{
try {
Class.forName("org.hsqldb.jdbcDriver");
String dbPath =
"C:\\jboss-3.0.6_tomcat-4.1.18\\server\\default\\db\\hypersonic\\default";
conn =
DriverManager.getConnection("jdbc:hsqldb:" +
dbPath,"sa","");
}
catch (Exception e)
{
System.out.println(e.getMessage()) ;
}
}
public
void addPurchaseOrder(PurchaseOrderVO po)
throws ModelAccessException, IntegrityException
{
try
{
OrderingDAO.addPurchaseOrder(po,conn);
}
catch (SQLException se) {
System.out.println(po.getPoNumber());
}
}
public
Collection getPODescriptors(int partnerID, String status)
throws ModelAccessException, NotFoundException
{
Collection
descs = new ArrayList();
try {
descs = OrderingDAO.getPODescriptors(partnerID,
status,conn);
}
catch (Exception se)
{
}
return descs;
}
public
PurchaseOrderVO getPurchaseOrder(int id) throws ModelAccessException,
NotFoundException
{
PurchaseOrderVO po = new PurchaseOrderVO();
try {
po = OrderingDAO.getPurchaseOrder(id, conn);
}
catch (Exception e)
{
}
return po;
}
public
void acceptPurchaseOrder(int id) throws ModelAccessException, NotFoundException
{
try {
PurchaseOrderVO po = getPurchaseOrder(id);
po.setStatus(Constants.STATUS_ACCEPTED);
po.getDescriptorVO().setStatus(Constants.STATUS_ACCEPTED);
System.out.println(po.getPoNumber()+":"+po.getStatus());
} catch (NotFoundException e) {
}
}
public
void rejectPurchaseOrder(int id) throws ModelAccessException, NotFoundException
{
PurchaseOrderVO po = getPurchaseOrder(id);
po.setStatus(Constants.STATUS_REJECTED);
}
public
Collection getInvoiceDescriptors(int partnerId,String status)
throws ModelAccessException,NotFoundException
{
Collection
descs = new ArrayList();
return descs;
}
public
InvoiceVO getInvoice(int id) throws ModelAccessException,NotFoundException
{
InvoiceVO
invoice = new InvoiceVO();
return invoice;
}
public
void saveInvoice(InvoiceVO invoice) throws ModelAccessException,
IntegrityException{}
public
void sendInvoice(int id) throws ModelAccessException{}
public
int newId(String sequence_name) throws ModelAccessException
{
return 0;
}
}