1 4 package com.openedit.archive.history; 5 6 import java.util.HashMap ; 7 import java.util.Iterator ; 8 import java.util.Map ; 9 10 import org.apache.commons.collections.map.ListOrderedMap; 11 12 import com.openedit.store.Product; 13 14 public class UsageHistory 15 { 16 protected String fieldId; 17 protected String fieldName; 18 protected Map fieldRecords; 19 protected Product fieldProduct; 20 protected int fieldCounter; 21 22 public UsageHistory() 23 { 24 25 } 26 27 public String getName() 28 { 29 return fieldName; 30 } 31 public void setName(String inName) 32 { 33 fieldName = inName; 34 } 35 public Map getRecords() 36 { 37 if (fieldRecords == null) 38 { 39 fieldRecords = ListOrderedMap.decorate(new HashMap ()); 40 } 41 return fieldRecords; 42 } 43 public Iterator getRecordIds() 44 { 45 return getRecords().keySet().iterator(); 46 } 47 public Iterator getRecordData() 48 { 49 return getRecords().values().iterator(); 50 } 51 52 public void addRecord(HistoryRecord inItem) 53 { 54 getRecords().put(inItem.getId(),inItem); 55 } 56 public void removeRecord(HistoryRecord inFound) 57 { 58 getRecords().remove(inFound); 59 } 60 public void clear() 61 { 62 getRecords().clear(); 63 } 64 65 public Product getProduct() 66 { 67 return fieldProduct; 68 } 69 70 public void setProduct(Product inProduct) 71 { 72 fieldProduct = inProduct; 73 } 74 75 public HistoryRecord createNewRecord() 76 { 77 HistoryRecord record = new HistoryRecord(); 78 record.setId(String.valueOf(getProduct().getId() + System.currentTimeMillis() + fieldCounter++ ) ); 79 return record; 80 } 81 } 82 | Popular Tags |