Class QRecord

java.lang.Object
com.kingsrook.qqq.backend.core.model.data.QRecord
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
QRecordWithJoinedRecords

public class QRecord extends Object implements Serializable
Data Record within qqq. e.g., a single row from a database. Actual values (e.g., as stored in the backend system) are in the `values` map. Keys in this map are fieldNames from the QTableMetaData. "Display values" (e.g., labels for possible values, or formatted numbers (e.g., quantities with commas)) are in the displayValues map. backendDetails are additional data about a record, that aren't strictly values, but are more like meta-data - e.g., for a file-backend, what file the record came from. Errors are meant to hold information about things that went wrong when processing a record - e.g., in a list of records that may be the output of an action, like a bulk load. Warnings play a similar role, but are just advice - they don't mean that the action was failed, just something you may need to know.
See Also:
  • Field Details

    • BACKEND_DETAILS_TYPE_JSON_SOURCE_OBJECT

      public static final String BACKEND_DETAILS_TYPE_JSON_SOURCE_OBJECT
      /////////////////////////////////////////////
      See Also:
    • BACKEND_DETAILS_TYPE_HEAVY_FIELD_LENGTHS

      public static final String BACKEND_DETAILS_TYPE_HEAVY_FIELD_LENGTHS
      See Also:
  • Constructor Details

    • QRecord

      public QRecord()
      Default constructor.
    • QRecord

      public QRecord(QTableMetaData tableMetaData, Serializable primaryKeyValue)
    • QRecord

      public QRecord(QRecord record)
      Copy constructor. Makes a deep clone.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setValue

      public void setValue(String fieldName, Object value)
      Added when QRecords got exposed in scripts, and passing a constant String raised a class-cast exception, because it was some nashorn non-serializable type (though once inside *this* method, the value was a java.lang.String...)
    • addJoinedRecordValues

      public void addJoinedRecordValues(String joinTableName, QRecord joinedRecord)
      copy all values from 'joinedRecord' into this record's values map, prefixing field names with joinTableNam + "."
    • setValue

      public void setValue(String fieldName, Serializable value)
    • removeValue

      public void removeValue(String fieldName)
    • setValue

      public void setValue(QFieldMetaData field, Serializable value)
    • withValue

      public QRecord withValue(String fieldName, Serializable value)
    • setDisplayValue

      public void setDisplayValue(String fieldName, String displayValue)
    • withDisplayValue

      public QRecord withDisplayValue(String fieldName, String displayValue)
    • getTableName

      public String getTableName()
      Getter for tableName
    • setTableName

      public void setTableName(String tableName)
      Setter for tableName
    • withTableName

      public QRecord withTableName(String tableName)
      Setter for tableName
    • getRecordLabel

      public String getRecordLabel()
      Getter for recordLabel
    • setRecordLabel

      public void setRecordLabel(String recordLabel)
      Setter for recordLabel
    • withRecordLabel

      public QRecord withRecordLabel(String recordLabel)
      Fluent setter for recordLabel
    • getValues

      public Map<String,Serializable> getValues()
      Getter for values
    • setValues

      public void setValues(Map<String,Serializable> values)
      Setter for values
    • getValue

      public Serializable getValue(String fieldName)
      Getter for a single field's value
    • getDisplayValues

      public Map<String,String> getDisplayValues()
      Getter for displayValues
    • setDisplayValues

      public void setDisplayValues(Map<String,String> displayValues)
      Setter for displayValues
    • getDisplayValue

      public String getDisplayValue(String fieldName)
      Getter for a single field's value
    • getValueString

      public String getValueString(String fieldName)
      Getter for a single field's value
    • getValueInteger

      public Integer getValueInteger(String fieldName)
      Getter for a single field's value
    • getValueLong

      public Long getValueLong(String fieldName)
      Getter for a single field's value
    • getValueBigDecimal

      public BigDecimal getValueBigDecimal(String fieldName)
    • getValueBoolean

      public Boolean getValueBoolean(String fieldName)
    • getValueLocalTime

      public LocalTime getValueLocalTime(String fieldName)
    • getValueLocalDate

      public LocalDate getValueLocalDate(String fieldName)
    • getValueByteArray

      public byte[] getValueByteArray(String fieldName)
    • getValueInstant

      public Instant getValueInstant(String fieldName)
    • getBackendDetails

      public Map<String,Serializable> getBackendDetails()
      Getter for backendDetails
    • setBackendDetails

      public void setBackendDetails(Map<String,Serializable> backendDetails)
      Setter for backendDetails
    • addBackendDetail

      public void addBackendDetail(String key, Serializable value)
      Add one backendDetail to this record
    • withBackendDetail

      public QRecord withBackendDetail(String key, Serializable value)
      Fluently Add one backendDetail to this record
    • getBackendDetail

      public Serializable getBackendDetail(String key)
      Get one backendDetail from this record
    • getBackendDetailString

      public String getBackendDetailString(String key)
      Get one backendDetail from this record as a String
    • getErrors

      public List<QErrorMessage> getErrors()
      Getter for errors
    • getErrorsAsString

      public String getErrorsAsString()
      Getter for errors
    • setErrors

      public void setErrors(List<QErrorMessage> errors)
      Setter for errors
    • addError

      public void addError(QErrorMessage error)
      Add one error to this record
    • withError

      public QRecord withError(QErrorMessage error)
      Fluently Add one error to this record
    • toEntity

      public <T extends QRecordEntity> T toEntity(Class<T> c) throws QException
      Convert this record to an QRecordEntity
      Throws:
      QException
    • getAssociatedRecords

      public Map<String,List<QRecord>> getAssociatedRecords()
      Getter for associatedRecords
    • setAssociatedRecords

      public void setAssociatedRecords(Map<String,List<QRecord>> associatedRecords)
      Setter for associatedRecords
    • withAssociatedRecords

      public QRecord withAssociatedRecords(Map<String,List<QRecord>> associatedRecords)
      Fluent setter for associatedRecords
    • withAssociatedRecords

      public QRecord withAssociatedRecords(String name, List<QRecord> associatedRecords)
      Fluent setter for associatedRecords
    • withAssociatedRecord

      public QRecord withAssociatedRecord(String name, QRecord associatedRecord)
      Fluent setter for associatedRecord
    • getWarnings

      public List<QWarningMessage> getWarnings()
      Getter for warnings
    • getWarningsAsString

      public String getWarningsAsString()
      Getter for warnings
    • setWarnings

      public void setWarnings(List<QWarningMessage> warnings)
      Setter for warnings
    • withWarning

      public QRecord withWarning(QWarningMessage warning)
      Fluently Add one warning to this record
    • withWarnings

      public QRecord withWarnings(List<QWarningMessage> warnings)
      Fluent setter for warnings
    • addWarning

      public void addWarning(QWarningMessage warning)
      Add one warning to this record