// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Product.java
// @NodeEntity
// public class Product {
// 
// 	@GraphId
// 	private Long id;
// 
// 	@Override
// 	public String toString() {
// 		return "Product{" + "id=" + id + ", productId='" + productId + '\'' + ", name='" + name + '\'' + '}';
// 	}
// 
// 	@Indexed(unique = true)
// 	private String productId;
// 	private String name;
// 
// 	public Long getId() {
// 		return id;
// 	}
// 
// 	public void setId(Long id) {
// 		this.id = id;
// 	}
// 
// 	public String getProductId() {
// 		return productId;
// 	}
// 
// 	public void setProductId(String productId) {
// 		this.productId = productId;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// }


import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.repository.query.Param;
import com.idugalic.recommendations.model.Product;
package com.idugalic.recommendations.repositories;



public interface ProductRepository extends GraphRepository<Product> {
	@Query("MATCH (product:Product) WHERE product.productId = {productId} RETURN product")
	Product findByProductId(@Param("productId") String productId);

	@Query("MATCH (p:Person) WHERE p.userName = {userName} MATCH p-[:LIKES]->product<-[:LIKES]-slm-[:LIKES]->recommendations "
			+ "WHERE not(p = slm) and not (p--recommendations) return recommendations")
	Iterable<Product> recommendedProductsFor(@Param("userName") String userName);

	@Query("MATCH (product:Product) WHERE product.productId = {productId} MATCH product<-[:LIKES]-slm-[:LIKES]->recommendations "
			+ "RETURN distinct recommendations")
// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/model/Product.java
// @NodeEntity
// public class Product {
// 
// 	@GraphId
// 	private Long id;
// 
// 	@Override
// 	public String toString() {
// 		return "Product{" + "id=" + id + ", productId='" + productId + '\'' + ", name='" + name + '\'' + '}';
// 	}
// 
// 	@Indexed(unique = true)
// 	private String productId;
// 	private String name;
// 
// 	public Long getId() {
// 		return id;
// 	}
// 
// 	public void setId(Long id) {
// 		this.id = id;
// 	}
// 
// 	public String getProductId() {
// 		return productId;
// 	}
// 
// 	public void setProductId(String productId) {
// 		this.productId = productId;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 
// }


// Path: microservices-recommendations/src/main/java/com/idugalic/recommendations/repositories/ProductRepository.java
import org.springframework.data.neo4j.annotation.Query;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.repository.query.Param;
import com.idugalic.recommendations.model.Product;

package com.idugalic.recommendations.repositories;



public interface ProductRepository extends GraphRepository<Product> {
	@Query("MATCH (product:Product) WHERE product.productId = {productId} RETURN product")
	Product findByProductId(@Param("productId") String productId);

	@Query("MATCH (p:Person) WHERE p.userName = {userName} MATCH p-[:LIKES]->product<-[:LIKES]-slm-[:LIKES]->recommendations "
			+ "WHERE not(p = slm) and not (p--recommendations) return recommendations")
	Iterable<Product> recommendedProductsFor(@Param("userName") String userName);

	@Query("MATCH (product:Product) WHERE product.productId = {productId} MATCH product<-[:LIKES]-slm-[:LIKES]->recommendations "
			+ "RETURN distinct recommendations")
	Iterable<Product> productsLikedByPeopleWhoLiked(@Param("productId") String productId);