beat.web.algorithms.Algorithm & related code cannot handle Libraries on save()

As it is currently implemented, the Algorithm class on beat.web cannot handle an existing JSON (for example through an upload via the command-line), which references libraries. Its save() method will not updated the library relationship as it should.

The JSON of an algorithm (or library for that matter), already contains a mapping description, which defines which libraries it uses. Upon save(), the field referenced_libraries should be updated.

I think the issue comes from the fact you can add a library w/o going through the save(), whereas I think the system was designed in such a way you must always go through the save().

This means that any modification operation should:

  1. Load the old JSON
  2. Allow the user to modify it
  3. Overwrite the old JSON on the object with the new one (at the file field)
  4. Call the object's save() method

This strategy should automatically update the referenced_libraries field. This strategy also assures that we have a consistent representation of the object w.r.t. beat.web and beat.core.

We allow for no other way to modify this object.