// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
// 
// 	/**
// 	 * Create or update relationship between parent and child node
// 	 * @param parent
// 	 * @param child
// 	 * @param context
// 	 * @return
// 	 */
// 	Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
// 	
// 	/**
// 	 * Remove all relationships regarding document context
// 	 * @param context
// 	 * @return the 'orphan' nodes
// 	 */
// 	Set<Node> deleteRelations(DocumentRelationContext context);
// 
// 	void setDb(GraphDatabaseService db);
// 
// 	void setLog(Log log);
// }
// 
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
// 
// 	private String documentKey;
// 
// 	/**
// 	 * @return the documentKey
// 	 */
// 	public String getDocumentKey() {
// 		return documentKey;
// 	}
// 
// 	/**
// 	 * @param documentKey
// 	 *            the documentKey to set
// 	 */
// 	public void setDocumentKey(String documentKey) {
// 		this.documentKey = documentKey;
// 	}
// 
// }


import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Result;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.Log;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.StringUtils;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
/**
 * Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
 * <p>
 * This file is part of the "LARUS Integration Framework for Neo4j".
 * <p>
 * The "LARUS Integration Framework for Neo4j" is licensed
 * under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.neo4j.helpers.json.document.impl;



/**
 * Build relationship using document key as label
 * @author Omar Rampado
 *
 */
public class DocumentRelationBuilderByKey implements DocumentRelationBuilder {
	
	private GraphDatabaseService db;
	
	private Log log;
	
	/**
	 * @param db the db to set
	 */
	public void setDb(GraphDatabaseService db) {
		this.db = db;
	}
	
	/**
	 * @param log the log to set
	 */
	public void setLog(Log log) {
		this.log = log;
	}

	/* (non-Javadoc)
	 * @see org.neo4j.helpers.json.document.DocumentRelationBuilder#buildRelation(org.neo4j.graphdb.Node, org.neo4j.graphdb.Node, org.neo4j.helpers.json.document.DocumentRelationContext)
	 */
	@Override
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/DocumentRelationBuilder.java
// public interface DocumentRelationBuilder {
// 
// 	/**
// 	 * Create or update relationship between parent and child node
// 	 * @param parent
// 	 * @param child
// 	 * @param context
// 	 * @return
// 	 */
// 	Relationship buildRelation(Node parent, Node child, DocumentRelationContext context);
// 	
// 	/**
// 	 * Remove all relationships regarding document context
// 	 * @param context
// 	 * @return the 'orphan' nodes
// 	 */
// 	Set<Node> deleteRelations(DocumentRelationContext context);
// 
// 	void setDb(GraphDatabaseService db);
// 
// 	void setLog(Log log);
// }
// 
// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/context/DocumentRelationContext.java
// public class DocumentRelationContext {
// 
// 	private String documentKey;
// 
// 	/**
// 	 * @return the documentKey
// 	 */
// 	public String getDocumentKey() {
// 		return documentKey;
// 	}
// 
// 	/**
// 	 * @param documentKey
// 	 *            the documentKey to set
// 	 */
// 	public void setDocumentKey(String documentKey) {
// 		this.documentKey = documentKey;
// 	}
// 
// }


// Path: neo4j-json/src/main/java/org/neo4j/helpers/json/document/impl/DocumentRelationBuilderByKey.java
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Result;
import org.neo4j.helpers.json.document.DocumentRelationBuilder;
import org.neo4j.helpers.json.document.context.DocumentRelationContext;
import org.neo4j.logging.Log;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.lang3.StringUtils;
import org.neo4j.graphdb.Direction;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;

/**
 * Copyright (c) 2017 LARUS Business Automation [http://www.larus-ba.it]
 * <p>
 * This file is part of the "LARUS Integration Framework for Neo4j".
 * <p>
 * The "LARUS Integration Framework for Neo4j" is licensed
 * under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.neo4j.helpers.json.document.impl;



/**
 * Build relationship using document key as label
 * @author Omar Rampado
 *
 */
public class DocumentRelationBuilderByKey implements DocumentRelationBuilder {
	
	private GraphDatabaseService db;
	
	private Log log;
	
	/**
	 * @param db the db to set
	 */
	public void setDb(GraphDatabaseService db) {
		this.db = db;
	}
	
	/**
	 * @param log the log to set
	 */
	public void setLog(Log log) {
		this.log = log;
	}

	/* (non-Javadoc)
	 * @see org.neo4j.helpers.json.document.DocumentRelationBuilder#buildRelation(org.neo4j.graphdb.Node, org.neo4j.graphdb.Node, org.neo4j.helpers.json.document.DocumentRelationContext)
	 */
	@Override
	public Relationship buildRelation(Node parent, Node child, DocumentRelationContext context) {