package com.sun.j2ee.blueprints.admin.web;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
import org.xml.sax.InputSource;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.ParserConfigurationException;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;
import java.util.Date;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import com.sun.j2ee.blueprints.opc.admin.ejb.OPCAdminFacadeHome;
import com.sun.j2ee.blueprints.opc.admin.ejb.OPCAdminFacade;
import com.sun.j2ee.blueprints.opc.admin.ejb.OrdersTO;
import com.sun.j2ee.blueprints.opc.admin.ejb.OPCAdminFacadeException;
import com.sun.j2ee.blueprints.asyncsender.util.JNDINames;
import com.sun.j2ee.blueprints.asyncsender.ejb.AsyncSenderLocalHome;
import com.sun.j2ee.blueprints.asyncsender.ejb.AsyncSender;
import com.sun.j2ee.blueprints.xmldocuments.OrderApproval;
import com.sun.j2ee.blueprints.xmldocuments.ChangedOrder;
import com.sun.j2ee.blueprints.xmldocuments.XMLDocumentException;
import com.sun.j2ee.blueprints.servicelocator.web.ServiceLocator;
import com.sun.j2ee.blueprints.servicelocator.ServiceLocatorException;
public class AdminRequestBD {
private String OPC_ADMIN_NAME = "java:comp/env/ejb/OPCAdminFacadeRemote";
private OPCAdminFacade opcAdminEJB = null;
public AdminRequestBD() throws AdminBDException {
try {
OPCAdminFacadeHome home = (OPCAdminFacadeHome) ServiceLocator.getInstance().getRemoteHome(OPC_ADMIN_NAME, OPCAdminFacadeHome.class);
opcAdminEJB = home.create();
} catch (ServiceLocatorException sle) {
sle.printStackTrace();
throw new AdminBDException(sle.getMessage());
} catch (CreateException ce) {
ce.printStackTrace();
throw new AdminBDException(ce.getMessage());
} catch (RemoteException re) {
re.printStackTrace();
throw new AdminBDException(re.getMessage());
}
}
public OrdersTO getOrdersByStatus(String status)
throws AdminBDException {
try {
return opcAdminEJB.getOrdersByStatus(status);
} catch (RemoteException re) {
re.printStackTrace();
throw new AdminBDException(re.getMessage());
} catch (OPCAdminFacadeException oafee) {
oafee.printStackTrace();
throw new AdminBDException(oafee.getMessage());
}
}
public void updateOrders(OrderApproval oa) throws AdminBDException {
try {
AsyncSenderLocalHome home = (AsyncSenderLocalHome)
ServiceLocator.getInstance().getLocalHome(JNDINames.ASYNCSENDER_LOCAL_EJB_HOME);
AsyncSender sender= home.create();
sender.sendAMessage(oa.toXML());
} catch (ServiceLocatorException sle) {
sle.printStackTrace();
throw new AdminBDException(sle.getMessage());
} catch (XMLDocumentException xde) {
xde.printStackTrace();
throw new AdminBDException(xde.getMessage());
} catch (CreateException ce) {
throw new AdminBDException(ce.getMessage());
}
}
public Map getChartInfo(String request, Date start, Date end,
String category)
throws AdminBDException {
try {
return opcAdminEJB.getChartInfo(request, start, end, category);
} catch (RemoteException re) {
re.printStackTrace();
throw new AdminBDException(re.getMessage());
} catch (OPCAdminFacadeException oafee) {
oafee.printStackTrace();
throw new AdminBDException(oafee.getMessage());
}
}
}