Class EQMessageProductCreator

java.lang.Object
gov.usgs.earthquake.eids.EQMessageProductCreator
All Implemented Interfaces:
ProductCreator

public class EQMessageProductCreator extends Object implements 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 Details

    • XML_CONTENT_TYPE

      public static final String XML_CONTENT_TYPE
      Static var for the xml content type
      See Also:
    • EQMESSAGE_CONTENT_PATH

      public static final String EQMESSAGE_CONTENT_PATH
      Path to content where source message is stored in created product.
      See Also:
    • CONTENTS_XML_PATH

      public static final String CONTENTS_XML_PATH
      Path to contests xml
      See Also:
    • GENERAL_TEXT_TYPE

      public static final String GENERAL_TEXT_TYPE
      Type for general text
      See Also:
    • GENERAL_TEXT_ADDONS

      public static final String[] GENERAL_TEXT_ADDONS
      Empty string array for general text addons
    • SCITECH_TEXT_TYPE

      public static final String SCITECH_TEXT_TYPE
      Type for scitech text
      See Also:
    • SCITECH_TEXT_ADDONS

      public static final String[] SCITECH_TEXT_ADDONS
      Empty string array for scitech text addons
    • IMPACT_TEXT_TYPE

      public static final String IMPACT_TEXT_TYPE
      Type for impact text
      See Also:
    • IMPACT_TEXT_ADDONS

      public static final String[] IMPACT_TEXT_ADDONS
      String array for impact text addons
  • Constructor Details

    • EQMessageProductCreator

      public EQMessageProductCreator()
      Default, empty constructor.
  • Method Details

    • getEQMessageProducts

      public List<Product> getEQMessageProducts(gov.usgs.ansseqmsg.EQMessage message) throws Exception
      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

      public List<Product> getEQMessageProducts(String rawEqxml) throws Exception
      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

      protected List<Product> getEventProducts(gov.usgs.ansseqmsg.Event event) throws Exception
      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

      protected List<Product> getMagnitudeProducts(List<gov.usgs.ansseqmsg.Magnitude> magnitudes)
      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

      protected List<Product> getCommentProducts(gov.usgs.ansseqmsg.Comment comment) throws Exception
      Get product(s) from a Comment object.
      Parameters:
      comment - the comment object.
      Returns:
      a list of found products.
      Throws:
      Exception - if error occurs
    • getProduct

      protected Product getProduct(String type, String action)
      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

      protected Content getContentsXML()
      Returns:
      a buffer of XML content
    • getCubeCode

      protected String getCubeCode(List<gov.usgs.ansseqmsg.Comment> comments)
      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 interface ProductCreator
      Returns:
      boolean sendOriginWhenPhasesExist
    • setSendOriginWhenPhasesExist

      public void setSendOriginWhenPhasesExist(boolean sendOriginWhenPhasesExist)
      Description copied from interface: ProductCreator
      Enable sending origin when phases exist
      Specified by:
      setSendOriginWhenPhasesExist in interface ProductCreator
      Parameters:
      sendOriginWhenPhasesExist - boolean to set
    • setSendMechanismWhenPhasesExist

      public void setSendMechanismWhenPhasesExist(boolean sendMechanismWhenPhasesExist)
      Unsupported functionality for an EQMessageProductCreator
      Specified by:
      setSendMechanismWhenPhasesExist in interface ProductCreator
      Parameters:
      sendMechanismWhenPhasesExist - boolean to set
    • isSendMechanismWhenPhasesExist

      public boolean isSendMechanismWhenPhasesExist()
      Unsupported functionality for an EQMessageProductCreator
      Specified by:
      isSendMechanismWhenPhasesExist in interface ProductCreator
      Returns:
      whether to send mechanism when phases exist
    • isValidate

      public boolean isValidate()
      Specified by:
      isValidate in interface ProductCreator
      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 interface ProductCreator
      Parameters:
      validate - boolean to enable/disable
    • getProducts

      public List<Product> getProducts(File file) throws Exception
      Description copied from interface: ProductCreator
      Parse product(s) from a file or directory.
      Specified by:
      getProducts in interface ProductCreator
      Parameters:
      file - file or directory.
      Returns:
      list of parsed products.
      Throws:
      Exception - if error occurs
    • getLinkAddonProductType

      public String getLinkAddonProductType(String addonType)
      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

      public String getTextAddonProductType(String addonType)
      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.