-
Notifications
You must be signed in to change notification settings - Fork 51
Description
The old traditional class hierarchy for tasks in CBRAIN is messy.
At the top, we have CbrainTask.
Then underneath, we have subclasses that exist in two branches, where only one branch exist depending if the current Rails app is a BrainPortal or a Bourreau. The hieracrhy also depends on the type of integration that the task was implemented as (yuk, sentence!)
On a BrainPortal:
# Standard integration, and old template-based Boutiques integration
CbrainTask > PortalTask > CbrainTask::ToolName
# New Boutiques integration
CbrainTask > PortalTask > BoutiquesPortalTask > BoutiquesTask::ToolName
On a Bourreau, it's similar yet different but not the same yet almost identical:
# Standard integration, and old template-based Boutiques integration
CbrainTask > ClusterTask > CbrainTask::ToolName
# New Boutiques integration
CbrainTask > ClusterTask > BoutiquesClusterTask > BoutiquesTask::ToolName
The files that implement all the classes are:
- CbrainTask :
app/models/cbrain_task.rb
- PortalTask :
app/models/portal_task.rb
- BoutiquesPortalTask :
app/models/boutiques_portal_task.rb
- CbrainTask::ToolName :
a. (Standard integration): in a plugins, incbrain_task/toolname/{portal|bourreau|common}/toolname.rb
b. (Old Boutiques integration): from templates inlib/cbrain_task_generators
- BoutiquesPortalTask :
app/models/boutiques_portal_task.rb
- BoutiquesTask::ToolName : Empty class generated dynamically at boot time
- ClusterTask :
app/models/cluster_task.rb
- BoutiquesClusterTask :
app/models/boutiques_cluster_task.rb
- BoutiquesTask :
cbrain_plugins/cbrain-plugins-base/cbrain_task/boutiques_task/{portal|bourreau}/boutiques_task.rb
; this is an empty class that does not inherit from anything, and is used as a namespace for the other BoutiquesTask::ToolName constants
Now, the ideal refactoring would be to
- get rid of the two branches PortalTask vs ClusterTask
- move all the methods of these two classes into modules (maybe with the same names)
- have the CbrainTask class include one or the other of these now modules depending if we're on a Bourreau or Portal
Some consequences: we will need to either edit the code of all the tasks that are integrated in the standard way, to change e.g. CbrainTask::ToolName < PortalTask
into CbrainTask::ToolName < CbrainTask
or we can reassign the constants PortalTask and ClusterTask to be synonyms of CbrainTask (in that case, the new modules need new names)