在使用ID匹配节点之后创建节点和关系

时间:2017-04-29 05:15:00

标签: neo4j cypher

我有3种类型的节点 - 挑战,进入和用户,以及这些节点之间的2种关系:(条目) - [POSTED_BY] - >(用户)和(条目) - [PART_OF] - >(挑战)

以下是我想要完成的事情: - 我有一个现有的挑战,我可以通过它的ID识别它(内部neo4j id) - 我也有一个现有用户,我可以通过它的id识别它(与neo4j内部id不同) - 鉴于现有的挑战和用户,我需要创建一个新的Entry节点,并将其与具有PART_OF关系的Challenge节点链接。
- 此外,我需要通过POSTED_BY关系将新条目与用户节点链接 - 如果可能的话,我想在单个Cypher查询语句中实现上述目的

这就是我正在尝试的:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form method="post" enctype="multipart/form-data" class="form-horizontal">
  <div class="form-group" style="margin-left:0px;">
    <label for="headPortraitFile">注:选择头像文件尽量小于2M</label>
    <input id="headPortraitFile" type="file" name="portrait">
  </div>
  <button id="headPortraitSubmit" type="submit" class="btn-sm btn-primary">上传头像</button>
</form>

然而,这是失败的,因为我似乎无法使用上述语法匹配两个节点。但是,如果我将挑战与非内部属性匹配,比如名称,它似乎有效:

    // Tag used to cancel the request
    String  tag_string_req = "string_req";

    //String url = "URL......";



    final ProgressDialog pDialog = new ProgressDialog(this);
    pDialog.setMessage("Loading...");
    pDialog.show();

    StringRequest strReq = new StringRequest(Request.Method.POST,
            url, new Response.Listener<String>() {

        @Override
        public void onResponse(String response) {
            Log.d(TAG, response.toString());
            pDialog.hide();

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d(TAG, "Error: " + error.getMessage());
            pDialog.hide();
        }
    }){

        @Override
        public String getBodyContentType() {
            return "application/xml; charset=" +
                    getParamsEncoding();
        }

        @Override
        public byte[] getBody() throws AuthFailureError {
            String postData = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                    "<sampletag>\n" +
                    "\t<sampletag>data</sampletag>\n" +
                    "</sampletag>"; // TODO get your final output
            try {
                return postData == null ? null :
                        postData.getBytes(getParamsEncoding());
            } catch (UnsupportedEncodingException uee) {
                // TODO consider if some other action should be taken
                return null;
            }
        }
        };

但是,正如我上面提到的,我想匹配挑战的neo4j内部节点ID,并且我不确定是否有其他方法可以匹配除{{1}之外的其他节点ID条款。

1 个答案:

答案 0 :(得分:1)

您的语法几乎是正确的,但您不需要WHERE和下一个MATCH之间的逗号。

if(getActivity()!=null){    
  ((MainActivity) getActivity()).openGallery(); 
}
相关问题