/* * [OnlineStore.java] * * Summary: The generalisation of an online store, used for books, DVDs and electronics. * * Copyright: (c) 2012-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.0 2012-02-01 initial version * 1.1 2014-05-20 add buildQueryLink */ package com.mindprod.stores; import com.mindprod.aws.jax.AWSECommerceService; import com.mindprod.aws.jax.AWSECommerceServicePortType; import com.mindprod.http.Get; /** * The generalisation of an online store, used for books, DVDs and electronics. *
* Can't be an abstract class since enums implement it. * * @author Roedy Green, Canadian Mind Products * @version 1.1 2014-05-20 add buildQueryLink * @since 2012-02-01 */ public interface OnlineStore { // methods /** * build html to probe for a product (no affiliate info) * * @param product product number isbn13/asin/upc * * @return url */ String buildProductLink( final String product );// /method /** * @param title title of book or product * @param author author of this book. * * @return link to do a general query about the products */ String buildQueryLink( final String title, final String author );// /method /** * clear counts of products added and dropped */ void clearStats();// /method /** * configure this bookstore to use a particular stock (numbering system, inventory) * * @param stock Stack that tracks products for this store. * @param ordinal number 1..31 assigned by Stack to indicate this store. */ void configureStock( Stock stock, int ordinal ); /** * enqueue a product to be probed to see if it is in-stock for this bookstore. * * @param product isbn13, upc, asin */ void enqueueProductToProbe( final String product );// /method /** * forgive past string of refusals because we had a success */ void forgiveRefusals(); /** * get the affiliate account number */ String getAccount();// /method /** * get all products this store potentially has in stock. * * @return Set of all products * @see #getSortedProductsToProbe * There is no method to get size. */ String[] getAllSortedProducts();// /method /** * get strings that indicate item is in or out of stock. * * @return markers array */ Clue[] getClues();// /method /** * how many products we still have to probe */ int getCountOfProductsYetToProbe(); /** * name of store, with entities * * @return name of store */ String getDecoratedStoreName();// /method /** * make enum.name() visible. Don't change to name. * * @return enum name */ String getEnumName(); /** * get the Get connection in progress * * @return Get connection in progress, null if none */ Get getGetInProgress(); /** * website url for store without lead http: * * @return website without http: */ String getHost();// /method /** * milliseconds minimum between probing the same store. * * @return minimum time between probes to the same store in ms. * Different for each store. */ long getInterProbeTime();// /method /** * record last product probed for this store * * @return last product probed, not necessary completed. */ String getLastProductProbed(); /** * record last product probed for this store * * @param product product id */ void setLastProductProbed( String product ); /** * minimum length of response from store to parse */ int getMinimumResponseLength(); /** * gets ordinal for implementing class */ int getOrdinal(); /** * get the port for the server for that country * * @param service the soap service * * @return the port for that country. */ AWSECommerceServicePortType getPort( final AWSECommerceService service );// /method /** * at what stage of completion in the most recent probe? * * @return 0 .. 7 */ int getProbeCompletionStage(); /** * record whether probe completed * * @param completionStage 0..7 */ void setProbeCompletionStage( int completionStage ); /** * is a given product in stock? * * @param product product number * @param probe true if should probe to get status if one not on file. * * @return StockStatus enum for product stock status */ StockStatus getProductStatus( final String product, final boolean probe );// /method /** * get count of products recently added */ int getProductsAddedCount();// /method /** * get count of products recently added */ int getProductsDroppedCount();// /method /** * get http:// or https:// * * @return protocol with trailing // */ String getProtocol();// /method /** * get sorted array of all the products we plan to probe for this store * * @see #getAllSortedProducts */ String[] getSortedProductsToProbe();// /method /** * get timestamp previous probe completed */ long getTimeLastProbeCompleted();// /method /** * name of store, with entities * * @return name of store */ String getUndecoratedStoreName();// /method /** * true if still probing this store, it has not refused too many probes */ boolean isAcceptingProbes();// /method /** * is this store alive. Otherwise we suppress the link and put up a construction icon. * * @return true if this store is functioning. */ boolean isAlive();// /method /** * Should we give up reviving this stall store? * * @return true if this store has stalled many times and should not be revived, * false if store should be revived from stall yet again; */ boolean isHopelesslyStalled(); /** * restart the counter of refused probes, remove product from queue * * @param product isbn, asin, upc just completed * @param straggler false this is a bulk probe. true this is an incidental new product probe. */ void noteCompletedProbe( final String product, final boolean straggler );// /method /** * increment count of products added on this probe */ void noteProductAdded();// /method /** * increment count of products dropped on this probe */ void noteProductDropped();// /method /** * increment the count of refused probes */ void noteRefusedProbe( final String product ); /** * record fact this store has stalled again */ void noteStall(); /** * Probe this store to see if it carries the given isbn/product. * Do a Get, analyse clues or possibly ask the AWS database. * * @param product to check * * @return StockStatus enum for product stock status. */ StockStatus probe( final String product ); // method /** * what this store sells, * * @return "book", "DVD" "electronic" */ String productCategory();// /method /** * record the Get connection in progress * * @param get Get connection */ void recordGetInProgress( Get getInProgress ); /** * set single stockItem status * * @param product product number * @param status StockStatus enum for product stock status. */ void setProductStockStatus( String product, StockStatus status );// /method /** * true if this store's inventory should be checked, according to parms in the environment */ boolean shouldCheck();// /method // /methods /** * true if need to suppress cookie errors. Only Kobo has this problem */ boolean suppressCookieErrors();// /method /** * Was this item successfully probed on a recent run? * * @param product product number, may be null or empty. * * @return true if recently probed already. */ boolean wasRecentlyProbed( String product ); }