void importOrders(DataSource dataSource, InputSource inputSource)
throws SQLException, ParserConfigurationException, SAXException, IOException, InterruptedException, VerticesProcessingException {
Connection connection;
SingletonDataSource updateDataSource;
ExecutorServiceFactory factory;
GraphReducer reducer;
GraphBuilder builder;
OrdersParser parser;
Vertex<Object> root;
connection = null;
try {
connection = dataSource.getConnection();
connection.setAutoCommit(false);
updateDataSource = new SingletonDataSource(connection);
factory = new FixedThreadPoolFactory(3);
reducer = new GraphReducerImpl(factory);
builder = new GraphBuilder();
builder.rootBuilder = reducer.addProcessor(
new SingleVertexProcessor<Object>());
builder.selectCustomerBuilder = reducer.addProcessor(
new SelectCustomerProcessor(dataSource), 50);
builder.selectProductBuilder = reducer.addProcessor(
new SelectProductProcessor(dataSource), 50);
builder.insertOrderBuilder = reducer.addProcessor(
new InsertOrderProcessor(updateDataSource), 50);
builder.insertLineItemBuilder = reducer.addProcessor(
new InsertLineItemProcessor(updateDataSource), 50);
parser = new OrdersParser();
parser.parse(builder, inputSource);
root = builder.getRoot();
reducer.reduceGraph(root);
} catch (SQLException exception) {
JdbcUtils.rollback(connection);
throw exception;
} catch (ParserConfigurationException exception) {
JdbcUtils.rollback(connection);