def get_filtered_datatypes(self, dt_module, dt_class, filters, has_all_option, has_none_option): """ Given the name from the input tree, the dataType required and a number of filters, return the available dataType that satisfy the conditions imposed. """ index_class = getattr(sys.modules[dt_module], dt_class)() filters_dict = json.loads(filters) for idx in range(len(filters_dict['fields'])): if filters_dict['values'][idx] in ['True', 'False']: filters_dict['values'][idx] = string2bool( filters_dict['values'][idx]) filter = FilterChain(fields=filters_dict['fields'], operations=filters_dict['operations'], values=filters_dict['values']) project = common.get_current_project() data_type_gid_attr = DataTypeGidAttr( linked_datatype=REGISTRY.get_datatype_for_index(index_class)) data_type_gid_attr.required = not string2bool(has_none_option) select_field = TraitDataTypeSelectField( data_type_gid_attr, conditions=filter, has_all_option=string2bool(has_all_option)) self.algorithm_service.fill_selectfield_with_datatypes( select_field, project.id) return {'options': select_field.options()}
def get_operation_details(self, entity_gid, is_group=False, back_page='burst'): """ Returns the HTML which contains the details for the given operation. """ if string2bool(str(is_group)): # we have an OperationGroup entity. template_specification = self._compute_operation_details( entity_gid, True) # I expect that all the operations from a group are visible or not template_specification["nodeType"] = self.NODE_OPERATION_GROUP_TYPE else: # we have a simple Operation template_specification = self._compute_operation_details( entity_gid) template_specification["displayRelevantButton"] = True template_specification["nodeType"] = self.NODE_OPERATION_TYPE template_specification["backPageIdentifier"] = back_page overlay_class = "can-browse editor-node node-type-" + template_specification[ "nodeType"] if template_specification["isRelevant"]: overlay_class += " node-relevant" else: overlay_class += " node_irrelevant" template_specification = self.fill_overlay_attributes( template_specification, "Details", "Operation", "project/details_operation_overlay", overlay_class) return self.flow_controller.fill_default_attributes( template_specification)
def test_switch_online_help(self): """ Test the switch_online_help method and make sure it adds corresponding entry to UserPreferences. """ self._expect_redirect('/user/profile', self.user_c.switch_online_help) assert not string2bool(self.test_user.preferences[UserPreferences.ONLINE_HELP_ACTIVE]), \ "Online help should be switched to False."
def removelink(self, link_data, project_id, is_group): """ Delegate the creation of the actual link to the flow service. """ if not string2bool(str(is_group)): self.algorithm_service.remove_link(link_data, project_id) else: all_data = self.project_service.get_datatype_in_group(link_data) for data in all_data: self.algorithm_service.remove_link(data.id, project_id) self.algorithm_service.remove_link(int(link_data), project_id)
def createlink(self, link_data, project_id, is_group): """ Delegate the creation of the actual link to the flow service. """ if not string2bool(str(is_group)): self.algorithm_service.create_link([link_data], project_id) else: all_data = self.project_service.get_datatype_in_group(link_data) # Link all Dts in group and the DT_Group entity data_ids = [data.id for data in all_data] data_ids.append(int(link_data)) self.algorithm_service.create_link(data_ids, project_id)
def get_simple_adapter_interface(self, algorithm_id, parent_div='', is_uploader=False): """ AJAX exposed method. Will return only the interface for a adapter, to be used when tabs are needed. """ curent_project = common.get_current_project() is_uploader = string2bool(is_uploader) template_specification = self.get_adapter_template( curent_project.id, algorithm_id, is_uploader) template_specification[common.KEY_PARENT_DIV] = parent_div return self.fill_default_attributes(template_specification)
def set_visibility(self, entity_type, entity_gid, to_de_relevant): """ Method used for setting the relevancy/visibility on a DataType(Group)/Operation(Group. """ to_de_relevant = string2bool(to_de_relevant) is_operation, is_group = False, False if entity_type == self.NODE_OPERATION_TYPE: is_group = False is_operation = True elif entity_type == self.NODE_OPERATION_GROUP_TYPE: is_group = True is_operation = True if is_operation: self.project_service.set_operation_and_group_visibility(entity_gid, to_de_relevant, is_group) else: self.project_service.set_datatype_visibility(entity_gid, to_de_relevant)
def _deserialize_value(self, value): """ This method takes value loaded from H5 file and transform it to TVB data. """ if value is not None: if isinstance(value, numpy.string_): if len(value) == 0: value = None else: value = str(value) if isinstance(value, str): if value.startswith(self.BOOL_VALUE_PREFIX): # Remove bool prefix and transform to bool return utils.string2bool( value[len(self.BOOL_VALUE_PREFIX):]) if value.startswith(self.DATETIME_VALUE_PREFIX): # Remove datetime prefix and transform to datetime return utils.string2date( value[len(self.DATETIME_VALUE_PREFIX):], date_format=self.DATE_TIME_FORMAT) return value