Ejemplo n.º 1
0
 def new_portlet_configuration(portlet_id,
                               tab_nr=-1,
                               index_in_tab=-1,
                               portlet_name='Default'):
     """
     Return a new portlet configuration entitiy with default parameters.
     
     :param portlet_id: the id of the portlet for which a configuration will
         be stored
     :param tab_nr: the index of the currently selected tab
     :param index_in_tab: the index from the currently selected tab
     
     """
     portlet_entity = dao.get_portlet_by_id(portlet_id)
     if portlet_entity is None:
         raise InvalidPortletConfiguration(
             "No portlet entity located in database with id=%s." %
             portlet_id)
     portlet_configurer = PortletConfigurer(portlet_entity)
     configuration = portlet_configurer.create_new_portlet_configuration(
         portlet_name)
     for wf_step in configuration.analyzers:
         wf_step.tab_index = tab_nr
         wf_step.index_in_tab = index_in_tab
     configuration.visualizer.tab_index = tab_nr
     configuration.visualizer.index_in_tab = index_in_tab
     return configuration
Ejemplo n.º 2
0
 def update_portlet_configuration(portlet_configuration, submited_parameters):
     """
     :param portlet_configuration: the portlet configuration that needs to be updated
     :param submited_parameters: a list of parameters as submitted from the UI. This 
         is a dictionary in the form : 
         {'dynamic' : {name:value pairs}, 'static' : {name:value pairs}}
         
     All names are prefixed with adapter specific generated prefix.
     """
     portlet_entity = dao.get_portlet_by_id(portlet_configuration.portlet_id)
     portlet_configurer = PortletConfigurer(portlet_entity)
     return portlet_configurer.update_portlet_configuration(portlet_configuration, submited_parameters)
Ejemplo n.º 3
0
    def _get_portlet_configurer(self, portlet_id):

        if portlet_id not in self.cache_portlet_configurators:

            portlet_entity = dao.get_portlet_by_id(portlet_id)
            if portlet_entity is None:
                raise InvalidPortletConfiguration("No portlet entity located in database with id=%s. " % portlet_id)

            self.cache_portlet_configurators[portlet_id] = PortletConfigurer(portlet_entity)
            self.logger.debug("Recently parsed portlet XML:" + str([portlet_entity]))

        return self.cache_portlet_configurators[portlet_id]
Ejemplo n.º 4
0
 def update_portlet_configuration(portlet_configuration,
                                  submited_parameters):
     """
     :param portlet_configuration: the portlet configuration that needs to be updated
     :param submited_parameters: a list of parameters as submitted from the UI. This 
         is a dictionary in the form : 
         {'dynamic' : {name:value pairs}, 'static' : {name:value pairs}}
         
     All names are prefixed with adapter specific generated prefix.
     """
     portlet_entity = dao.get_portlet_by_id(
         portlet_configuration.portlet_id)
     portlet_configurer = PortletConfigurer(portlet_entity)
     return portlet_configurer.update_portlet_configuration(
         portlet_configuration, submited_parameters)
