Package gov.usgs.earthquake.eids
Class EQMessageProductCreator
java.lang.Object
gov.usgs.earthquake.eids.EQMessageProductCreator
- All Implemented Interfaces:
ProductCreator
Convert EQXML messages to Products.
Product source is EQMessage/Source.
Product type is "origin", "magnitude", or "addon". Types may be prefixed by non-Public Event/Scope, and suffixed by non-Actual Event/Usage (internal-magnitude-scenario).
Product code is Event/DataSource + Event/EventId. When an addon product, either ProductLink/Code or Comment/TypeKey is appended to code.
Product updateTime is EQMessage/Sent.
Origin properties appear only on origin type products. Magnitude properties appear on both magnitude and origin products.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Path to contests xmlstatic final String
Path to content where source message is stored in created product.static final String[]
String array for general link addonsstatic final String
Selected link type products have a mapping.static final String[]
Empty string array for general text addonsstatic final String
Type for general textstatic final String[]
String array for impact linkstatic final String
Type for impact linkstatic final String[]
String array for impact text addonsstatic final String
Type for impact textstatic final String[]
String array for scitech linkstatic final String
Type for scitech linkstatic final String[]
Empty string array for scitech text addonsstatic final String
Type for scitech textstatic final String
Static var for the xml content type -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCommentProducts
(gov.usgs.ansseqmsg.Comment comment) Get product(s) from a Comment object.protected Content
protected String
getCubeCode
(List<gov.usgs.ansseqmsg.Comment> comments) Extract a CUBE_Code from a Comment.getEQMessageProducts
(gov.usgs.ansseqmsg.EQMessage message) Get all the products contained in an EQMessage.getEQMessageProducts
(gov.usgs.ansseqmsg.EQMessage message, String rawEqxml) Get all the products contained in an EQMessage.getEQMessageProducts
(String rawEqxml) Get all the products contained in an EQMessage.getEventProducts
(gov.usgs.ansseqmsg.Event event) Get products from an event.getFocalMechanismProducts
(List<gov.usgs.ansseqmsg.MomentTensor> momentTensors) Gets a list of Focal Mechanism products from momentTensorsgetLinkAddonProductType
(String addonType) Map from cube style link addon to product type.getMagnitudeProducts
(List<gov.usgs.ansseqmsg.Magnitude> magnitudes) Build magnitude products.getOriginProducts
(List<gov.usgs.ansseqmsg.Origin> origins, gov.usgs.ansseqmsg.Event event) Get origin product(s).protected Product
getProduct
(String type, String action) Build a product skeleton based on the current state.getProductLinkProducts
(gov.usgs.ansseqmsg.ProductLink link) Get product(s) from a ProductLink object.getProducts
(File file) Parse product(s) from a file or directory.getTextAddonProductType
(String addonType) Map from cube style text addon to product type.boolean
Unsupported functionality for an EQMessageProductCreatorboolean
boolean
void
setSendMechanismWhenPhasesExist
(boolean sendMechanismWhenPhasesExist) Unsupported functionality for an EQMessageProductCreatorvoid
setSendOriginWhenPhasesExist
(boolean sendOriginWhenPhasesExist) Enable sending origin when phases existvoid
setValidate
(boolean validate) Enable validation during getProducts method.
-
Field Details
-
XML_CONTENT_TYPE
Static var for the xml content type- See Also:
-
EQMESSAGE_CONTENT_PATH
Path to content where source message is stored in created product.- See Also:
-
CONTENTS_XML_PATH
Path to contests xml- See Also:
-
GENERAL_TEXT_TYPE
Type for general text- See Also:
-
GENERAL_TEXT_ADDONS
Empty string array for general text addons -
SCITECH_TEXT_TYPE
Type for scitech text- See Also:
-
SCITECH_TEXT_ADDONS
Empty string array for scitech text addons -
IMPACT_TEXT_TYPE
Type for impact text- See Also:
-
IMPACT_TEXT_ADDONS
String array for impact text addons -
GENERAL_LINK_TYPE
Selected link type products have a mapping.- See Also:
-
GENERAL_LINK_ADDONS
String array for general link addons -
SCITECH_LINK_TYPE
Type for scitech link- See Also:
-
SCITECH_LINK_ADDONS
String array for scitech link -
IMPACT_LINK_TYPE
Type for impact link- See Also:
-
IMPACT_LINK_ADDONS
String array for impact link
-
-
Constructor Details
-
EQMessageProductCreator
public EQMessageProductCreator()Default, empty constructor.
-
-
Method Details
-
getEQMessageProducts
Get all the products contained in an EQMessage. Same as getEQMessageProducts(message, null).- Parameters:
message
- the EQMessage containing products.- Returns:
- a list of created products.
- Throws:
Exception
- if error occurs
-
getEQMessageProducts
Get all the products contained in an EQMessage. Parses rawEqxml string into an EQMessage, but preserves raw eqxml in created products. Same as getEQMessageProducts(EQMessageParser.parse(rawEqxml), rawEqxml);- Parameters:
rawEqxml
- the raw EQXML message.- Returns:
- a list of created products.
- Throws:
Exception
- if error occurs
-
getEQMessageProducts
public List<Product> getEQMessageProducts(gov.usgs.ansseqmsg.EQMessage message, String rawEqxml) throws Exception Get all the products contained in an EQMessage.- Parameters:
message
- the EQMessage containing products.rawEqxml
- the raw EQXML message. When null, an EQXML message is serialized from the object.- Returns:
- a list of created products.
- Throws:
Exception
- if error occurs
-
getEventProducts
Get products from an event.- Parameters:
event
- the event containing products.- Returns:
- a list of created products.
- Throws:
Exception
- if error occurs
-
getOriginProducts
protected List<Product> getOriginProducts(List<gov.usgs.ansseqmsg.Origin> origins, gov.usgs.ansseqmsg.Event event) throws Exception Get origin product(s). This implementation only creates one origin (the first one) regardless of how many origins are provided.- Parameters:
origins
- the list of origins.event
- A specific event- Returns:
- a list of created products.
- Throws:
Exception
- if error occurs
-
getMagnitudeProducts
Build magnitude products. This implementation builds at most one magnitude product (the first).- Parameters:
magnitudes
- a list of candidate magsnitude objects.- Returns:
- a list of built magnitude products, which may be empty.
-
getFocalMechanismProducts
protected List<Product> getFocalMechanismProducts(List<gov.usgs.ansseqmsg.MomentTensor> momentTensors) Gets a list of Focal Mechanism products from momentTensors- Parameters:
momentTensors
- List of Moment Tensors- Returns:
- a list of products
-
getProductLinkProducts
protected List<Product> getProductLinkProducts(gov.usgs.ansseqmsg.ProductLink link) throws Exception Get product(s) from a ProductLink object.- Parameters:
link
- the link object.- Returns:
- a list of found products.
- Throws:
Exception
- if error occurs
-
getCommentProducts
Get product(s) from a Comment object.- Parameters:
comment
- the comment object.- Returns:
- a list of found products.
- Throws:
Exception
- if error occurs
-
getProduct
Build a product skeleton based on the current state. Product type is : [internal-](origin,magnitude,addon)[-(scenario|test)] where the optional scope is not "Public", and the optional usage is not "Actual".- Parameters:
type
- short product type, like "origin", "magnitude".action
- override the global message action.- Returns:
- a Product so that properties and content can be added.
-
getContentsXML
- Returns:
- a buffer of XML content
-
getCubeCode
Extract a CUBE_Code from a Comment. This is the ISTI convention for preserving CUBE information in EQXML messages. Checks a list of Comment objects for one with TypeKey="CUBE_Code" and Text="CUBE_Code X", where X is the returned cube code.- Parameters:
comments
- the list of comments.- Returns:
- the cube code, or null if not found.
-
isSendOriginWhenPhasesExist
public boolean isSendOriginWhenPhasesExist()- Specified by:
isSendOriginWhenPhasesExist
in interfaceProductCreator
- Returns:
- boolean sendOriginWhenPhasesExist
-
setSendOriginWhenPhasesExist
public void setSendOriginWhenPhasesExist(boolean sendOriginWhenPhasesExist) Description copied from interface:ProductCreator
Enable sending origin when phases exist- Specified by:
setSendOriginWhenPhasesExist
in interfaceProductCreator
- Parameters:
sendOriginWhenPhasesExist
- boolean to set
-
setSendMechanismWhenPhasesExist
public void setSendMechanismWhenPhasesExist(boolean sendMechanismWhenPhasesExist) Unsupported functionality for an EQMessageProductCreator- Specified by:
setSendMechanismWhenPhasesExist
in interfaceProductCreator
- Parameters:
sendMechanismWhenPhasesExist
- boolean to set
-
isSendMechanismWhenPhasesExist
public boolean isSendMechanismWhenPhasesExist()Unsupported functionality for an EQMessageProductCreator- Specified by:
isSendMechanismWhenPhasesExist
in interfaceProductCreator
- Returns:
- whether to send mechanism when phases exist
-
isValidate
public boolean isValidate()- Specified by:
isValidate
in interfaceProductCreator
- Returns:
- whether product creator is currently validating.
-
setValidate
public void setValidate(boolean validate) Description copied from interface:ProductCreator
Enable validation during getProducts method.- Specified by:
setValidate
in interfaceProductCreator
- Parameters:
validate
- boolean to enable/disable
-
getProducts
Description copied from interface:ProductCreator
Parse product(s) from a file or directory.- Specified by:
getProducts
in interfaceProductCreator
- Parameters:
file
- file or directory.- Returns:
- list of parsed products.
- Throws:
Exception
- if error occurs
-
getLinkAddonProductType
Map from cube style link addon to product type.- Parameters:
addonType
- String to find correct link type- Returns:
- null if link should not be converted to a product.
-
getTextAddonProductType
Map from cube style text addon to product type.- Parameters:
addonType
- to find correct addon type- Returns:
- null if comment should not be converted to a product.
-