Пример #1
0
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)
Пример #2
0
 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
Пример #3
0
 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
Пример #4
0
 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
Пример #5
0
 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
Пример #6
0
 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
Пример #7
0
 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
Пример #8
0
 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
Пример #9
0
 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
Пример #10
0
 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
Пример #11
0
    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)
Пример #12
0
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
Пример #13
0
 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')