Ejemplo n.º 5
0
    def build_portlet_interface(self, portlet_configuration, project_id):
        """
        From a portlet_id and a project_id, first build the portlet
        entity then get it's configurable interface. 
        
        :param portlet_configuration: a portlet configuration entity. It holds at the
            least the portlet_id, and in case any default parameters were saved
            they can be rebuilt from the analyzers // visualizer parameters
        :param project_id: the id of the current project   
            
        :returns: the portlet interface will be of the following form::
            [{'interface': adapter_interface, 
            'prefix': prefix_for_parameter_names, 
            'subalg': {algorithm_field_name: default_algorithm_value},
            'algo_group': algorithm_group,
            'alg_ui_name': displayname},
            ......]
            A list of dictionaries for each adapter that makes up the portlet.
            
        """
        portlet_entity = dao.get_portlet_by_id(
            portlet_configuration.portlet_id)
        if portlet_entity is None:
            raise InvalidPortletConfiguration(
                "No portlet entity located in database with id=%s. "
                "Portlet configuration %s is not valid." %
                (portlet_configuration.portlet_id, portlet_configuration))
        portlet_configurer = PortletConfigurer(portlet_entity)
        portlet_interface = portlet_configurer.get_configurable_interface()
        self.logger.debug("Created interface for portlet " +
                          str([portlet_entity]))

        for adapter_conf in portlet_interface:
            interface = adapter_conf.interface
            interface = FlowService().prepare_parameters(
                interface, project_id, adapter_conf.group.fk_category)
            interface = ABCAdapter.prepare_param_names(interface,
                                                       adapter_conf.prefix)
            adapter_conf.interface = interface

        portlet_configurer.update_default_values(portlet_interface,
                                                 portlet_configuration)
        portlet_configurer.prefix_adapters_parameters(portlet_interface)

        return portlet_interface
Ejemplo n.º 6
0
 def new_portlet_configuration(portlet_id, tab_nr=-1, index_in_tab=-1, portlet_name='Default'):
     """
     Return a new portlet configuration entity with default parameters.
     
     :param portlet_id: the id of the portlet for which a configuration will be stored
     :param tab_nr: the index of the currently selected tab
     :param index_in_tab: the index from the currently selected tab
     """
     portlet_entity = dao.get_portlet_by_id(portlet_id)
     if portlet_entity is None:
         raise InvalidPortletConfiguration("No portlet entity located in database with id=%s." % portlet_id)
     portlet_configurer = PortletConfigurer(portlet_entity)
     configuration = portlet_configurer.create_new_portlet_configuration(portlet_name)
     for wf_step in configuration.analyzers:
         wf_step.tab_index = tab_nr
         wf_step.index_in_tab = index_in_tab
     configuration.visualizer.tab_index = tab_nr
     configuration.visualizer.index_in_tab = index_in_tab
     return configuration 
Ejemplo n.º 7
0
    def build_portlet_interface(self, portlet_configuration, project_id):
        """
        From a portlet_id and a project_id, first build the portlet
        entity then get it's configurable interface. 
        
        :param portlet_configuration: a portlet configuration entity. It holds at the
            least the portlet_id, and in case any default parameters were saved
            they can be rebuilt from the analyzers // visualizer parameters
        :param project_id: the id of the current project   
            
        :returns: the portlet interface will be of the following form::
            [{'interface': adapter_interface, 
            'prefix': prefix_for_parameter_names, 
            'subalg': {algorithm_field_name: default_algorithm_value},
            'algo_group': algorithm_group,
            'alg_ui_name': displayname},
            ......]
            A list of dictionaries for each adapter that makes up the portlet.
            
        """
        portlet_entity = dao.get_portlet_by_id(portlet_configuration.portlet_id)
        if portlet_entity is None:
            raise InvalidPortletConfiguration(
                "No portlet entity located in database with id=%s. "
                "Portlet configuration %s is not valid." % (portlet_configuration.portlet_id, portlet_configuration)
            )
        portlet_configurer = PortletConfigurer(portlet_entity)
        portlet_interface = portlet_configurer.get_configurable_interface()
        self.logger.debug("Created interface for portlet " + str([portlet_entity]))

        for adapter_conf in portlet_interface:
            interface = adapter_conf.interface
            interface = FlowService().prepare_parameters(interface, project_id, adapter_conf.group.fk_category)
            interface = ABCAdapter.prepare_param_names(interface, adapter_conf.prefix)
            adapter_conf.interface = interface

        portlet_configurer.update_default_values(portlet_interface, portlet_configuration)
        portlet_configurer.prefix_adapters_parameters(portlet_interface)

        return portlet_interface
