Class DFInsertDescription


  • public final class DFInsertDescription
    extends java.lang.Object
    This data structure describes a single row to be inserted into the getTargetEntity(). You can record data to be inserted into row's DFFields, as well as relations to other DFEntity's rows. For complex data setups, which require relationship-bound fields to be set, you can
    • bind the row field's data to an already existing other Entity's row
    • create a new row in another Entity to satisfy the constraint.
    If a value is assigned to a Field, which form a Relationship, that Relationship is automatically implied, established and fired on the relevant DFRelationDataProviders.
    Author:
    svata
    • Field Detail

      • NO_VALUES

        public static final java.util.Map<java.lang.String,​java.lang.Object> NO_VALUES
    • Method Detail

      • getTargetEntity

        public DFEntity getTargetEntity()
        Returns:
        The entity where the data will be inserted.
      • getRelatedData

        public java.util.Map<java.lang.String,​DFInsertDescription> getRelatedData()
        Returns map of related data, which ought to be inserted as a part of the operation. The Map is keyed by entityID and values are DFInsertDescription instances for that entity.
        Returns:
        Map entityID - insertion for that entity
      • getLookupField

        public DFField getLookupField()
      • setLookupField

        public void setLookupField​(DFField lookupField)
      • getInsertOptions

        public java.util.Map<java.lang.String,​java.lang.Object> getInsertOptions()
      • setInsertOptions

        public void setInsertOptions​(java.util.Map<java.lang.String,​java.lang.Object> insertOptions)
      • setLock

        public void setLock​(com.im.commons.progress.DFLock lock)
      • getLock

        public com.im.commons.progress.DFLock getLock()
      • addRelatedData

        public void addRelatedData​(DFRelationship.Direction rel,
                                   DFInsertDescription data)
        Adds related data to the insert operation. Note that it is an error when the two sets of related data (now being joined together) both contain different instances of DFInsertDescription for the same DFEntity. In that case, IllegalArgumentException will be thrown.
      • getRequiredRelations

        public java.util.Set<DFRelationship.Direction> getRequiredRelations()
        Finds fields, which must be filled in order to insert the row. The value is computed as fields participating in a relation, that have required property set to DFField.Required.TRUE. For One-to-Many or Many-to-One, the "many" endpoint field is checked, since that field has to identify the "one" endpoint. For One-to-One relations, both endpoints are checked.
        Returns:
        Set of fields, whose values have to be present
      • insertRow

        public DFInsertDescription.InsertRow insertRow​(java.util.Map<java.lang.String,​java.lang.Object> values)
        Registers a new Row of values for this insert description. The new DFInsertDescription.InsertRow object is returned. Do not pass null for values. Use NO_VALUES instead
        Parameters:
        values - The v alues for this row
        Returns:
        The new InsertRow object
      • getFirstRow

        public DFInsertDescription.InsertRow getFirstRow()
        A convenience method, which will return the first DFInsertDescription.InsertRow object for this description. Returns null if there are no rows in the InsertDescription.
        Returns:
        The first row, or null if there are no rows available.
      • create

        public static DFInsertDescription create​(DFEntity en,
                                                 java.util.Map<java.lang.String,​java.lang.Object> values)
        Creates DFInsertDescription that inserts data into the given Entity. The call also inserts the first row into the Description object.
        Parameters:
        en - The target entity for the insertion
        values - The v alues for the row. Use null to insert no rows.
        Returns:
        The new DFInsertDescription object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object