Beispiel #1
0
 /**
  * @brief Delete from ALL auction lists!
  *     <p>The FilterManager does this, as it needs to be internally self-consistent.
  * @param ae - The auction entry to delete.
  */
 public void delEntry(AuctionEntry ae) {
   String id = ae.getIdentifier();
   DeletedEntry.create(id);
   ae.cancelSnipe(false);
   mFilter.deleteAuction(ae);
   ae.delete();
 }
Beispiel #2
0
  private void retrieveAndVerifyAuctions(List<String> params) {
    if (params.size() == 0) return;
    try {
      if (params.size() > 1) {
        XMLElement auctionList = new XMLElement("auctions");
        for (String id : params) {
          XMLElement xmlized = EntryFactory.getInstance().retrieveAuctionXML(id);
          if (xmlized != null) auctionList.addChild(xmlized);
        }
        JConfig.log().logMessage(auctionList.toString());
      } else {
        StringBuffer auctionXML =
            EntryFactory.getInstance().retrieveAuctionXMLString(params.get(0));
        if (auctionXML != null) {
          JConfig.log().logMessage(auctionXML.toString());
          XMLElement xmlized = new XMLElement();
          xmlized.parseString(auctionXML.toString());

          if (JConfig.debugging() && mTestQuantity) {
            AuctionEntry ae2 = EntryFactory.getInstance().constructEntry();
            ae2.fromXML(xmlized);
            JConfig.log().logDebug("ae2.quantity == " + ae2.getQuantity());
          }
        }
      }
    } catch (Exception dumpMe) {
      JConfig.log()
          .handleException("Failure during serialization or deserialization of an auction", dumpMe);
    }
  }
Beispiel #3
0
 public List<AuctionEntry> findAllSniped() {
   List<AuctionEntry> sniped = AuctionEntry.findAllSniped();
   if (sniped != null) {
     List<AuctionEntry> results = new ArrayList<AuctionEntry>();
     for (AuctionEntry ae : sniped) {
       results.add(chooseLatest(ae, ae.getIdentifier()));
     }
     return results;
   }
   return null;
 }
Beispiel #4
0
 private void buildAuctionEntryFromFile(String fname) {
   StringBuffer sb = new StringBuffer(StringTools.cat(fname));
   try {
     long start = System.currentTimeMillis();
     AuctionInfo ai = mEbay.doParse(sb);
     AuctionEntry ae = EntryFactory.getInstance().constructEntry();
     ae.setAuctionInfo(ai);
     System.out.println("Took: " + (System.currentTimeMillis() - start));
     JConfig.log().logMessage(ae.toXML().toString());
   } catch (Exception e) {
     JConfig.log().handleException("Failed to load auction from file: " + fname, e);
   }
 }
Beispiel #5
0
  public static void main(String[] args) {
    JConfig.setLogger(new ErrorManagement());
    ActiveRecord.disableDatabase();
    AuctionEntry.addObserver(EntryFactory.getInstance());
    AuctionEntry.addObserver(
        new Observer<AuctionEntry>() {
          public void afterCreate(AuctionEntry o) {
            EntryCorral.getInstance().putWeakly(o);
          }
        });
    JBTool tool = new JBTool(args);

    tool.execute();
    System.exit(0);
  }
Beispiel #6
0
  public int loadAuctionsFromDatabase() {
    int totalCount = AuctionInfo.count();
    int activeCount = AuctionEntry.activeCount();

    MQFactory.getConcrete("splash").enqueue("WIDTH " + activeCount);
    MQFactory.getConcrete("splash").enqueue("SET 0");

    AuctionServer newServer = AuctionServerManager.getInstance().getServer();
    AuctionServerManager.setEntryManager(this);
    if (totalCount == 0) {
      if (JConfig.queryConfiguration("stats.auctions") == null)
        JConfig.setConfiguration("stats.auctions", "0");
      return totalCount;
    }

    AuctionServerManager.getInstance().loadAuctionsFromDB(newServer);
    AuctionStats as = AuctionServerManager.getInstance().getStats();

    //  TODO -- Do something more valuable than just notify, when the auction counts are off.
    int savedCount = Integer.parseInt(JConfig.queryConfiguration("last.auctioncount", "-1"));
    if (as != null) {
      if (as.getCount() != activeCount || (savedCount != -1 && as.getCount() != savedCount)) {
        MQFactory.getConcrete("Swing").enqueue("NOTIFY Failed to load all auctions.");
      }
    }

    return activeCount;
  }
Beispiel #7
0
 public List<Snipeable> getMultisnipedByGroup(String multisnipeIdentifier) {
   List<? extends Snipeable> entries =
       AuctionEntry.findAllBy("multisnipe_id", multisnipeIdentifier);
   List<Snipeable> rval = new ArrayList<Snipeable>(entries.size());
   for (Snipeable entry : entries) {
     Snipeable ae = takeForRead(entry.getIdentifier());
     if (!ae.isComplete()) rval.add(ae);
   }
   return rval;
 }
Beispiel #8
0
 public void updateConfiguration() {
   String newSnipeTime = JConfig.queryConfiguration("snipemilliseconds");
   if (newSnipeTime != null) {
     AuctionEntry.setDefaultSnipeTime(Long.parseLong(newSnipeTime));
   }
 }
Beispiel #9
0
 /**
  * @brief Verify that an auction entry exists.
  *     <p>This should query the filter manager instead of doing it itself. This would let
  *     FilterManager handle all this, and AuctionsManager wouldn't need to know anything too much
  *     about the items in the auction lists.
  * @note Both Verify and Get should proxy to FilterManager! FUTURE FEATURE -- mrs:
  *     29-September-2001 14:59
  * @param id - The auction id to search for.
  * @return - True if the item exists someplace in our list of Auctions.
  */
 public boolean verifyEntry(String id) {
   return AuctionEntry.findByIdentifier(id) != null;
 }
Beispiel #10
0
 @Override
 public AuctionEntry getItem(String param) {
   return AuctionEntry.findByIdentifier(param);
 }