Class EntityImportHelper


  • public class EntityImportHelper
    extends Object
    Helper class for importing entities
    Author:
    XIMA MEDIA GmbH
    • 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.
        Parameters:
        entity - IEntity entity for which the field value should be added/set
        fieldDescriptor - 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
      • 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 use
        entity - IEntity entity for which the field value should be added/set
        fieldDescriptor - 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
      • 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
        Parameters:
        clazz - Class to check for the field name
        fieldName - String field name to look for
        Returns:
        Field of the class or null if none was found
      • 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 used
        entity - 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 used
        name - String to check for
        entity - IEntity to check for
        excludeSelf - 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 used
        title - String to check for
        project - Projekt to check for
        excludeSelf - 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
      • 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
      • compareByEntityClass

        public static final int compareByEntityClass​(Object o1,
                                                     Object o2)
      • 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
      • 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 is null
        Parameters:
        proc - IInboxDependent processing to set reference for
        inbox - 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.
        Type Parameters:
        T - the entity-class-type
        Parameters:
        uuid - UUID of the entity
        entityClass - Class of the entity
        importConfigs - List of import configs to look through
        Returns:
        the name of the entity or null if none was found
      • 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.
        Parameters:
        uuid - UUID of the entity
        entityClass - Class of the entity
        importConfigs - List of import configs to look through
        Returns:
        IEntity entity or null if none was found