From: Ian Jackson Date: Sat, 4 Sep 2010 15:59:41 +0000 (+0100) Subject: Do not do PCTB stuff at all if we're not doing PCTB; make progress messages clearer... X-Git-Tag: 0.9.9~30 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=jarrg-ian.git;a=commitdiff_plain;h=0b0a3e3376419ae1321e349764092c0210cda5eb Do not do PCTB stuff at all if we're not doing PCTB; make progress messages clearer about what the activity is for --- diff --git a/src/com/tedpearson/ypp/market/MarketUploader.java b/src/com/tedpearson/ypp/market/MarketUploader.java index 4cd16dd..7632c01 100644 --- a/src/com/tedpearson/ypp/market/MarketUploader.java +++ b/src/com/tedpearson/ypp/market/MarketUploader.java @@ -402,7 +402,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis ArrayList> data = getData(t); if (uploadToYarrg && yarrgts != null) { - pm.setNote("Preparing data for Yarrg"); + pm.setNote("Yarrg: Preparing data"); pm.setProgress(10); StringBuilder yarrgsb = new StringBuilder(); @@ -422,7 +422,7 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis yarrgdata = yarrgsb.toString(); - pm.setNote("Uploading to Yarrg"); + pm.setNote("Yarrg: Uploading"); if (islandName != null) { doneyarrg = runYarrg(yarrgts, oceanName, islandName, yarrgdata); @@ -431,53 +431,53 @@ public class MarketUploader implements TopLevelWindowListener, GUIInitializedLis } } - pm.setNote("Getting stall names"); - pm.setProgress(20); - if(pm.isCanceled()) { + if (uploadToPCTB) { + pm.setNote("PCTB: Getting stall names"); + pm.setProgress(20); + if(pm.isCanceled()) { return; - } - TreeSet buys = new TreeSet(); - TreeSet sells = new TreeSet(); - LinkedHashMap stallMap = getStallMap(data); - pm.setProgress(40); - pm.setNote("Sorting offers"); - if(pm.isCanceled()) { + } + TreeSet buys = new TreeSet(); + TreeSet sells = new TreeSet(); + LinkedHashMap stallMap = getStallMap(data); + pm.setProgress(40); + pm.setNote("PCTB: Sorting offers"); + if(pm.isCanceled()) { return; - } - // get commod map + } + // get commod map - HashMap commodMap = getCommodMap(); - if(commodMap == null) { + HashMap commodMap = getCommodMap(); + if(commodMap == null) { return; - } - int[] offerCount = getBuySellMaps(data,buys,sells,stallMap,commodMap); - //println(buys.toString()); - //System.out.println(sells); - //System.out.println("\n\n\n"+buys); - - if (uploadToPCTB) { - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - pm.setProgress(60); - pm.setNote("Sending data"); - if(pm.isCanceled()) { - return; - } - GZIPOutputStream out = new GZIPOutputStream(outStream); - //FileOutputStream out = new FileOutputStream(new File("output.text")); - DataOutputStream dos = new DataOutputStream(out); - dos.writeBytes("005y\n"); - dos.writeBytes(stallMap.size()+"\n"); - dos.writeBytes(getAbbrevStallList(stallMap)); - writeBuySellOffers(buys,sells,offerCount,out); - out.finish(); - InputStream in = sendInitialData(new ByteArrayInputStream(outStream.toByteArray())); - if (in == null) return; - pm.setProgress(80); - if(pm.isCanceled()) { - return; - } - pm.setNote("Waiting for PCTB..."); - donepctb = finishUpload(in); + } + int[] offerCount = getBuySellMaps(data,buys,sells,stallMap,commodMap); + //println(buys.toString()); + //System.out.println(sells); + //System.out.println("\n\n\n"+buys); + + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + pm.setProgress(60); + pm.setNote("PCTB: Sending data"); + if(pm.isCanceled()) { + return; + } + GZIPOutputStream out = new GZIPOutputStream(outStream); + //FileOutputStream out = new FileOutputStream(new File("output.text")); + DataOutputStream dos = new DataOutputStream(out); + dos.writeBytes("005y\n"); + dos.writeBytes(stallMap.size()+"\n"); + dos.writeBytes(getAbbrevStallList(stallMap)); + writeBuySellOffers(buys,sells,offerCount,out); + out.finish(); + InputStream in = sendInitialData(new ByteArrayInputStream(outStream.toByteArray())); + if (in == null) return; + pm.setProgress(80); + if(pm.isCanceled()) { + return; + } + pm.setNote("PCTB: Waiting ..."); + donepctb = finishUpload(in); } pm.setProgress(100);