public class EntityImportPlan
extends java.lang.Object
implements java.io.Serializable
EntityImportPlanBuilder for building instances of EntityImportPlan. EntityImportPlanBuilder may be obtained with the EntityImportPlans factory.
EntityImportPlan describes how entity fields should be saved during the import performed by EntityImportExport.
Only fields that are added as properties to the EntityImportPlan will be saved.
For local entity
property the rule is simple: if property name is added to the plan, then the property will be saved. Use EntityImportPlanBuilder.addLocalProperty(String) method for adding local property to the plan.
For many-to-one references there are two possible options:
EntityImportPlanBuilder.addManyToOneProperty(String, EntityImportPlan) method. The referenced entity will
be saved according to the EntityImportPlan passed as parameterEntityImportPlanBuilder.addManyToOneProperty(String,
ReferenceImportBehaviour) must be used for this. ReferenceImportBehaviour parameter specifies the behaviour
in case when referenced entity is missed in the database: missing entity can be ignored or import may fail with an
error.
For one-to-one references behavior is the same as for the many-to-one references. Just use the corresponding
methods for adding properties to the plan: EntityImportPlanBuilder.addOneToOneProperty(String,
EntityImportPlan) or EntityImportPlanBuilder.addOneToOneProperty(String, ReferenceImportBehaviour).
For one-to-many references you must specify the EntityImportPlan which defines how entities from the
collection must be saved. The second parameter is the CollectionImportPolicy which specifies what to do with
collection items that weren't passed to the import: they can be removed or remained.
For many-to-many references the following things must be defined:
You can invoke methods for adding plan properties in fluent interface style. There are also useful methods like
EntityImportPlanBuilder.addLocalProperties(), EntityImportPlanBuilder.addSystemProperties() or EntityImportPlanBuilder.addProperties(String...)
Example of creating the EntityImportPlan object:
EntityImportPlan importPlan = entityImportPlans.builder(Group.class)
.addLocalProperties()
.addOneToManyProperty("constraints",
entityImportPlans.builder(Constraint.class).addLocalProperties().build(),
CollectionImportPolicy.KEEP_ABSENT_ITEMS)
.addManyToOneProperty("parent", ReferenceImportBehaviour.ERROR_ON_MISSING)
.build();
| Constructor and Description |
|---|
EntityImportPlan(java.lang.Class<?> entityClass) |
EntityImportPlan(java.lang.Class<?> entityClass,
java.util.Map<java.lang.String,EntityImportPlanProperty> properties) |
| Modifier and Type | Method and Description |
|---|---|
EntityImportPlan |
addProperty(EntityImportPlanProperty property) |
java.lang.Class<?> |
getEntityClass() |
java.util.Collection<EntityImportPlanProperty> |
getProperties() |
EntityImportPlanProperty |
getProperty(java.lang.String name) |
public EntityImportPlan(java.lang.Class<?> entityClass)
public EntityImportPlan(java.lang.Class<?> entityClass,
java.util.Map<java.lang.String,EntityImportPlanProperty> properties)
public EntityImportPlan addProperty(EntityImportPlanProperty property)
public EntityImportPlanProperty getProperty(java.lang.String name)
public java.util.Collection<EntityImportPlanProperty> getProperties()
public java.lang.Class<?> getEntityClass()