in bigtop-data-generators/bigpetstore-data-generator/src/main/java/org/apache/bigtop/datagenerators/bigpetstore/cli/Driver.java [144:173]
private void writeTransactions(Collection<Transaction> transactions) throws Exception
{
File outputFile = new File(outputDir.toString() + File.separator + "transactions.txt");
System.out.println(outputFile.toString());
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
for(Transaction transaction : transactions)
{
for(Product product : transaction.getProducts())
{
String record = transaction.getId() + ",";
record += transaction.getDateTime() + ",";
record += transaction.getStore().getId() + ",";
record += transaction.getStore().getLocation().getZipcode() + ",";
record += transaction.getStore().getLocation().getCity() + ",";
record += transaction.getStore().getLocation().getState() + ",";
record += transaction.getCustomer().getId() + ",";
Pair<String, String> name = transaction.getCustomer().getName();
record += name.getLeft() + " " + name.getRight() + ",";
record += transaction.getCustomer().getLocation().getZipcode() + ",";
record += transaction.getCustomer().getLocation().getCity() + ",";
record += transaction.getCustomer().getLocation().getState() + ",";
record += product.toString() + "\n";
outputStream.write(record.getBytes());
}
}
outputStream.close();
}