Ejemplo n.º 8
0
    def _build_workflow_step_info(workflow):
        """
        For the input workflow, get all workflow steps and return a list with information
        that can be then exported.
        """
        wf_steps = []
        view_steps = []
        for wf_step in dao.get_workflow_steps(workflow.id):

            if wf_step.fk_operation is None or wf_step.fk_algorithm is None:
                # Avoid exporting old form of View Steps.
                LOG.warning("Skipping " + str(workflow) + " " + str(wf_step))
                continue
            # Get all basic information for this workflow step
            wf_step_info = WorkflowStepInformation(wf_step.to_dict()[1])
            # We need to store the gid for the operation since the id might be
            # different in case of a project export / import
            linked_operation = dao.get_operation_by_id(wf_step.fk_operation)
            wf_step_info.set_operation(linked_operation)
            # We also need to keep info about algorithm in the form of module
            # and classname because that id might also be different in case
            # of project export / import.
            linked_algorithm = dao.get_algorithm_by_id(wf_step.fk_algorithm)
            wf_step_info.set_algorithm(linked_algorithm)
            wf_steps.append(wf_step_info)
        for view_step in dao.get_visualization_steps(workflow.id):
            # Get all basic information for this view step
            view_step_info = WorkflowViewStepInformation(
                view_step.to_dict()[1])
            # We need to store portlet identifier, since portlet id might be different
            # in project we are importing into.
            portlet = dao.get_portlet_by_id(view_step.fk_portlet)
            view_step_info.set_portlet(portlet)
            # We also need to keep info about algorithm in the form of module
            # and classname because that id might also be different in case
            # of project export / import.
            linked_algorithm = dao.get_algorithm_by_id(view_step.fk_algorithm)
            view_step_info.set_algorithm(linked_algorithm)
            view_steps.append(view_step_info)
        return wf_steps, view_steps
    def _build_workflow_step_info(workflow):
        """
        For the input workflow, get all workflow steps and return a list with information
        that can be then exported.
        """
        wf_steps = []
        view_steps = []
        for wf_step in dao.get_workflow_steps(workflow.id):

            if wf_step.fk_operation is None or wf_step.fk_algorithm is None:
                # Avoid exporting old form of View Steps.
                LOG.warning("Skipping " + str(workflow) + " " + str(wf_step))
                continue
            # Get all basic information for this workflow step
            wf_step_info = WorkflowStepInformation(wf_step.to_dict()[1])
            # We need to store the gid for the operation since the id might be
            # different in case of a project export / import
            linked_operation = dao.get_operation_by_id(wf_step.fk_operation)
            wf_step_info.set_operation(linked_operation)
            # We also need to keep info about algorithm in the form of module
            # and classname because that id might also be different in case
            # of project export / import.
            linked_algorithm = dao.get_algorithm_by_id(wf_step.fk_algorithm)
            wf_step_info.set_algorithm(linked_algorithm)
            wf_steps.append(wf_step_info)
        for view_step in dao.get_visualization_steps(workflow.id):
            # Get all basic information for this view step
            view_step_info = WorkflowViewStepInformation(view_step.to_dict()[1])
            # We need to store portlet identifier, since portlet id might be different
            # in project we are importing into.
            portlet = dao.get_portlet_by_id(view_step.fk_portlet)
            view_step_info.set_portlet(portlet)
            # We also need to keep info about algorithm in the form of module
            # and classname because that id might also be different in case
            # of project export / import.
            linked_algorithm = dao.get_algorithm_by_id(view_step.fk_algorithm)
            view_step_info.set_algorithm(linked_algorithm)
            view_steps.append(view_step_info)
        return wf_steps, view_steps
Ejemplo n.º 10
0
 def get_portlet_by_id(portlet_id):
     """
     :returns: the portlet entity with the id =@portlet_id
     """
     return dao.get_portlet_by_id(portlet_id)
Ejemplo n.º 11
0
 def get_portlet_by_id(portlet_id):
     """
     :returns: the portlet entity with the id =@portlet_id
     """
     return dao.get_portlet_by_id(portlet_id)