java.lang.Object
io.openems.backend.metadata.odoo.postgres.PgUtils

public class PgUtils extends Object
  • Constructor Details

    • PgUtils

      public PgUtils()
  • Method Details

    • addChatterMessage

      protected static void addChatterMessage(Credentials credentials, String model, int id, 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, String model, 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 String getAsString(ResultSet rs, Field field) throws SQLException, OpenemsException
      Return the Field of the ResultSet.
      Parameters:
      rs - the ResultSet
      field - the EdgeDevice
      Returns:
      the value as String
      Throws:
      SQLException - on error
      OpenemsException - on null
    • getAsStringOrElse

      public static String getAsStringOrElse(ResultSet rs, Field field, 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(ResultSet rs, Field field) throws SQLException
      Return the Field of the ResultSet.
      Parameters:
      rs - the ResultSet
      field - the EdgeDevice
      Returns:
      the value as Integer
      Throws:
      SQLException - on error
    • getAsIntegerOrElse

      public static Integer getAsIntegerOrElse(ResultSet rs, Field field, 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
    • getAsDate

      public static ZonedDateTime getAsDate(ResultSet rs, Field field) throws SQLException, OpenemsException
      Return the Field of the ResultSet.
      Parameters:
      rs - the ResultSet
      field - the EdgeDevice field
      Returns:
      the value as ZonedDateTime
      Throws:
      SQLException - SQL-Error
      OpenemsException - OpenEMS-Error
    • getAsDateOrElse

      public static ZonedDateTime getAsDateOrElse(ResultSet rs, Field field, ZonedDateTime 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 ZonedDateTime