Package de.xima.fc.importer.util
Class EntityImportHelper
- java.lang.Object
-
- de.xima.fc.importer.util.EntityImportHelper
-
public class EntityImportHelper extends Object
Helper class for importing entities- Author:
- XIMA MEDIA GmbH
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
TaddValueToEntityField(IEntityContext ec, T entity, String fieldDescriptor, Object value)
Adds/sets the given value to the field property of the entity.static <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
TaddValueToEntityField(T entity, String fieldDescriptor, Object value)
Adds/sets the given value to the field property of the entity.static boolean
checkEntityNameExists(IEntityContext ec, String name, de.xima.cmn.dao.interfaces.IEntity<Long> entity, de.xima.cmn.dao.interfaces.IEntity<Long> excludeEntity)
static int
compareByEntityClass(Object o1, Object o2)
static String
getDisplayName(de.xima.cmn.dao.interfaces.IEntity<Long> entity)
Returns a String representation of the entity for displaying to the userstatic String
getDisplayName(de.xima.cmn.dao.interfaces.IEntity<Long> entity, Locale locale)
Returns a String representation of the entity for displaying to the userstatic de.xima.cmn.dao.interfaces.IEntity<Long>
getEntity(UUID uuid, Class<? extends de.xima.cmn.dao.interfaces.IEntity<Long>> entityClass, List<IEntityImportConfig<?>> importConfigs)
Looks for entity with the given uuid and class in the list of import configs and returns it.static Field
getEntityField(Class<?> clazz, String fieldName)
Gets the class field by name.static <T extends de.xima.cmn.dao.interfaces.IEntity<Long>>
StringgetEntityName(UUID uuid, Class<T> entityClass, List<IEntityImportConfig<?>> importConfigs)
Looks for entity with the given uuid and class in the list of import configs and returns its name if there is any.static ExportMetadata
getExportMetaData(InputStream is)
static <T extends INameProviding & de.xima.cmn.dao.interfaces.IEntity<Long>>
StringgetUniqueEntityName(IEntityContext ec, T entity, T excludeEntity)
Gets a unique entity name for the given entitystatic String
getUniqueProjectAlias(IEntityContext ec, Projekt project, boolean excludeSelf)
static String
getUniqueProjectTitle(IEntityContext ec, Projekt project, boolean excludeSelf)
Gets a unique project title for the given projectstatic List<BenutzerGruppe>
getUserGroups(IEntityContext ec, List<UUID> uuids, Mandant client, List<IEntityImportConfig<?>> importConfigs)
Gets a list of user groups in th given client with the given uuidsstatic boolean
isEntityNameExists(IEntityContext ec, String name, de.xima.cmn.dao.interfaces.IEntity<Long> entity, boolean excludeSelf)
Checks whether or not the name of the entity is used by any other entity in its contextstatic boolean
isIdentical(de.xima.cmn.dao.interfaces.IEntity<Long> e1, de.xima.cmn.dao.interfaces.IEntity<Long> e2)
Compares to entities and checks if they are "identical"static boolean
isProjectTitleExists(IEntityContext ec, String title, Projekt project, boolean excludeSelf)
Checks whether or not the given title is used by any other project of this clientstatic void
removeConfig(UUID uuid, Class<? extends de.xima.cmn.dao.interfaces.IEntity<Long>> clazz, List<IEntityImportConfig<?>> configs)
static IEntityDependency
removeDependency(IEntityImportConfig<?> config, String fieldDescriptor)
Removes the first dependency from the given config with the given field descriptorstatic void
setEntityField(de.xima.cmn.dao.interfaces.IEntity<Long> entity, String fieldDescriptor, Object value)
Sets the field property of the entity with the given valuestatic void
updateInboxRef(IInboxDependent proc, Postfach inbox)
Sets the inbox reference in the given inbox dependent processing to the given inbox.
-
-
-
Method Detail
-
addValueToEntityField
public static <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> T addValueToEntityField(T entity, String fieldDescriptor, Object value) throws Exception
Adds/sets the given value to the field property of the entity.
-
addValueToEntityField
public static <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> T addValueToEntityField(IEntityContext ec, T entity, String fieldDescriptor, Object value) throws Exception
Adds/sets the given value to the field property of the entity. The entity will be reloaded from DAO if possible- Parameters:
ec
-IEntityContext
to useentity
-IEntity
entity for which the field value should be added/setfieldDescriptor
-String
descriptor of the field to set e.g 'bedingung#folgeAktion'value
-Object
to set for the field or add to the field (if list)- Throws:
Exception
- on errors during setting the value
-
setEntityField
public static void setEntityField(de.xima.cmn.dao.interfaces.IEntity<Long> entity, String fieldDescriptor, Object value) throws IllegalArgumentException, IllegalAccessException
Sets the field property of the entity with the given value- Parameters:
entity
-IEntity
entity for which the field should be setfieldDescriptor
-String
descriptor of the field to set e.g 'bedingung#folgeAktion'value
-Object
to set for the field- Throws:
IllegalAccessException
Exception
- on errors during setting the valueIllegalArgumentException
-
getEntityField
public static final Field getEntityField(Class<?> clazz, String fieldName)
Gets the class field by name. If none is found and the class has a superclass, this method will recursively call itself with the superclass
-
getUniqueProjectTitle
public static final String getUniqueProjectTitle(IEntityContext ec, Projekt project, boolean excludeSelf) throws LimitExceededException
Gets a unique project title for the given project- Parameters:
ec
-IEntityContext
to be usedproject
-Projekt
to get unique title forexcludeSelf
-Boolean
whether to include this project's title (based on UUID)- Returns:
String
unique project title- Throws:
LimitExceededException
-
getUniqueProjectAlias
public static final String getUniqueProjectAlias(IEntityContext ec, Projekt project, boolean excludeSelf) throws LimitExceededException
- Throws:
LimitExceededException
-
getUniqueEntityName
public static final <T extends INameProviding & de.xima.cmn.dao.interfaces.IEntity<Long>> String getUniqueEntityName(IEntityContext ec, T entity, T excludeEntity)
Gets a unique entity name for the given entity- Type Parameters:
T
- type of entity- Parameters:
ec
-IEntityContext
to be usedentity
-to get unique name for excludeEntity
-to be excluded in search for a unique name - Returns:
String
unique entity name
-
checkEntityNameExists
public static final boolean checkEntityNameExists(IEntityContext ec, String name, de.xima.cmn.dao.interfaces.IEntity<Long> entity, de.xima.cmn.dao.interfaces.IEntity<Long> excludeEntity)
-
isEntityNameExists
public static final boolean isEntityNameExists(IEntityContext ec, String name, de.xima.cmn.dao.interfaces.IEntity<Long> entity, boolean excludeSelf)
Checks whether or not the name of the entity is used by any other entity in its context- Parameters:
ec
-IEntityContext
to be usedname
-String
to check forentity
-IEntity
to check forexcludeSelf
-Boolean
whether to include this entity's name (based on UUID if existing, otherwise based on ID)- Returns:
true
if another entity has the given entity's name within its context.false
otherwise
-
isProjectTitleExists
public static final boolean isProjectTitleExists(IEntityContext ec, String title, Projekt project, boolean excludeSelf)
Checks whether or not the given title is used by any other project of this client- Parameters:
ec
-IEntityContext
to be usedtitle
-String
to check forproject
-Projekt
to check forexcludeSelf
-Boolean
whether to include this project's title (based on UUID)- Returns:
true
if another entity has the given entity's name within its context.false
otherwise
-
getExportMetaData
public static final ExportMetadata getExportMetaData(InputStream is) throws Exception
- Throws:
Exception
-
getDisplayName
public static final String getDisplayName(de.xima.cmn.dao.interfaces.IEntity<Long> entity, Locale locale)
Returns a String representation of the entity for displaying to the user
-
getDisplayName
public static final String getDisplayName(de.xima.cmn.dao.interfaces.IEntity<Long> entity)
Returns a String representation of the entity for displaying to the user- Parameters:
entity
-IEntity
to get a display name for- Returns:
String
name representing the entity for messaging
-
isIdentical
public static final boolean isIdentical(de.xima.cmn.dao.interfaces.IEntity<Long> e1, de.xima.cmn.dao.interfaces.IEntity<Long> e2)
Compares to entities and checks if they are "identical"- Parameters:
e1
-IEntity
e2
-IEntity
- Returns:
Boolean
-
getUserGroups
public static final List<BenutzerGruppe> getUserGroups(IEntityContext ec, List<UUID> uuids, Mandant client, List<IEntityImportConfig<?>> importConfigs)
Gets a list of user groups in th given client with the given uuids- Parameters:
ec
-IEntityContext
to useuuids
-List
ofUUID
s to look forclient
-Mandant
to look inimportConfigs
-List
of import configs used for getting the names of the user groups- Returns:
List
ofBenutzerGruppe
-
removeDependency
public static final IEntityDependency removeDependency(IEntityImportConfig<?> config, String fieldDescriptor)
Removes the first dependency from the given config with the given field descriptor- Parameters:
config
-IEntityImportConfig
config to remove dependency fromfieldDescriptor
-String
describing the dependency- Returns:
IEntityDependency
that has been removed
-
removeConfig
public static final void removeConfig(UUID uuid, Class<? extends de.xima.cmn.dao.interfaces.IEntity<Long>> clazz, List<IEntityImportConfig<?>> configs)
-
updateInboxRef
public static final void updateInboxRef(IInboxDependent proc, Postfach inbox)
Sets the inbox reference in the given inbox dependent processing to the given inbox. An invalid refernce will be set if the inbox isnull
- Parameters:
proc
-IInboxDependent
processing to set reference forinbox
-Postfach
to set reference to
-
getEntityName
public static final <T extends de.xima.cmn.dao.interfaces.IEntity<Long>> String getEntityName(UUID uuid, Class<T> entityClass, List<IEntityImportConfig<?>> importConfigs)
Looks for entity with the given uuid and class in the list of import configs and returns its name if there is any.
-
getEntity
public static final de.xima.cmn.dao.interfaces.IEntity<Long> getEntity(UUID uuid, Class<? extends de.xima.cmn.dao.interfaces.IEntity<Long>> entityClass, List<IEntityImportConfig<?>> importConfigs)
Looks for entity with the given uuid and class in the list of import configs and returns it.
-
-