Class PgUtils


  • public class PgUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      PgUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static void addChatterMessage​(Credentials credentials, java.lang.String model, int id, java.lang.String message)
      Adds a message in Odoo Chatter ('mail.thread').
      static int getAsInt​(java.sql.ResultSet rs, Field.EdgeDevice field)
      Return the Field of the ResultSet.
      static java.lang.Integer getAsIntegerOrElse​(java.sql.ResultSet rs, Field.EdgeDevice field, java.lang.Integer other)
      Return the Field of the ResultSet; or default value on error.
      static java.lang.String getAsString​(java.sql.ResultSet rs, Field field)
      Return the Field of the ResultSet.
      static java.lang.String getAsStringOrElse​(java.sql.ResultSet rs, Field.EdgeDevice field, java.lang.String other)
      Return the Field of the ResultSet; or default value on error.
      static void write​(Credentials credentials, java.lang.String model, java.lang.Integer[] ids, FieldValue<?>... fieldValues)
      Update a record in Odoo.
      • Methods inherited from class java.lang.Object

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

      • PgUtils

        public PgUtils()
    • Method Detail

      • addChatterMessage

        protected static void addChatterMessage​(Credentials credentials,
                                                java.lang.String model,
                                                int id,
                                                java.lang.String message)
                                         throws OpenemsException
        Adds a message in Odoo Chatter ('mail.thread').
        Parameters:
        credentials - the Odoo credentials
        model - Odoo model (e.g. 'res.partner')
        id - id of model
        message - the message
        Throws:
        OpenemsException - on error
      • write

        public static void write​(Credentials credentials,
                                 java.lang.String model,
                                 java.lang.Integer[] ids,
                                 FieldValue<?>... fieldValues)
                          throws OpenemsException
        Update a record in Odoo.
        Parameters:
        credentials - the Odoo credentials
        model - the Odoo model
        ids - ids of model to update
        fieldValues - fields and values that should be written
        Throws:
        OpenemsException - on error
      • getAsString

        public static java.lang.String getAsString​(java.sql.ResultSet rs,
                                                   Field field)
                                            throws java.sql.SQLException,
                                                   OpenemsException
        Return the Field of the ResultSet.
        Parameters:
        rs - the ResultSet
        field - the EdgeDevice
        Returns:
        the value as String
        Throws:
        java.sql.SQLException - on error
        OpenemsException - on null
      • getAsStringOrElse

        public static java.lang.String getAsStringOrElse​(java.sql.ResultSet rs,
                                                         Field.EdgeDevice field,
                                                         java.lang.String other)
        Return the Field of the ResultSet; or default value on error.
        Parameters:
        rs - the ResultSet
        field - the EdgeDevice field
        other - the default value
        Returns:
        the value as String
      • getAsInt

        public static int getAsInt​(java.sql.ResultSet rs,
                                   Field.EdgeDevice field)
                            throws java.sql.SQLException
        Return the Field of the ResultSet.
        Parameters:
        rs - the ResultSet
        field - the EdgeDevice
        Returns:
        the value as Integer
        Throws:
        java.sql.SQLException - on error
      • getAsIntegerOrElse

        public static java.lang.Integer getAsIntegerOrElse​(java.sql.ResultSet rs,
                                                           Field.EdgeDevice field,
                                                           java.lang.Integer other)
        Return the Field of the ResultSet; or default value on error.
        Parameters:
        rs - the ResultSet
        field - the EdgeDevice field
        other - the default value
        Returns:
        the value as Integer