Package de.xima.fc.importer.config
Class AEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- java.lang.Object
-
- de.xima.fc.importer.config.AEntityImportConfig<T>
-
- Type Parameters:
T
- Type of entity to import
- All Implemented Interfaces:
IEntityImportConfig<T>
,Serializable
,Comparable<IEntityImportConfig<?>>
- Direct Known Subclasses:
ActionImportConfig
,AppointmentTemplateImportConfig
,ClientCounterImportConfig
,ClientFormThemeImportConfig
,ClientResourceImportConfig
,DataSourceImportConfig
,EntityImportConfig
,FormVersionImportConfig
,InboxImportConfig
,ProjectDoiDataImportConfig
,ProjectIdentityCheckDataImportConfig
,ProjectImportConfig
,ProjectInviteDataImportConfig
,ProjectPortalDataImportConfig
,ProjectResourceImportConfig
,StateImportConfig
,TemplateImportConfig
,UserGroupImportConfig
public abstract class AEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>> extends Object implements IEntityImportConfig<T>
Configuration class for entity imports- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Object
alternative
protected EEntityConflictResolveAction
conflictResolveAction
protected de.xima.cmn.dao.interfaces.IEntity<Long>
context
protected T
entity
protected com.vdurmont.semver4j.Semver
formcycleVersion
protected String
importJson
protected static org.slf4j.Logger
LOG
protected static String
LOG_PREFIX
protected Long
originalID
protected String
originalName
protected UUID
originalUUID
protected T
persisted
protected String
persistedName
protected Map<de.xima.cmn.dao.interfaces.IEntity<Long>,List<IEntityDependency>>
unresolvedDependencies
-
Constructor Summary
Constructors Constructor Description AEntityImportConfig(IEntityContext ec, de.xima.cmn.dao.interfaces.IEntity<Long> context, T entity, Set<IEntityDependency> dependencies, String importJson)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description List<DependencyDescriptor>
finalize(IEntityContext ec, String fcVersion, String exportVersion)
Finish the import.protected T
findPersisted(IEntityContext ec)
List<IEntityImportConfig<?>>
getAllChildrenFlat()
List<IEntityImportConfig<?>>
getChildren()
EEntityConflictResolveAction
getConflictResolveAction()
protected abstract IGenericDao<T>
getDao()
protected static UUID
getDependencyUuid(IEntityImportConfig<?> config, String fieldDescriptor)
T
getEntity()
Class<?>
getEntityClass()
de.xima.cmn.dao.interfaces.IEntity<Long>
getEntityToOverride()
Deprecated.String
getImportJson()
Deprecated.Object
getOriginal()
Gets the reference to the original object referenced in the import file.Long
getOriginalExportId()
Long
getOriginalID()
String
getOriginalName()
UUID
getOriginalUUID()
T
getPersisted()
Map<de.xima.cmn.dao.interfaces.IEntity<Long>,List<IEntityDependency>>
getUnresolvedDependencies()
protected static String
getUuidEntityValue(com.google.gson.JsonObject authConfig, String key)
boolean
isEntityExists()
boolean
isImported()
protected boolean
isUuidExisting(IEntityContext ec)
Object
loadAlternative(IEntityContext ec)
Loads the alternative that should be used instead of the entity represented by this import config.protected abstract void
makeEntityUnique(IEntityContext ec)
protected void
postCreate(IEntityContext ec)
protected void
postUpdate(IEntityContext ec)
protected void
preCreate(IEntityContext ec)
protected void
preUpdate(IEntityContext ec)
void
resolveDependencies(IEntityContext ec)
Deprecated.void
setAlternative(Object alternative)
Sets a reference to the alternative that should be used instead of the entity represented by this import config.void
setConflictResolveAction(EEntityConflictResolveAction conflictResolveAction)
void
setEntity(T entity)
Deprecated.void
setEntityToOverride(de.xima.cmn.dao.interfaces.IEntity<Long> entityToOverride)
Deprecated.void
setImported(boolean imported)
Deprecated.void
setOriginal(Object original)
void
setPersisted(T persisted)
void
stage(IEntityContext ec)
Stages the import for execution based on the given configurationString
toString()
void
updatePersisted(IEntityContext ec)
Updates the persisted entity if existing based on the entity represented by this configprotected void
validateImport(IEntityContext ec)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.xima.fc.importer.interfaces.IEntityImportConfig
compareTo, getDependencies, isRelevantForImport, setAlternativeId
-
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
-
LOG_PREFIX
protected static final String LOG_PREFIX
- See Also:
- Constant Field Values
-
formcycleVersion
protected final com.vdurmont.semver4j.Semver formcycleVersion
-
persistedName
protected String persistedName
-
unresolvedDependencies
protected final Map<de.xima.cmn.dao.interfaces.IEntity<Long>,List<IEntityDependency>> unresolvedDependencies
-
importJson
protected String importJson
-
originalID
protected Long originalID
-
originalUUID
protected UUID originalUUID
-
originalName
protected String originalName
-
context
protected de.xima.cmn.dao.interfaces.IEntity<Long> context
-
alternative
protected Object alternative
-
conflictResolveAction
protected EEntityConflictResolveAction conflictResolveAction
-
-
Constructor Detail
-
AEntityImportConfig
@Deprecated public AEntityImportConfig(IEntityContext ec, de.xima.cmn.dao.interfaces.IEntity<Long> context, T entity, Set<IEntityDependency> dependencies, String importJson)
Deprecated.
-
-
Method Detail
-
getEntity
public T getEntity()
- Specified by:
getEntity
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- The entity that should be imported
-
setEntity
@Deprecated public void setEntity(T entity)
Deprecated.- Specified by:
setEntity
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
entity
- The entity that should be imported
-
getPersisted
public T getPersisted()
- Specified by:
getPersisted
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- The persisted entity that may be overridden
-
setPersisted
public void setPersisted(T persisted)
- Specified by:
setPersisted
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
persisted
- The persisted entity that may be overridden
-
getEntityClass
public Class<?> getEntityClass()
- Specified by:
getEntityClass
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- the class of the entity
-
getUnresolvedDependencies
public Map<de.xima.cmn.dao.interfaces.IEntity<Long>,List<IEntityDependency>> getUnresolvedDependencies()
- Specified by:
getUnresolvedDependencies
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- a map of all the entities of this import config that have unresolved dependencies. This includes not only entity dependencies of this import config entity but also dependencies of its children, e.g.: a ProjectImportConfig might have unresolved dependencies for one of its WorkflowStates.
-
getConflictResolveAction
public EEntityConflictResolveAction getConflictResolveAction()
- Specified by:
getConflictResolveAction
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
EEntityConflictResolveAction
specifying what to do if the entity already exists
-
setConflictResolveAction
public void setConflictResolveAction(EEntityConflictResolveAction conflictResolveAction)
- Specified by:
setConflictResolveAction
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
conflictResolveAction
-EEntityConflictResolveAction
specifying what to do if the entity already exists
-
isEntityExists
public boolean isEntityExists()
- Specified by:
isEntityExists
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
true
if the given entity already exists (based on UUID and its context)
-
isImported
public boolean isImported()
- Specified by:
isImported
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- Whether the entity has been imported yet
-
setImported
@Deprecated public void setImported(boolean imported)
Deprecated.Description copied from interface:IEntityImportConfig
Sets whether the entity has been imported.- Specified by:
setImported
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
imported
- Whether the entity has been imported.
-
getOriginal
public Object getOriginal()
Description copied from interface:IEntityImportConfig
Gets the reference to the original object referenced in the import file. The exact type of the object depends on the type of import config. For example, for client form theme import configs, this might be theFormThemeReference
of a plugin form theme.- Specified by:
getOriginal
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- original A reference to the original object referenced in the import file.
-
setOriginal
public void setOriginal(Object original)
- Specified by:
setOriginal
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
original
- A reference to the original object referenced in the import file.
-
getOriginalID
public Long getOriginalID()
- Specified by:
getOriginalID
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- original ID of the entity
-
getOriginalExportId
public Long getOriginalExportId()
- Specified by:
getOriginalExportId
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- The original ID of the entity from the export file. Note that
IEntityImportConfig.getOriginalID()
may benull
when the IDs are not preserved, this will always be set to the original ID from the export file.
-
getOriginalUUID
public UUID getOriginalUUID()
- Specified by:
getOriginalUUID
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- original UUID of the entity or
null
if the entity is noIUUIDEntity
-
getOriginalName
public String getOriginalName()
- Specified by:
getOriginalName
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- original name of the entity before import (and possible name change)
-
getChildren
public List<IEntityImportConfig<?>> getChildren()
- Specified by:
getChildren
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- all child importConfigs
-
getAllChildrenFlat
public List<IEntityImportConfig<?>> getAllChildrenFlat()
- Specified by:
getAllChildrenFlat
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- all child importConfigs. Including the children of children
-
getEntityToOverride
@Deprecated public de.xima.cmn.dao.interfaces.IEntity<Long> getEntityToOverride()
Deprecated.- Specified by:
getEntityToOverride
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
IEntity
that should be overridden instead of the persisted
-
setEntityToOverride
@Deprecated public void setEntityToOverride(de.xima.cmn.dao.interfaces.IEntity<Long> entityToOverride)
Deprecated.- Specified by:
setEntityToOverride
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
entityToOverride
-IEntity
that should be overridden instead of the persisted
-
getImportJson
@Deprecated public String getImportJson()
Deprecated.- Specified by:
getImportJson
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Returns:
- the original JSON String of the import entity
-
setAlternative
public void setAlternative(Object alternative)
Description copied from interface:IEntityImportConfig
Sets a reference to the alternative that should be used instead of the entity represented by this import config. The type of object depends on the entity type of this import config.IEntityImportConfig.loadAlternative(IEntityContext)
must be able to use this object to load the alternative. Often, this will be aLong
, representing theID
of an existing entity to use instead.- Specified by:
setAlternative
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
alternative
- An object referencing the alternative to use.
-
loadAlternative
public Object loadAlternative(IEntityContext ec)
Description copied from interface:IEntityImportConfig
Loads the alternative that should be used instead of the entity represented by this import config. The alternative must have been set viaIEntityImportConfig.setAlternative(Object)
before. If it was not set, this method should return null.- Specified by:
loadAlternative
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
ec
- The entity context to use for accessing the database.- Returns:
- Alternative that should be used instead. Often, this will be an
IEntity
with the same type as the entity represented by this import config.
-
updatePersisted
public void updatePersisted(IEntityContext ec)
Description copied from interface:IEntityImportConfig
Updates the persisted entity if existing based on the entity represented by this config- Specified by:
updatePersisted
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
ec
-IEntityContext
to be used for updating the persisted entity
-
stage
public void stage(IEntityContext ec) throws Exception
Description copied from interface:IEntityImportConfig
Stages the import for execution based on the given configuration- Specified by:
stage
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
ec
-IEntityContext
to be used- Throws:
Exception
- When the entity could not be staged.
-
finalize
public List<DependencyDescriptor> finalize(IEntityContext ec, String fcVersion, String exportVersion) throws Exception
Description copied from interface:IEntityImportConfig
Finish the import. Should be called after every import config has been staged for import and deprecated fields have been handled.- Specified by:
finalize
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
ec
-IEntityContext
to be usedfcVersion
- The current formcycle version where the entity is imported.exportVersion
- The formcycle version that was used to create the export file with the entity.- Returns:
List
ofDependencyDescriptor
s of missing dependencies- Throws:
Exception
- When the entity import could not be finalized.
-
resolveDependencies
@Deprecated public void resolveDependencies(IEntityContext ec)
Deprecated.Description copied from interface:IEntityImportConfig
Resolves the dependencies of this entity- Specified by:
resolveDependencies
in interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
- Parameters:
ec
-IEntityContext
to be used
-
findPersisted
protected T findPersisted(IEntityContext ec)
-
getDao
protected abstract IGenericDao<T> getDao()
-
isUuidExisting
protected boolean isUuidExisting(IEntityContext ec)
-
makeEntityUnique
protected abstract void makeEntityUnique(IEntityContext ec) throws Exception
- Throws:
Exception
-
postCreate
protected void postCreate(IEntityContext ec) throws Exception
- Throws:
Exception
-
postUpdate
protected void postUpdate(IEntityContext ec) throws Exception
- Throws:
Exception
-
preCreate
protected void preCreate(IEntityContext ec) throws Exception
- Throws:
Exception
-
preUpdate
protected void preUpdate(IEntityContext ec) throws Exception
- Throws:
Exception
-
validateImport
protected void validateImport(IEntityContext ec) throws Exception
- Throws:
Exception
-
getDependencyUuid
protected static UUID getDependencyUuid(IEntityImportConfig<?> config, String fieldDescriptor)
-
-