Class Item

    • Field Detail

      • accessorLog

        public static final org.apache.log4j.Logger accessorLog
      • FEATURE_ACCESSMAP_QUALIFIER

        public static final java.lang.String FEATURE_ACCESSMAP_QUALIFIER
      • SAVE_FROM_SERVICE_LAYER

        public static final java.lang.String SAVE_FROM_SERVICE_LAYER
        SessionContext attribute flag providing information if the save operation was triggered from Service Layer. If enabled - the allowed principals should not be copied into related categories.
        See Also:
        Constant Field Values
      • DISABLE_ITEMCHECK_BEFORE_REMOVABLE

        public static final java.lang.String DISABLE_ITEMCHECK_BEFORE_REMOVABLE
        SessionContext Flag. If this Flag is in the ctx set to true the check before Item removable is disabled.
        See Also:
        Constant Field Values
      • isJaloOnly

        protected final boolean isJaloOnly
      • staticTransientObjects

        protected static final java.util.concurrent.ConcurrentMap<PK,​java.util.Map<java.lang.String,​java.lang.Object>> staticTransientObjects
        The transient object cache. Since this is implemented as Guava Cache with maximum capacity, transient objects can disappear when not used for a longer time.
      • PK

        public static final java.lang.String PK
        The PK attribute constant.
      • _CREATION_TIME_INTERNAL

        public static final java.lang.String _CREATION_TIME_INTERNAL
        The _CREATION_TIME_INTERNAL attribute constant.
      • _MODIFIED_TIME_INTERNAL

        public static final java.lang.String _MODIFIED_TIME_INTERNAL
        The _MODIFIED_TIME_INTERNAL attribute constant.
      • TYPE

        public static final java.lang.String TYPE
        The TYPE attribute constant.
      • CREATION_TIME

        public static final java.lang.String CREATION_TIME
        The CREATION_TIME attribute constant.
      • MODIFIED_TIME

        public static final java.lang.String MODIFIED_TIME
        The MODIFIED_TIME attribute constant.
      • OWNER

        public static final java.lang.String OWNER
        The OWNER attribute constant.
      • NOT_FOUND

        public static final int NOT_FOUND
        The internal security check result constant NOT_FOUND. Dont use.
        See Also:
        Constant Field Values
      • POSITIVE

        public static final int POSITIVE
        The internal security check result constant POSITIVE. Dont use.
        See Also:
        Constant Field Values
      • NEGATIVE

        public static final int NEGATIVE
        The internal security check result constant NEGATIVE. Dont use.
        See Also:
        Constant Field Values
      • EVEN

        public static final int EVEN
        The internal security check result constant EVEN. Dont use.
        See Also:
        Constant Field Values
      • HJMPTS

        public static final java.lang.String HJMPTS
        The MODIFIED_TIME attribute constant.
      • INITIAL_CREATION_FLAG

        public static final java.lang.String INITIAL_CREATION_FLAG
        This flag indicates the creation phase of an item. The flag will be set to the session context and can be tested using the isInCreate(SessionContext) method.
        See Also:
        Constant Field Values
      • DISABLE_ATTRIBUTE_CHECK

        public static final java.lang.String DISABLE_ATTRIBUTE_CHECK
        See Also:
        Constant Field Values
    • Constructor Detail

      • Item

        public Item()
        The default no-arg constructor which every Jalo Item must provide.

        Do not use it directly since Item creation and Item retrieval e.g. via FlexibleSearch requires a process within creating the Item object is one part besides several others. For creating Item instances always use the appopriate Manager methods or ComposedType.newInstance(Map).

    • Method Detail

      • registerJaloInvalidationListeners

        public static void registerJaloInvalidationListeners​(InvalidationManager invMan,
                                                             Cache cache)
      • isMarkModifiedDisabled

        public boolean isMarkModifiedDisabled​(Item refenrecedItem)
      • registerAccessFor

        public static void registerAccessFor​(java.lang.Class clazz,
                                             java.lang.String qualifier,
                                             AttributeAccess access)
        Registers an attribute access for a given item class and qualifier.

        use it in your items as follows:

          public class MyJaloItem extends ...
          {
                ...
                public static final String THE_QUALIFIER_CONSTANT = "qualifier";
                ...
                static
            {
                        registerAccessFor(
                                MyJaloItem.class,
                                THE_QUALIFIER_CONSTANT,
                                new AttributeAccess()
                    {
                                        public void setValue(SessionContext ctx, Item item, Object value) throws JaloTypeException,
                                                                                                                                                JaloInvalidParameterException, JaloSecurityException
                        {
                                                        // set the value here
                            }
                                                public Object getValue(SessionContext ctx, Item item ) throws JaloTypeException, JaloInvalidParameterException,
                                                                                                                                                                                                                JaloSecurityException
                            {
                                                        // get the value here
                            }
                        }
                                );
                }
                        ...
            }
         

        if there is no attribute access registered for a jalo class all superclasses are processed to find an access.

        this way you may even register attribute accesses outside the actual item class which the attribute belongs to. especially useful for extension programming when adding attributes to core items is required.

        Parameters:
        clazz - the item class
        qualifier - the attribute qualifier
        access - the access object
      • registerAccessFor

        public static void registerAccessFor​(java.lang.String extensionName,
                                             java.lang.Class clazz,
                                             java.lang.String qualifier,
                                             AttributeAccess access)
      • internal_registerClassAccessorFor

        protected static final void internal_registerClassAccessorFor​(Tenant tenant,
                                                                      java.lang.Class clazz,
                                                                      java.lang.String qualifier,
                                                                      AttributeAccess access)
      • hasRegisteredClassAccessorFor

        public static boolean hasRegisteredClassAccessorFor​(Tenant tenant,
                                                            java.lang.Class clazz,
                                                            java.lang.String qualifier)
      • getAccessorFor

        protected final AttributeAccess getAccessorFor​(java.lang.String qualifier,
                                                       java.lang.Class myClass)
        Tries to find a static AttributeAccess member with _AD_ + {attribute qualifier} as name within this item's class and its super classes.

        this method may be overridden if you need to return access objects which cannot be static members of this item's class for some reason. Never forget to call super.getAccessorFor() for all other attributes !

        Parameters:
        qualifier - the attribute qualifier to find an access object for
        myClass - the class to search within
        Returns:
        the matching access object or null if none exists
      • assureExtensionsLoaded

        protected void assureExtensionsLoaded()
      • removeItemCollection

        public static void removeItemCollection​(java.util.Collection collection)
                                         throws ConsistencyCheckException
        Removes a collection of Items's.

        This method iterates through the bean collection and calls remove() on each item.

        Parameters:
        collection - The collection of items, which will be removed.
        Throws:
        ConsistencyCheckException - if an error occurs during the remove process.
      • removeItemCollection

        public static void removeItemCollection​(SessionContext ctx,
                                                java.util.Collection collection)
                                         throws ConsistencyCheckException
        Removes a collection of Items's.

        This method iterates through the bean collection and calls remove() on each item.

        Parameters:
        ctx - the session context to perform removal within
        collection - The collection of items, which will be removed.
        Throws:
        ConsistencyCheckException - if an error occurs during the remove process.
      • setImplementation

        public void setImplementation​(BridgeInterface impl)
        Assigns the persistence implementation object to this Item instance.

        Do not use directly. This is part of the Item creation and retrieval process.

        Overrides:
        setImplementation in class BridgeAbstraction
        Parameters:
        impl - the BridgeInterface object
      • getPK

        public PK getPK()
        Returns the primary key of this item.

        This is used to get a serializable reference to this Item which can be transfered for example through HTTP POST/GET requests. This PK does not change in the lifetime of an item, so the PK can definitely always be cached. You can be sure that no exception is thrown if the underlaying EJB is no longer valid.

        getPK() is a simple Java method invocation which NEVER will hit the network.

        Returns:
        the primary key of this item
      • getCreationTime

        public java.util.Date getCreationTime()
        Returns the time when this Item was created. Please note that the result describes the time of the application server and is not translated into the possibly different client timezone.
      • setCreationTime

        protected void setCreationTime​(java.util.Date creationTime)
      • getModificationTime

        public java.util.Date getModificationTime()
        Returns the time when this Item was modifed the last time. Please note that the result describes the time of the application server and is not translated into the possibly different client timezone.
      • getPersistenceVersion

        public long getPersistenceVersion()
      • setModificationTime

        public void setModificationTime​(java.util.Date date)
      • getSession

        public JaloSession getSession()
        Returns the session which is responsible for managing this item.

        When no session instance is available otherwise always use this to access any Jalo Manager:

         UserManager um = myItem.getSession().getUserManager();
         
        Returns:
        the JaloSession object
      • ctx

        protected SessionContext ctx()
        A shortcut for getSession().getSessionContext().
      • getComposedTypePK

        public PK getComposedTypePK()
        Directly returns the PK of this item's composed type.
      • getComposedType

        public ComposedType getComposedType()
        Returns this Item's type.
      • isInstanceOf

        public boolean isInstanceOf​(ComposedType type)
        Tells whether this Item is instance of a given type or not. This is just a shortcut for ComposedType.isInstance(Object).
        Parameters:
        type - the ComposedType
        Returns:
        true if this Item is an instance of the specified ComposedType
      • setComposedType

        public Item setComposedType​(ComposedType type)
                             throws JaloInvalidParameterException
        Changes the type of an item.

        Please note that the Item instance class may have changed! The safes way changing the type is as follows:

                        Item myItem = ...
                        myItem = myItem.setComposedType( someType ); // directly assign new instance here
         
        Parameters:
        type - the new type of the item
        Returns:
        the new version of this item - the new type may require a new jalo class type !!!
        Throws:
        JaloInvalidParameterException - in case the new type is not compatible with the current type. this happens a) if the type is abstract, b) the new type's class is not compatible with the current class, or c) if the new type has a different deployment (JNDI name, Table) than the current one
      • getOwner

        public Item getOwner()
      • getAttribute

        public java.lang.Object getAttribute​(SessionContext ctx,
                                             java.lang.String qualifier)
                                      throws JaloInvalidParameterException,
                                             JaloSecurityException
        Returns the attribute value for a single item attribute with a specified session context.
        Parameters:
        qualifier - the attribute qualifier (case insensitive)
        ctx - the session context defining the language to fetch the value for (applies for to localized attributes only )
        Throws:
        JaloInvalidParameterException - in case the attribute cannot be read
        JaloSecurityException - in case it is not allowed to read this attribute
      • setAttributeFromString

        public void setAttributeFromString​(java.lang.String qualifier,
                                           java.lang.String value)
                                    throws JaloInvalidParameterException,
                                           JaloBusinessException
        Still experimental! This method changes the attribute value by parsing a string value representation.
        Parameters:
        qualifier - the attribute qualifier
        value - the string value representation
        Throws:
        JaloInvalidParameterException - in case the attribute cannot be read or is not string-representable
        JaloBusinessException - if an error occurs during setting the value
        Since:
        2.10
      • setAttributeFromString

        public void setAttributeFromString​(SessionContext ctx,
                                           java.lang.String qualifier,
                                           java.lang.String value)
                                    throws JaloInvalidParameterException,
                                           JaloBusinessException
        Still experimental! This method changes the attribute value by parsing a string value representation.
        Parameters:
        ctx - the session context
        qualifier - the attribute qualifier
        value - the string value representation
        Throws:
        JaloInvalidParameterException - in case the attribute cannot be read or is not string-representable
        JaloBusinessException - if an error occurs during setting the value
        Since:
        2.10
      • setUseTA

        protected void setUseTA​(SessionContext ctx,
                                boolean use)
      • useTA

        protected boolean useTA​(SessionContext ctx,
                                boolean def)
      • isInCreate

        public static boolean isInCreate​(SessionContext ctx)
      • getLinkedItems

        public java.util.List getLinkedItems​(boolean itemIsSource,
                                             java.lang.String qualifier,
                                             Language lang)
        Finds items linked to this item for a given link qualifier. The result list is ordered either
        • by the link sequence number in case this item is link source, or
        • by the link creation time if this item is link target.
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to find
        qualifier - the link qualifier
        lang - optional: the language for localized links
      • getLinkedItems

        public java.util.List getLinkedItems​(boolean itemIsSource,
                                             java.lang.String qualifier,
                                             Language lang,
                                             int start,
                                             int count)
        Finds a range of items linked to this item for a given link qualifier. The result list is ordered either
        • by the link sequence number in case this item is link source, or
        • by the link creation time if this item is link target.
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to find
        qualifier - the link qualifier
        lang - optional: the language for localized links
        start - the start index of the item range
        count - the amount of items to fetch, use -1 for unlimited amount
      • getLinkedItemsCount

        public long getLinkedItemsCount​(boolean itemIsSource,
                                        java.lang.String qualifier,
                                        Language lang)
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to count
        qualifier - the link qualifier
        lang - optional: the link language for localized links
        Returns:
        the amount of existing links or localized links for the given qualifier
      • getLinkedItems

        public java.util.List getLinkedItems​(SessionContext ctx,
                                             boolean itemIsSource,
                                             java.lang.String qualifier,
                                             Language lang)
        Finds items linked to this item for a given link qualifier. The result list is ordered either
        • by the link sequence number in case this item is link source, or
        • by the link creation time if this item is link target.
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to find
        qualifier - the link qualifier
        lang - optional: the language for localized links
        ctx - the session context to execute this method within
      • getLinkedItems

        public java.util.List getLinkedItems​(SessionContext ctx,
                                             boolean itemIsSource,
                                             java.lang.String qualifier,
                                             Language lang,
                                             boolean sortSrc2Tgt,
                                             boolean sortTgt2Src)
      • getLinkedItems

        public java.util.List getLinkedItems​(SessionContext ctx,
                                             boolean itemIsSource,
                                             java.lang.String relationCode,
                                             java.lang.String relatedItemCode,
                                             Language lang,
                                             boolean sortSrc2Tgt,
                                             boolean sortTgt2Src)
      • isEmptyRelationValue

        protected boolean isEmptyRelationValue​(SessionContext ctx,
                                               java.lang.String name,
                                               java.util.List value)
        Override this method to implement different language fallback behaviour. As default only null values are considered as empty. Example:
         @Override
         protected boolean isEmptyRelationValue(SessionContext ctx, String name, Object value)
         {
                return super.isEmptyValue(ctx, name, value) || ("myAttr".equals(name) && ((String) value).trim().length() == 0);
         }
         
        Parameters:
        ctx - the session context while getting the property
        name - the property name
        value - the actual stored value
        Returns:
        true if the value should be treated as empty - in this case values for fallback languages are fetched
      • isRelationLocalizationFallbackEnabled

        protected boolean isRelationLocalizationFallbackEnabled​(SessionContext ctx)
      • getLinkedItems

        public java.util.List getLinkedItems​(SessionContext ctx,
                                             boolean itemIsSource,
                                             java.lang.String qualifier,
                                             Language lang,
                                             int start,
                                             int count)
        Finds a range of items linked to this item for a given link qualifier. The result list is ordered either
        • by the link sequence number in case this item is link source, or
        • by the link creation time if this item is link target.
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to find
        qualifier - the link qualifier
        lang - optional: the language for localized links
        start - the start index of the item range
        count - the amount of items to fetch, use -1 for unlimited amount
        ctx - the session context to execute this method within
      • getLinkedItems

        public java.util.List getLinkedItems​(SessionContext ctx,
                                             boolean itemIsSource,
                                             java.lang.String qualifier,
                                             Language lang,
                                             int start,
                                             int count,
                                             boolean sortSrc2Tgt,
                                             boolean sortTgt2Src)
      • getLinkedItemsCount

        public long getLinkedItemsCount​(SessionContext ctx,
                                        boolean itemIsSource,
                                        java.lang.String qualifier,
                                        Language lang)
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to count
        qualifier - the link qualifier
        lang - optional: the link language for localized links
        ctx - the session context to execute this method within
        Returns:
        the amount of existing links or localized links for the given qualifier
      • getLinkedItemsCount

        public long getLinkedItemsCount​(SessionContext ctx,
                                        boolean itemIsSource,
                                        java.lang.String relationTypeCode,
                                        java.lang.String relatedItemCode,
                                        Language lang)
        Parameters:
        ctx - the session context to execute this method within
        itemIsSource - tells whether this item is source or target of the links to count
        relationTypeCode - the link qualifier
        relatedItemCode - the related item qualifier
        lang - optional: the link language for localized links
        Returns:
        the amount of existing links or localized links for the given qualifier
      • getAllLinkedItems

        public java.util.Map getAllLinkedItems​(boolean itemIsSource,
                                               java.lang.String qualifier)
        Returns all localized linked items for a given qualifier. The map contains { Language -> [ Item+] } mappings. The item lists are ordered as described in getLinkedItems(boolean, String, Language).
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to evaluate
        qualifier - the link qualifier
      • setLinkedItems

        public void setLinkedItems​(boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List<? extends Item> itemsToLink)
        Replaces the items currently linked to this item for the given qualifier by the new item list. If this item becomes the links source the order of this list is preserved by setting according sequence numbers within the links. Otherwise all existing links keep their sequence numbers ( in case the item has been linked before ) and new links are put at top having 0 as sequence number.
        Parameters:
        itemIsSource - tells whether this item is link source or target
        qualifier - the link qualifier
        lang - optional: the language if the links should be localized
        itemsToLink - the new collection of items to link to
      • setLinkedItems

        public void setLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List<? extends Item> itemsToLink)
        Replaces the items currently linked to this item for the given qualifier by the new item list. If this item becomes the links source the order of this list is preserved by setting according sequence numbers within the links. Otherwise all existing links keep their sequence numbers ( in case the item has been linked before ) and new links are put at top having 0 as sequence number.
        Parameters:
        itemIsSource - tells whether this item is link source or target
        qualifier - the link qualifier
        lang - optional: the language if the links should be localized
        itemsToLink - the new collection of items to link to
        ctx - the session context to execute this method within
      • setLinkedItems

        public void setLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.Collection<? extends Item> itemsToLink)
      • setLinkedItems

        public void setLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.Collection<? extends Item> itemsToLink,
                                   boolean markModified)
      • setLinkedItems

        public void setLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List<? extends Item> itemsToLink,
                                   boolean sortSrc2Tgt,
                                   boolean sortTgt2Src)
      • setLinkedItems

        public void setLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List<? extends Item> itemsToLink,
                                   boolean sortSrc2Tgt,
                                   boolean sortTgt2Src,
                                   boolean markModified)
      • setLinkedItems

        public void setLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.Collection<? extends Item> itemsToLink,
                                   boolean sortSrc2Tgt,
                                   boolean sortTgt2Src)
      • setLinkedItems

        public void setLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.Collection<? extends Item> itemsToLink,
                                   boolean sortSrc2Tgt,
                                   boolean sortTgt2Src,
                                   boolean markModified)
      • setAllLinkedItems

        public void setAllLinkedItems​(boolean itemIsSource,
                                      java.lang.String qualifier,
                                      java.util.Map languageToItemListMap)
        Replaces the items currently being linked via localized links to this item for the given qualifier. These items have to be provided within a map containing Languages as keys and lists of items as values. The order within these lists is preserved if this item is the source item of these links.
        Parameters:
        itemIsSource - tells whether this item is link source or target
        qualifier - the link qualifier
        languageToItemListMap - the new items to link as Language -> [Item] map
      • setAllLinkedItems

        public void setAllLinkedItems​(boolean itemIsSource,
                                      java.lang.String qualifier,
                                      java.util.Map languageToItemListMap,
                                      boolean markModified)
        Replaces the items currently being linked via localized links to this item for the given qualifier. These items have to be provided within a map containing Languages as keys and lists of items as values. The order within these lists is preserved if this item is the source item of these links.
        Parameters:
        itemIsSource - tells whether this item is link source or target
        qualifier - the link qualifier
        languageToItemListMap - the new items to link as Language -> [Item] map
      • setAllLinkedItems

        public void setAllLinkedItems​(SessionContext ctx,
                                      boolean itemIsSource,
                                      java.lang.String qualifier,
                                      java.util.Map languageToItemListMap)
        Replaces the items currently being linked via localized links to this item for the given qualifier. These items have to be provided within a map containing Languages as keys and lists of items as values. The order within these lists is preserved if this item is the source item of these links.
        Parameters:
        itemIsSource - tells whether this item is link source or target
        qualifier - the link qualifier
        languageToItemListMap - the new items to link as Language -> [Item] map
      • setAllLinkedItems

        public void setAllLinkedItems​(SessionContext ctx,
                                      boolean itemIsSource,
                                      java.lang.String qualifier,
                                      java.util.Map languageToItemListMap,
                                      boolean markModified)
      • addLinkedItems

        public void addLinkedItems​(boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink)
        Creates new links between this item and a given list of items. These links will be appended to existing links.
        Parameters:
        itemIsSource - tells whether this item is source or target of the new links
        qualifier - specifies the link qualifier
        lang - optional: the language to create localized links for
        itemsToLink - the items which will be linked with this item
      • addLinkedItems

        public void addLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink)
        Creates new links between this item and a given list of items. These links will be appended to existing links.
        Parameters:
        itemIsSource - tells whether this item is source or target of the new links
        qualifier - specifies the link qualifier
        lang - optional: the language to create localized links for
        itemsToLink - the items which will be linked with this item
        ctx - the session context to execute this method within
      • addLinkedItems

        public void addLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink,
                                   boolean markModified)
      • addLinkedItems

        public void addLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink,
                                   boolean sortSrc2Tgt,
                                   boolean sortTgt2Src)
      • addLinkedItems

        public void addLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink,
                                   boolean sortSrc2Tgt,
                                   boolean sortTgt2Src,
                                   boolean markModified)
      • addLinkedItems

        public void addLinkedItems​(boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink,
                                   int position)
        Creates new links between this item and a given list of items at a speciic position among this items link list. All preceding (existing) links will be shifted.
        Parameters:
        itemIsSource - tells whether this item is source or target of the new links
        qualifier - specifies the link qualifier
        lang - optional: the language to create localized links for
        itemsToLink - the items which will be linked with this item
        position - the position where to insert the new links ( -1 means append at the end )
      • addLinkedItems

        public void addLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink,
                                   int position)
        Creates new links between this item and a given list of items at a speciic position among this items link list. All succeeding (existing) links will be shifted.
        Parameters:
        itemIsSource - tells whether this item is source or target of the new links
        qualifier - specifies the link qualifier
        lang - optional: the language to create localized links for
        itemsToLink - the items which will be linked with this item
        position - the position where to insert the new links ( -1 means append at the end )
        ctx - the session context to execute this method within
      • addLinkedItems

        public void addLinkedItems​(boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink,
                                   int position,
                                   boolean shift)
        Creates new links between this item and a given list of items at a speciic position among this items link list. Optionally the succeeding (existing) links can be shifted or not. If not they keep their position.

        Use this to add links at specific positions like this:

                Item myItem = ...
                Item[] toLink = ...
                // add at 3
                myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[0]), 3, false );
        
                // add at 1 *and* avoid shifting the previous link from 3 to 4 !
                myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[1]), 1, false );
        
                // add at 7
                myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[2]), 7, false );
         
        Parameters:
        itemIsSource - tells whether this item is source or target of the new links
        qualifier - specifies the link qualifier
        lang - optional: the language to create localized links for
        itemsToLink - the items which will be linked with this item
        position - the position where to insert the new links ( -1 means append at the end )
        shift - thells whether succeeding links should shift their positions accoding to new links size or not
      • addLinkedItems

        public void addLinkedItems​(SessionContext ctx,
                                   boolean itemIsSource,
                                   java.lang.String qualifier,
                                   Language lang,
                                   java.util.List itemsToLink,
                                   int position,
                                   boolean shift)
        Creates new links between this item and a given list of items at a speciic position among this items link list. Optionally the succeeding (existing) links can be shifted or not. If not they keep their position.

        Use this to add links at specific positions like this:

                Item myItem = ...
                Item[] toLink = ...
                // add at 3
                myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[0]), 3, false );
        
                // add at 1 *and* avoid shifting the previous link from 3 to 4 !
                myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[1]), 1, false );
        
                // add at 7
                myItem.addLinkedItems( myItem, true, "myRel", null, Collections.singletonList(toLink[2]), 7, false );
         
        Parameters:
        itemIsSource - tells whether this item is source or target of the new links
        qualifier - specifies the link qualifier
        lang - optional: the language to create localized links for
        itemsToLink - the items which will be linked with this item
        position - the position where to insert the new links ( -1 means append at the end )
        shift - thells whether succeeding links should shift their positions accoding to new links size or not
        ctx - the session context to execute this method within
      • removeLinkedItems

        public void removeLinkedItems​(boolean itemIsSource,
                                      java.lang.String qualifier,
                                      Language lang,
                                      java.util.List itemsToUnlink)
        Removes all links between this item and the given item list.
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to remove
        qualifier - the qualifier of the links
        lang - optional: the language of the localized links
        itemsToUnlink - the items to unlink (non-existing links will be ignored)
      • removeLinkedItems

        public void removeLinkedItems​(SessionContext ctx,
                                      boolean itemIsSource,
                                      java.lang.String qualifier,
                                      Language lang,
                                      java.util.List itemsToUnlink)
        Removes all links between this item and the given item list.
        Parameters:
        itemIsSource - tells whether this item is source or target of the links to remove
        qualifier - the qualifier of the links
        lang - optional: the language of the localized links
        itemsToUnlink - the items to unlink (non-existing links will be ignored)
        ctx - the session context to execute this method within
      • removeLinkedItems

        public void removeLinkedItems​(SessionContext ctx,
                                      boolean itemIsSource,
                                      java.lang.String qualifier,
                                      Language lang,
                                      java.util.List itemsToUnlink,
                                      boolean sortSrc2Tgt,
                                      boolean sortTgt2Src)
      • removeLinkedItems

        public void removeLinkedItems​(SessionContext ctx,
                                      boolean itemIsSource,
                                      java.lang.String qualifier,
                                      Language lang,
                                      java.util.List itemsToUnlink,
                                      boolean sortSrc2Tgt,
                                      boolean sortTgt2Src,
                                      boolean markModified)
      • remove

        public void remove​(SessionContext ctx)
                    throws ConsistencyCheckException
        Removes this item.

        This method is using the following attributes of the given SessionContext:

        CacheUsage   Language   StagingMethod
        n/a (this is a setter method)   no, language doesn't matter for removal   yes if called on a StageableItem, no otherwise


        Parameters:
        ctx - A SessionContext object
        Throws:
        ConsistencyCheckException - if this item could not be removed for some reason
      • doBeforeRemove

        protected void doBeforeRemove​(SessionContext ctx,
                                      java.util.Map removalCtx)
        Hook method to perform removal logic just before this item is being deleted from database. Please prefer this to overriding remove(SessionContext) because this method is guaranteed to be called in synchronized context.
      • doAfterRemove

        protected void doAfterRemove​(SessionContext ctx,
                                     java.util.Map removalCtx)
        Hook method to perform removal logic just after this item is being deleted from database. Please prefer this to overriding remove(SessionContext) because this method is guaranteed to be called in synchronized context.
      • isCurrentlyRemoving

        public static boolean isCurrentlyRemoving​(Item item)
      • isCurrentlyRemoving

        public static boolean isCurrentlyRemoving​(PK pk)
      • getCurrentlyRemovingCount

        public static int getCurrentlyRemovingCount()
      • removeLinks

        protected void removeLinks()
      • notifyItemRemoval

        protected void notifyItemRemoval​(SessionContext ctx)
        Notifies all managers (including all extensions) about this item being removed soon. This method will not throw any exception even if one of the managers raised one. These exceptions will be logged only!
        Parameters:
        ctx -
      • notifyManagerAboutItemRemoval

        protected void notifyManagerAboutItemRemoval​(Manager manager,
                                                     SessionContext ctx)
      • equals

        public final boolean equals​(java.lang.Object object)
        Two items are equal, if their primary keys are equals.

        Thus, performing a item.getPK().equals(item2.getPK() ) produces the same result, but this method can use optimized code so you should use item.equals(item2) whenever you want to compare two items for equality.

        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - the object that should be tested for equality.
        Returns:
        true if the two objects are equal, false otherwise
      • compareTo

        public int compareTo​(java.lang.Object object)
        Implements item comparison by PK. Subclasses may override this.
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        object - which will be compared to this item.
        Returns:
        the value 0 if the argument item pk is equal to this item pk; a value less than 0 if this item pk is lexicographically less than the argument item pk; and a value greater than 0 if this item pk is lexicographically greater than the argument item pk.
      • hashCode

        public final int hashCode()
        Returns the hashcode of this item.

        The hashcode of an item is defined as the hashcode of its primary key object.

        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hashcode of this item.
      • toString

        public java.lang.String toString()
        Returns the String representation of this item. This is by default the representation of the primary key of this item.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the String representation of this item.
      • getRestrictedPrincipals

        public java.util.Set getRestrictedPrincipals()
        Returns:
        a set of all principals which own a restriction upon this item
      • getPermissions

        public java.util.Set getPermissions​(Principal principal,
                                            boolean negative)
        Finds all positive or negative permissions upon this item and the given Principal.
        Parameters:
        principal - the Principal whos permissions will be returned
        negative - if set to true, all negative permissions will be returned, if set to false, all positive permission will be returned.
        Returns:
        a set of UserRight
      • getPermissionMap

        public java.util.Map getPermissionMap​(java.util.List userRights)
        Finds the all permission settings for a given list of user rights. The result is a map { Principal -> [ Boolean.TRUE == negative | Boolean.FALSE == positive | null == not set ] }.

        an example:

        
                rights =                                        [       r1      ,       r2      ,       r3      ]
                result = {      user1 -> [ T    , F     ,  F    ]
                                                user2 -> [ null, null,  T       ]
                        }
                which means:
                user1 is denied r1, allowed r2 and r3
         user2  is denied r3, others are not set ( default or derived permission is take )
         
        Parameters:
        userRights - a list of UserRights
        Returns:
        the permission map.
      • setPermissionsByMap

        public void setPermissionsByMap​(java.util.List userRights,
                                        java.util.Map permissionMap)
                                 throws JaloSecurityException
        Changes permission settings for a given list of user rights. This is done by a map Principal -> [ Boolean.TRUE == negative || Boolean.FALSE == positive || null == not set }.

        An example:

        
         rights = [ r1 , r2 , r3 ] permissionMap = { user1 -> [ T , F , F ] user2 -> [ null, null, T ] } which means:
         user1 is denied r1, allowed r2 and r3 user2 is denied r3, others are not set ( default or derived permission is
         take )
         
        Parameters:
        userRights - a list of UserRight, <code> null </code> is not allowed
        permissionMap - a map containing the user to permission information.
        Throws:
        JaloSecurityException
      • getPositivePermissions

        public java.util.Set getPositivePermissions​(Principal principal)
        Finds all positive permissions for the item and the given Principal.
        Parameters:
        principal - all returned permissions belong to.
        Returns:
        a set of UserRight
      • getNegativePermissions

        public java.util.Set getNegativePermissions​(Principal principal)
        Finds all negative permissions for the item and the given Principal.
        Parameters:
        principal - all returned permissions belong to.
        Returns:
        a set of UserRight
      • addPermission

        public void addPermission​(Principal principal,
                                  UserRight right,
                                  boolean negative)
        Add a permission for the Principal and the UserRight on the Item.
        Parameters:
        principal - the Principal the permission belongs to.
        right - the UserRight the permission belongs to.
        negative - true if the permission should be negative, otherwise a positive permission
      • clearPermission

        public void clearPermission​(Principal principal,
                                    UserRight right)
        Remove any permission for the Principal and the UserRight on the Item.
        Parameters:
        principal - the Principal the removed permission belongs to.
        right - the UserRight the removed permission belongs to.
      • addPositivePermission

        public void addPositivePermission​(Principal principal,
                                          UserRight right)
        Add a positive permission for the Principal and the UserRight on the Item.
        Parameters:
        principal - the Principal the positive permission belongs to.
        right - the UserRight the positive permission belongs to.
      • addNegativePermission

        public void addNegativePermission​(Principal principal,
                                          UserRight right)
        Add a negative permission for the Principal and the UserRight on the Item.
        Parameters:
        principal - the Principal the negative permission belongs to.
        right - the UserRight the negative permission belongs to.
      • checkPermission

        public boolean checkPermission​(UserRight right)
        Checks if the current session user has the given UserRight on the Item.
        Parameters:
        right - the UserRight the permission should be checked for
        Returns:
        true if the current session user has the UserRight for this Item
      • checkPermission

        public boolean checkPermission​(Principal principal,
                                       UserRight right)
        Checks if the Principal has the given UserRight on the Item.
        Parameters:
        principal - the Principal the permission should be checked for
        right - the UserRight the permission should be checked for
        Returns:
        true if the Principal has the UserRight for this Item
      • checkItemPermission

        protected int checkItemPermission​(Principal principal,
                                          UserRight right)
      • setTransientObject

        public void setTransientObject​(java.lang.String key,
                                       java.lang.Object value)
        Sets a transient object.

        the value will be mapped to this object until

        • it will be removed with setTransientObject(key,null)
        • or the garbage collector will remove this BridgeAbstraction.
        .
        Specified by:
        setTransientObject in class BridgeAbstraction
        Parameters:
        key - the key
        value - may be null; this will remove the transient object mapping
      • getTransientObject

        public java.lang.Object getTransientObject​(java.lang.String key)
        Get a transient object.

        null is returned if no transient object is mapped to the given key.

        Specified by:
        getTransientObject in class BridgeAbstraction
        Parameters:
        key - the key of the transient object which should be returned.
        Returns:
        the transient object
      • getTransientObjectMap

        @Deprecated
        public java.util.Map<java.lang.String,​java.lang.Object> getTransientObjectMap()
        Deprecated.
        since 18.08 - don't operate on transient object map directly. Use setTransientObject(String, Object) and getTransientObject(String)
        Returns the complete Map of transient objects.

        Note: Changes are directly reflected to the BridgeAbstraction object. The returned map is bound to the object. So be careful when modifying the map.

        Specified by:
        getTransientObjectMap in class BridgeAbstraction
        Returns:
        a Map of all transient objects.
      • isAlive

        public boolean isAlive()
        Is true if this item is still valid.
        Returns:
        true if this item is still valid.
      • getCacheBoundItem

        public <T extends Item> T getCacheBoundItem()
        NOTE: hybris internal method, do not use
        Returns:
        the Item that is in the cache (either THIS or a new instance which is put in the cache
      • getAndCheckCacheBoundItem

        public <T extends Item> T getAndCheckCacheBoundItem()
      • setCacheBound

        public void setCacheBound​(boolean bound)
      • isCacheBound

        public boolean isCacheBound()
      • invalidateLocalCaches

        public void invalidateLocalCaches()
      • newInstance

        public final Item newInstance​(SessionContext ctx,
                                      ComposedType type,
                                      java.util.Map attributeAssignment)
                               throws JaloBusinessException
        Creates a new Item using the specified parameters.
        Parameters:
        ctx - the session context which the new item should be created within
        type - the ComposedType of the newly created Item
        attributeAssignment - a map containing the attribute values of the newly created Item
        Returns:
        the created Item
        Throws:
        JaloBusinessException
      • changeTypeAfterCreation

        protected Item changeTypeAfterCreation​(Item newOne,
                                               ComposedType requestedType)
                                        throws JaloInvalidParameterException
        Changes the item type in case createItem(SessionContext, ComposedType, ItemAttributeMap) did not set the requested type directly.

        overriding this method should hardly be necessary - common case might be disallowing the type to be changed at all.

        Parameters:
        newOne - the newly created item
        requestedType - the type which triggered this items creation
        Returns:
        the item with the correct type which possibly has to be re-wrapped ( if the requested type declares a jalo class differently from the current items instance class )
        Throws:
        JaloInvalidParameterException
      • getNonInitialAttributes

        protected Item.ItemAttributeMap getNonInitialAttributes​(SessionContext ctx,
                                                                Item.ItemAttributeMap allAttributes)
        Defines all attributes which should be set after item creation. this is done be removing all attributes which are already set by 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!
        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.
      • checkMandatoryAttribute

        protected static boolean checkMandatoryAttribute​(java.lang.String qualifier,
                                                         Item.ItemAttributeMap allAttributes,
                                                         java.util.Set missingSet)
        Checks if the attributes map contains a given qualifier. if the qualifier is mapped to a null value it is treated as missing.
        Parameters:
        qualifier - the qualifier to check
        allAttributes - the creation attributes map
        missingSet - the container to add a missing qualifier to
        Returns:
        true if the qualifier is present
      • checkMandatoryAttribute

        protected static boolean checkMandatoryAttribute​(java.lang.String qualifier,
                                                         Item.ItemAttributeMap allAttributes,
                                                         java.util.Set missingSet,
                                                         boolean nullAllowed)
        Checks if the attributes map contains a given qualifier. It may be specified if qualifiers mapped to null values are allowed or not.
        Parameters:
        qualifier - the qualifier to check
        allAttributes - the creation attributes map
        missingSet - the container to add a missing qualifier to
        nullAllowed - tells whether null values are allowed or such qualifiers are treated as missing ones
        Returns:
        true if the qualifier is present
      • createItem

        protected abstract Item createItem​(SessionContext ctx,
                                           ComposedType type,
                                           Item.ItemAttributeMap allAttributes)
                                    throws JaloBusinessException
        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 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; }
        
         
        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 )
        allAttributes -
        Returns:
        the new item instance
        Throws:
        JaloBusinessException - indicates an error during creation - any changes will be rollbacked
      • getSyncObject

        public java.lang.Object getSyncObject()
        returns an object that can be used for synchronization on the current item pk. e.g. synchronized( getSyncObject() ) { ... }. Please do not use the item or PK object for itself, because they might be subject of garbage-collection.
        Returns:
        the syncobject
      • writeReplace

        public java.lang.Object writeReplace()
                                      throws java.io.ObjectStreamException
        Takes care of serialization of items. We don't write the real item instances but new instance of the same class just holding its PK and its removal flag.

        This is sufficient because reading items is also handled specially by fetching it via PK instead of using the object from the stream ( see readResolve() ).

        Throws:
        java.io.ObjectStreamException
      • readResolve

        public java.lang.Object readResolve()
                                     throws java.io.ObjectStreamException
        Takes care of the de-serialization of items because we cannot have several instances of one item per PK. So the actual item is always tried to fetch via JaloSession.getItem(PK).
        Throws:
        java.io.ObjectStreamException
      • isItemCheckBeforeRemoveableDisabled

        protected boolean isItemCheckBeforeRemoveableDisabled​(SessionContext ctx)
        Parameters:
        ctx - the sessioncontext
        Returns:
        true if in the given SessionContext the attribute DISABLE_SUBCATEGORY_REMOVALCHECK exists AND the value of this attribute is true
      • getDefaultAttributeModes

        protected java.util.Map<java.lang.String,​Item.AttributeMode> getDefaultAttributeModes()
      • getRelatedItems

        public <T extends Item> java.util.Collection<T> getRelatedItems​(java.lang.String relationQualifier)
        Internal method to directly return related items linked by the One To Many relation. Its purpose is to allow the underlying persistence to intercept this call and handle it in a more efficient way.
        Parameters:
        relationQualifier - name of the attribute seen from the One end of the relation.
        Returns:
        the collection of related items or null if direct access is not supported by the underlying persistence layer.
      • setRelatedItems

        public <T extends Item> boolean setRelatedItems​(java.lang.String relationQualifier,
                                                        java.util.Collection<T> values)
        Internal method to directly set related items linked by the One To Many relation. Its purpose is to allow the underlying persistence to intercept this call and handle it in a more efficient way.
        Parameters:
        relationQualifier - name of the attribute seen from the One end of the relation.
        values - collection of Items to be set.
        Returns:
        false if operation is not supported by the underlying persistence layer.