Class DefaultObjectFacade

    • 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
    • Constructor Detail

      • DefaultObjectFacade

        public DefaultObjectFacade()
    • Method Detail

      • load

        public <T> T load​(java.lang.String id)
                   throws ObjectNotFoundException
        Description copied from interface: ObjectFacade
        Gets an object instance by it's id.
        Specified by:
        load in interface ObjectFacade
        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 ObjectNotFoundException
        Description copied from interface: ObjectCRUDHandler
        Gets an object instance by it's id.
        Specified by:
        load in interface ObjectCRUDHandler
        Parameters:
        id - for which the object is needed
        ctx - 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
      • create

        public <T> T create​(java.lang.String typeId)
                     throws ObjectCreationException
        Description copied from interface: ObjectFacade
        Creates a new object in the system using given object data.
        Specified by:
        create in interface ObjectFacade
        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 ObjectCreationException
        Description copied from interface: ObjectCRUDHandler
        Creates a new object in the system using given object data.
        Specified by:
        create in interface ObjectCRUDHandler
        Parameters:
        typeId - the data for creation of object in system
        ctx - 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 ObjectSavingException
        Description copied from interface: ObjectFacade
        Persist an object by given object data.
        Specified by:
        save in interface ObjectFacade
        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.
      • save

        public <T> T save​(T object,
                          Context ctx)
                   throws ObjectSavingException
        Description copied from interface: ObjectCRUDHandler
        Persist an object by given object data.
        Specified by:
        save in interface ObjectCRUDHandler
        Parameters:
        object - the data for updating an object in system
        ctx - 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:
        save in interface ObjectCRUDHandler
        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 ObjectNotFoundException
        Description copied from interface: ObjectCRUDHandler
        Gets 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:
        reload in interface ObjectCRUDHandler
        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 ObjectNotFoundException
        Description copied from interface: ObjectFacade
        Gets 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:
        reload in interface ObjectFacade
        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: ObjectCRUDHandler
        Tells if an object has been created and has not been saved yet.
        Specified by:
        isNew in interface ObjectCRUDHandler
        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: ObjectCRUDHandler
        Tells if an object is not persisted or has unsaved changes.
        Specified by:
        isModified in interface ObjectCRUDHandler
        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: ObjectCRUDHandler
        Tells if an object was once persisted, but now is deleted
        Specified by:
        isDeleted in interface ObjectCRUDHandler
        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 ObjectCloningException
        Description copied from interface: ObjectCRUDHandler
        Clone an object by given object data.
        Specified by:
        clone in interface ObjectCRUDHandler
        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:
        getObjectId in interface ObjectCRUDHandler
        Parameters:
        object - The object which identifier should be returned
        Returns:
        object identifier
      • 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)
      • setTypeFacade

        public void setTypeFacade​(TypeFacade typeFacade)
      • publishEvent

        protected void publishEvent​(java.lang.String eventName,
                                    java.lang.Object object,
                                    Context ctx)
      • isCockpitEventNotificationEnabled

        protected boolean isCockpitEventNotificationEnabled()
      • isCockpitEventNotificationDisabledInCtx

        protected boolean isCockpitEventNotificationDisabledInCtx​(Context ctx)