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 Objectalternativeprotected EEntityConflictResolveActionconflictResolveActionprotected de.xima.cmn.dao.interfaces.IEntity<Long>contextprotected Tentityprotected com.vdurmont.semver4j.SemverformcycleVersionprotected StringimportJsonprotected static org.slf4j.LoggerLOGprotected static StringLOG_PREFIXprotected LongoriginalIDprotected StringoriginalNameprotected UUIDoriginalUUIDprotected Tpersistedprotected StringpersistedNameprotected 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 TfindPersisted(IEntityContext ec)List<IEntityImportConfig<?>>getAllChildrenFlat()List<IEntityImportConfig<?>>getChildren()EEntityConflictResolveActiongetConflictResolveAction()protected abstract IGenericDao<T>getDao()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)protected voidpostCreate(IEntityContext ec)protected voidpostUpdate(IEntityContext ec)protected voidpreCreate(IEntityContext ec)protected voidpreUpdate(IEntityContext ec)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, 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:
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()
-
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)
-
-