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 Deprecated 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 booleancheckEntityNameExists(IEntityContext ec, String name, de.xima.cmn.dao.interfaces.IEntity<Long> entity, de.xima.cmn.dao.interfaces.IEntity<Long> excludeEntity)static intcompareByEntityClass(Object o1, Object o2)static StringgetDisplayName(de.xima.cmn.dao.interfaces.IEntity<Long> entity)Returns a String representation of the entity for displaying to the userstatic StringgetDisplayName(de.xima.cmn.dao.interfaces.IEntity<Long> entity, Locale locale)Returns a String representation of the entity for displaying to the userstatic StringgetDisplayName(IEntityImportConfig<?> config)Returns a human-readable name of the entity from the given config 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 FieldgetEntityField(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 ExportMetadatagetExportMetaData(InputStream is)static StringgetSubtitle(Locale locale, IEntityImportConfig<?> config, IMessageLocalizer localizer)Returns the subtitle of the entity from the given config for displaying to the user.static StringgetTypeName(Locale locale, IEntityImportConfig<?> config, IMessageLocalizer localizer)Returns a string representation type of object from the given config for displaying to the userstatic <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 StringgetUniqueProjectAlias(IEntityContext ec, Projekt project, boolean excludeSelf)static StringgetUniqueProjectTitle(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 the given client with the given uuidsstatic booleanisEntityNameExists(IEntityContext ec, String name, de.xima.cmn.dao.interfaces.IEntity<Long> entity, boolean excludeSelf)Checks whether the name of the entity is used by any other entity in its contextstatic booleanisIdentical(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 booleanisProjectTitleExists(IEntityContext ec, String title, Projekt project, boolean excludeSelf)Checks whether or not the given title is used by any other project of this clientstatic voidremoveConfig(UUID uuid, Class<? extends de.xima.cmn.dao.interfaces.IEntity<Long>> clazz, List<IEntityImportConfig<?>> configs)static IEntityDependencyremoveDependency(IEntityImportConfig<?> config, String fieldDescriptor)Removes the first dependency from the given config with the given field descriptorstatic voidsetEntityField(de.xima.cmn.dao.interfaces.IEntity<Long> entity, String fieldDescriptor, Object value)Sets the field property of the entity with the given valuestatic voidupdateInboxRef(IInboxDependent proc, Postfach inbox)Deprecated.
-
-
-
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-IEntityContextto useentity-IEntityentity for which the field value should be added/setfieldDescriptor-Stringdescriptor of the field to set e.g 'bedingung#folgeAktion'value-Objectto 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-IEntityentity for which the field should be setfieldDescriptor-Stringdescriptor of the field to set e.g 'bedingung#folgeAktion'value-Objectto set for the field- Throws:
IllegalAccessException- When the field is inaccssible.IllegalArgumentException- When the type of the field is incompatible with the givenvalue.
-
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-IEntityContextto be usedproject-Projektto get unique title forexcludeSelf-Booleanwhether to include this project's title (based on UUID)- Returns:
Stringunique 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-IEntityContextto be usedentity-to get unique name for excludeEntity-to be excluded in search for a unique name - Returns:
Stringunique 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 the name of the entity is used by any other entity in its context- Parameters:
ec-IEntityContextto be usedname-Stringto check forentity-IEntityto check forexcludeSelf-Booleanwhether to include this entity's name (based on UUID if existing, otherwise based on ID)- Returns:
trueif another entity has the given entity's name within its context.falseotherwise
-
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-IEntityContextto be usedtitle-Stringto check forproject-Projektto check forexcludeSelf-Booleanwhether to include this project's title (based on UUID)- Returns:
trueif another entity has the given entity's name within its context.falseotherwise
-
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 String getDisplayName(de.xima.cmn.dao.interfaces.IEntity<Long> entity)
Returns a String representation of the entity for displaying to the user- Parameters:
entity-IEntityto get a display name for- Returns:
Stringname representing the entity for messaging
-
getTypeName
public static String getTypeName(Locale locale, IEntityImportConfig<?> config, IMessageLocalizer localizer)
Returns a string representation type of object from the given config for displaying to the user- Parameters:
locale- Locale in which to display the nameconfig- Import config to get a display name forlocalizer- Function to localize message keys.- Returns:
Stringname representing the entity for messaging
-
getSubtitle
public static String getSubtitle(Locale locale, IEntityImportConfig<?> config, IMessageLocalizer localizer)
Returns the subtitle of the entity from the given config for displaying to the user. The subtitle may contain further details, in addition to thedisplay name. Might be empty if there are no further details.- Parameters:
locale- Locale in which to display the subtitle.config- Import config for which to get the subtitle.localizer- Function to localize message keys.- Returns:
- A subtitle with further details about the entity.
-
getDisplayName
public static String getDisplayName(IEntityImportConfig<?> config)
Returns a human-readable name of the entity from the given config for displaying to the user- Parameters:
config- Import config to get a display name for- Returns:
Stringname 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-IEntitye2-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 the given client with the given uuids- Parameters:
ec-IEntityContextto useuuids-ListofUUIDs to look forclient-Mandantto look inimportConfigs-Listof import configs used for getting the names of the user groups- Returns:
ListofBenutzerGruppe
-
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-IEntityImportConfigconfig to remove dependency fromfieldDescriptor-Stringdescribing the dependency- Returns:
IEntityDependencythat 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
@Deprecated public static final void updateInboxRef(IInboxDependent proc, Postfach inbox)
Deprecated.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-IInboxDependentprocessing to set reference forinbox-Postfachto 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.
-
-