ExtentSummary.java

  1. /**
  2.  * ExtentSummary
  3.  */
  4. package gov.usgs.earthquake.indexer;

  5. import java.math.BigDecimal;
  6. import java.util.Date;
  7. import java.util.Map;

  8. import gov.usgs.util.XmlUtils;

  9. /**
  10.  * Stores ExtentSummary information for products.
  11.  */
  12. public class ExtentSummary {
  13.   private Long id;
  14.   private Date startTime;
  15.   private Date endTime;
  16.   private BigDecimal maxLatitude;
  17.   private BigDecimal minLatitude;
  18.   private BigDecimal maxLongitude;
  19.   private BigDecimal minLongitude;

  20.   /** Property for Extent Start time */
  21.   public static final String EXTENT_START_TIME_PROPERTY = "starttime";
  22.   /** Property for Extent End Time */
  23.   public static final String EXTENT_END_TIME_PROPERTY = "endtime";
  24.   /** Property for Extent Max Lat */
  25.   public static final String EXTENT_MAX_LAT_PROPERTY = "maximum-latitude";
  26.   /** Property for Extent Min lat */
  27.   public static final String EXTENT_MIN_LAT_PROPERTY = "minimum-latitude";
  28.   /** Property for Extent Max Long */
  29.   public static final String EXTENT_MAX_LONG_PROPERTY = "maximum-longitude";
  30.   /** Property for Extent Min Long */
  31.   public static final String EXTENT_MIN_LONG_PROPERTY = "minimum-longitude";


  32.   /** Empty constructor */
  33.   public ExtentSummary() {
  34.     //Do nothing; this is if member vars are to be set manually
  35.   }

  36.   /**
  37.    * Builds an extentSummary from product properties. If the product has none of
  38.    * the properties, the ExtentSummary is still built.
  39.    *
  40.    * @param product the productSummary to build from
  41.    */
  42.   public ExtentSummary(ProductSummary product) {
  43.     Map<String,String> properties = product.getProperties();

  44.     id = product.getIndexId();

  45.     if (properties.get(EXTENT_START_TIME_PROPERTY) != null) {
  46.       startTime = XmlUtils.getDate(properties.get(EXTENT_START_TIME_PROPERTY));
  47.     }
  48.     if (properties.get(EXTENT_END_TIME_PROPERTY) != null) {
  49.       endTime = XmlUtils.getDate(properties.get(EXTENT_END_TIME_PROPERTY));
  50.     }
  51.     if (properties.get(EXTENT_MAX_LAT_PROPERTY) != null) {
  52.       maxLatitude = new BigDecimal(properties.get(EXTENT_MAX_LAT_PROPERTY));
  53.     }
  54.     if (properties.get(EXTENT_MAX_LONG_PROPERTY) != null) {
  55.       maxLongitude = new BigDecimal(properties.get(EXTENT_MAX_LONG_PROPERTY));
  56.     }
  57.     if (properties.get(EXTENT_MIN_LAT_PROPERTY) != null) {
  58.       minLatitude = new BigDecimal(properties.get(EXTENT_MIN_LAT_PROPERTY));
  59.     }
  60.     if (properties.get(EXTENT_MIN_LONG_PROPERTY) != null) {
  61.       minLongitude = new BigDecimal(properties.get(EXTENT_MIN_LONG_PROPERTY));
  62.     }
  63.   }

  64.   /**
  65.    * Returns TRUE if this extent should be put in the extentSummary table (at
  66.    * least one property is not null)
  67.    * @return boolean
  68.    */
  69.   public boolean isValid() {
  70.     return
  71.       startTime != null ||
  72.       endTime != null ||
  73.       maxLatitude != null ||
  74.       maxLongitude != null ||
  75.       minLatitude != null ||
  76.       minLongitude != null;
  77.   }

  78.   /** @return index Id */
  79.   public Long getIndexId() {
  80.     return this.id;
  81.   }

  82.   /** @param id indexId to set */
  83.   public void setIndexId(Long id) {
  84.     this.id = id;
  85.   }

  86.   /** @return startTime */
  87.   public Date getStartTime() {
  88.     return this.startTime;
  89.   }

  90.   /** @param startTime date to set */
  91.   public void setStartTime(Date startTime) {
  92.     this.startTime = startTime;
  93.   }

  94.   /** @return endTime */
  95.   public Date getEndTime() {
  96.     return this.endTime;
  97.   }

  98.   /** @param endTime date to set */
  99.   public void setEndTime(Date endTime) {
  100.     this.endTime = endTime;
  101.   }

  102.   /** @return maxLatitude */
  103.   public BigDecimal getMaxLatitude() {
  104.     return this.maxLatitude;
  105.   }

  106.   /** @param maxLatitude BigDecimal to set */
  107.   public void setMaxLatitude(BigDecimal maxLatitude) {
  108.     this.maxLatitude = maxLatitude;
  109.   }

  110.   /** @return minLatitude */
  111.   public BigDecimal getMinLatitude() {
  112.     return this.minLatitude;
  113.   }

  114.   /** @param minLatitude BigDecimal to set */
  115.   public void setMinLatitude(BigDecimal minLatitude) {
  116.     this.minLatitude = minLatitude;
  117.   }

  118.   /** @return maxLongitude */
  119.   public BigDecimal getMaxLongitude() {
  120.     return this.maxLongitude;
  121.   }

  122.   /** @param maxLongitude BigDecimal to set */
  123.   public void setMaxLongitude(BigDecimal maxLongitude) {
  124.     this.maxLongitude = maxLongitude;
  125.   }

  126.   /** @return minLongitude */
  127.   public BigDecimal getMinLongitude() {
  128.     return this.minLongitude;
  129.   }

  130.   /** @param minLongitude to set */
  131.   public void setMinLongitude(BigDecimal minLongitude) {
  132.     this.minLongitude = minLongitude;
  133.   }

  134. }