Commit 6e08fe7a authored by liadomide's avatar liadomide

TVB-2598, TVB-2594 Preliminary refactor, not yet fixed

parent 9f4d7a34
......@@ -70,7 +70,7 @@ class CaseDAO(RootDAO):
try:
user = self.session.query(User).filter_by(username=name).one()
except SQLAlchemyError:
self.logger.exception("Could not retrieve user for name " + str(name))
self.logger.debug("Could not retrieve user for name " + str(name))
return user
def get_system_user(self):
......
......@@ -174,7 +174,8 @@ class FlowService:
self.logger.info("Starting operation " + operation_name)
project = dao.get_project_by_id(project_id)
result = OperationService().initiate_operation(current_user, project, adapter_instance, visible, model_view=view_model, **data)
result = OperationService().initiate_operation(current_user, project, adapter_instance, visible,
model_view=view_model, **data)
self.logger.info("Finished operation launch:" + operation_name)
return result
......
......@@ -51,7 +51,6 @@ from tvb.basic.exceptions import TVBException
from tvb.basic.neotraits.api import Range
from tvb.basic.profile import TvbProfile
from tvb.basic.logger.builder import get_logger
from tvb.core import utils
from tvb.core.adapters import constants
from tvb.core.adapters.abcadapter import ABCAdapter, ABCSynchronous
from tvb.core.adapters.exceptions import LaunchException
......@@ -111,7 +110,7 @@ class OperationService:
self.logger.warning("Inconsistent Adapter Class:" + str(adapter_instance.__class__))
raise LaunchException("Developer Exception!!")
### Store Operation entity.
# Store Operation entity.
algo = adapter_instance.stored_adapter
algo_category = dao.get_category_by_id(algo.fk_category)
......
......@@ -460,31 +460,34 @@ class FlowController(BaseController):
view_model = form.get_view_model()()
form.fill_trait(view_model)
except NotImplementedError:
raise formencode.Invalid("Could not find a model for this form!", {}, None, error_dict=form.get_errors_dict())
raise formencode.Invalid("Could not find a model for this form!", {}, None,
error_dict=form.get_errors_dict())
else:
raise formencode.Invalid("Could not fill algorithm from the given inputs!", {}, None,
error_dict=form.get_errors_dict())
adapter_instance.submit_form(form)
if issubclass(type(adapter_instance), ABCDisplayer):
adapter_instance.current_project_id = project_id
adapter_instance.user_id = common.get_logged_user().id
result = adapter_instance.launch(view_model)
if isinstance(result, dict):
return result
result = self.flow_service.fire_operation(adapter_instance, common.get_logged_user(), project_id, view_model=view_model)
else:
common.set_error_message("Invalid result returned from Displayer! Dictionary is expected!")
return {}
result = self.flow_service.fire_operation(adapter_instance, common.get_logged_user(),
project_id, view_model=view_model)
# Store input data in session, for informing user of it.
step = self.flow_service.get_category_by_id(step_key)
if not step.rawinput:
self.context.add_adapter_to_session(None, None, copy.deepcopy(data))
if isinstance(result, list):
result = "Launched %s operations." % len(result)
common.set_important_message(str(result))
if isinstance(adapter_instance, ABCDisplayer):
if isinstance(result, dict):
result[common.KEY_OPERATION_ID] = adapter_instance.operation_id
return result
else:
common.set_error_message("Invalid result returned from Displayer! Dictionary is expected!")
else:
if isinstance(result, list):
result = "Launched %s operations." % len(result)
common.set_important_message(str(result))
except formencode.Invalid as excep:
errors = excep.unpack_errors()
common.set_error_message("Invalid form inputs")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment