@Component(value="core_EntityImportExport") public class EntityImportExportImpl extends java.lang.Object implements EntityImportExport
Modifier and Type | Class and Description |
---|---|
protected static class |
EntityImportExportImpl.ReferenceInfo |
Modifier and Type | Field and Description |
---|---|
protected AccessConstraintsRegistry |
accessConstraintsRegistry |
protected AccessManager |
accessManager |
protected org.springframework.context.ApplicationContext |
applicationContext |
protected CoreProperties |
coreProperties |
protected UnconstrainedDataManager |
dataManager |
protected EntitySerialization |
entitySerialization |
protected EntityStates |
entityStates |
protected FetchPlanRepository |
fetchPlanRepository |
protected FetchPlans |
fetchPlans |
protected Metadata |
metadata |
protected MetadataTools |
metadataTools |
protected ReferenceToEntitySupport |
referenceToEntitySupport |
protected Stores |
stores |
protected javax.validation.Validator |
validator |
Constructor and Description |
---|
EntityImportExportImpl() |
Modifier and Type | Method and Description |
---|---|
protected void |
assertToken(java.lang.Object entity,
FetchPlan fetchPlan) |
protected FetchPlanBuilder |
constructFetchPlanFromImportPlan(EntityImportPlan importPlan)
|
protected java.util.Collection<java.lang.Object> |
createNewCollection(MetaProperty metaProperty) |
java.lang.String |
exportEntitiesToJSON(java.util.Collection<java.lang.Object> entities)
Serializes a collection of entities to JSON using
EntitySerialization . |
java.lang.String |
exportEntitiesToJSON(java.util.Collection<java.lang.Object> entities,
FetchPlan fetchPlan)
Serializes a collection of entities to JSON using
EntitySerialization . |
byte[] |
exportEntitiesToZIP(java.util.Collection<java.lang.Object> entities)
Serializes a collection of entities to JSON using
EntitySerialization
and packs the JSON file into ZIP archive. |
byte[] |
exportEntitiesToZIP(java.util.Collection<java.lang.Object> entities,
FetchPlan fetchPlan)
Serializes a collection of entities to JSON using
EntitySerialization
and packs the JSON file into ZIP archive. |
protected java.lang.Object |
findReferenceEntity(java.lang.Object entity,
EntityImportPlanProperty importPlanProperty,
SaveContext saveContext,
java.util.Set<java.lang.Object> loadedEntities) |
protected java.util.Collection<java.lang.Object> |
getFilteredIds(SecurityState securityState,
java.lang.String propertyName) |
protected java.lang.Object |
importEmbeddedAttribute(java.lang.Object srcEntity,
java.lang.Object dstEntity,
boolean createOp,
EntityImportPlanProperty importPlanProperty,
FetchPlan fetchPlan,
SaveContext saveContext,
java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList,
boolean optimisticLock) |
java.util.Collection<java.lang.Object> |
importEntities(java.util.Collection<java.lang.Object> entities,
EntityImportPlan importPlan,
boolean validate,
boolean optimisticLocking,
boolean additionComposition) |
java.util.Collection |
importEntities(java.util.Collection entities,
EntityImportPlan importPlan)
|
java.util.Collection |
importEntities(java.util.Collection entities,
EntityImportPlan importPlan,
boolean validate)
Persists entities according to the rules, described by the
importPlan parameter. |
java.util.Collection |
importEntities(java.util.Collection entities,
EntityImportPlan importPlan,
boolean validate,
boolean optimisticLocking)
Persists entities according to the rules, described by the
importPlan parameter. |
java.util.Collection |
importEntitiesFromJson(java.lang.String json,
EntityImportPlan importPlan)
Deserializes the JSON and persists deserialized entities according to the rules, described by the
importPlan parameter. |
java.util.Collection<java.lang.Object> |
importEntitiesFromZIP(byte[] zipBytes,
EntityImportPlan importPlan)
Reads a zip archive that contains a JSON file, deserializes the JSON and persists deserialized entities according
to the rules, described by the
importPlan parameter. |
protected java.lang.Object |
importEntity(java.lang.Object srcEntity,
java.lang.Object dstEntity,
EntityImportPlan importPlan,
FetchPlan fetchPlan,
SaveContext saveContext,
java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList,
boolean optimisticLocking,
boolean additionComposition)
Method imports the entity.
|
void |
importEntityIntoSaveContext(SaveContext saveContext,
java.lang.Object srcEntity,
EntityImportPlan importPlan,
boolean validate) |
void |
importEntityIntoSaveContext(SaveContext saveContext,
java.lang.Object srcEntity,
EntityImportPlan importPlan,
boolean validate,
boolean optimisticLocking) |
void |
importEntityIntoSaveContext(SaveContext saveContext,
java.lang.Object srcEntity,
EntityImportPlan importPlan,
boolean validate,
boolean optimisticLocking,
boolean additionComposition) |
protected void |
importManyToManyCollectionAttribute(java.lang.Object srcEntity,
java.lang.Object dstEntity,
EntityImportPlanProperty importPlanProperty,
FetchPlan fetchPlan,
SaveContext saveContext,
java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList,
boolean optimisticLocking) |
protected void |
importOneToManyCollectionAttribute(java.lang.Object srcEntity,
java.lang.Object dstEntity,
EntityImportPlanProperty importPlanProperty,
FetchPlan fetchPlan,
SaveContext saveContext,
java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList,
boolean optimisticLocking,
boolean additionalComposition) |
protected void |
importReference(java.lang.Object srcEntity,
java.lang.Object dstEntity,
EntityImportPlanProperty importPlanProperty,
FetchPlan fetchPlan,
SaveContext saveContext,
java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList,
boolean optimisticLocking) |
protected org.apache.commons.compress.archivers.ArchiveEntry |
newStoredEntry(java.lang.String name,
byte[] data) |
protected void |
processReferenceInfo(EntityImportExportImpl.ReferenceInfo referenceInfo,
SaveContext saveContext,
java.util.Set<java.lang.Object> loadedEntities)
Method finds and set a reference value to the entity or throws EntityImportException if ERROR_ON_MISSING policy
is violated
|
protected byte[] |
readBytesFromEntry(org.apache.commons.compress.archivers.zip.ZipArchiveInputStream archiveReader) |
protected java.util.Collection |
reloadEntities(java.util.Collection<java.lang.Object> entities,
FetchPlan fetchPlan) |
protected void |
validateEntities(java.util.Collection<java.lang.Object> entitiesToValidate) |
@Autowired protected EntitySerialization entitySerialization
@Autowired protected Metadata metadata
@Autowired protected UnconstrainedDataManager dataManager
@Autowired protected MetadataTools metadataTools
@Autowired protected FetchPlans fetchPlans
@Autowired protected javax.validation.Validator validator
@Autowired protected Stores stores
@Autowired protected org.springframework.context.ApplicationContext applicationContext
@Autowired protected FetchPlanRepository fetchPlanRepository
@Autowired protected ReferenceToEntitySupport referenceToEntitySupport
@Autowired protected EntityStates entityStates
@Autowired protected AccessConstraintsRegistry accessConstraintsRegistry
@Autowired protected AccessManager accessManager
@Autowired protected CoreProperties coreProperties
public byte[] exportEntitiesToZIP(java.util.Collection<java.lang.Object> entities, FetchPlan fetchPlan)
EntityImportExport
Serializes a collection of entities to JSON using EntitySerialization
and packs the JSON file into ZIP archive. Before the serialization entities will be reloaded with the fetch plan
passed as method parameter.
Serialization is described in the EntitySerialization.toJson(Collection)
method documentation
exportEntitiesToZIP
in interface EntityImportExport
entities
- a collection of entities to exportfetchPlan
- before serialization to JSON entities will be reloaded with this fetch planpublic byte[] exportEntitiesToZIP(java.util.Collection<java.lang.Object> entities)
EntityImportExport
Serializes a collection of entities to JSON using EntitySerialization
and packs the JSON file into ZIP archive.
Serialization is described in the EntitySerialization.toJson(Collection)
method documentation
exportEntitiesToZIP
in interface EntityImportExport
entities
- a collection of entities to exportpublic java.lang.String exportEntitiesToJSON(java.util.Collection<java.lang.Object> entities, FetchPlan fetchPlan)
EntityImportExport
Serializes a collection of entities to JSON using EntitySerialization
.
Before the serialization entities will be reloaded with the fetch plan passed as method parameter.
Serialization is described in the EntitySerialization.toJson(Collection)
method documentation
exportEntitiesToJSON
in interface EntityImportExport
entities
- a collection of entities to exportfetchPlan
- before serialization to JSON entities will be reloaded with this fetch planpublic java.lang.String exportEntitiesToJSON(java.util.Collection<java.lang.Object> entities)
EntityImportExport
Serializes a collection of entities to JSON using EntitySerialization
.
Serialization is described in the EntitySerialization.toJson(Collection)
method documentation
exportEntitiesToJSON
in interface EntityImportExport
entities
- a collection of entities to exportprotected java.util.Collection reloadEntities(java.util.Collection<java.lang.Object> entities, FetchPlan fetchPlan)
protected org.apache.commons.compress.archivers.ArchiveEntry newStoredEntry(java.lang.String name, byte[] data)
public java.util.Collection importEntitiesFromJson(java.lang.String json, EntityImportPlan importPlan)
EntityImportExport
importPlan
parameter. If the entity is not present in the database, it will be saved. Otherwise the fields of
the existing entity that are in the importPlan
will be updated.importEntitiesFromJson
in interface EntityImportExport
json
- JSON file containing entitiesimportPlan
- EntityImportPlan
with the rules that describes how entities should be persisted.EntityImportPlan
public java.util.Collection<java.lang.Object> importEntitiesFromZIP(byte[] zipBytes, EntityImportPlan importPlan)
EntityImportExport
importPlan
parameter. If the entity is not present in the database, it
will be saved. Otherwise the fields of the existing entity that are in the importPlan
will be updated.importEntitiesFromZIP
in interface EntityImportExport
zipBytes
- byte array of ZIP archive with JSON fileimportPlan
- EntityImportPlan
with the rules that describes how entities should be persisted.EntityImportPlan
protected byte[] readBytesFromEntry(org.apache.commons.compress.archivers.zip.ZipArchiveInputStream archiveReader) throws java.io.IOException
java.io.IOException
public java.util.Collection importEntities(java.util.Collection entities, EntityImportPlan importPlan)
EntityImportExport
EntityImportExport.importEntities(Collection, EntityImportPlan, boolean)
. The current method doesn't perform bean
validationimportEntities
in interface EntityImportExport
public java.util.Collection importEntities(java.util.Collection entities, EntityImportPlan importPlan, boolean validate)
EntityImportExport
importPlan
parameter. If the entity is not
present in the database, it will be saved. Otherwise the fields of the existing entity that are in the importPlan
will be updated.
If the import plan contains a property for composition attribute then all composition collection members that are absent in the passed entity will be removed.
importEntities
in interface EntityImportExport
importPlan
- EntityImportPlan
with the rules that describes how entities should be persisted.validate
- whether the passed entities should be validated by the bean validation mechanism before
entities are persistedpublic java.util.Collection importEntities(java.util.Collection entities, EntityImportPlan importPlan, boolean validate, boolean optimisticLocking)
EntityImportExport
importPlan
parameter. If the entity is not
present in the database, it will be saved. Otherwise the fields of the existing entity that are in the importPlan
will be updated.
If the import plan contains a property for composition attribute then all composition collection members that are absent in the passed entity will be removed.
importEntities
in interface EntityImportExport
importPlan
- EntityImportPlan
with the rules that describes how entities should be
persisted.validate
- whether the passed entities should be validated by the bean validation mechanism before
entities are persistedoptimisticLocking
- whether the passed entities versions should be validated before entities are persistedpublic java.util.Collection<java.lang.Object> importEntities(java.util.Collection<java.lang.Object> entities, EntityImportPlan importPlan, boolean validate, boolean optimisticLocking, boolean additionComposition)
importEntities
in interface EntityImportExport
public void importEntityIntoSaveContext(SaveContext saveContext, java.lang.Object srcEntity, EntityImportPlan importPlan, boolean validate)
importEntityIntoSaveContext
in interface EntityImportExport
public void importEntityIntoSaveContext(SaveContext saveContext, java.lang.Object srcEntity, EntityImportPlan importPlan, boolean validate, boolean optimisticLocking)
importEntityIntoSaveContext
in interface EntityImportExport
public void importEntityIntoSaveContext(SaveContext saveContext, java.lang.Object srcEntity, EntityImportPlan importPlan, boolean validate, boolean optimisticLocking, boolean additionComposition)
importEntityIntoSaveContext
in interface EntityImportExport
protected void validateEntities(java.util.Collection<java.lang.Object> entitiesToValidate)
protected java.lang.Object importEntity(java.lang.Object srcEntity, @Nullable java.lang.Object dstEntity, EntityImportPlan importPlan, FetchPlan fetchPlan, SaveContext saveContext, java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList, boolean optimisticLocking, boolean additionComposition)
srcEntity
- entity that came to the EntityImportExport
beandstEntity
- reloaded srcEntity or null if entity doesn't exist in the databaseimportPlan
- importPlan used for importing the entityfetchPlan
- fetchPlan that was used for loading dstEntitysaveContext
- entities that must be commited or deleted will be set to the saveContextreferenceInfoList
- list of referenceInfos for further processingoptimisticLocking
- whether the passed entity version should be validated before entity is persistedprotected void importReference(java.lang.Object srcEntity, java.lang.Object dstEntity, EntityImportPlanProperty importPlanProperty, @Nullable FetchPlan fetchPlan, SaveContext saveContext, java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList, boolean optimisticLocking)
protected void importOneToManyCollectionAttribute(java.lang.Object srcEntity, java.lang.Object dstEntity, EntityImportPlanProperty importPlanProperty, @Nullable FetchPlan fetchPlan, SaveContext saveContext, java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList, boolean optimisticLocking, boolean additionalComposition)
protected void importManyToManyCollectionAttribute(java.lang.Object srcEntity, java.lang.Object dstEntity, EntityImportPlanProperty importPlanProperty, @Nullable FetchPlan fetchPlan, SaveContext saveContext, java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList, boolean optimisticLocking)
@Nullable protected java.lang.Object importEmbeddedAttribute(java.lang.Object srcEntity, java.lang.Object dstEntity, boolean createOp, EntityImportPlanProperty importPlanProperty, FetchPlan fetchPlan, SaveContext saveContext, java.util.Collection<EntityImportExportImpl.ReferenceInfo> referenceInfoList, boolean optimisticLock)
protected void processReferenceInfo(EntityImportExportImpl.ReferenceInfo referenceInfo, SaveContext saveContext, java.util.Set<java.lang.Object> loadedEntities)
protected FetchPlanBuilder constructFetchPlanFromImportPlan(EntityImportPlan importPlan)
FetchPlanBuilder
for a regular FetchPlan
from the EntityImportPlan
. The
regular fetchPlan will include all properties defined in the import plan.protected java.util.Collection<java.lang.Object> getFilteredIds(@Nullable SecurityState securityState, java.lang.String propertyName)
protected java.util.Collection<java.lang.Object> createNewCollection(MetaProperty metaProperty)
@Nullable protected java.lang.Object findReferenceEntity(java.lang.Object entity, EntityImportPlanProperty importPlanProperty, SaveContext saveContext, java.util.Set<java.lang.Object> loadedEntities)
protected void assertToken(java.lang.Object entity, FetchPlan fetchPlan)