Package gov.usgs.earthquake.indexer
Class Event
java.lang.Object
gov.usgs.earthquake.indexer.Event
- All Implemented Interfaces:
Comparable<Event>
An event is a group of products that are nearby in space and time.
Which products appear in an event depend primarily on the
ProductIndexQuery.ResultType that is used when retrieving an event from the
index. Unless CURRENT is used, you may not get what you expect.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProduct
(ProductSummary summary) A convenience method for adding a product summary to an event object.int
getAllEventCodes
(boolean includeDeleted) Get a map of all event ids associated with this event, recognizing that one source may have multiple codes (they broke the rules, but it happens).Get all event products (including those that are deleted or superseded).Get all products associated with event, even if they are deleted.getDepth()
Get the preferred depth for this event.Deprecated.getEventCodes
(List<ProductSummary> summaries) Deprecated.usegetAllEventCodes(boolean)
instead.Get the event id.protected ProductSummary
Get the product used for eventsource and eventsourcecode.Summarize this event into preferred values.Get the index id.Get the preferred latitude for this event.Get the preferred longitude for this event.Get the preferred magntitude for this event.static ProductSummary
getMostPreferred
(List<ProductSummary> products, String preferredType, String preferredNotNullProperty) Find the most preferred product.Get the most preferred magnitude product for event.Get the most preferred origin-like product for this event.getPreferredProduct
(String type) Get the preferred product of a specific type.static ProductSummary
Get the most preferred product from a list of products.Get preferred products of all types.Get a list of all the preferred products sorted based on their authoritative weightsGet all event products that have not been deleted or superseded as a list.Get the event products.getProducts
(String type) Convenience method to get products of a given type.Get the most recent product with origin properties (id, lat, lon, time).static List<ProductSummary>
getSortedMostPreferredFirst
(List<ProductSummary> products) Sort a list of products, most preferred first.Get the preferred source for this event.Get the preferred source code for this event.Return a list of sub-events that make up this event.getTime()
Get the preferred time for this event.Event update time is most recent product update time.static List<ProductSummary>
getWithEventId
(List<ProductSummary> products) Remove deleted products from the list.static List<ProductSummary>
getWithoutDeleted
(List<ProductSummary> products) Remove deleted products from the list.static List<ProductSummary>
getWithoutSuperseded
(List<ProductSummary> products) Remove old versions of products from the list.boolean
hasAssociateProduct
(Event otherEvent) Check if this event has an associate product for another given Event.boolean
hasDisassociateProduct
(Event otherEvent) Check if this event has an disassociate product for another given Event.boolean
isAssociated
(Event that) Same as isAssociated(that, new DefaultAssociator());boolean
isAssociated
(Event that, Associator associator) Check if an event is associated to this event.boolean
void
Depending on logger level, takes in summary data and appends to bufferstatic boolean
productHasOriginProperties
(ProductSummary product) Check if a product can define an event (id, lat, lon, time).void
removeProduct
(ProductSummary summary) A convenience method for removing a product summary from an event object.void
setIndexId
(Long indexId) Set the index id.void
setProducts
(Map<String, List<ProductSummary>> newProducts) Set products.
-
Field Details
-
ORIGIN_PRODUCT_TYPE
Origin product type- See Also:
-
ASSOCIATE_PRODUCT_TYPE
Associate product type- See Also:
-
DISASSOCIATE_PRODUCT_TYPE
Disassociate product type- See Also:
-
OTHEREVENTSOURCE_PROPERTY
Property for othereventsource- See Also:
-
OTHEREVENTSOURCECODE_PROPERTY
Property for othereventsourcecode- See Also:
-
-
Constructor Details
-
Event
public Event()Default constructor. All fields are set to null, and the list of products is empty. -
Event
Construct an event with only an indexId. The products map will be empty.- Parameters:
indexId
- the indexId to set.
-
Event
Construct and event with an indexId and a list of products.- Parameters:
indexId
- the product index id.products
- the list of products.
-
Event
Copy constructor for event. The products associated with this event are not cloned, but the list of products is.- Parameters:
copy
- the event to clone.
-
-
Method Details
-
getIndexId
Get the index id.- Returns:
- the indexId or null if one hasn't been assigned.
-
setIndexId
Set the index id.- Parameters:
indexId
- the indexId to set.
-
getAllProducts
Get all products associated with event, even if they are deleted.- Returns:
- all products associated with event.
-
getProducts
Get the event products. Only returns products that have not been deleted or superseded. This method returns a copy of the underlying product map that has been filtered to remove deleted products.- Returns:
- a map of event products.
- See Also:
-
setProducts
Set products. ProductSummaries are not cloned, but lists are.- Parameters:
newProducts
- the products to set.
-
addProduct
A convenience method for adding a product summary to an event object. Note: this method does not update any associated product index.- Parameters:
summary
- the summary to add to this event.
-
removeProduct
A convenience method for removing a product summary from an event object. Note: this method does not update any associated product index.- Parameters:
summary
- the summary to remove from this event.
-
getProducts
Convenience method to get products of a given type. This method always returns a copy of the internal list, and may be empty. Only returns products that have not been deleted or superseded.- Parameters:
type
- the product type.- Returns:
- a list of products of that type, which may be empty.
-
getAllProductList
Get all event products (including those that are deleted or superseded).- Returns:
- a list of event products.
-
getProductList
Get all event products that have not been deleted or superseded as a list.- Returns:
- a list of event products.
-
getPreferredProducts
Get preferred products of all types. This map will contain one product of each type, chosen by preferred weight.- Returns:
- a map from product type to the preferred product of that type.
-
getPreferredProduct
Get the preferred product of a specific type.- Parameters:
type
- type of product to get.- Returns:
- most preferred product of that type, or null if no product of that type is associated.
-
getEventCodes
Deprecated.usegetAllEventCodes(boolean)
instead.Get a map of all event ids associated with this event. Same as Event.getEventCodes(this.getAllProductList());- Returns:
- map of all event ids associated with this event.
-
getEventCodes
Deprecated.usegetAllEventCodes(boolean)
instead.Get a map of all event ids associated with this event. Map key is eventSource, Map value is eventSourceCode.- Parameters:
summaries
- the summaries list to extract event codes from.- Returns:
- map of all event ids associated with this event.
-
getAllEventCodes
Get a map of all event ids associated with this event, recognizing that one source may have multiple codes (they broke the rules, but it happens).- Parameters:
includeDeleted
- whether to include ids for sub events whose products have all been deleted.- Returns:
- Map from source to a list of codes from that source.
-
getPreferredProductsSorted
Get a list of all the preferred products sorted based on their authoritative weights- Returns:
- sorted list of ProductSummary objects
-
getEventId
Get the event id. The event id is the combination of event source and event source code.- Returns:
- the event id, or null if either event source or event source code is null.
- See Also:
-
getSource
Get the preferred source for this event. If an origin product exists, it's value is used.- Returns:
- Source from preferred product or null
-
getSourceCode
Get the preferred source code for this event. If an origin product exists, it's value is used.- Returns:
- Source code from preferred product or null
-
getEventIdProduct
Get the product used for eventsource and eventsourcecode. Event ID comes from the preferred origin product.- Returns:
- The most preferred product summary. This summary is used to determine the eventsouce and eventsourcecode.
- See Also:
-
getProductWithOriginProperties
Get the most recent product with origin properties (id, lat, lon, time). NOTE: this product may have been superseded by a delete. When an event has not been deleted, this method should be consistent withgetPreferredOriginProduct()
. Products are checked in the following order, sorted most preferred first within each group. The first matching product is returned:- "origin" products not superseded or deleted, that have origin properties
- "origin" products superseded by a delete, that have origin properties
- products not superseded or deleted, that have origin properties
- products superseded by a delete, that have origin properties
- Returns:
- the most recent product with origin properties.
- See Also:
-
getPreferredOriginProduct
Get the most preferred origin-like product for this event. The event is considered deleted if the returned product is null, deleted, or does not have origin properties. Information about the event may still be available usinggetProductWithOriginProperties()
. Products are checked in the following order, sorted most preferred first within each group. The first matching product is returned:- If any "origin" products exist:
- "origin" products not superseded or deleted, that have origin properties.
- "origin" products not superseded, that have an event id.
- If no "origin" products exist:
- products not superseded or deleted, that have origin properties.
- products not superseded, that have an event id.
- Returns:
- the most recent product with origin properties.
- See Also:
- If any "origin" products exist:
-
productHasOriginProperties
Check if a product can define an event (id, lat, lon, time).- Parameters:
product
- product to check.- Returns:
- true if product has id, lat, lon, and time properties.
-
getPreferredMagnitudeProduct
Get the most preferred magnitude product for event. Currently callsgetPreferredOriginProduct()
.- Returns:
- the most preferred magnitude product for event.
-
getTime
Get the preferred time for this event. If an origin product exists, it's value is used.- Returns:
- Time from preferred product or null
-
getLatitude
Get the preferred latitude for this event. If an origin product exists, it's value is used.- Returns:
- Latitude from preferred product or null
-
getLongitude
Get the preferred longitude for this event. If an origin product exists, it's value is used.- Returns:
- Longitude from preferred product or null
-
getUpdateTime
Event update time is most recent product update time.- Returns:
- the most recent product update time.
-
getDepth
Get the preferred depth for this event. If an origin product exists, it's value is used.- Returns:
- Depth from preferred product or null
-
getMagnitude
Get the preferred magntitude for this event. If an origin product exists, it's value is used.- Returns:
- magnitude from preferred product or null
-
isDeleted
public boolean isDeleted()- Returns:
- boolean if the preferred event is deleted
-
getPreferredProduct
Get the most preferred product from a list of products.- Parameters:
all
- a list of products containing only one type of product.- Returns:
- the product with the highest preferred weight, and if tied the most recent update time wins.
-
getEventSummary
Summarize this event into preferred values. NOTE: the event summary may include information from an origin product, even when the preferred origin for the event has been deleted. Use getPreferredOriginProduct() to check the preferred origin of the event.- Returns:
- an event summary.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Event>
-
getMostPreferred
public static ProductSummary getMostPreferred(List<ProductSummary> products, String preferredType, String preferredNotNullProperty) Find the most preferred product. If preferredType is not null, products of this type are favored over those not of this type. If preferredNotNullProperty is not null, products that have this property set are favored over those without this property set.- Parameters:
products
- the list of products to search.preferredType
- the preferred product type, if available.preferredNotNullProperty
- the preferred property name, if available.- Returns:
- The most preferred product summary of the given type.
-
getWithoutDeleted
Remove deleted products from the list.- Parameters:
products
- list of products to filter.- Returns:
- copy of the products list with deleted products removed.
-
getWithEventId
Remove deleted products from the list.- Parameters:
products
- list of products to filter.- Returns:
- copy of the products list with deleted products removed.
-
getWithoutSuperseded
Remove old versions of products from the list.- Parameters:
products
- list of products to filter.- Returns:
- a copy of the products list with products of the same source+type+code but with older updateTimes (superseded) removed.
-
getSortedMostPreferredFirst
Sort a list of products, most preferred first.- Parameters:
products
- the list of products to sort.- Returns:
- a copy of the list sorted with most preferred first.
-
getSubEvents
Return a list of sub-events that make up this event. Event lines are drawn by eventid. Products that have no eventid are included with the sub event whose id is considered preferred.- Returns:
- map from eventid to event object with products for that eventid.
-
hasAssociateProduct
Check if this event has an associate product for another given Event.- Parameters:
otherEvent
- the other event.- Returns:
- true if there is an associate product, false otherwise.
-
hasDisassociateProduct
Check if this event has an disassociate product for another given Event.- Parameters:
otherEvent
- the other event.- Returns:
- true if there is an disassociate product, false otherwise.
-
isAssociated
Same as isAssociated(that, new DefaultAssociator());- Parameters:
that
- an event to test- Returns:
- boolean true if associated, false otherwise
-
isAssociated
Check if an event is associated to this event. Reasons events may be considered disassociated:- Share a common EVENTSOURCE with different EVENTSOURCECODE.
- Either has a disassociate product for the other.
- Preferred location in space and time is NOT nearby, and no other reason to associate.
- Share a common EVENTID
- Either has an associate product for the other.
- Their preferred location in space and time is nearby.
- Parameters:
that
- candidate event to test.associator
- An associator to compare two events- Returns:
- true if associated, false otherwise.
-
log
Depending on logger level, takes in summary data and appends to buffer- Parameters:
logger
- logger object
-
getAllEventCodes(boolean)
instead.