public class EntityImportView
extends java.lang.Object
implements java.io.Serializable
EntityImportExportService
Only fields that are added as properties to the EntityImportView
will be
saved.
For local entity property the rule is simple: if property name is added to the view, then the property
will be saved. Use addLocalProperty(String)
method for adding local property to the view.
For many-to-one references there are two possible options:
addManyToOneProperty(String, EntityImportView)
method. The referenced entity will be saved according to
the EntityImportView
passed as parameteraddManyToOneProperty(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 view: addOneToOneProperty(String, EntityImportView)
or addOneToOneProperty(String, ReferenceImportBehaviour)
.
For one-to-many references you must specify the EntityImportView
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 view properties in fluent interface style. There are also useful methods like
addLocalProperties()
, addSystemProperties()
or addProperties(String...)
Example of creating the EntityImportView object:
EntityImportView importView = new EntityImportView(Group.class) .addLocalProperties() .addOneToManyProperty("constraints", new EntityImportView(Constraint.class).addLocalProperties(), CollectionImportPolicy.KEEP_ABSENT_ITEMS) .addManyToOneProperty("parent", ReferenceImportBehaviour.ERROR_ON_MISSING);
Constructor and Description |
---|
EntityImportView(java.lang.Class<? extends Entity> entityClass) |
public EntityImportView(java.lang.Class<? extends Entity> entityClass)
public EntityImportView addLocalProperty(java.lang.String name)
public EntityImportView addManyToOneProperty(java.lang.String name, EntityImportView view)
public EntityImportView addManyToOneProperty(java.lang.String name, ReferenceImportBehaviour referenceImportBehaviour)
public EntityImportView addOneToOneProperty(java.lang.String name, EntityImportView view)
public EntityImportView addOneToOneProperty(java.lang.String name, ReferenceImportBehaviour referenceImportBehaviour)
public EntityImportView addOneToManyProperty(java.lang.String name, EntityImportView view, CollectionImportPolicy collectionImportPolicy)
public EntityImportView addManyToManyProperty(java.lang.String name, EntityImportView view, CollectionImportPolicy collectionImportPolicy)
public EntityImportView addManyToManyProperty(java.lang.String name, ReferenceImportBehaviour referenceImportBehaviour, CollectionImportPolicy collectionImportPolicy)
public EntityImportView addEmbeddedProperty(java.lang.String name, EntityImportView view)
public EntityImportView addProperty(EntityImportViewProperty property)
public EntityImportViewProperty getProperty(java.lang.String name)
public java.util.Collection<EntityImportViewProperty> getProperties()
public java.lang.Class<? extends Entity> getEntityClass()
public EntityImportView addLocalProperties()
public EntityImportView addSystemProperties()
public EntityImportView addProperties(java.lang.String... names)
public EntityImportView removeProperty(java.lang.String name)