Interface IKeyedObjectService<T extends IKeyedObject<T>>

    • Method Detail

      • validateCreate

        void validateCreate​(T object)
                     throws ValidationException
        Validate the object for creation. This method can be used upon starting the workflow process for approving the object creation, and prior to calling create(IKeyedObject).

        Included in the validation will be checking that an object with the same key does not already exist.

        Parameters:
        object - the object to create
        Throws:
        ValidationException - if the new object cannot be created
      • create

        T create​(T object)
          throws ValidationException
        Create a new object in the persistence layer. This method can be called once the object has been approved in the workflow process.

        The object will also be validated using validateCreate(IKeyedObject)

        Parameters:
        object - the object being created
        Returns:
        the object that was persisted
        Throws:
        ValidationException - if the object fails validation.
      • validateUpdate

        void validateUpdate​(T object)
                     throws ValidationException
        Validate the object for update. This method can be used upon starting the workflow process for approving the object update, and prior to calling update(IKeyedObject).

        Included in the validation will be checking that an object with the same key exists and that the update is compatible with the existing object.

        Parameters:
        object - the object to update
        Throws:
        ValidationException - if the existing object cannot be updated with the new value
      • update

        T update​(T object)
          throws ValidationException
        Update an object in the persistence layer. This method can be called once the update has been approved in the workflow process.

        The object will also be validated using validateUpdate(IKeyedObject)

        Parameters:
        object - the object being updated
        Returns:
        the object that was persisted
        Throws:
        ValidationException - if the update fails validation.
      • validateCreateOrUpdate

        void validateCreateOrUpdate​(T object)
                             throws ValidationException
        Validate the object for creation or update. This method can be used upon starting the workflow process for approving the object update, and prior to calling createOrUpdate(IKeyedObject).

        The validation may depend on if the objects exists or not.

        Parameters:
        object - the object to validate
        Throws:
        ValidationException - if the object cannot be created or updated with the new value
      • createOrUpdate

        T createOrUpdate​(T object)
                  throws ValidationException
        Create or Update an object in the persistence layer. This method can be used if it is unknown if the object already exists, for example when importing multiple objects. This method can be called once the update has been approved in the workflow process.

        The object will also be validated using validateCreateOrUpdate(IKeyedObject)

        Parameters:
        object - the object being created or updated
        Returns:
        the object that was persisted
        Throws:
        ValidationException - if the object fails validation.
      • validateDelete

        void validateDelete​(String key)
                     throws ValidationException
        Validate the deletion of an object referenced by key. This method can be used upon starting the workflow process for deleting the object referenced by the key, and prior to calling delete(String).

        Included in the validation will be checking that an object with the key exists.

        Parameters:
        key - unique key for the object to delete
        Throws:
        ValidationException - if an object with this key cannot be deleted
      • delete

        T delete​(String key)
          throws ValidationException
        Delete an object (referenced by key) in the persistence layer. This method can be called once the deletion has been approved in the workflow process.

        The object will also be validated using validateDelete(String)

        Parameters:
        key - unique key for the object being deleted
        Returns:
        the old value of the object that was deleted
        Throws:
        ValidationException - if the deletion fails validation.
      • delete

        default T delete​(T object)
                  throws ValidationException
        Delete an object in the persistence layer. This method can be called once the deletion has been approved in the workflow process.

        The object will also be validated using validateDelete(String)

        Parameters:
        object - the object being deleted
        Returns:
        the old value of the object that was deleted
        Throws:
        ValidationException - if the deletion fails validation.
      • get

        T get​(String key)
        Retrieve an object by key.
        Parameters:
        key - the reference to the object to retrieve
        Returns:
        the object with the specified key
      • get

        Map<String,​T> get()
        Retrieve all objects.
        Returns:
        a Map of all objects, indexed by key.