EventSummary.java

  1. package gov.usgs.earthquake.indexer;

  2. import java.math.BigDecimal;
  3. import java.util.Date;
  4. import java.util.HashMap;
  5. import java.util.Map;

  6. /**
  7.  * Summary of an Event and its products.
  8.  */
  9. public class EventSummary implements Comparable<EventSummary> {

  10.     /** The product index id for the original event. */
  11.     private Long indexId;

  12.     /** Event attributes. */
  13.     private String source;
  14.     private String sourceCode;
  15.     private Date time;
  16.     private BigDecimal latitude;
  17.     private BigDecimal longitude;
  18.     private BigDecimal depth;
  19.     private BigDecimal magnitude;
  20.     private boolean deleted = false;

  21.     /** A map of all event codes associated with this event. */
  22.     private final Map<String, String> eventCodes = new HashMap<String, String>();

  23.     /** Summary properties for an event. */
  24.     private final Map<String, String> properties = new HashMap<String, String>();

  25.     /**
  26.      * Create a new EventSummary.
  27.      */
  28.     public EventSummary() {
  29.     }

  30.     /** @param indexId to set */
  31.     public void setIndexId(Long indexId) {
  32.         this.indexId = indexId;
  33.     }

  34.     /** @return indexID */
  35.     public Long getIndexId() {
  36.         return indexId;
  37.     }

  38.     /**
  39.      * Combines source + source code for ID or returns null
  40.      * @return Id or null
  41.      */
  42.     public String getId() {
  43.         if (source != null && sourceCode != null) {
  44.             return source + sourceCode;
  45.         }
  46.         return null;
  47.     }

  48.     /** @return source */
  49.     public String getSource() {
  50.         return source;
  51.     }

  52.     /** @param source to set */
  53.     public void setSource(String source) {
  54.         this.source = source;
  55.     }

  56.     /** @return sourceCode */
  57.     public String getSourceCode() {
  58.         return sourceCode;
  59.     }

  60.     /** @param sourceCode to set */
  61.     public void setSourceCode(String sourceCode) {
  62.         this.sourceCode = sourceCode;
  63.     }

  64.     /** @return time */
  65.     public Date getTime() {
  66.         return time;
  67.     }

  68.     /** @param time to set */
  69.     public void setTime(Date time) {
  70.         this.time = time;
  71.     }

  72.     /** @return latitude */
  73.     public BigDecimal getLatitude() {
  74.         return latitude;
  75.     }

  76.     /** @param latitude to set */
  77.     public void setLatitude(BigDecimal latitude) {
  78.         this.latitude = latitude;
  79.     }

  80.     /** @return longitude */
  81.     public BigDecimal getLongitude() {
  82.         return longitude;
  83.     }

  84.     /** @param longitude to set */
  85.     public void setLongitude(BigDecimal longitude) {
  86.         this.longitude = longitude;
  87.     }

  88.     /** @return depth */
  89.     public BigDecimal getDepth() {
  90.         return depth;
  91.     }

  92.     /** @param depth to set */
  93.     public void setDepth(BigDecimal depth) {
  94.         this.depth = depth;
  95.     }

  96.     /** @return magnitude */
  97.     public BigDecimal getMagnitude() {
  98.         return magnitude;
  99.     }

  100.     /** @param magnitude to set */
  101.     public void setMagnitude(BigDecimal magnitude) {
  102.         this.magnitude = magnitude;
  103.     }

  104.     /** @param deleted to set */
  105.     public void setDeleted(final boolean deleted) {
  106.         this.deleted = deleted;
  107.     }

  108.     /** @return deleted */
  109.     public boolean isDeleted() {
  110.         return deleted;
  111.     }

  112.     /**
  113.      * These properties are derived from product properties, and are those
  114.      * desirable for searching at an event level.
  115.      *
  116.      * @return The properties of this event.
  117.      */
  118.     public Map<String, String> getProperties() {
  119.         return this.properties;
  120.     }

  121.     /**
  122.      *
  123.      * @return A map of event codes associated with this event.
  124.      */
  125.     public Map<String, String> getEventCodes() {
  126.         return this.eventCodes;
  127.     }

  128.     @Override
  129.     public int compareTo(EventSummary that) {
  130.         int r;

  131.         r = this.getSource().compareTo(that.getSource());
  132.         if (r != 0) {
  133.             return r;
  134.         }
  135.         r = this.getSourceCode().compareTo(that.getSourceCode());

  136.         return r;
  137.     }

  138. }