Class SearchRestriction

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable

    public class SearchRestriction
    extends TypeManagerManaged
    A SearchRestriction represents a restricted search for a principal, which will be used for realizing personalization
    See Also:
    Serialized Form
    • Constructor Detail

      • SearchRestriction

        public SearchRestriction()
    • Method Detail

      • createItem

        protected Item createItem​(SessionContext ctx,
                                  ComposedType type,
                                  Item.ItemAttributeMap atts)
                           throws JaloBusinessException,
                                  JaloInvalidParameterException
        Description copied from class: Item
        Has to be implemented for each concrete subtype of item. This method is responsible for creating a new item instance ( by calling managers, ejb homes, etc. ) during ComposedType.newInstance(Map).

        In case this method uses any of the attribute values during creation it is required to override Item.getNonInitialAttributes(SessionContext, ItemAttributeMap) too.
        Sn example:

        
         public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext
         ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return
         man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) );
         // here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes(
         SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret =
         super.getNonInitialAttributes( ctx, allAttributes );
         // remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }
        
         
        Specified by:
        createItem in class Item
        Parameters:
        ctx - the current session context which this item is created within
        type - the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )
        Returns:
        the new item instance
        Throws:
        JaloBusinessException - indicates an error during creation - any changes will be rollbacked
        JaloInvalidParameterException
      • getNonInitialAttributes

        protected Item.ItemAttributeMap getNonInitialAttributes​(SessionContext ctx,
                                                                Item.ItemAttributeMap allAttributes)
        Description copied from class: Item
        Defines all attributes which should be set after item creation. this is done be removing all attributes which are already set by Item.createItem(SessionContext, ComposedType, ItemAttributeMap).

        use it like this:

        
         protected ItemAttributeMap getNonInitialAttributes( SessionContext ctx, ItemAttributeMap allAttributes ) {
         // let all superclasses remove their intial attributes too final ItemAttributeMap attributes =
         super.getNonInitialAttributes( ctx, allAttributes ); // remove own initial attributes here attributes.remove(
         MyItem.MY_INITIAL_ATTR ); return ret; }
        
         
        it is vital to optain the map via super.getNonInitialAttributes and pass it on as such since this ensures that attribute qualifiers are treated case insensitive!
        Overrides:
        getNonInitialAttributes in class Item
        Parameters:
        ctx - session context with language = NULL
        allAttributes - a ItemAttributeMap contaning attribute values.
        Returns:
        a ItemAttributeMap containing all attribute values, which belong to non-initial attributes.
      • getCode

        public java.lang.String getCode()
      • setCode

        public void setCode​(SessionContext ctx,
                            java.lang.String code)
      • setCode

        public void setCode​(java.lang.String code)
      • isActive

        public boolean isActive()
        Since:
        2.10
      • setActive

        public void setActive​(boolean active)
        Since:
        2.10
      • getName

        public java.lang.String getName​(SessionContext ctx)
        Overrides:
        getName in class TypeManagerManaged
        Parameters:
        ctx - the session context specifying the language to get the name for
        Returns:
        the name of this type system item localized for the specified session context
      • getName

        public java.lang.String getName()
        Overrides:
        getName in class TypeManagerManaged
        Returns:
        the name of this type system item localized for the current session language
      • getAllName

        public java.util.Map getAllName​(SessionContext ctx)
      • getAllName

        public java.util.Map getAllName()
      • setName

        public void setName​(SessionContext ctx,
                            java.lang.String name)
        Description copied from class: TypeManagerManaged
        Changes the name of this type system item for the specified language.
        Overrides:
        setName in class TypeManagerManaged
        Parameters:
        ctx - the session context defining the language to change the name for
        name - the new name
      • setName

        public void setName​(java.lang.String name)
        Description copied from class: TypeManagerManaged
        Changes the name of this type system item for the current session language.
        Overrides:
        setName in class TypeManagerManaged
        Parameters:
        name - the new name
      • setAllName

        public void setAllName​(SessionContext ctx,
                               java.util.Map names)
      • getQuery

        public java.lang.String getQuery()
      • getRestrictionType

        public ComposedType getRestrictionType()
      • setRestrictionType

        public void setRestrictionType​(ComposedType type)
      • getPrincipal

        public Principal getPrincipal()
      • setPrincipal

        public void setPrincipal​(Principal p)
      • getExcludedSubtypes

        @Deprecated
        public java.util.Set<ComposedType> getExcludedSubtypes()
        Deprecated.
        since ages - not needed any longer
        Returns all subtypes of this restrictions type for which a specialized form of this restriction exists.

        These restrictions must have the exactly the same code but are assigned to subtypes of the original restriction.

        Within FlexibleSearch queries all these subtypes are excluded from the original restriction considering that their own restrictions are inserted too.

        Since:
        2.10
      • toString

        public java.lang.String toString()
        Description copied from class: Item
        Returns the String representation of this item. This is by default the representation of the primary key of this item.
        Overrides:
        toString in class Item
        Returns:
        the String representation of this item.
      • checkUniqueCodeTypePrincipal

        public static void checkUniqueCodeTypePrincipal​(Principal principal,
                                                        ComposedType type,
                                                        java.lang.String code)
        Check that the code-type-principal combination is unique.
        Parameters:
        principal - the principal
        type - the type
        code - the code