com.im.df.api 14.11.24.0

com.im.df.api.dml
Class DFInsertDescription

java.lang.Object
  extended by com.im.df.api.dml.DFInsertDescription

public final class DFInsertDescription
extends 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

If a value is assigned to a Field, which form a Relationship, that Relationship is automatically implied, established and fired on the relevant DFRelationDataProviders.


Nested Class Summary
 class DFInsertDescription.InsertRow
          Description of the row to be inserted.
 
Field Summary
static Map<String,Object> NO_VALUES
           
 
Method Summary
 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, Map<String,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 first DFInsertDescription.InsertRow object for this description.
 Set<DFInsertDescription.InsertRow> getInsertedRows()
           
 Map<String,DFInsertDescription> getInsertionSet()
          Returns all DFInsertDescriptions in this operation.
 Map<String,Object> getInsertOptions()
           
 DFLock getLock()
           
 DFField getLookupField()
           
 Map<String,DFInsertDescription> getRelatedData()
          Returns map of related data, which ought to be inserted as a part of the operation.
 Set<DFRelationship.Direction> getRequiredRelations()
          Finds fields, which must be filled in order to insert the row.
 DFEntity getTargetEntity()
           
 DFInsertDescription.InsertRow insertRow(Map<String,Object> values)
          Registers a new Row of values for this insert description.
 void setInsertOptions(Map<String,Object> insertOptions)
           
 void setLock(DFLock lock)
           
 void setLookupField(DFField lookupField)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_VALUES

public static final Map<String,Object> NO_VALUES
Method Detail

getTargetEntity

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

getInsertionSet

public Map<String,DFInsertDescription> getInsertionSet()
Returns all DFInsertDescriptions in this operation. As DFInsertDescriotions are connected using addRelatedData(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 Map<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 Map<String,Object> getInsertOptions()

setInsertOptions

public void setInsertOptions(Map<String,Object> insertOptions)

setLock

public void setLock(DFLock lock)

getLock

public 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 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(Map<String,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

createDescription

public DFInsertDescription createDescription(DFEntity target)
Creates an empty DFInsertDescription. You may call insertRow(java.util.Map) to add individual rows to the description.

Parameters:
target -
Returns:
The new object

getInsertedRows

public Set<DFInsertDescription.InsertRow> getInsertedRows()
Returns:
The rows that will be inserted

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,
                                         Map<String,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

create

public static DFInsertDescription create(DFEntity en)
Creates DFInsertDescription that inserts data into the given Entity. No rows are inserted, use insertRow(java.util.Map) to populate the DFInsertDescription instance with rows

Parameters:
en - The insertion's target entity.

toString

public String toString()
Overrides:
toString in class Object

com.im.df.api 14.11.24.0