Fix event logging; events were being referred to by entry_id, but we were filling in entry_id with the auction identifier.
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/AuctionEntry.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/event/EventLogger.java view
- M jbidwatcher/trunk/src/com/jbidwatcher/auction/event/EventStatus.java view
| 589 | 590 | |
|---|---|---|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | private EventLogger getEvents() { |
| 887 | if(mEntryEvents == null) mEntryEvents = new EventLogger(get("id"), getTitle()); | |
| 887 | if(mEntryEvents == null) mEntryEvents = new EventLogger(getIdentifier(), getId(), getTitle()); | |
| 888 | 888 | return mEntryEvents; |
| 889 | 889 | } |
| 890 | 890 | |
| --- | --- | |
| 931 | 931 | setComment(curElement.getContents()); |
| 932 | 932 | break; |
| 933 | 933 | case 6: |
| 934 | mEntryEvents = new EventLogger(getIdentifier(), getTitle()); | |
| 934 | mEntryEvents = new EventLogger(getIdentifier(), getId(), getTitle()); | |
| 935 | 935 | mEntryEvents.fromXML(curElement); |
| 936 | 936 | break; |
| 937 | 937 | case 7: |
| --- | --- | |
| 976 | 976 | if(isBidOn()) { |
| 977 | 977 | XMLElement xbid = new XMLElement("bid"); |
| 978 | 978 | xbid.setEmpty(); |
| 979 | xbid.setProperty("quantity", Integer.toString(getInteger("last_bid_quantity"))); | |
| 979 | xbid.setProperty("quantity", Integer.toString(getBidQuantity())); | |
| 980 | 980 | xbid.setProperty("currency", getBid().fullCurrencyName()); |
| 981 | 981 | xbid.setProperty("price", Double.toString(getBid().getValue())); |
| 982 | 982 | if(mBidAt != 0) { |
| 382 | 590 | |
|---|---|---|
| 35 | 35 | /** Records all status messages that are added. |
| 36 | 36 | * |
| 37 | 37 | */ |
| 38 | private String mId =null; | |
| 38 | private String mIdentifier =null; | |
| 39 | 39 | private String mTitle =null; |
| 40 | private Integer mEntryId = null; | |
| 40 | 41 | private List<EventStatus> mAllEvents; |
| 41 | 42 | private final EventStatus mNullEvent = new EventStatus("Nothing has happened.", new Date()); |
| 42 | 43 | |
| --- | --- | |
| 65 | 66 | if(entryField.getTagName().equals("date")) msgtime = Long.parseLong(entryField.getContents()); |
| 66 | 67 | } |
| 67 | 68 | |
| 68 | EventStatus newEvent = new EventStatus(msg, new Date(msgtime), mId, mTitle); | |
| 69 | EventStatus newEvent = new EventStatus(msg, new Date(msgtime), mEntryId, mIdentifier, mTitle); | |
| 69 | 70 | newEvent.setRepeatCount(curCount); |
| 70 | 71 | newEvent.saveDB(); |
| 71 | 72 | |
| --- | --- | |
| 103 | 104 | return(xmlLog); |
| 104 | 105 | } |
| 105 | 106 | |
| 106 | public EventLogger(String identifier, String title) { | |
| 107 | mId = identifier; | |
| 107 | public EventLogger(String identifier, Integer entryId, String title) { | |
| 108 | mIdentifier = identifier; | |
| 109 | mEntryId = entryId; | |
| 108 | 110 | mTitle = title; |
| 109 | mNullEvent.setEntryId(mId); | |
| 111 | mNullEvent.setEntryId(mEntryId); | |
| 112 | mNullEvent.setAuctionIdentifier(mIdentifier); | |
| 110 | 113 | mNullEvent.setTitle(mTitle); |
| 111 | 114 | |
| 112 | mAllEvents = EventStatus.findAllByEntry(mId); | |
| 115 | mAllEvents = EventStatus.findAllByEntry(mEntryId, mIdentifier); | |
| 113 | 116 | if(mAllEvents == null) mAllEvents = new ArrayList<EventStatus>(); |
| 114 | 117 | } |
| 115 | 118 | |
| --- | --- | |
| 133 | 136 | if(inStatus.equals(lastStatus.getMessage())) { |
| 134 | 137 | lastStatus.setRepeatCount(lastStatus.getRepeatCount() + 1); |
| 135 | 138 | } else { |
| 136 | whatHappened = new EventStatus(inStatus, new Date(), mId, mTitle); | |
| 139 | whatHappened = new EventStatus(inStatus, new Date(), mEntryId, mIdentifier, mTitle); | |
| 137 | 140 | |
| 138 | 141 | mAllEvents.add(whatHappened); |
| 139 | 142 | ErrorManagement.logMessage(whatHappened.toString()); |
| 490 | 590 | |
|---|---|---|
| 25 | 25 | * |
| 26 | 26 | */ |
| 27 | 27 | public class EventStatus extends ActiveRecord { |
| 28 | private String mAuctionIdentifier; | |
| 29 | ||
| 28 | 30 | // For ActiveRecord construction. |
| 29 | 31 | public EventStatus() { } |
| 30 | 32 | |
| --- | --- | |
| 34 | 36 | setRepeatCount(1); |
| 35 | 37 | } |
| 36 | 38 | |
| 37 | public EventStatus(String what, Date when, String id, String title) { | |
| 39 | public EventStatus(String what, Date when, Integer entryId, String identifier, String title) { | |
| 38 | 40 | setMessage(what); |
| 39 | 41 | setLoggedAt(when); |
| 40 | 42 | setRepeatCount(1); |
| 41 | setEntryId(id); | |
| 43 | setEntryId(entryId); | |
| 44 | setAuctionIdentifier(identifier); | |
| 42 | 45 | setTitle(title); |
| 43 | 46 | } |
| 44 | 47 | |
| --- | --- | |
| 53 | 56 | public String toString() { |
| 54 | 57 | String count = ""; |
| 55 | 58 | if (getRepeatCount() > 1) count = " (" + getRepeatCount() + ")"; |
| 56 | String outStatus = getLoggedAt() + ": " + getEntryId() + " (" + getTitle() + ") - " + getMessage() + count; | |
| 59 | String outStatus = getLoggedAt() + ": " + getAuctionIdentifier() + " (" + getTitle() + ") - " + getMessage() + count; | |
| 57 | 60 | |
| 58 | 61 | return(outStatus); |
| 59 | 62 | } |
| --- | --- | |
| 80 | 83 | return (EventStatus) ActiveRecord.findFirstBy(EventStatus.class, "id", Integer.toString(id)); |
| 81 | 84 | } |
| 82 | 85 | |
| 83 | public static List<EventStatus> findAllByEntry(String entry_id) { | |
| 84 | List<ActiveRecord> records = ActiveRecord.findAllBy(EventStatus.class, "entry_id", entry_id, "created_at ASC"); | |
| 86 | public static List<EventStatus> findAllByEntry(Integer entryId, String identifier) { | |
| 87 | List<ActiveRecord> records = ActiveRecord.findAllBy(EventStatus.class, "entry_id", Integer.toString(entryId), "created_at ASC"); | |
| 85 | 88 | |
| 86 | 89 | if(records != null) { |
| 87 | 90 | List<EventStatus> results = new ArrayList<EventStatus>(records.size()); |
| 88 | 91 | for(ActiveRecord record : records) { |
| 89 | results.add((EventStatus)record); | |
| 92 | EventStatus es = (EventStatus)record; | |
| 93 | es.setAuctionIdentifier(identifier); | |
| 94 | results.add(es); | |
| 90 | 95 | } |
| 91 | 96 | |
| 92 | 97 | return results; |
| --- | --- | |
| 94 | 99 | return null; |
| 95 | 100 | } |
| 96 | 101 | |
| 102 | private String getAuctionIdentifier() { | |
| 103 | return mAuctionIdentifier; | |
| 104 | } | |
| 105 | ||
| 106 | public void setAuctionIdentifier(String identifier) { | |
| 107 | mAuctionIdentifier = identifier; | |
| 108 | } | |
| 109 | ||
| 97 | 110 | public String getMessage() { return getString("message"); } |
| 98 | 111 | public Date getLoggedAt() { return getDate("created_at"); } |
| 99 | public int getRepeatCount() { return getInteger("repeat_count"); } | |
| 112 | public int getRepeatCount() { return getInteger("repeat_count", 1); } | |
| 100 | 113 | public String getTitle() { return getString("title"); } |
| 101 | 114 | public String getEntryId() { return getString("entry_id"); } |
| 102 | 115 | |
| --- | --- | |
| 104 | 117 | public void setLoggedAt(Date loggedAt) { setDate("created_at", loggedAt); } |
| 105 | 118 | public void setRepeatCount(int repeatCount) { setInteger("repeat_count", repeatCount); } |
| 106 | 119 | public void setTitle(String title) { setString("title", title); } |
| 107 | public void setEntryId(String entryId) { setString("entry_id", entryId); } | |
| 120 | public void setEntryId(Integer entryId) { setInteger("entry_id", entryId); } | |
| 108 | 121 | |
| 109 | 122 | public boolean deleteForEntry(int id) { |
| 110 | 123 | return deleteAllEntries(Integer.toString(id)); |
