这就是我最终做到的:
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参数由this返回的地方:
match (t:Translation) return id(t)
我使用请求的每个迭代器调用 getTradParameters(),然后我有一个容器,其中包含我节点的所有参数的名称。
最后一部分是调用这个函数:
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 将其显示在表中。