Class EQMessageProductCreator

  • All Implemented Interfaces:
    ProductCreator

    public class EQMessageProductCreator
    extends java.lang.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 Detail

      • XML_CONTENT_TYPE

        public static final java.lang.String XML_CONTENT_TYPE
        Static var for the xml content type
        See Also:
        Constant Field Values
      • EQMESSAGE_CONTENT_PATH

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

        public static final java.lang.String CONTENTS_XML_PATH
        Path to contests xml
        See Also:
        Constant Field Values
      • GENERAL_TEXT_TYPE

        public static final java.lang.String GENERAL_TEXT_TYPE
        Type for general text
        See Also:
        Constant Field Values
      • GENERAL_TEXT_ADDONS

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

        public static final java.lang.String SCITECH_TEXT_TYPE
        Type for scitech text
        See Also:
        Constant Field Values
      • SCITECH_TEXT_ADDONS

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

        public static final java.lang.String IMPACT_TEXT_TYPE
        Type for impact text
        See Also:
        Constant Field Values
      • IMPACT_TEXT_ADDONS

        public static final java.lang.String[] IMPACT_TEXT_ADDONS
        String array for impact text addons
      • GENERAL_LINK_TYPE

        public static final java.lang.String GENERAL_LINK_TYPE
        Selected link type products have a mapping.
        See Also:
        Constant Field Values
      • GENERAL_LINK_ADDONS

        public static final java.lang.String[] GENERAL_LINK_ADDONS
        String array for general link addons
      • SCITECH_LINK_TYPE

        public static final java.lang.String SCITECH_LINK_TYPE
        Type for scitech link
        See Also:
        Constant Field Values
      • SCITECH_LINK_ADDONS

        public static final java.lang.String[] SCITECH_LINK_ADDONS
        String array for scitech link
      • IMPACT_LINK_TYPE

        public static final java.lang.String IMPACT_LINK_TYPE
        Type for impact link
        See Also:
        Constant Field Values
      • IMPACT_LINK_ADDONS

        public static final java.lang.String[] IMPACT_LINK_ADDONS
        String array for impact link
    • Constructor Detail

      • EQMessageProductCreator

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

      • getEQMessageProducts

        public java.util.List<Product> getEQMessageProducts​(gov.usgs.ansseqmsg.EQMessage message)
                                                     throws java.lang.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:
        java.lang.Exception - if error occurs
      • getEQMessageProducts

        public java.util.List<Product> getEQMessageProducts​(java.lang.String rawEqxml)
                                                     throws java.lang.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:
        java.lang.Exception - if error occurs
      • getEQMessageProducts

        public java.util.List<Product> getEQMessageProducts​(gov.usgs.ansseqmsg.EQMessage message,
                                                            java.lang.String rawEqxml)
                                                     throws java.lang.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:
        java.lang.Exception - if error occurs
      • getEventProducts

        protected java.util.List<Product> getEventProducts​(gov.usgs.ansseqmsg.Event event)
                                                    throws java.lang.Exception
        Get products from an event.
        Parameters:
        event - the event containing products.
        Returns:
        a list of created products.
        Throws:
        java.lang.Exception - if error occurs
      • getOriginProducts

        protected java.util.List<Product> getOriginProducts​(java.util.List<gov.usgs.ansseqmsg.Origin> origins,
                                                            gov.usgs.ansseqmsg.Event event)
                                                     throws java.lang.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:
        java.lang.Exception - if error occurs
      • getMagnitudeProducts

        protected java.util.List<Product> getMagnitudeProducts​(java.util.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 java.util.List<Product> getFocalMechanismProducts​(java.util.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 java.util.List<Product> getProductLinkProducts​(gov.usgs.ansseqmsg.ProductLink link)
                                                          throws java.lang.Exception
        Get product(s) from a ProductLink object.
        Parameters:
        link - the link object.
        Returns:
        a list of found products.
        Throws:
        java.lang.Exception - if error occurs
      • getCommentProducts

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

        protected Product getProduct​(java.lang.String type,
                                     java.lang.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 java.lang.String getCubeCode​(java.util.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()
        Returns:
        boolean sendOriginWhenPhasesExist
      • setSendOriginWhenPhasesExist

        public void setSendOriginWhenPhasesExist​(boolean sendOriginWhenPhasesExist)
        Parameters:
        sendOriginWhenPhasesExist - boolean to set
      • 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 java.util.List<Product> getProducts​(java.io.File file)
                                            throws java.lang.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:
        java.lang.Exception - if error occurs
      • getLinkAddonProductType

        public java.lang.String getLinkAddonProductType​(java.lang.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 java.lang.String getTextAddonProductType​(java.lang.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.