Class DefaultObjectFacade
- java.lang.Object
-
- com.hybris.cockpitng.dataaccess.facades.object.impl.DefaultObjectFacade
-
- All Implemented Interfaces:
ObjectCRUDHandler,ObjectFacade
- Direct Known Subclasses:
PermissionAwareObjectFacade
public class DefaultObjectFacade extends java.lang.Object implements ObjectFacade
Default implementation of ObjectFacade. Delegates to a matchingObjectFacadeStrategy.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCOCKPITNG_CRUD_COCKPIT_EVENT_NOTIFICATIONstatic java.lang.StringCTX_PARAM_UPDATED_OBJECT_IS_NEWprotected TypeFacadetypeFacade-
Fields inherited from interface com.hybris.cockpitng.dataaccess.facades.object.ObjectCRUDHandler
OBJECT_CREATED_EVENT, OBJECTS_DELETED_EVENT, OBJECTS_UPDATED_EVENT
-
Fields inherited from interface com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade
CTX_DISABLE_CRUD_COCKPIT_EVENT_NOTIFICATION, CTX_PARAM_SUPPRESS_EVENT
-
-
Constructor Summary
Constructors Constructor Description DefaultObjectFacade()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> Tclone(T objectToClone, Context ctx)Clone an object by given object data.<T> Tcreate(java.lang.String typeId)Creates a new object in the system using given object data.<T> Tcreate(java.lang.String typeId, Context ctx)Creates a new object in the system using given object data.<T> ObjectFacadeOperationResult<T>delete(java.util.Collection<T> objects, Context ctx)Deletes many given objects from the system.
Default implementation callsObjectCRUDHandler.delete(Object, Context)in a loop and does not publishObjectCRUDHandler.OBJECTS_DELETED_EVENTevent.<T> voiddelete(T object)Deletes an object from system.<T> voiddelete(T object, Context ctx)Deletes given object from the system.protected CockpitGlobalEventPublishergetEventPublisher()<T> java.lang.ObjectgetObjectId(T object)protected booleanisCockpitEventNotificationDisabledInCtx(Context ctx)protected booleanisCockpitEventNotificationEnabled()<T> booleanisDeleted(T object)Tells if an object was once persisted, but now is deleted<T> booleanisModified(T object)Tells if an object is not persisted or has unsaved changes.<T> booleanisNew(T object)Tells if an object has been created and has not been saved yet.<T> Tload(java.lang.String id)Gets an object instance by it's id.<T> Tload(java.lang.String id, Context ctx)Gets an object instance by it's id.protected voidpopulateEventContext(Context source, DefaultCockpitEvent destination)Deprecated, for removal: This API element is subject to removal in a future version.since 6.5protected voidpublishEvent(java.lang.String eventName, java.lang.Object object, Context ctx)<T> Treload(T object)Gets a fresh instance of the given object.<T> Treload(T object, Context ctx)Gets a fresh instance of the given object.<T> ObjectFacadeOperationResult<T>save(java.util.Collection<T> objects, Context ctx)Persist objects by given collection data.<T> Tsave(T objectToSave)Persist an object by given object data.<T> Tsave(T object, Context ctx)Persist an object by given object data.protected <T> TsaveSingleObject(T object, Context ctx)voidsetCockpitProperties(CockpitProperties cockpitProperties)voidsetEventPublisher(CockpitGlobalEventPublisher eventPublisher)voidsetEventQueue(CockpitEventQueue eventQueue)Deprecated, for removal: This API element is subject to removal in a future version.since 6.5voidsetStrategyRegistry(AbstractStrategyRegistry<ObjectFacadeStrategy,java.lang.Object> strategyRegistry)voidsetTypeFacade(TypeFacade typeFacade)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.hybris.cockpitng.dataaccess.facades.object.ObjectCRUDHandler
reload
-
Methods inherited from interface com.hybris.cockpitng.dataaccess.facades.object.ObjectFacade
clone, delete, isPersisted, reload, save
-
-
-
-
Field Detail
-
CTX_PARAM_UPDATED_OBJECT_IS_NEW
public static final java.lang.String CTX_PARAM_UPDATED_OBJECT_IS_NEW
- See Also:
- Constant Field Values
-
COCKPITNG_CRUD_COCKPIT_EVENT_NOTIFICATION
public static final java.lang.String COCKPITNG_CRUD_COCKPIT_EVENT_NOTIFICATION
- See Also:
- Constant Field Values
-
typeFacade
protected TypeFacade typeFacade
-
-
Method Detail
-
load
public <T> T load(java.lang.String id) throws ObjectNotFoundExceptionDescription copied from interface:ObjectFacadeGets an object instance by it's id.- Specified by:
loadin interfaceObjectFacade- Parameters:
id- The unique qualifier of the object.- Returns:
- loaded object instance for given id
- Throws:
ObjectNotFoundException- if no object with the given id could be found.
-
load
public <T> T load(java.lang.String id, Context ctx) throws ObjectNotFoundExceptionDescription copied from interface:ObjectCRUDHandlerGets an object instance by it's id.- Specified by:
loadin interfaceObjectCRUDHandler- Parameters:
id- for which the object is neededctx- context specifying the loaded attributes of the returned object as well as application settings- Returns:
- the object instance for given id loaded with attributes defined in context
- Throws:
ObjectNotFoundException- if no object with the given id could be found
-
delete
public <T> void delete(T object) throws ObjectDeletionExceptionDescription copied from interface:ObjectFacadeDeletes an object from system.- Specified by:
deletein interfaceObjectFacade- Parameters:
object- The object which should be deleted.- Throws:
ObjectDeletionException- if the given object could not be deleted.
-
delete
public <T> void delete(T object, Context ctx) throws ObjectDeletionExceptionDescription copied from interface:ObjectCRUDHandlerDeletes given object from the system.- Specified by:
deletein interfaceObjectCRUDHandler- Parameters:
object- which should get deletedctx- context specifying application settings- Throws:
ObjectDeletionException- if the given object could not be deleted
-
delete
public <T> ObjectFacadeOperationResult<T> delete(java.util.Collection<T> objects, Context ctx)
Description copied from interface:ObjectCRUDHandlerDeletes many given objects from the system.
Default implementation callsObjectCRUDHandler.delete(Object, Context)in a loop and does not publishObjectCRUDHandler.OBJECTS_DELETED_EVENTevent.- Specified by:
deletein interfaceObjectCRUDHandler- Parameters:
objects- which should get deleted- Returns:
- Result of the operation containing both successful and failed objects. Should never be null.
-
create
public <T> T create(java.lang.String typeId) throws ObjectCreationExceptionDescription copied from interface:ObjectFacadeCreates a new object in the system using given object data.- Specified by:
createin interfaceObjectFacade- Parameters:
typeId- The type qualifier specifying the type of which the new object is an instance.- Returns:
- The newly created object.
- Throws:
ObjectCreationException- if the object couldn't be created, like an object with the specified id already exists.
-
create
public <T> T create(java.lang.String typeId, Context ctx) throws ObjectCreationExceptionDescription copied from interface:ObjectCRUDHandlerCreates a new object in the system using given object data.- Specified by:
createin interfaceObjectCRUDHandler- Parameters:
typeId- the data for creation of object in systemctx- context specifying the loaded attributes of the returned object as well as application settings- Returns:
- the created object with attributes loaded as specified in context
- Throws:
ObjectCreationException- if the object couldn't be created, like an object with the specified id already exists
-
save
public <T> T save(T objectToSave) throws ObjectSavingExceptionDescription copied from interface:ObjectFacadePersist an object by given object data.- Specified by:
savein interfaceObjectFacade- Parameters:
objectToSave- An object, on which the save action should be applied (usually persisting in a DBS)- Returns:
- The updated object, if saving it was successful.
- Throws:
ObjectSavingException- if the object couldn't be persisted, like a unique attribute was updated to be non-unique.
-
saveSingleObject
protected <T> T saveSingleObject(T object, Context ctx) throws ObjectSavingException- Throws:
ObjectSavingException
-
save
public <T> T save(T object, Context ctx) throws ObjectSavingExceptionDescription copied from interface:ObjectCRUDHandlerPersist an object by given object data.- Specified by:
savein interfaceObjectCRUDHandler- Parameters:
object- the data for updating an object in systemctx- context specifying the loaded attributes of the returned object as well as application settings- Returns:
- the updated object
- Throws:
ObjectSavingException- if the object couldn't be persisted, like a unique attribute was updated to be non-unique
-
save
public <T> ObjectFacadeOperationResult<T> save(java.util.Collection<T> objects, Context ctx)
Persist objects by given collection data. Since 1808 this method is transactional.- Specified by:
savein interfaceObjectCRUDHandler- Parameters:
objects- the data for updating objects in system. Each object is saved separately in a dedicated transaction.ctx- context specifying the loaded attributes of the returned object as well as application settings- Returns:
- ObjectFacadeOperationResult object
-
reload
public <T> T reload(T object, Context ctx) throws ObjectNotFoundExceptionDescription copied from interface:ObjectCRUDHandlerGets a fresh instance of the given object. Usually it re-fetches a domain object from the persistence layer, but could also just return the same instance, if the object is not managed.- Specified by:
reloadin interfaceObjectCRUDHandler- Parameters:
object- The object that should be refreshed.ctx- context specifying the loaded attributes of the returned object as well as application settings- Returns:
- A new instance of the given object, or the object itself, if it's not managed.
- Throws:
ObjectNotFoundException- If the current object couldn't be found (could be deleted in the mean time).
-
reload
public <T> T reload(T object) throws ObjectNotFoundExceptionDescription copied from interface:ObjectFacadeGets a fresh instance of the given object. Usually it re-fetches a domain object from the persistence layer, but could also just return the same instance, if the object is not managed.- Specified by:
reloadin interfaceObjectFacade- Parameters:
object- The object that should be refreshed.- Returns:
- A new instance of the given object, or the object itself, if it's not managed.
- Throws:
ObjectNotFoundException- If the current object couldn't be found (could be deleted in the mean time).
-
isNew
public <T> boolean isNew(T object)
Description copied from interface:ObjectCRUDHandlerTells if an object has been created and has not been saved yet.- Specified by:
isNewin interfaceObjectCRUDHandler- Type Parameters:
T- object type.- Parameters:
object- the object to check.- Returns:
- true if an object has been created and has not been saved yet.
-
isModified
public <T> boolean isModified(T object)
Description copied from interface:ObjectCRUDHandlerTells if an object is not persisted or has unsaved changes.- Specified by:
isModifiedin interfaceObjectCRUDHandler- Type Parameters:
T- object type.- Parameters:
object- the object to check.- Returns:
- true if an object has been modified.
-
isDeleted
public <T> boolean isDeleted(T object)
Description copied from interface:ObjectCRUDHandlerTells if an object was once persisted, but now is deleted- Specified by:
isDeletedin interfaceObjectCRUDHandler- Type Parameters:
T- object type.- Parameters:
object- the object to check.- Returns:
- true if an object has been deleted
-
clone
public <T> T clone(T objectToClone, Context ctx) throws ObjectCloningExceptionDescription copied from interface:ObjectCRUDHandlerClone an object by given object data.- Specified by:
clonein interfaceObjectCRUDHandler- Parameters:
objectToClone- - source object to be cloned.ctx- context specifying the loaded attributes of the returned object as well as application settings.- Returns:
- ObjectFacadeOperationResult object.
- Throws:
ObjectCloningException- if cannot perform the clone.
-
getObjectId
public <T> java.lang.Object getObjectId(T object)
- Specified by:
getObjectIdin interfaceObjectCRUDHandler- Parameters:
object- The object which identifier should be returned- Returns:
- object identifier
-
setStrategyRegistry
public void setStrategyRegistry(AbstractStrategyRegistry<ObjectFacadeStrategy,java.lang.Object> strategyRegistry)
-
setEventQueue
@Deprecated(since="6.5", forRemoval=true) public void setEventQueue(CockpitEventQueue eventQueue)Deprecated, for removal: This API element is subject to removal in a future version.since 6.5- See Also:
eventPublisher
-
setCockpitProperties
public void setCockpitProperties(CockpitProperties cockpitProperties)
-
getEventPublisher
protected CockpitGlobalEventPublisher getEventPublisher()
-
setEventPublisher
public void setEventPublisher(CockpitGlobalEventPublisher eventPublisher)
-
setTypeFacade
public void setTypeFacade(TypeFacade typeFacade)
-
publishEvent
protected void publishEvent(java.lang.String eventName, java.lang.Object object, Context ctx)
-
populateEventContext
@Deprecated(since="6.5", forRemoval=true) protected void populateEventContext(Context source, DefaultCockpitEvent destination)Deprecated, for removal: This API element is subject to removal in a future version.since 6.5- See Also:
DefaultCockpitGlobalEventPublisher
-
isCockpitEventNotificationEnabled
protected boolean isCockpitEventNotificationEnabled()
-
isCockpitEventNotificationDisabledInCtx
protected boolean isCockpitEventNotificationDisabledInCtx(Context ctx)
-
-