def attach(executor: Callable[[PostAgggregatePointsEntity], Any], dataset_and_fields: Iterable[DatasetAndFields], to_attach: NamedObjects): point_datasets = [ resource for resource in dataset_and_fields if is_point(resource) ] region_dataset_names = [ get_name(resource) for resource in dataset_and_fields if is_region(resource) ] for dataset in point_datasets: name = get_name(dataset) options = None if hasattr(to_attach, name): options = to_attach[name] else: options = NamedObjects() to_attach[name] = options field_names = [ field.fieldInfo.name for field in dataset.fields if not field.fieldInfo.isSystemField and field.fieldInfo.name.lower() != 'smuserid' and field.fieldInfo.type in (FieldType.INT16, FieldType.INT32, FieldType.INT64, FieldType.SINGLE, FieldType.DOUBLE) ] options.prepare_summary_region_aggregate = lambda: SummaryRegion( name, field_names, region_dataset_names, executor) options.prepare_summary_mesh_aggregate = lambda: SummaryMesh( name, field_names, executor)
def _init_field_options(self, field_names: Iterable[str]): self._field_options = NamedObjects() modes = ['max', 'min', 'average', 'sum', 'variance'] for name in field_names: statistic_mode_options = NamedObjects() for mode_name in modes: statistic_mode_options['statistic_with_' + mode_name] = Option( partial(self._add_statistic_field, name, mode_name)) statistic_mode_options['statistic_with_std_deviation'] = Option( partial(self._add_statistic_field, name, 'stdDeviation')) self._field_options[name] = statistic_mode_options
def use_file_workspace(self): self._clear_workspace_info() workspace = NamedObjects() workspace['set_path'] = partial(self._add_workspace_info, 'path') setattr(self, 'workspace', workspace) self._attach_file_explorer(workspace) return self
def services(self): servicelist = self._services_page.list_services() # type: List[ServiceMetaInfo] result = NamedObjects() for meta_info in servicelist: ui = ui_class_register.new_service_ui_from_meta_info(meta_info, self._apifactory) if ui is not None: result[meta_info.name] = ui return result
def _init_servicetype(self, servicestypes: List[ServiceType]): for type in servicestypes: type_name_objects = NamedObjects() type_name_objects["select"] = partial(self._service_type_select, type) type_name_objects["remove"] = partial(self._service_type_remove, type) self._service_types_options[type.value] = type_name_objects
def __init__(self, post_workspace: Callable, mng: Management): self._post_entity = PostWorkspaceParameter() self._post_entity.servicesTypes = [] self._service_types_options = NamedObjects() self._init_servicetype([ServiceType.RESTMAP, ServiceType.RESTDATA]) self._executor = post_workspace self._workspace_info = {} self._mng = mng
def use_file_workspace_with_password(self): self._clear_workspace_info() file_workspace = NamedObjects() file_workspace['set_path'] = partial(self._add_workspace_info_kv, 'server') file_workspace['set_password'] = partial(self._add_workspace_info_kv, 'password') self._attach_file_explorer(file_workspace) setattr(self, 'workspace', file_workspace) return self
def available_mesh_sieze_units(self): result = NamedObjects() for unit in [ DistanceUnit.Meter, DistanceUnit.Kilometer, DistanceUnit.Yard, DistanceUnit.Foot, DistanceUnit.Mile ]: result[unit.name] = Option( partial(self._mesh_size_unit_selected, unit), 'select') return result
def __call__(self, param: PostWorkspaceParameter): post_result = self._management.post_workspaces(param) # type:List[PostWorkspaceResultItem] result = NamedObjects() for item in post_result: service_addr = item.serviceAddress service_name = service_addr[ service_addr.rfind('/services/') + len('/services/'):] result[service_name] = ui_class_register.new_service_ui_from_service_type(service_name=service_name, service_type=item.serviceType, api_factory=self._api_factory) return result
def use_oracle_workspace(self): self._clear_workspace_info() workspace = NamedObjects() self._add_workspace_info_kv('type', 'ORACLE') workspace['set_server_name'] = partial(self._add_workspace_info_kv, 'server') workspace['set_workspace_name'] = partial(self._add_workspace_info_kv, 'name') workspace['set_database_name'] = partial(self._add_workspace_info_kv, 'database') workspace['set_username'] = partial(self._add_workspace_info_kv, 'username') workspace['set_password'] = partial(self._add_workspace_info_kv, 'password') setattr(self, 'workspace', workspace) return self
def test_NamedObjects(self): named = NamedObjects() named['a'] = object() named['b'] = object() original_a = named.a self.assertIs(named[0], named.a) self.assertIs(named[1], named.b) named['a'] = object() self.assertIsNot(original_a, named.a) self.assertIs(named[0], named.a)
def get_datas( datacatalog: Datacatalog, attach_list: List[Callable[[Iterable[DatasetAndFields], NamedObjects], None]] ) -> NamedObjects: result = NamedObjects() sharefile_contents = datacatalog.get_sharefile() #type:DatasetsContent relationship_contents = datacatalog.get_relationship_datasets( ) #type:DatasetsContent dataset_and_fields_list = [] #type:List[DatasetAndFields] for name in sharefile_contents.datasetNames: dataset_and_fields_list.append( _get_dataset(datacatalog.get_sharefile_dataset, datacatalog.get_sharefile_dataset_fields, datacatalog.get_sharefile_dataset_field, name)) for name in relationship_contents.datasetNames: dataset_and_fields_list.append( _get_dataset(datacatalog.get_relationship_dataset, datacatalog.get_relationship_dataset_fields, datacatalog.get_relationship_dataset_field, name)) for attach in attach_list: attach(dataset_and_fields_list, result) return result
def _init_region_dataset_options(self, region_dataset_names: List[str]): self._region_dataset_options = NamedObjects() for name in region_dataset_names: self._region_dataset_options[name] = Option( partial(self._dataset_selected, name), 'select')