/* * [JetPrices.java] * * Summary: Convert Element 5 price list to Jet Prices table. * * Copyright: (c) 2007-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.9 2007-04-12 tidy with code inspector, move the anchor to details. */ package com.mindprod.prices; import com.mindprod.common18.BigDate; import com.mindprod.common18.Build; import com.mindprod.common18.EIO; import com.mindprod.common18.Misc; import com.mindprod.csv.CSVReader; import com.mindprod.fastcat.FastCat; import java.io.EOFException; import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.text.DecimalFormat; /** * Convert Element 5 price list to Jet Prices table. *

* * @author Roedy Green, Canadian Mind Products * @version 1.9 2007-04-12 tidy with code inspector, move the anchor to details. * @noinspection WeakerAccess * @since 2007 */ public final class JetPrices { /** * used to format prices for CurrCon, not humans to read. */ private static final DecimalFormat df2 = new DecimalFormat( "#0.00" ); /** * discount CMP offers, Excelsior gives me 20.00. I get 6%. */ private static final double discount = 14.00; /** * price info extracted from Jet Page: * var priceList = new Array( * {code: 'SWB', priceNew: '1200', idNew: '300300555', fsIdNew: 'jet-std-win32-bs', idUpgrade: '3000xxxxx', * priceRenewal: '300', idRenewal: '300300536'}, * {code: 'SWS', priceNew: '1500', idNew: '300019116', fsIdNew: 'jet-std-win32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '600', idRenewal: '534517'}, * {code: 'PWB', priceNew: '2000', idNew: '300300552', fsIdNew: 'jet-pro-win32-bs', idUpgrade: '3000xxxxx', * priceRenewal: '500', idRenewal: '300300534'}, * {code: 'PWS', priceNew: '2500', idNew: '300019104', fsIdNew: 'jet-pro-win32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '1000', idRenewal: '534510'}, * {code: 'PWP', priceNew: '3000', idNew: '300019108', fsIdNew: 'jet-pro-win32-ps', idUpgrade: '3000xxxxx', * priceRenewal: '1500', idRenewal: '534512'}, * {code: 'EWS', priceNew: '4000', idNew: '300077600', fsIdNew: 'jet-ent-win32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '1600', idRenewal: '300077572'}, * {code: 'EWP', priceNew: '4800', idNew: '300077603', fsIdNew: 'jet-ent-win32-ps', idUpgrade: '3000xxxxx', * priceRenewal: '2400', idRenewal: '300077577'}, * {code: 'SLB', priceNew: '1900', idNew: '300300554', fsIdNew: 'jet-std-lin32-bs', idUpgrade: '3000xxxxx', * priceRenewal: '800', idRenewal: '300300537'}, * {code: 'SLS', priceNew: '2200', idNew: '300019119', fsIdNew: 'jet-std-lin32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '1100', idRenewal: '534519'}, * {code: 'PLB', priceNew: '2500', idNew: '300300550', fsIdNew: 'jet-pro-lin32-bs', idUpgrade: '3000xxxxx', * priceRenewal: '1000', idRenewal: '300300518'}, * {code: 'PLS', priceNew: '3000', idNew: '300044331', fsIdNew: 'jet-pro-lin32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '1500', idRenewal: '534511'}, * {code: 'PLP', priceNew: '3500', idNew: '300044333', fsIdNew: 'jet-pro-lin32-ps', idUpgrade: '3000xxxxx', * priceRenewal: '2000', idRenewal: '534513'}, * {code: 'ELS', priceNew: '5000', idNew: '300077601', fsIdNew: 'jet-ent-lin32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '2600', idRenewal: '300077569'}, * {code: 'ELP', priceNew: '5800', idNew: '300077604', fsIdNew: 'jet-ent-lin32-ps', idUpgrade: '3000xxxxx', * priceRenewal: '3400', idRenewal: '300077579'}, * {code: 'SWLB', priceNew: '2500', idNew: '300300556', fsIdNew: 'jet-std-win32-lin32-bs', idUpgrade: '3000xxxxx', * priceRenewal: '950', idRenewal: '300300936'}, * {code: 'SWLS', priceNew: '2950', idNew: '300016760', fsIdNew: 'jet-std-win32-lin32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '1400', idRenewal: '300016784'}, * {code: 'PWLB', priceNew: '3500', idNew: '300300553', fsIdNew: 'jet-pro-win32-lin32-bs', idUpgrade: '3000xxxxx', * priceRenewal: '1250', idRenewal: '300300935'}, * {code: 'PWLS', priceNew: '4250', idNew: '300016751', fsIdNew: 'jet-pro-win32-lin32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '2000', idRenewal: '300016772'}, * {code: 'PWLP', priceNew: '5000', idNew: '300016755', fsIdNew: 'jet-pro-win32-lin32-ps', idUpgrade: '3000xxxxx', * priceRenewal: '2750', idRenewal: '300016773'}, * {code: 'EWLS', priceNew: '7000', idNew: '300077618', fsIdNew: 'jet-ent-win32-lin32-ss', idUpgrade: '3000xxxxx', * priceRenewal: '3400', idRenewal: '300077616'}, * {code: 'EWLP', priceNew: '8200', idNew: '300077621', fsIdNew: 'jet-ent-win32-lin32-ps', idUpgrade: '3000xxxxx', * priceRenewal: '4600', idRenewal: '300077608'}); */ private static final String DO_NOT_EDIT = "\n"; /** * build a link offsite to either a trial downloadURL or Element 5. * * @param productId 0=trial otherwise Element 5 id. * * @return html to describe results of that trial. */ private static String buildLink( String productId ) { if ( productId.equals( "0" ) ) { return ""; } else { return ""; } } /* also via Element5 http://esd.element5.com/product.html?cart=1&productid=534519&backlink=http%3A%2F%2Fmindprod .com%2Fjgloss%2Fjet.html&cookies=1&quickbuy=1&affiliateid=200010251 534519, 534517, Standard, Standard Support Contract (just support, no compiler), 600 534511, 534510, Professional, Standard Support Contract (just support, no compiler), 1150 300019119, 300019116, Standard, with Standard Support, 1200 534513, 534512, Professional, Premium Support And Maintenance Contract (just support, no compiler), 2000 300044331, 300019104, Professional, with Standard Support, 2300 300044333, 300019108, Professional, with Premium Support and Maintenance, 4300 300077600, 300077600, Enterprise, with Standard Support and Maintenance, 4500 */ /** * Generate HTML to display a price and its discounted price * * @param price US dollar value to display * * @return generated HTML String. */ private static String buildPriceAndDiscountedPrice( final double price ) { final FastCat sb = new FastCat( 9 ); sb.append( "" ); if ( price == 0 ) { sb.append( "free trial " ); } else { sb.append( "" ); } sb.append( "\n" ); if ( price == 0 ) { sb.append( "free trial " ); } else { sb.append( "" ); } sb.append( "\n" ); return sb.toString(); } /** * generate the HTML for a price table * * @param forLinux true means generate table for Linux * * @throws IOException on trouble with I/O on jetprices.csv */ private static void generatePriceTable( boolean forLinux ) throws IOException { // O P E N final CSVReader r = new CSVReader( EIO.getBufferedReader( new File( "E:/com/mindprod/prices/jetprices.csv" ), 4 * 1024, EIO.UTF8 ) ); // O P E N final String target = Build.MINDPROD_WEBROOT + "/jgloss/include/" + ( forLinux ? "linuxjetprices.htmlfrag" : "winjetprices.htmlfrag" ); final PrintWriter prw = EIO.getPrintWriter( new File( target ), 4 * 1024, EIO.UTF8 ); try { final String version = Build.JET_VERSION; final String os = forLinux ? "Linux" : "Windows"; prw.print( DO_NOT_EDIT + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" ); /** * mark begin of automatically generated table */ while ( true ) { /* # Jet prices # linux, win, level, support, linuxNew, winNew, linuxUpgrade, windowsUpgrade, linuxRenew, winRenew 0, 0, Enterprise, none, 0, 0, 0, 0, 0, 0 jet-std-lin32-bs, jet-std-win32-bs, Standard, basic, 1900, 1200, 800, 300, 800, 300 jet-std-lin32-ss, jet-std-win32-ss, Standard, standard, 2200, 1500, 1100, 600, 1100, 600 jet-pro-lin32-bs, jet-pro-win32-bs, Professional, basic, 2500, 2000, 1000, 500, 1000, 500 jet-pro-lin32-ss, jet-pro-win32-ss, Professional, standard, 3000, 2500, 1500, 1000, 1500, 1000 jet-pro-lin32-ps, jet-pro-win32-ps, Professional, premium, 3500, 3000, 2000, 1500, 2000, 1500 jet-ent-lin32-ss, jet-ent-win32-ss, Enterprise, standard, 5000, 4000, 2600, 1600, 2600, 1600 jet-ent-lin32-ps, jet-ent-win32-ps, Enterprise, premium, 5800, 4800, 3400, 2400, 3400, 2400 */ final String productIdForLinux = r.get(); final String productIdForWindows = r.get(); final Level level = Level.valueOf( r.get() ); final SupportLevel supportLevel = SupportLevel.valueOf( r.get() ); final double newPriceLinux = r.getDouble(); final double newPriceWindows = r.getDouble(); final double newPrice = forLinux ? newPriceLinux : newPriceWindows; final double upgradePriceLinux = r.getDouble(); final double upgradePriceWindows = r.getDouble(); final double upgradePrice = forLinux ? upgradePriceLinux : upgradePriceWindows; final double renewPriceLinux = r.getDouble(); final double renewPriceWindows = r.getDouble(); final double renewPrice = forLinux ? renewPriceLinux : renewPriceWindows; final boolean maintenanceIncluded = supportLevel != SupportLevel.none; final boolean proFeaturesIncluded = level == Level.Professional || level == Level.Enterprise; final boolean enterpriseFeaturesIncluded = level == Level.Enterprise; StringBuilder sb = new StringBuilder( 300 ); // generate a line of html sb.append( "" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( buildPriceAndDiscountedPrice( newPrice ) ); sb.append( buildPriceAndDiscountedPrice( upgradePrice ) ); sb.append( buildPriceAndDiscountedPrice( renewPrice ) ); if ( forLinux ) { sb.append( "\n" ); } else { sb.append( "" ); } sb.append( "\n" ); prw.print( sb.toString() ); r.skipToNextLine(); } // end while } catch ( EOFException e ) { prw.print( "
\n" + "Excelsior Jet " + version + " for " + os + " Prices\n" + "
Excelsior Jet\n" + version + " For + os + Prices
Includes\n" + "
\n" + "Pro\n" + "
\n" + "Features
Includes\n" + "
\n" + "Enterprise\n" + "
\n" + "Features
Includes\n" + "
\n" + "Maintenance\n" + "
\n" + "Updates
Includes\n" + "
\n" + "1 year\n" + "
\n" + "Support
Prices in\n" + "
\n" + "\n" + "
" + "
\n" + os + "
NewUpgradeRenew Support
Direct\n" + "
\n" + "From Excelsior
Discounted\n" + "
\n" + "14% from CMP
Direct\n" + "
\n" + "From Excelsior
Discounted\n" + "
\n" + "14% from CMP
Direct\n" + "
\n" + "From Excelsior
Discounted\n" + "
\n" + "14% from CMP
Buy Direct From Excelsior
" ); sb.append( buildLink( productIdForLinux ) ); sb.append( "" ); sb.append( buildLink( productIdForWindows ) ); sb.append( "
\n" ); // C L O S E r.close(); prw.close(); } } /** * read E:\com\mindprod\prices\jetprices.csv and produce equivalent html * and puts it direcly in * E:\mindprod\jgloss\include\linuxjetprices.htmlfrag and winjetprices.htmlfrag * produces files * * @param args not used. * * @throws IOException on trouble reading jetprices file * @noinspection InfiniteLoopStatement, EmptyCatchBlock */ public static void main( String[] args ) throws IOException { generatePriceTable( false ); // windows generatePriceTable( true ); // linux Misc.trackLastThread(); System.exit( 0 ); } /** * which level of compiler. */ private enum Level { Standard, Professional, Enterprise } /** * which level of compiler. */ private enum SupportLevel { none { String cssClass() { return "x"; } }, basic { String cssClass() { return "basicsupport"; } }, standard { String cssClass() { return "standardsupport"; } }, premium { String cssClass() { return "premiumsupport"; } }; abstract String cssClass(); } }