avatar

611

More improvements to using the auction identifier as the (basically) primary key.

by mrs, 18 Aug, 2008 09:01 AM
610 611  
676676    *
677677    * @return The unique identifier for this auction.
678678    */
679   public String getIdentifier() { if(getAuction() == null) return null; else return getAuction().getIdentifier(); }
679   public String getIdentifier() {
680     return getAuction() == null ? null : getAuction().getIdentifier();
681   }
680682 
681683   ///////////////////////////
682684   //  Actual logic functions
------
15271529     return r_flags;
15281530   }
15291531 
1530   ////////////////////////////////////////
1531   //  Passthrough functions to AuctionInfo
1532 
1533   protected AuctionInfo getAuction() {
1532   public AuctionInfo getAuction() {
15341533     if(mAuction == null) {
15351534       String aid = get("auction_id");
15361535       if(aid != null && aid.length() != 0) {
------
15391538       if(mAuction == null && getString("identifier") != null) {
15401539         mAuction = AuctionInfo.findByIdentifier(getString("identifier"));
15411540       }
1541 
1542       //  If we successfully loaded an auction info object...
1543       if(mAuction != null) {
1544         setDefaultCurrency(mAuction.getDefaultCurrency());
1545 
1546         if(getString("identifier") == null) {
1547           setString("identifier", mAuction.getIdentifier());
1548           saveDB();
1549         }
1550       }
15421551     }
1543     if(mAuction != null & getString("identifier")==null) {
1544       setString("identifier", mAuction.getIdentifier());
1545       saveDB();
1546     }
1552 
15471553     return mAuction;
15481554   }
15491555 
------
15691575     if(doRefresh) refreshSnipe();
15701576     if(newAuctionId != null) {
15711577       set("auction_id", newAuctionId);
1578       setString("identifier", mAuction.getIdentifier());
15721579       //  If we had an old auction, and it's not the same as the new one,
15731580       //  and the IDs are different, delete the old one.
15741581       if (oldAuction != null &&
------
15841591     saveDB();
15851592   }
15861593 
1594   ////////////////////////////////////////
1595   //  Passthrough functions to AuctionInfo
1596 
15871597   /* Accessor functions that are passed through directly down
15881598    * to the internal AuctionInfo object.
15891599    */
------
16051615   public int getQuantity() { return getAuction().getQuantity(); }
16061616   public int getNumBidders() { return getAuction().getNumBidders(); }
16071617 
1608 
16091618   public String getSeller() { return getAuction().getSellerName(); }
16101619   public String getHighBidder() { return getAuction().getHighBidder(); }
16111620   public String getHighBidderEmail() { return getAuction().getHighBidderEmail(); }
------
17951804    * otherwise an AuctionEntry will be loaded and returned.
17961805    */
17971806   public static AuctionEntry findByIdentifier(String identifier) {
1798     AuctionInfo ai = AuctionInfo.findFirstBy("identifier", identifier);
1799     AuctionEntry ae = null;
1807     AuctionEntry ae = findFirstBy("identifier", identifier);
18001808 
1801     if(ai != null) {
1802       ae = AuctionEntry.findFirstBy("auction_id", ai.getString("id"));
1803       if(ae != null) ae.setAuctionInfo(ai);
1809     if(ae != null) {
1810       if(ae.getAuction() == null) {
1811         ErrorManagement.logMessage("Error loading auction #" + identifier + ", entry found, auction missing.");
1812         ae = null;
1813       }
18041814     }
18051815 
1816     if(ae == null) {
1817       AuctionInfo ai = AuctionInfo.findByIdentifier(identifier);
1818       if(ai != null) {
1819         ae = AuctionEntry.findFirstBy("auction_id", ai.getString("id"));
1820         if (ae != null) ae.setAuctionInfo(ai);
1821       }
1822     }
1823 
18061824     return ae;
18071825   }
18081826 
588 611  
107107       AuctionEntry ae = (AuctionEntry) entries.get(auction_id);
108108       ae.setServer(newServer);
109109 
110       if (ae.getIdentifier() == null) {
110       if (ae.getAuction() == null) {
111111         ErrorManagement.logMessage("We lost the underlying auction for: " + ae.dumpRecord());
112112       } else {
113113         sEntryManager.addEntry(ae);