Package io.jmix.core

Class EntityImportPlan

java.lang.Object
io.jmix.core.EntityImportPlan
All Implemented Interfaces:
Serializable

public class EntityImportPlan extends Object implements Serializable
Use 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:

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:

  • Whether the passed collection members must be created/updated or just searched in the database
  • Whether the collection items not passed to the import must be removed or remain. Keep in mind that for many-to-many properties missing collection members will be removed from the collection only, not from the database

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();
 
See Also: