workflows: revamp session handling

* Changes the way the db.session is called in
  BibWorkflowEngine and BibWorkflowObject models
  to use a session_manager decorator.

* Adds new classmethods to BibWorkflowObject to create
  objects and revisions.

* New BibWorkflowObject's are now by default initiated
  with version set to INITIAL (from RUNNING).

* RUNNING version is only set when a BibWorkflowObject is
  actually being executed in a BibWorkflowEngine.

* Removes the workflow status FINISHED, as it was too
  ambiguous compared to COMPLETED. If a workflow contains
  data objects that have not reached FINAL version, the
  workflow status is set to HALTED.

* Cleans some of the log messages in the engine.

* Reworks what happens when a workflow is asked to *fully*
  restart. It will take the INITIAL version of every
  associated object and run it through the workflow from
  the start.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
workflows: sphinx documentation and more

* Adds sphinx documentation syntax to functions in the module.

* Fixes a problem with duplication of logger, the logger was
  a singleton but not the handlers which were accumulated each time
  we were continuing a workflow, producing database burst.

* Deletes some dead code.

* Fixes a mistake which was due to limitations in extra_data
  access.

Reviewed-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
Signed-off-by: Guillaume Lastecoueres <guillaume.lastecoueres@techie.com>
workflows: add more unit tests

* Adds more unit tests with new tasks and workflows.

Signed-off-by: Guillaume Lastecoueres <guillaume.lastecoueres@cern.ch>
workflows: update generic_harvesting_workflow

* Updates the generic_harvesting_workflow.

Signed-off-by: Guillaume Lastecoueres <guillaume.lastecoueres@cern.ch>
workflows: update API and errors

* Workers now return directly, removing some preliminary code
  to close sessions.

* Adds new exception WorkflowAPIError to alert about API usage
  errors.

* Amends the way workflows within a workflow is initiated.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
workflows: revamp testsuite

* Implements a renewed testsuite for workflows with better coverage
  overall.

* Moves the workflows and widgets loading to use registry. Tests
  also use their own test registry.

* Test specific workflows are now moved to the testsuite.

* Cleans up the tests a bit, renaming and moving the tests in
  test_halt into the renewed test_workflows suite.

* Makes the tests visible for the overall invenio testsuite by
  adding the TEST_SUITE variable.

* Fixes an issue with the custom Log handler and inheritance.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
workflows: add more docs

* Adds basic documentation for API and Holding Pen view under
  api.rst.

* Adds docstrings in various modules to be included in general
  documentation.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
workflows: registry recreation in test setUp

Signed-off-by: Jiri Kuncar <jiri.kuncar@cern.ch>
workflows: auto discover registry

* Adds registry for auto discovering workflows and make
  manual registering workflows easier.

Signed-off-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch>
workflows: unit tests stabilization

* Goes over the unit tests and treats query results in a more
  stable way by ordering results directly. Should avoid problems
  of occasional failures when running the unit tests.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
deposit: workflow integration update

* Updates part of the workflows module integration to
  create and save workflow objects in the new way. Versioning
  and statuses are now handled by the workflow engine itself.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
workflows: continue execution fix

* Fixes an issue with continue workflow execution of an
  initial object due to unknown workflow position.

Signed-off-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch>
workflows: test registry cleanup

* Adds a function to cleanup registries initialized for each
  unit test. This avoids RegistryError when running several tests.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
workflows: object workflow API addition

* Adds new BibWorkflowObject bound methods to start and continue
  workflows for easier integration with the workflows module when
  pre-creating objects.

* Adds new tests for the new methods.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
deposit: workflow integration changes

* Updates the Deposition and DepositionType classes to use
  newer workflows object bound API.

Signed-off-by: Jan Aage Lavik <jan.age.lavik@cern.ch>
workflows: registry refactoring

* Refactors registry into generic registry integrated in
  invenio.ext.registry and workflow specific registry.

Signed-off-by: Lars Holm Nielsen <lars.holm.nielsen@cern.ch>