Package com.im.df.api.dml
Class DFInsertDescription
- java.lang.Object
-
- com.im.df.api.dml.DFInsertDescription
-
public final class DFInsertDescription extends java.lang.Object
This data structure describes a single row to be inserted into thegetTargetEntity()
. You can record data to be inserted into row'sDFField
s, as well as relations to otherDFEntity
'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.
DFRelationDataProvider
s.- Author:
- svata
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
DFInsertDescription.InsertRow
Description of the row to be inserted.
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<java.lang.String,java.lang.Object>
NO_VALUES
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRelatedData(DFRelationship.Direction rel, DFInsertDescription data)
Adds related data to the insert operation.static DFInsertDescription
create(DFEntity en)
Creates DFInsertDescription that inserts data into the given Entity.static DFInsertDescription
create(DFEntity en, java.util.Map<java.lang.String,java.lang.Object> values)
Creates DFInsertDescription that inserts data into the given Entity.DFInsertDescription
createDescription(DFEntity target)
Creates an empty DFInsertDescription.DFInsertDescription.InsertRow
getFirstRow()
A convenience method, which will return the firstDFInsertDescription.InsertRow
object for this description.java.util.Set<DFInsertDescription.InsertRow>
getInsertedRows()
java.util.Map<java.lang.String,DFInsertDescription>
getInsertionSet()
Returns allDFInsertDescription
s in this operation.java.util.Map<java.lang.String,java.lang.Object>
getInsertOptions()
com.im.commons.progress.DFLock
getLock()
DFField
getLookupField()
java.util.Map<java.lang.String,DFInsertDescription>
getRelatedData()
Returns map of related data, which ought to be inserted as a part of the operation.java.util.Set<DFRelationship.Direction>
getRequiredRelations()
Finds fields, which must be filled in order to insert the row.DFEntity
getTargetEntity()
DFInsertDescription.InsertRow
insertRow(java.util.Map<java.lang.String,java.lang.Object> values)
Registers a new Row of values for this insert description.void
setInsertOptions(java.util.Map<java.lang.String,java.lang.Object> insertOptions)
void
setLock(com.im.commons.progress.DFLock lock)
void
setLookupField(DFField lookupField)
java.lang.String
toString()
-
-
-
Method Detail
-
getTargetEntity
public DFEntity getTargetEntity()
- Returns:
- The entity where the data will be inserted.
-
getInsertionSet
public java.util.Map<java.lang.String,DFInsertDescription> getInsertionSet()
Returns allDFInsertDescription
s in this operation. As DFInsertDescriotions are connected usingaddRelatedData(com.im.df.api.ddl.DFRelationship.Direction, com.im.df.api.dml.DFInsertDescription)
, this method returns a complete set of to-be-inserted data. The resulting Map is keyed by entity ID, and values are DFInsertDescription instance of that entity.- Returns:
- Map of EntityID - Insert description
-
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 toDFField.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 newDFInsertDescription.InsertRow
object is returned. Do not passnull
for values. UseNO_VALUES
instead- Parameters:
values
- The v alues for this row- Returns:
- The new InsertRow object
-
createDescription
public DFInsertDescription createDescription(DFEntity target)
Creates an empty DFInsertDescription. You may callinsertRow(java.util.Map<java.lang.String, java.lang.Object>)
to add individual rows to the description.- Parameters:
target
-- Returns:
- The new object
-
getInsertedRows
public java.util.Set<DFInsertDescription.InsertRow> getInsertedRows()
- Returns:
- The rows that will be inserted
-
getFirstRow
public DFInsertDescription.InsertRow getFirstRow()
A convenience method, which will return the firstDFInsertDescription.InsertRow
object for this description. Returnsnull
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 insertionvalues
- The v alues for the row. Usenull
to insert no rows.- Returns:
- The new DFInsertDescription object
-
create
public static DFInsertDescription create(DFEntity en)
Creates DFInsertDescription that inserts data into the given Entity. No rows are inserted, useinsertRow(java.util.Map<java.lang.String, java.lang.Object>)
to populate the DFInsertDescription instance with rows- Parameters:
en
- The insertion's target entity.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-