Class Item
- java.lang.Object
-
- de.hybris.platform.util.BridgeAbstraction
-
- de.hybris.platform.jalo.Item
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable
- Direct Known Subclasses:
ConfigProxyItem
,ExtensibleItem
,ViewResultItem
public abstract class Item extends BridgeAbstraction implements java.lang.Comparable
The superclass of all the hybris platform persistent data-objects. Important:
To retrieve any object by itsPK
you just have to use
(class)JaloSession.getItem(PK)
JaloSession
.each item is typed by a
ComposedType
which defines its class, datbase table, jndi name and all attributes. besides composed types can be used to create new item instances a generic way ( opposite to creating them by their managers ) - seeComposedType.newInstance(Map)
.each concrete subclass of item has to implement
createItem(SessionContext, ComposedType, de.hybris.platform.jalo.Item.ItemAttributeMap)
which is responsible for creating a new instance of this item. please note that the instance which this method is called on is not assoziated with an exiting item, so any access to attributes will fail!
in addition it is intented that each jalo class implementingcreateItem(SessionContext, ComposedType, de.hybris.platform.jalo.Item.ItemAttributeMap)
should also overridegetNonInitialAttributes(SessionContext, de.hybris.platform.jalo.Item.ItemAttributeMap)
to avoid setting initial attribute twice.
another method which subclasses may override issetNonInitialAttributes(SessionContext, Item, de.hybris.platform.jalo.Item.ItemAttributeMap)
. it is called after item creation and sets all additional (non-initial) attributes.each declared attribute (see items.xml) which is not backed by a property or a relation requires a
AttributeAccess
to allow generic value handling. to do so useregisterAccessFor(Class, String, AttributeAccess)
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Item.AttributeFilter
Describes anAttributeFilter
Internal use only!static class
Item.AttributeMode
class
Item.CachedGetter
class
Item.CachedSetter
static class
Item.ItemAttributeMap
internal use only!static interface
Item.ItemConstraint
Interface for implementing transaction aware consistency checks using the item methodcheckConstraint(ItemConstraint)
.static interface
Item.ItemImpl
object used by getSyncObject()static class
Item.JaloCachedComputationException
Thrown byItem.CachedGetter.get(SessionContext)
andItem.CachedSetter.set(SessionContext)
whenever the executed code throws an exception.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
_CREATION_TIME_INTERNAL
The_CREATION_TIME_INTERNAL
attribute constant.static java.lang.String
_MODIFIED_TIME_INTERNAL
The_MODIFIED_TIME_INTERNAL
attribute constant.static org.apache.log4j.Logger
accessorLog
static java.lang.String
CREATION_TIME
TheCREATION_TIME
attribute constant.static java.lang.String
DISABLE_ATTRIBUTE_CHECK
static java.lang.String
DISABLE_ITEMCHECK_BEFORE_REMOVABLE
SessionContext Flag.static int
EVEN
The internal security check result constantEVEN
.static java.lang.String
FEATURE_ACCESSMAP_QUALIFIER
static java.lang.String
HJMPTS
TheMODIFIED_TIME
attribute constant.static java.lang.String
INITIAL_CREATION_FLAG
This flag indicates the creation phase of an item.protected boolean
isJaloOnly
static java.lang.String
MODIFIED_TIME
TheMODIFIED_TIME
attribute constant.static int
NEGATIVE
The internal security check result constantNEGATIVE
.static int
NOT_FOUND
The internal security check result constantNOT_FOUND
.static java.lang.String
OWNER
TheOWNER
attribute constant.static java.lang.String
PK
ThePK
attribute constant.static int
POSITIVE
The internal security check result constantPOSITIVE
.static java.lang.String
SAVE_FROM_SERVICE_LAYER
SessionContext attribute flag providing information if the save operation was triggered from Service Layer.protected static java.util.concurrent.ConcurrentMap<PK,java.util.Map<java.lang.String,java.lang.Object>>
staticTransientObjects
The transient object cache.static java.lang.String
TYPE
TheTYPE
attribute constant.-
Fields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant
-
-
Constructor Summary
Constructors Constructor Description Item()
The default no-arg constructor which every Jalo Item must provide.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.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.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.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.void
addLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.List itemsToLink, boolean markModified)
void
addLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.List itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src)
void
addLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.List itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified)
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.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.void
addNegativePermission(Principal principal, UserRight right)
Add a negative permission for thePrincipal
and theUserRight
on theItem
.void
addPermission(Principal principal, UserRight right, boolean negative)
Add a permission for thePrincipal
and theUserRight
on theItem
.void
addPositivePermission(Principal principal, UserRight right)
Add a positive permission for thePrincipal
and theUserRight
on theItem
.protected void
assureExtensionsLoaded()
protected Item
changeTypeAfterCreation(Item newOne, ComposedType requestedType)
Changes the item type in casecreateItem(SessionContext, ComposedType, ItemAttributeMap)
did not set the requested type directly.protected void
checkConstraint(Item.ItemConstraint constr)
Allows to implement transaction safe consistency checking code.protected int
checkItemPermission(Principal principal, UserRight right)
protected static boolean
checkMandatoryAttribute(java.lang.String qualifier, Item.ItemAttributeMap allAttributes, java.util.Set missingSet)
Checks if the attributes map contains a given qualifier.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.boolean
checkPermission(Principal principal, UserRight right)
Checks if thePrincipal
has the givenUserRight
on theItem
.boolean
checkPermission(UserRight right)
Checks if the current session user has the givenUserRight
on theItem
.protected void
checkRemovable(SessionContext ctx)
Checks whether or not this it may be removed or not.void
clearPermission(Principal principal, UserRight right)
Remove any permission for thePrincipal
and theUserRight
on theItem
.int
compareTo(java.lang.Object object)
Implements item comparison by PK.protected abstract Item
createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes)
Has to be implemented for each concrete subtype of item.protected AttributeAccess
createNonClassAccessor(AttributeDescriptor fieldDescriptor)
protected SessionContext
ctx()
A shortcut forgetSession().getSessionContext()
.protected void
doAfterRemove(SessionContext ctx, java.util.Map removalCtx)
Hook method to perform removal logic just after this item is being deleted from database.protected void
doBeforeRemove(SessionContext ctx, java.util.Map removalCtx)
Hook method to perform removal logic just before this item is being deleted from database.boolean
equals(java.lang.Object object)
Two items are equal, if their primary keys are equals.protected 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.java.util.Map
getAllAttributes()
Reads all (readable) attribute values of this item using the current session context.java.util.Map
getAllAttributes(SessionContext ctx)
Reads all (readable) attribute values of this item using a specific session context.java.util.Map
getAllAttributes(SessionContext ctx, Item.AttributeFilter filter)
Reads all attribute values of this item which pass a given attribute filter.java.util.Map
getAllAttributes(SessionContext ctx, java.util.Set<java.lang.String> qualfiers)
Reads all values of specified attributes for this item.protected java.util.Map<java.lang.String,java.lang.Object>
getAllAttributesInternal(SessionContext ctx, java.util.Set<java.lang.String> qualfiers)
java.util.Map
getAllLinkedItems(boolean itemIsSource, java.lang.String qualifier)
Returns all localized linked items for a given qualifier.<T extends Item>
TgetAndCheckCacheBoundItem()
java.lang.Object
getAttribute(SessionContext ctx, java.lang.String qualifier)
Returns the attribute value for a single item attribute with a specified session context.java.lang.Object
getAttribute(java.lang.String qualifier)
Returns the attribute value for a single item attribute using the current session context.<T extends Item>
TgetCacheBoundItem()
NOTE: hybris internal method, do not useComposedType
getComposedType()
Returns this Item's type.PK
getComposedTypePK()
Directly returns the PK of this item's composed type.java.util.Date
getCreationTime()
Returns the time when this Item was created.static int
getCurrentlyRemovingCount()
protected java.util.Map<java.lang.String,Item.AttributeMode>
getDefaultAttributeModes()
Item.ItemImpl
getImplementation()
returns the implementation object of this jalo bridge abstractionjava.util.List
getLinkedItems(boolean itemIsSource, java.lang.String qualifier, Language lang)
Finds items linked to this item for a given link qualifier.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.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.java.util.List
getLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, boolean sortSrc2Tgt, boolean sortTgt2Src)
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.java.util.List
getLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, int start, int count, boolean sortSrc2Tgt, boolean sortTgt2Src)
java.util.List
getLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String relationCode, java.lang.String relatedItemCode, Language lang, boolean sortSrc2Tgt, boolean sortTgt2Src)
long
getLinkedItemsCount(boolean itemIsSource, java.lang.String qualifier, Language lang)
long
getLinkedItemsCount(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang)
long
getLinkedItemsCount(SessionContext ctx, boolean itemIsSource, java.lang.String relationTypeCode, java.lang.String relatedItemCode, Language lang)
java.util.Date
getModificationTime()
Returns the time when this Item was modifed the last time.java.util.Set
getNegativePermissions(Principal principal)
Finds all negative permissions for the item and the givenPrincipal
.protected Item.ItemAttributeMap
getNonInitialAttributes(SessionContext ctx, Item.ItemAttributeMap allAttributes)
Defines all attributes which should be set after item creation.Item
getOwner()
java.util.Map
getPermissionMap(java.util.List userRights)
Finds the all permission settings for a given list of user rights.java.util.Set
getPermissions(Principal principal, boolean negative)
Finds all positive or negative permissions upon this item and the givenPrincipal
.long
getPersistenceVersion()
PK
getPK()
Returns the primary key of this item.java.util.Set
getPositivePermissions(Principal principal)
Finds all positive permissions for the item and the givenPrincipal
.<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.java.util.Set
getRestrictedPrincipals()
JaloSession
getSession()
Returns the session which is responsible for managing this item.java.lang.Object
getSyncObject()
returns an object that can be used for synchronization on the current item pk.Tenant
getTenant()
java.lang.Object
getTransientObject(java.lang.String key)
Get a transient object.java.util.Map<java.lang.String,java.lang.Object>
getTransientObjectMap()
Deprecated.since 18.08 - don't operate on transient object map directly.int
hashCode()
Returns the hashcode of this item.static boolean
hasRegisteredClassAccessorFor(Tenant tenant, java.lang.Class clazz, java.lang.String qualifier)
protected static void
internal_registerClassAccessorFor(Tenant tenant, java.lang.Class clazz, java.lang.String qualifier, AttributeAccess access)
protected static void
internal_registerNonClassAccessorFor(Tenant tenant, AttributeDescriptor attributeDescriptor, AttributeAccess access)
void
invalidateLocalCaches()
boolean
isAlive()
Istrue
if this item is still valid.boolean
isCacheBound()
static boolean
isCurrentlyRemoving(PK pk)
static boolean
isCurrentlyRemoving(Item item)
protected boolean
isEmptyRelationValue(SessionContext ctx, java.lang.String name, java.util.List value)
Override this method to implement different language fallback behaviour.static boolean
isInCreate(SessionContext ctx)
boolean
isInstanceOf(ComposedType type)
Tells whether this Item is instance of a given type or not.protected boolean
isItemCheckBeforeRemoveableDisabled(SessionContext ctx)
boolean
isMarkModifiedDisabled(Item refenrecedItem)
protected boolean
isRelationLocalizationFallbackEnabled(SessionContext ctx)
Item
newInstance(SessionContext ctx, ComposedType type, java.util.Map attributeAssignment)
Creates a newItem
using the specified parameters.protected void
notifyExtensionsAfterItemCreation(SessionContext ctx, ComposedType type, Item createdItem, Item.ItemAttributeMap attributes)
protected void
notifyExtensionsBeforeItemCreation(SessionContext ctx, ComposedType type, Item.ItemAttributeMap attributes)
protected void
notifyItemRemoval(SessionContext ctx)
Notifies all managers (including all extensions) about this item being removed soon.protected void
notifyManagerAboutItemRemoval(Manager manager, SessionContext ctx)
java.lang.Object
readResolve()
Takes care of the de-serialization of items because we cannot have several instances of one item per PK.static void
registerAccessFor(java.lang.Class clazz, java.lang.String qualifier, AttributeAccess access)
Registers an attribute access for a given item class and qualifier.static void
registerAccessFor(java.lang.String extensionName, java.lang.Class clazz, java.lang.String qualifier, AttributeAccess access)
static void
registerJaloInvalidationListeners(InvalidationManager invMan, Cache cache)
void
remove()
Removes this item.void
remove(SessionContext ctx)
Removes this item.static void
removeItemCollection(SessionContext ctx, java.util.Collection collection)
Removes a collection of Items's.static void
removeItemCollection(java.util.Collection collection)
Removes a collection of Items's.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.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.void
removeLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.List itemsToUnlink, boolean sortSrc2Tgt, boolean sortTgt2Src)
void
removeLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.List itemsToUnlink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified)
protected void
removeLinks()
protected void
removePartOfItems(SessionContext ctx)
Removes all partOf items.protected void
removePartOfItems(SessionContext ctx, java.util.Map<java.lang.String,java.lang.Object> emptyValuesMap)
void
setAllAttributes(SessionContext ctx, java.util.Map values)
Sets multiple attributes at once using a specific session context.void
setAllAttributes(java.util.Map values)
Sets multiple attributes at once using the default session context.protected void
setAllAttributesInternal(SessionContext ctx, java.util.Map values)
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.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.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.void
setAllLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, java.util.Map languageToItemListMap, boolean markModified)
void
setAttribute(SessionContext ctx, java.lang.String qualifier, java.lang.Object value)
Sets the value of the attribute specified by the attribute qualifier.void
setAttribute(java.lang.String qualifier, java.lang.Object value)
Sets the value of the attribute specified by the attribute qualifier.void
setAttributeFromString(SessionContext ctx, java.lang.String qualifier, java.lang.String value)
Still experimental! This method changes the attribute value by parsing a string value representation.void
setAttributeFromString(java.lang.String qualifier, java.lang.String value)
Still experimental! This method changes the attribute value by parsing a string value representation.void
setCacheBound(boolean bound)
Item
setComposedType(ComposedType type)
Changes the type of an item.protected void
setCreationTime(java.util.Date creationTime)
void
setImplementation(BridgeInterface impl)
Assigns the persistence implementation object to this Item instance.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.void
setLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.Collection<? extends Item> itemsToLink)
void
setLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.Collection<? extends Item> itemsToLink, boolean markModified)
void
setLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.Collection<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src)
void
setLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.Collection<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified)
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.void
setLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.List<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src)
void
setLinkedItems(SessionContext ctx, boolean itemIsSource, java.lang.String qualifier, Language lang, java.util.List<? extends Item> itemsToLink, boolean sortSrc2Tgt, boolean sortTgt2Src, boolean markModified)
void
setModificationTime(java.util.Date date)
void
setNonInitialAttributes(SessionContext ctx, Item item, Item.ItemAttributeMap nonInitialAttributes)
Sets all attributes which could not be set duringcreateItem(SessionContext, ComposedType, ItemAttributeMap)
.void
setOwner(Item item)
void
setPermissionsByMap(java.util.List userRights, java.util.Map permissionMap)
Changes permission settings for a given list of user rights.<T extends Item>
booleansetRelatedItems(java.lang.String relationQualifier, java.util.Collection<T> values)
Internal method to directly set related items linked by the One To Many relation.void
setTransientObject(java.lang.String key, java.lang.Object value)
Sets a transient object.protected void
setUseTA(SessionContext ctx, boolean use)
java.lang.String
toString()
Returns theString
representation of this item.protected boolean
useTA(SessionContext ctx, boolean def)
java.lang.Object
writeReplace()
Takes care of serialization of items.-
Methods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
-
-
-
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 totrue
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
ThePK
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
TheTYPE
attribute constant.
-
CREATION_TIME
public static final java.lang.String CREATION_TIME
TheCREATION_TIME
attribute constant.
-
MODIFIED_TIME
public static final java.lang.String MODIFIED_TIME
TheMODIFIED_TIME
attribute constant.
-
OWNER
public static final java.lang.String OWNER
TheOWNER
attribute constant.
-
NOT_FOUND
public static final int NOT_FOUND
The internal security check result constantNOT_FOUND
. Dont use.- See Also:
- Constant Field Values
-
POSITIVE
public static final int POSITIVE
The internal security check result constantPOSITIVE
. Dont use.- See Also:
- Constant Field Values
-
NEGATIVE
public static final int NEGATIVE
The internal security check result constantNEGATIVE
. Dont use.- See Also:
- Constant Field Values
-
EVEN
public static final int EVEN
The internal security check result constantEVEN
. Dont use.- See Also:
- Constant Field Values
-
HJMPTS
public static final java.lang.String HJMPTS
TheMODIFIED_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 theisInCreate(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)
-
getImplementation
public Item.ItemImpl getImplementation()
Description copied from class:BridgeAbstraction
returns the implementation object of this jalo bridge abstraction- Overrides:
getImplementation
in classBridgeAbstraction
- Returns:
- the implementation object of this jalo bridge abstraction
-
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 classqualifier
- the attribute qualifieraccess
- the access object
-
registerAccessFor
public static void registerAccessFor(java.lang.String extensionName, java.lang.Class clazz, java.lang.String qualifier, AttributeAccess access)
-
internal_registerNonClassAccessorFor
protected static final void internal_registerNonClassAccessorFor(Tenant tenant, AttributeDescriptor attributeDescriptor, 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 formyClass
- the class to search within- Returns:
- the matching access object or null if none exists
-
createNonClassAccessor
protected AttributeAccess createNonClassAccessor(AttributeDescriptor fieldDescriptor)
-
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 withincollection
- The collection of items, which will be removed.- Throws:
ConsistencyCheckException
- if an error occurs during the remove process.
-
getTenant
public Tenant getTenant()
- Overrides:
getTenant
in classBridgeAbstraction
-
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 classBridgeAbstraction
- 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 forgetSession().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 forComposedType.isInstance(Object)
.- Parameters:
type
- theComposedType
- Returns:
true
if thisItem
is an instance of the specifiedComposedType
-
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()
-
setOwner
public void setOwner(Item item) throws ConsistencyCheckException
- Throws:
ConsistencyCheckException
-
getAttribute
public java.lang.Object getAttribute(java.lang.String qualifier) throws JaloInvalidParameterException, JaloSecurityException
Returns the attribute value for a single item attribute using the current session context.- Parameters:
qualifier
- the attribute qualifier (case insensitive)- Returns:
- Object the value of the attribute
- Throws:
JaloInvalidParameterException
- in case the attribute cannot be readJaloSecurityException
- in case it is not allowed to read this attribute
-
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 readJaloSecurityException
- 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 qualifiervalue
- the string value representation- Throws:
JaloInvalidParameterException
- in case the attribute cannot be read or is not string-representableJaloBusinessException
- 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 contextqualifier
- the attribute qualifiervalue
- the string value representation- Throws:
JaloInvalidParameterException
- in case the attribute cannot be read or is not string-representableJaloBusinessException
- if an error occurs during setting the value- Since:
- 2.10
-
getAllAttributes
public java.util.Map getAllAttributes() throws JaloInvalidParameterException, JaloSecurityException
Reads all (readable) attribute values of this item using the current session context. Please note that only non-private attributes are fetched. To read them as well usegetAllAttributes(SessionContext, Set)
instead.- Throws:
JaloInvalidParameterException
- in case one attribute cannot be readJaloSecurityException
- in case one attribute is not allowed to be read
-
getAllAttributes
public java.util.Map getAllAttributes(SessionContext ctx) throws JaloInvalidParameterException, JaloSecurityException
Reads all (readable) attribute values of this item using a specific session context. Please note that only non-private attributes are fetched. To read them as well usegetAllAttributes(SessionContext, Set)
instead.- Parameters:
ctx
- the session context defining the language to fetch the value for (applies for to localized attributes only )- Throws:
JaloInvalidParameterException
- in case one attribute cannot be readJaloSecurityException
- in case one attribute is not allowed to be read
-
getAllAttributes
public java.util.Map getAllAttributes(SessionContext ctx, Item.AttributeFilter filter) throws JaloInvalidParameterException, JaloSecurityException
Reads all attribute values of this item which pass a given attribute filter. Please note that only non-private attributes are fetched. To read them as well usegetAllAttributes(SessionContext, Set)
instead.- Parameters:
ctx
- the session context to read values forfilter
- the attribute filter to specify which attributes should be read and which should be skipped- Throws:
JaloInvalidParameterException
- in case one attribute cannot be readJaloSecurityException
- in case one attribute is not allowed to be read
-
setUseTA
protected void setUseTA(SessionContext ctx, boolean use)
-
useTA
protected boolean useTA(SessionContext ctx, boolean def)
-
getAllAttributes
public java.util.Map getAllAttributes(SessionContext ctx, java.util.Set<java.lang.String> qualfiers) throws JaloInvalidParameterException, JaloSecurityException
Reads all values of specified attributes for this item.- Parameters:
ctx
- the session context to read values forqualfiers
- the qualifiers of all attributes to read values form- Throws:
JaloInvalidParameterException
- in case one attribute cannot be readJaloSecurityException
- in case one attribute is not allowed to be read
-
getAllAttributesInternal
protected java.util.Map<java.lang.String,java.lang.Object> getAllAttributesInternal(SessionContext ctx, java.util.Set<java.lang.String> qualfiers) throws JaloInvalidParameterException, JaloSecurityException
-
setAllAttributes
public void setAllAttributes(java.util.Map values) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException
Sets multiple attributes at once using the default session context.- Parameters:
values
- a map containing mapping from attribute qualifier to its new value- Throws:
JaloInvalidParameterException
- in case a wrong value was provided or a attribute could not be found at allJaloSecurityException
- in case a attribute could not be writtenJaloBusinessException
- on misc application errors during attribute writing
-
setAllAttributes
public void setAllAttributes(SessionContext ctx, java.util.Map values) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException
Sets multiple attributes at once using a specific session context.- Parameters:
values
- a map containing mapping from attribute qualifier to its new valuectx
- the session context defining the language to fetch the value for (applies for to localized attributes only )- Throws:
JaloInvalidParameterException
- in case a wrong value was provided or a attribute could not be found at allJaloSecurityException
- in case a attribute could not be writtenJaloBusinessException
- on misc application errors during attribute writing
-
setAllAttributesInternal
protected void setAllAttributesInternal(SessionContext ctx, java.util.Map values) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException
-
checkConstraint
protected void checkConstraint(Item.ItemConstraint constr) throws ConsistencyCheckException
Allows to implement transaction safe consistency checking code. Please refer toItem.ItemConstraint
for more detail.- Parameters:
constr
- the consistency checking code object- Throws:
ConsistencyCheckException
- in case the constraint is violated
-
isInCreate
public static boolean isInCreate(SessionContext ctx)
-
setAttribute
public void setAttribute(java.lang.String qualifier, java.lang.Object value) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException
Sets the value of the attribute specified by the attribute qualifier.- Parameters:
qualifier
- the attribute qualifier of the attribute, of which the value will be set.value
- the attribute value which will be set- Throws:
JaloInvalidParameterException
JaloSecurityException
JaloBusinessException
-
setAttribute
public void setAttribute(SessionContext ctx, java.lang.String qualifier, java.lang.Object value) throws JaloInvalidParameterException, JaloSecurityException, JaloBusinessException
Sets the value of the attribute specified by the attribute qualifier.- Parameters:
ctx
- the session contextqualifier
- the attribute qualifier of the attribute, of which the value will be set.value
- the attribute value which will be set- Throws:
JaloInvalidParameterException
JaloSecurityException
JaloBusinessException
-
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 findqualifier
- the link qualifierlang
- 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 findqualifier
- the link qualifierlang
- optional: the language for localized linksstart
- the start index of the item rangecount
- 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 countqualifier
- the link qualifierlang
- 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 findqualifier
- the link qualifierlang
- optional: the language for localized linksctx
- 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 onlynull
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 propertyname
- the property namevalue
- 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 findqualifier
- the link qualifierlang
- optional: the language for localized linksstart
- the start index of the item rangecount
- the amount of items to fetch, use-1
for unlimited amountctx
- 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 countqualifier
- the link qualifierlang
- optional: the link language for localized linksctx
- 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 withinitemIsSource
- tells whether this item is source or target of the links to countrelationTypeCode
- the link qualifierrelatedItemCode
- the related item qualifierlang
- 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 ingetLinkedItems(boolean, String, Language)
.- Parameters:
itemIsSource
- tells whether this item is source or target of the links to evaluatequalifier
- 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 targetqualifier
- the link qualifierlang
- optional: the language if the links should be localizeditemsToLink
- 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 targetqualifier
- the link qualifierlang
- optional: the language if the links should be localizeditemsToLink
- the new collection of items to link toctx
- 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 containingLanguage
s 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 targetqualifier
- the link qualifierlanguageToItemListMap
- the new items to link asLanguage
-> [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 containingLanguage
s 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 targetqualifier
- the link qualifierlanguageToItemListMap
- the new items to link asLanguage
-> [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 containingLanguage
s 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 targetqualifier
- the link qualifierlanguageToItemListMap
- the new items to link asLanguage
-> [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 linksqualifier
- specifies the link qualifierlang
- optional: the language to create localized links foritemsToLink
- 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 linksqualifier
- specifies the link qualifierlang
- optional: the language to create localized links foritemsToLink
- the items which will be linked with this itemctx
- 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 linksqualifier
- specifies the link qualifierlang
- optional: the language to create localized links foritemsToLink
- the items which will be linked with this itemposition
- 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 linksqualifier
- specifies the link qualifierlang
- optional: the language to create localized links foritemsToLink
- the items which will be linked with this itemposition
- 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 linksqualifier
- specifies the link qualifierlang
- optional: the language to create localized links foritemsToLink
- the items which will be linked with this itemposition
- 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 linksqualifier
- specifies the link qualifierlang
- optional: the language to create localized links foritemsToLink
- the items which will be linked with this itemposition
- 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 notctx
- 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 removequalifier
- the qualifier of the linkslang
- optional: the language of the localized linksitemsToUnlink
- 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 removequalifier
- the qualifier of the linkslang
- optional: the language of the localized linksitemsToUnlink
- 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() throws ConsistencyCheckException
Removes this item.This method calls
remove(SessionContext)
with the current session's SessionContext object. See this method for more details.- Throws:
ConsistencyCheckException
- if this item could not be removed for some reason
-
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 overridingremove(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 overridingremove(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()
-
removePartOfItems
protected void removePartOfItems(SessionContext ctx) throws ConsistencyCheckException
Removes all partOf items. Override to add customized partOf removal logic.- Parameters:
ctx
-- Throws:
ConsistencyCheckException
-
removePartOfItems
protected void removePartOfItems(SessionContext ctx, java.util.Map<java.lang.String,java.lang.Object> emptyValuesMap) throws ConsistencyCheckException
- Throws:
ConsistencyCheckException
-
removeLinks
protected void removeLinks()
-
checkRemovable
protected void checkRemovable(SessionContext ctx) throws ConsistencyCheckException
Checks whether or not this it may be removed or not. Called before the actual removal process.- Parameters:
ctx
-- Throws:
ConsistencyCheckException
- to indicate that the item cannot be removed
-
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 useitem.equals(item2)
whenever you want to compare two items for equality.- Overrides:
equals
in classjava.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 interfacejava.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 classjava.lang.Object
- Returns:
- the hashcode of this item.
-
toString
public java.lang.String toString()
Returns theString
representation of this item. This is by default the representation of the primary key of this item.- Overrides:
toString
in classjava.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 givenPrincipal
.- Parameters:
principal
- thePrincipal
whos permissions will be returnednegative
- if set totrue
, all negative permissions will be returned, if set tofalse
, 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 ofUserRights
- 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 mapPrincipal -> [ 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 ofUserRight
, <code> null </code> is not allowedpermissionMap
- 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 givenPrincipal
.- 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 givenPrincipal
.- 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 thePrincipal
and theUserRight
on theItem
.- Parameters:
principal
- thePrincipal
the permission belongs to.right
- theUserRight
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 thePrincipal
and theUserRight
on theItem
.- Parameters:
principal
- thePrincipal
the removed permission belongs to.right
- theUserRight
the removed permission belongs to.
-
addPositivePermission
public void addPositivePermission(Principal principal, UserRight right)
Add a positive permission for thePrincipal
and theUserRight
on theItem
.- Parameters:
principal
- thePrincipal
the positive permission belongs to.right
- theUserRight
the positive permission belongs to.
-
addNegativePermission
public void addNegativePermission(Principal principal, UserRight right)
Add a negative permission for thePrincipal
and theUserRight
on theItem
.- Parameters:
principal
- thePrincipal
the negative permission belongs to.right
- theUserRight
the negative permission belongs to.
-
checkPermission
public boolean checkPermission(UserRight right)
Checks if the current session user has the givenUserRight
on theItem
.- Parameters:
right
- theUserRight
the permission should be checked for- Returns:
true
if the current session user has theUserRight
for thisItem
-
checkPermission
public boolean checkPermission(Principal principal, UserRight right)
Checks if thePrincipal
has the givenUserRight
on theItem
.- Parameters:
principal
- thePrincipal
the permission should be checked forright
- theUserRight
the permission should be checked for- Returns:
true
if thePrincipal
has theUserRight
for thisItem
-
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 classBridgeAbstraction
- Parameters:
key
- the keyvalue
- may be null; this will remove the transient object mapping
- it will be removed with
-
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 classBridgeAbstraction
- 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. UsesetTransientObject(String, Object)
andgetTransientObject(String)
Returns the completeMap
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 classBridgeAbstraction
- Returns:
- a
Map
of all transient objects.
-
isAlive
public boolean isAlive()
Istrue
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 newItem
using the specified parameters.- Parameters:
ctx
- the session context which the new item should be created withintype
- theComposedType
of the newly createdItem
attributeAssignment
- a map containing the attribute values of the newly createdItem
- Returns:
- the created
Item
- Throws:
JaloBusinessException
-
notifyExtensionsBeforeItemCreation
protected void notifyExtensionsBeforeItemCreation(SessionContext ctx, ComposedType type, Item.ItemAttributeMap attributes) throws JaloBusinessException
- Throws:
JaloBusinessException
-
notifyExtensionsAfterItemCreation
protected void notifyExtensionsAfterItemCreation(SessionContext ctx, ComposedType type, Item createdItem, Item.ItemAttributeMap attributes) throws JaloBusinessException
- Throws:
JaloBusinessException
-
changeTypeAfterCreation
protected Item changeTypeAfterCreation(Item newOne, ComposedType requestedType) throws JaloInvalidParameterException
Changes the item type in casecreateItem(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 itemrequestedType
- 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
-
setNonInitialAttributes
public void setNonInitialAttributes(SessionContext ctx, Item item, Item.ItemAttributeMap nonInitialAttributes) throws JaloBusinessException
Sets all attributes which could not be set duringcreateItem(SessionContext, ComposedType, ItemAttributeMap)
. as default this method just iterates over all attribute mappings and sets the value by invokingsetAttribute(SessionContext, String, Object)
.- Parameters:
ctx
- session context with language = NULLitem
- the newly created itemnonInitialAttributes
- the non-initial attributed obtained viagetNonInitialAttributes(SessionContext, ItemAttributeMap)
- Throws:
JaloBusinessException
-
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 bycreateItem(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 = NULLallAttributes
- aItemAttributeMap
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 checkallAttributes
- the creation attributes mapmissingSet
- 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 checkallAttributes
- the creation attributes mapmissingSet
- the container to add a missing qualifier tonullAllowed
- 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. ) duringComposedType.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 withintype
- 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 viaJaloSession.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.
-
-