コード例 #1
0
 /**
  * Returns the cypher representation of the chain of relationships,
  * <p>
  * Example:
  * <pre>
  * (n1:ENTITY {id: {n1}.id}) -[r0:type0 {property: {r0}.property}]-> (n2:EMBEDDED {property: {n2}.property}) -[r1:type1]-> (n3:EMBEDDED)
  * <pre>
  */
 public String toCypher() {
   StringBuilder builder = new StringBuilder();
   builder.append(start.toCypher());
   for (NextRelationship relationship : stream) {
     builder.append(" -[");
     if (!relationship.getProperties().isEmpty()) {
       builder.append(relationship.getAlias());
     }
     builder.append(":");
     builder.append(relationship.getRelationshipType());
     if (!relationship.getProperties().isEmpty()) {
       builder.append(" {");
       boolean first = true;
       for (String property : relationship.getProperties().keySet()) {
         if (first) {
           first = false;
         } else {
           builder.append(", ");
         }
         escapeIdentifier(builder, property);
         builder.append(": {");
         builder.append(relationship.getAlias());
         builder.append("}.");
         escapeIdentifier(builder, property);
       }
       builder.append(" }");
     }
     builder.append("]-> ");
     builder.append(relationship.getEnd().toCypher());
   }
   return builder.toString();
 }
コード例 #2
0
 /** Define a property on the last relationship of the chain. */
 public RelationshipsChainForGraphAssertions property(String name, Object value) {
   NextRelationship relationship = stream.get(stream.size() - 1);
   @SuppressWarnings("unchecked")
   Map<String, Object> properties = (Map<String, Object>) params.get(relationship.getAlias());
   if (properties == null) {
     params.put(relationship.getAlias(), relationship.getProperties());
   }
   relationship.addProperty(name, value);
   return this;
 }