Class AspectState<T extends ComplexEntity>

java.lang.Object
mc.core.system.base.BaseBean
mc.core.domain.base.dobj.AbstractAspect<T>
mc.core.domain.base.aspect.AspectState<T>

public class AspectState<T extends ComplexEntity> extends AbstractAspect<T>
  • Constructor Details

    • AspectState

      public AspectState()
  • Method Details

    • filterByEditAllowed

      @Deprecated public List<T> filterByEditAllowed(List<T> entityListToCheck)
      Deprecated.
      IMPORTANT CHANGES V13 - no fallback to getContentLocale more!
      use better filterByEditAllowed(List entityListToCheck, Locale locale)
      Parameters:
      entityListToCheck -
      Returns:
    • filterByEditAllowed

      public List<T> filterByEditAllowed(List<T> entityListToCheck, Locale locale)
    • filterByEditAllowed

      public List<T> filterByEditAllowed(List<T> entityListToCheck, User user, Locale locale)
      IMPORTANT CHANGES V13 - no fallback to getContentLocale more!
      filter list by edit allowed state pro object
      see isEditAllowed(IStateManaged, User, Locale)
    • isEditAllowed

      public boolean isEditAllowed(IStateManaged entity, User user, Locale locale)
      IMPORTANT CHANGES V13 - no fallback to getContentLocale more!
      checks if object is in edit state for session user for all state groups that require an edit state.
      If state group is language dependent checks on given locale.
      Parameters:
      locale - optional, if null -> check edit structure and edit state in ALL locales not in content locale only!
    • getStatesPreventingEdit

      public mc.core.system.util.misc.Pair<List<State>,List<StateGroupType>> getStatesPreventingEdit(IStateManaged entity, User user, Locale locale, boolean failFast)
      IMPORTANT CHANGES V13 - no fallback to getContentLocale more!
      Parameters:
      entity - mandatory
      user - mandatory
      locale - optional IMPORTANT CHANGES V13(#15828) changed logic !!! ->
      no fallback to content locale more if null -> check all language dependent states instead.
      Returns:
      returns null if entity is editable by current user. Otherwise returns pair: left contains list of states that prevent current user from editing given entity, or a empty list. Right contains StateGroupTypes for which entity has no state, thus also preventing editing, or empty list.
    • insertDefaultState

      public State insertDefaultState(IStateManaged entity, StateGroupType stateGroupType, Locale locale) throws ApplicationException
      if a stateGroup has been added to complexEntityType when already complex entities exist insert the default state for these entities
      Parameters:
      entity - mandatory
      stateGroupType - mandatory
      locale - optional, default is content locale
      Returns:
      inserted state entity
      Throws:
      ApplicationException
    • insertLocaleState

      public void insertLocaleState(IStateManaged entity, Locale locale) throws ApplicationException
      sets insert state for each configured stateGroupType in given locale. Also inserts first version for given locale
      Parameters:
      entity - mandatory
      locale - optional, default is content locale
      Throws:
      ApplicationException
    • setState

      public State setState(IStateManaged entity, StateType stateType, boolean recursive, Locale locale) throws ApplicationException
      sets given state for given entity. Overwrites old state for same stateGroup. handles setting of locale regarding the language dependency of stateGroup. Is stateGroup is language dependent and no locale is specified uses content locale.
      Parameters:
      entity - mandatory
      stateType - mandatory
      recursive - boolean: if entity is hierarchical entity also sets this state for all children.
      locale - optional, default is content locale, or undefinedLocale for locale independent states
      Returns:
      state set
      Throws:
      ApplicationException - the application exception
    • doStateTransition

      public void doStateTransition(IStateManaged entity, StateTransitionType stateTransitionType, Locale locale, String message) throws ApplicationException
      executes the transition and changes the state of the object. Calls on StateTransitionHandler before and after transition, if a handler is configured
      Parameters:
      entity - mandatory
      stateTransitionType - mandatory
      locale - optional, default is contentLocale or undefined locale for locale independent states
      message - optional
      Throws:
      ApplicationException
    • getAllowedStateTransitionTypes

      public List<StateTransitionType> getAllowedStateTransitionTypes(T entity, StateGroupType stateGroupType, Locale locale) throws ApplicationException
      returns all stateTransitionTypes for the current User, the specified stateGroup and the locale
      Parameters:
      entity - mandatory
      stateGroupType - mandatory
      locale - optional
      Returns:
      stateTransitionType list, never null
      Throws:
      ApplicationException