|
|
| 610 |
611 |
|
| 676 | 676 | *
|
| 677 | 677 | * @return The unique identifier for this auction.
|
| 678 | 678 | */
|
| 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 | }
|
| 680 | 682 |
|
| 681 | 683 | ///////////////////////////
|
| 682 | 684 | // Actual logic functions
|
| --- | --- | |
| 1527 | 1529 | return r_flags;
|
| 1528 | 1530 | }
|
| 1529 | 1531 |
|
| 1530 | | ////////////////////////////////////////
|
| 1531 | | // Passthrough functions to AuctionInfo
|
| 1532 | |
|
| 1533 | | protected AuctionInfo getAuction() {
|
| 1532 | public AuctionInfo getAuction() {
|
| 1534 | 1533 | if(mAuction == null) {
|
| 1535 | 1534 | String aid = get("auction_id");
|
| 1536 | 1535 | if(aid != null && aid.length() != 0) {
|
| --- | --- | |
| 1539 | 1538 | if(mAuction == null && getString("identifier") != null) {
|
| 1540 | 1539 | mAuction = AuctionInfo.findByIdentifier(getString("identifier"));
|
| 1541 | 1540 | }
|
| 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 | }
|
| 1542 | 1551 | }
|
| 1543 | | if(mAuction != null & getString("identifier")==null) {
|
| 1544 | | setString("identifier", mAuction.getIdentifier());
|
| 1545 | | saveDB();
|
| 1546 | | }
|
| 1552 |
|
| 1547 | 1553 | return mAuction;
|
| 1548 | 1554 | }
|
| 1549 | 1555 |
|
| --- | --- | |
| 1569 | 1575 | if(doRefresh) refreshSnipe();
|
| 1570 | 1576 | if(newAuctionId != null) {
|
| 1571 | 1577 | set("auction_id", newAuctionId);
|
| 1578 | setString("identifier", mAuction.getIdentifier());
|
| 1572 | 1579 | // If we had an old auction, and it's not the same as the new one,
|
| 1573 | 1580 | // and the IDs are different, delete the old one.
|
| 1574 | 1581 | if (oldAuction != null &&
|
| --- | --- | |
| 1584 | 1591 | saveDB();
|
| 1585 | 1592 | }
|
| 1586 | 1593 |
|
| 1594 | ////////////////////////////////////////
|
| 1595 | // Passthrough functions to AuctionInfo
|
| 1596 |
|
| 1587 | 1597 | /* Accessor functions that are passed through directly down
|
| 1588 | 1598 | * to the internal AuctionInfo object.
|
| 1589 | 1599 | */
|
| --- | --- | |
| 1605 | 1615 | public int getQuantity() { return getAuction().getQuantity(); }
|
| 1606 | 1616 | public int getNumBidders() { return getAuction().getNumBidders(); }
|
| 1607 | 1617 |
|
| 1608 | |
|
| 1609 | 1618 | public String getSeller() { return getAuction().getSellerName(); }
|
| 1610 | 1619 | public String getHighBidder() { return getAuction().getHighBidder(); }
|
| 1611 | 1620 | public String getHighBidderEmail() { return getAuction().getHighBidderEmail(); }
|
| --- | --- | |
| 1795 | 1804 | * otherwise an AuctionEntry will be loaded and returned.
|
| 1796 | 1805 | */
|
| 1797 | 1806 | public static AuctionEntry findByIdentifier(String identifier) {
|
| 1798 | | AuctionInfo ai = AuctionInfo.findFirstBy("identifier", identifier);
|
| 1799 | | AuctionEntry ae = null;
|
| 1807 | AuctionEntry ae = findFirstBy("identifier", identifier);
|
| 1800 | 1808 |
|
| 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 | }
|
| 1804 | 1814 | }
|
| 1805 | 1815 |
|
| 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 |
|
| 1806 | 1824 | return ae;
|
| 1807 | 1825 | }
|
| 1808 | 1826 |
|