Class InventoryBasic


  • public class InventoryBasic
    extends java.lang.Object

    An API for the PDMDB inventory stored as an XML document.

    • Constructor Summary

      Constructors 
      Constructor Description
      InventoryBasic​(java.lang.String fileName, java.lang.String tableName)
      Loads the inventory (.xml) document and locates the named table.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void doIndex​(java.lang.String indexField, java.lang.String attributeName)
      Indexes the table.
      java.lang.String getFieldValue​(java.lang.String name)
      Get the value for the named field for the current row.
      java.lang.String getFieldValue​(org.w3c.dom.Element el, java.lang.String name)
      Get the value for the named field in the Element.
      java.lang.String identify​(java.lang.String id, java.lang.String match, java.lang.String reference, java.lang.String idAttributeName)
      Prompts for an identify and updates the current element.
      boolean isCurrentElementNull()  
      void updateField​(java.lang.String name, java.lang.String value)
      Update the value for the named field.
      void write​(java.lang.String fileName)
      Writes the modfied inventory of PDMDBs.
      void writeBackup​(java.lang.String fileNamePrefix)
      Writes the current inventory document.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • inventoryDocument

        org.w3c.dom.Document inventoryDocument
      • inventoryElement

        org.w3c.dom.Element inventoryElement
      • currentElement

        org.w3c.dom.Element currentElement
    • Constructor Detail

      • InventoryBasic

        public InventoryBasic​(java.lang.String fileName,
                              java.lang.String tableName)

        Loads the inventory (.xml) document and locates the named table.

        Parameters:
        fileName - Directory path of XML file.
        tableName - Name of the table (sheet) containing the inventory data.
    • Method Detail

      • doIndex

        public void doIndex​(java.lang.String indexField,
                            java.lang.String attributeName)

        Indexes the table.

        An indexing attribute is added to each table row to allow simple searching using the getElementById method.

        LibreOffice won't recognise and will silently ignore this attribute therefore it will probably not be persistent.

        Parameters:
        indexField - The name of the field (column) in the table that will be used to create the index values.
        attributeName - The name of the attribute that will be created.
      • identify

        public java.lang.String identify​(java.lang.String id,
                                         java.lang.String match,
                                         java.lang.String reference,
                                         java.lang.String idAttributeName)

        Prompts for an identify and updates the current element.

        Parameters:
        id - The candidate identifier.
        match - The identifier must match this regular expression.
        reference - Identifier of existing element to clone.
        idAttributeName - The name of the id attribute.
        Returns:
        The id.
      • write

        public void write​(java.lang.String fileName)

        Writes the modfied inventory of PDMDBs.

        Parameters:
        fileName - Path of database XML file.
      • writeBackup

        public void writeBackup​(java.lang.String fileNamePrefix)

        Writes the current inventory document.

        A timestamp is appended to the created file name after the provided prefix.

        Note that the created files has .xml extension but it is also a valid .fods file that can be opened in LibreOffice.

        Parameters:
        fileNamePrefix - The file name prefix.
      • updateField

        public void updateField​(java.lang.String name,
                                java.lang.String value)

        Update the value for the named field.

        Parameters:
        name - Name of the field to update.
        value - The new value.
      • getFieldValue

        public java.lang.String getFieldValue​(java.lang.String name)

        Get the value for the named field for the current row.

        Parameters:
        name - Name of the field.
        Returns:
        The value.
      • getFieldValue

        public java.lang.String getFieldValue​(org.w3c.dom.Element el,
                                              java.lang.String name)

        Get the value for the named field in the Element.

        Parameters:
        el - The Element.
        name - Name of the field.
        Returns:
        The value.
      • isCurrentElementNull

        public boolean isCurrentElementNull()