如何使用Cypher返回节点的所有属性及其名称和值 [英] How to return all properties of a node with their name and their value using Cypher

查看:611
本文介绍了如何使用Cypher返回节点的所有属性及其名称和值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里看到:我如何才能返回一个使用Cypher的节点的所有属性?有人早在1年前就已经问过这个问题.

I saw here : How can I return all properties for a node using Cypher? that somebody already asked this question, but 1 year ago.

所以我现在要问:今天有没有办法使用密码返回节点的所有属性?我需要在以前的开发人员将其创建为每种语言1个节点的翻译系统中进行操作,该翻译系统包含所有属性以及所需语言的名称.我需要为Java应用程序获取它.

So i need to ask it now : is there a way, today, to return all properties of a node using cypher? i need to do it for a translation system where previous developpers have created it as 1 node per language, with contains all of the properties with their name in the desired language. I need to get it for a Java application.

示例:

node FR contains: "Salut_01" : "Bonjour"
node UK contains: "Salut_01" : "Hello"

等...

推荐答案

这是我最终的做法:

private IndexedContainer getTradParameters(int id){
        IndexedContainer container = new IndexedContainer();
        container.addContainerProperty("name", String.class, null);
        try {
            Document doc = Jsoup.connect("http://10.0.0.1:7474/db/data/node/"+id+"/").get();
            Elements properties = doc.select("th");
            for(int index = 0; index < properties.size(); index++){
                String parameter = properties.get(index).text();
                Item item = container.addItem(index);
                item.getItemProperty("name").setValue(parameter);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }   
        return container;
    }

其中的id参数是通过以下方式返回的:

Where the id parameter is returned by this:

match (t:Translation) return id(t)

我在请求的每个迭代器中调用getTradParameters(),然后有一个容器,其中包含节点的所有参数的名称.

I call getTradParameters() with every iterator of my request and then i have a container with the name of all of the parameters of my node.

最后一部分正在调用此函数:

The Last part is calling this function :

private String getTradRequest(String pays){
        String request = "match (n:Translation{trad_country:\""+pays+"\"}) return id(n) as id";
        QueryResult <Map<String,Object>>result = engine.query(request, Collections.EMPTY_MAP);
        Iterator<Map<String, Object>> iterator=result.iterator();
        Map<String,Object> row = iterator.next();
        int id = Integer.valueOf(row.get("id").toString());
        try {
            Document doc = Jsoup.connect("http://10.0.0.1:7474/db/data/node/"+id+"/").get();
            Elements properties = doc.select("th");
            for(int index = 0; index < properties.size(); index++){
                String parameter = properties.get(index).text();
                request = request + ",n."+parameter;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return request;
    }

要创建我的大型Cypher请求以获取我在节点上所需的所有属性,然后只需要获取答案并将其存储在容器中,即可使用vaadin将其显示在表格中.

To create my big Cypher request to get all of the properties i need on my node, and then i just need to get the answers and store them in a container, to display it in a table using vaadin.

这篇关于如何使用Cypher返回节点的所有属性及其名称和值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