def _get_property(self, resource, prop): url = resource.iri url = url + ('' if url.endswith('/') else '/') projection_url = u'{url}projection/{prop}/offset-limit/1&200'.format( url=url, prop=prop) resource = ResourceManager.load(projection_url) return resource.as_json()
def load_resources_from_model(self): model = Config.get('memo_urls') if not model: return for name, iri in model.items(): resource = ResourceManager.load(iri, name) self.load_resource(resource)
def _load_layer_from_iri(self, widget, name, iri): try: dummy = ResourceManager.load(iri, name) self._load_layer_on_qgis(dummy) widget.close() except Exception as e: raise
def open_operations_editor(self, name, url): resource = ResourceManager.load(url, name) dialog_construct_url = DialogConstructUrl(resource) dialog_construct_url.load_url_command.connect(lambda n, i: self._load_layer_from_iri(dialog_construct_url, n, i)) dialog_construct_url.exec_() return dialog_construct_url
def _load_empty_expects_frame(self, item): url = self.resource.iri url = url + ('' if url.endswith('/') else '/') url = url + item.text() resource = ResourceManager.load(url) widget = FrameEmptyExpects(resource) self._insert_in_operations_layout(widget)
def open_context_menu(self, position): item = self.list_resource.itemAt(position) if not item: return resource = ResourceManager.load(item.url(), item.name()) is_leaf_node = item.childCount() == 0 if is_leaf_node: self.show_context_menu(item, resource, position) else: self.show_entry_point_menu(item, resource, position)
def _append_entry_point(self, resource, entry_point_elements, parent_item=None): create_item = ComponentFactory.create_list_resource_element parent_item = parent_item or create_item(resource) parent_item.set_icon_entry_point() for name, url in entry_point_elements.items(): new_res = ResourceManager.load(url, name) item = create_item(new_res) self._append(item, parent_item) self._append(parent_item) return parent_item
def request_sample(self, lower, upper): url = self.resource.iri url = url + ('' if url.endswith('/') else '/') if self.resource.at_type() in [ FEATURE_COLLECTION_TYPE_VOCAB, COLLECTION_TYPE_VOCAB ]: projection_url = u'{url}projection/{prop}/offset-limit/{lower}&{upper}'\ .format(url=url, prop=self._property, lower=lower, upper=upper) else: # It not a Collection so offset-limit will not work projection_url = u'{url}projection/{prop}'.format( url=url, prop=self._property) resource = ResourceManager.load(projection_url) return resource.as_json()
def _itemDoubleClicked_event(self, item): iri = item.text(1) item_has_children = item.childCount() > 0 if item_has_children: return resource = ResourceManager.load(iri) if resource.error: MessageBox.critical(u'Link está indisponível ou fora do ar.\n {}'.format(resource.iri), u'Link indisponível') return # Verifica se é um entrypoint com layers ainda não carregadas if resource.is_entry_point(): item.set_icon_entry_point() self.add(resource, item) self.branch_resource_double_clicked.emit(item) return self.leaf_resource_double_clicked.emit(item)
def add_resource(self, name, url): resource = ResourceManager.load(url, name) self.load_resource(resource) Config.set('memo_urls', {name: url})