Class QRecordWithJoinedRecords
java.lang.Object
com.kingsrook.qqq.backend.core.model.data.QRecord
com.kingsrook.qqq.backend.core.model.data.QRecordWithJoinedRecords
- All Implemented Interfaces:
Serializable
Extension on QRecord, intended to be used where you've got records from
multiple tables, and you want to combine them into a single "wide" joined
record - but to do so without copying or modifying any of the individual
records.
e.g., given:
- Order (id, orderNo, orderDate) (main table)
- LineItem (id, sku, quantity)
- Extrinsic (id, key, value)
If set up in here as:
- new QRecordWithJoinedRecords(order)
.withJoinedRecordValues(lineItem)
.withJoinedRecordValues(extrinsic)
Then we'd have the appearance of values in the object like:
- id, orderNo, orderDate, lineItem.id, lineItem.sku, lineItem.quantity, extrinsic.id, extrinsic.key, extrinsic.value
Which, by the by, is how a query that returns joined records looks, and, is
what BackendQueryFilterUtils can use to do filter.
This is done without copying or mutating any of the records (which, if you just use
QRecord.withJoinedRecordValues, then those values are copied into the main record)
- because this object is just storing references to the input records.
Note that this implies that, values changed in this record (e.g, calls to setValue)
WILL impact the underlying records!
- See Also:
-
Field Summary
Fields inherited from class com.kingsrook.qqq.backend.core.model.data.QRecord
BACKEND_DETAILS_TYPE_HEAVY_FIELD_LENGTHS, BACKEND_DETAILS_TYPE_JSON_SOURCE_OBJECT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addJoinedRecordValues
(String joinTableName, QRecord joinedRecord) copy all values from 'joinedRecord' into this record's values map, prefixing field names with joinTableNam + "."Getter for associatedRecordsGetter for a single field's valueGetter for valuesvoid
removeValue
(String fieldName) void
setAssociatedRecords
(Map<String, List<QRecord>> associatedRecords) Setter for associatedRecordsvoid
setValue
(String fieldName, Serializable value) void
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...)withAssociatedRecord
(String name, QRecord associatedRecord) Fluent setter for associatedRecordwithAssociatedRecords
(String name, List<QRecord> associatedRecords) Fluent setter for associatedRecordswithAssociatedRecords
(Map<String, List<QRecord>> associatedRecords) Fluent setter for associatedRecordswithJoinedRecordValues
(QRecord record, String joinTableName) Methods inherited from class com.kingsrook.qqq.backend.core.model.data.QRecord
addBackendDetail, addError, addWarning, getBackendDetail, getBackendDetails, getBackendDetailString, getDisplayValue, getDisplayValues, getErrors, getErrorsAsString, getRecordLabel, getTableName, getValueBigDecimal, getValueBoolean, getValueByteArray, getValueInstant, getValueInteger, getValueLocalDate, getValueLocalTime, getValueLong, getValueString, getWarnings, getWarningsAsString, setBackendDetails, setDisplayValue, setDisplayValues, setErrors, setRecordLabel, setTableName, setValue, setValues, setWarnings, toEntity, toString, withBackendDetail, withDisplayValue, withError, withRecordLabel, withTableName, withValue, withWarning, withWarnings
-
Constructor Details
-
QRecordWithJoinedRecords
-
-
Method Details
-
addJoinedRecordValues
Description copied from class:QRecord
copy all values from 'joinedRecord' into this record's values map, prefixing field names with joinTableNam + "."- Overrides:
addJoinedRecordValues
in classQRecord
-
withJoinedRecordValues
-
getValue
Description copied from class:QRecord
Getter for a single field's value -
setValue
Description copied from class:QRecord
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...) -
setValue
-
removeValue
- Overrides:
removeValue
in classQRecord
-
getValues
-
getAssociatedRecords
-
withAssociatedRecord
-
withAssociatedRecords
-
setAssociatedRecords
-
withAssociatedRecords
-