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,DatatableImportConfig,DatenbankZugriffImportConfig,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 ObjectalternativeAlternative of the entity to be imported.protected EEntityConflictResolveActionconflictResolveActionBehavior of resolving a conflict.protected de.xima.cmn.dao.interfaces.IEntity<Long>contextTenant or project of the entity to be imported.protected TentityThe entity to be imported.protected com.vdurmont.semver4j.SemverformcycleVersionprotected StringimportJsonThe serialized representation of the import.protected static org.slf4j.LoggerLOGLoggerprotected static StringLOG_PREFIXprotected LongoriginalIDID of the entity to be imported.protected StringoriginalNameName of the entity to be imported.protected UUIDoriginalUUIDUUID of the entity to be imported.protected TpersistedThe existing entity.protected StringpersistedNameName of the existing entity.protected Map<de.xima.cmn.dao.interfaces.IEntity<Long>,List<IEntityDependency>>unresolvedDependenciesDependencies of the entity, referenced by UUID, to be resolved.
-
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 TfindPersisted(IEntityContext ec)List<IEntityImportConfig<?>>getAllChildrenFlat()List<IEntityImportConfig<?>>getChildren()EEntityConflictResolveActiongetConflictResolveAction()protected abstract IGenericDao<T>getDao()Returns the data access object of the entity to be imported.protected static UUIDgetDependencyUuid(IEntityImportConfig<?> config, String fieldDescriptor)TgetEntity()Class<?>getEntityClass()de.xima.cmn.dao.interfaces.IEntity<Long>getEntityToOverride()Deprecated.StringgetImportJson()Deprecated.ObjectgetOriginal()Gets the reference to the original object referenced in the import file.LonggetOriginalExportId()LonggetOriginalID()StringgetOriginalName()UUIDgetOriginalUUID()TgetPersisted()Map<de.xima.cmn.dao.interfaces.IEntity<Long>,List<IEntityDependency>>getUnresolvedDependencies()protected static StringgetUuidEntityValue(com.google.gson.JsonObject authConfig, String key)booleanisEntityExists()booleanisImported()protected booleanisUuidExisting(IEntityContext ec)ObjectloadAlternative(IEntityContext ec)Loads the alternative that should be used instead of the entity represented by this import config.protected abstract voidmakeEntityUnique(IEntityContext ec)Makes the entity to be imported unique with respect to database constraints.protected voidpostCreate(IEntityContext ec)Is called after creating the entity to be imported.protected voidpostUpdate(IEntityContext ec)Is called after overriding the entity to be imported.protected voidpreCreate(IEntityContext ec)Is called before the entity to be imported is created.protected voidpreUpdate(IEntityContext ec)Is called before the entity to be imported is overridden.voidresolveDependencies(IEntityContext ec)Deprecated.voidsetAlternative(Object alternative)Sets a reference to the alternative that should be used instead of the entity represented by this import config.voidsetConflictResolveAction(EEntityConflictResolveAction conflictResolveAction)voidsetEntity(T entity)Deprecated.voidsetEntityToOverride(de.xima.cmn.dao.interfaces.IEntity<Long> entityToOverride)Deprecated.voidsetImported(boolean imported)Deprecated.voidsetOriginal(Object original)voidsetPersisted(T persisted)voidstage(IEntityContext ec)Stages the import for execution based on the given configurationStringtoString()voidupdatePersisted(IEntityContext ec)Updates the persisted entity if existing based on the entity represented by this configprotected voidvalidateImport(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, ignore, isRelevantForImport, setAlternativeId, shouldAlsoBeIgnored
-
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
Logger
-
LOG_PREFIX
protected static final String LOG_PREFIX
- See Also:
- Constant Field Values
-
formcycleVersion
protected final com.vdurmont.semver4j.Semver formcycleVersion
-
entity
protected T extends de.xima.cmn.dao.interfaces.IEntity<Long> entity
The entity to be imported.
-
persisted
protected T extends de.xima.cmn.dao.interfaces.IEntity<Long> persisted
The existing entity. If the entity to be imported already exists, based on the UUID, this property holds the already existing entity.
-
persistedName
protected String persistedName
Name of the existing entity.
-
unresolvedDependencies
protected final Map<de.xima.cmn.dao.interfaces.IEntity<Long>,List<IEntityDependency>> unresolvedDependencies
Dependencies of the entity, referenced by UUID, to be resolved.
-
importJson
protected String importJson
The serialized representation of the import.
-
originalID
protected Long originalID
ID of the entity to be imported.
-
originalUUID
protected UUID originalUUID
UUID of the entity to be imported.
-
originalName
protected String originalName
Name of the entity to be imported.
-
context
protected de.xima.cmn.dao.interfaces.IEntity<Long> context
Tenant or project of the entity to be imported. The entity should implementIMandantDependentorIProjektDependent.
-
alternative
protected Object alternative
Alternative of the entity to be imported. If an alternative is selected, the entity to be imported is skipped.
-
conflictResolveAction
protected EEntityConflictResolveAction conflictResolveAction
Behavior of resolving a conflict. A conflict arises, if the entity to be imported already exists, based on UUID.
-
-
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:
getEntityin 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:
setEntityin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Parameters:
entity- The entity that should be imported
-
getPersisted
public T getPersisted()
- Specified by:
getPersistedin 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:
setPersistedin 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:
getEntityClassin 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:
getUnresolvedDependenciesin 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:
getConflictResolveActionin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Returns:
EEntityConflictResolveActionspecifying what to do if the entity already exists
-
setConflictResolveAction
public void setConflictResolveAction(EEntityConflictResolveAction conflictResolveAction)
- Specified by:
setConflictResolveActionin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Parameters:
conflictResolveAction-EEntityConflictResolveActionspecifying what to do if the entity already exists
-
isEntityExists
public boolean isEntityExists()
- Specified by:
isEntityExistsin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Returns:
trueif the given entity already exists (based on UUID and its context)
-
isImported
public boolean isImported()
- Specified by:
isImportedin 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:IEntityImportConfigSets whether the entity has been imported.- Specified by:
setImportedin 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:IEntityImportConfigGets 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 theFormThemeReferenceof a plugin form theme.- Specified by:
getOriginalin 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:
setOriginalin 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:
getOriginalIDin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Returns:
- original ID of the entity
-
getOriginalExportId
public Long getOriginalExportId()
- Specified by:
getOriginalExportIdin 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 benullwhen the IDs are not preserved, this will always be set to the original ID from the export file.
-
getOriginalUUID
public UUID getOriginalUUID()
- Specified by:
getOriginalUUIDin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Returns:
- original UUID of the entity or
nullif the entity is noIUUIDEntity
-
getOriginalName
public String getOriginalName()
- Specified by:
getOriginalNamein 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:
getChildrenin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Returns:
- all child importConfigs
-
getAllChildrenFlat
public List<IEntityImportConfig<?>> getAllChildrenFlat()
- Specified by:
getAllChildrenFlatin 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:
getEntityToOverridein interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Returns:
IEntitythat should be overridden instead of the persisted
-
setEntityToOverride
@Deprecated public void setEntityToOverride(de.xima.cmn.dao.interfaces.IEntity<Long> entityToOverride)
Deprecated.- Specified by:
setEntityToOverridein interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Parameters:
entityToOverride-IEntitythat should be overridden instead of the persisted
-
getImportJson
@Deprecated public String getImportJson()
Deprecated.- Specified by:
getImportJsonin 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:IEntityImportConfigSets 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 theIDof an existing entity to use instead.- Specified by:
setAlternativein 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:IEntityImportConfigLoads 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:
loadAlternativein 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
IEntitywith the same type as the entity represented by this import config.
-
updatePersisted
public void updatePersisted(IEntityContext ec)
Description copied from interface:IEntityImportConfigUpdates the persisted entity if existing based on the entity represented by this config- Specified by:
updatePersistedin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Parameters:
ec-IEntityContextto be used for updating the persisted entity
-
stage
public void stage(IEntityContext ec) throws Exception
Description copied from interface:IEntityImportConfigStages the import for execution based on the given configuration- Specified by:
stagein interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Parameters:
ec-IEntityContextto 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:IEntityImportConfigFinish the import. Should be called after every import config has been staged for import and deprecated fields have been handled.- Specified by:
finalizein interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Parameters:
ec-IEntityContextto 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:
ListofDependencyDescriptors 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:IEntityImportConfigResolves the dependencies of this entity- Specified by:
resolveDependenciesin interfaceIEntityImportConfig<T extends de.xima.cmn.dao.interfaces.IEntity<Long>>- Parameters:
ec-IEntityContextto be used
-
findPersisted
protected T findPersisted(IEntityContext ec)
-
getDao
protected abstract IGenericDao<T> getDao()
Returns the data access object of the entity to be imported.- Returns:
- data access object
-
isUuidExisting
protected boolean isUuidExisting(IEntityContext ec)
-
makeEntityUnique
protected abstract void makeEntityUnique(IEntityContext ec) throws Exception
Makes the entity to be imported unique with respect to database constraints. If the name is unique, this method should make the entity's name unique.- Parameters:
ec- entity context- Throws:
Exception- if an error occurs
-
postCreate
protected void postCreate(IEntityContext ec) throws Exception
Is called after creating the entity to be imported.- Parameters:
ec- entity context- Throws:
Exception- if an error occurs
-
postUpdate
protected void postUpdate(IEntityContext ec) throws Exception
Is called after overriding the entity to be imported. If the existing entity is overridden, it is being updated.- Parameters:
ec- entity context- Throws:
Exception- if an error occurs
-
preCreate
protected void preCreate(IEntityContext ec) throws Exception
Is called before the entity to be imported is created.- Parameters:
ec- entity context- Throws:
Exception- if an error occurs
-
preUpdate
protected void preUpdate(IEntityContext ec) throws Exception
Is called before the entity to be imported is overridden.- Parameters:
ec- entity context- Throws:
Exception- if an error occurs
-
validateImport
protected void validateImport(IEntityContext ec) throws Exception
- Throws:
Exception
-
getDependencyUuid
protected static UUID getDependencyUuid(IEntityImportConfig<?> config, String fieldDescriptor)
-
-