@Query("MATCH (product:Product),\n" + "\t(product)<-[:PRODUCT_TYPE]-(inventory:Inventory)\n" + "WHERE product.productId in {productIds} AND NOT (inventory)<-[:CONTAINS_PRODUCT]-()\n" + "RETURN inventory") List<Inventory> getAvailableInventoryForProductList(@Param("productIds") String[] productIds); }
public String getQuery() { return queryAnnotation.value(); }
public String getCountQueryString() { return queryAnnotation != null ? queryAnnotation.countQuery() : null; }
/** * Created by david on 2014-09-17. */ @RelationshipEntity(type = "Mention") public class Mention { @GraphId Long id; @StartNode public Tweet tweet; @EndNode public Profile profile; }
/** * Created by david on 2014-11-06. */ @NodeEntity public class Profile { @GraphId Long id; @Indexed(unique=true) public String screenName; public Profile() { } public Profile(String screenName) { this.screenName = screenName; } }
/** * Definition of a Relationship which does not actually exist, or rather the * name of the RelationshipType does not exist in an existing Neo4j graph. */ @RelationshipEntity(type = "DODGY_REL_DEF") public class DodgyRelDef { @GraphId Long nodeId; }
private Integer getStaticQueryDepth(Method method) { if (method.isAnnotationPresent(Depth.class)) { return method.getAnnotation(Depth.class).value(); } return null; }
@Override public boolean matches(Method method, Class<?> targetClass) { UseBookmark classAnnotation = AnnotatedElementUtils.findMergedAnnotation(targetClass, UseBookmark.class); UseBookmark methodAnnotation = AnnotatedElementUtils.findMergedAnnotation(method, UseBookmark.class); // method matches if @UseBookmark is on class, is true and not on method or // @UseBookmark is on method and is true // it is needed to cover @UseBookmark on class and @UseBookmark(false) on method return ((classAnnotation != null) && classAnnotation.value() && methodAnnotation == null) || ((methodAnnotation != null) && methodAnnotation.value()); } }
@Query("MATCH (product:Product),\n" + "\t(product)<-[:PRODUCT_TYPE]-(inventory:Inventory)\n" + "WHERE product.productId = {productId} AND NOT (inventory)<-[:CONTAINS_PRODUCT]-()\n" + "RETURN inventory") List<Inventory> getAvailableInventoryForProduct(@Param("productId") String productId);
/** * Created by david on 2014-12-22. */ @RelationshipEntity(type = "Author") public class Author { @GraphId Long id; @StartNode public Tweet tweet; @EndNode public Profile profile; }
@Query("MATCH (product:Product),\n" + "\t(product)<-[:PRODUCT_TYPE]-(inventory:Inventory),\n" + " (inventory)-[:STOCKED_IN]->(:Warehouse { name: \"{warehouseName}\" })\n" + "WHERE product.productId = {productId} AND NOT (inventory)<-[:CONTAINS_PRODUCT]-()\n" + "RETURN inventory") List<Inventory> getAvailableInventoryForProductAndWarehouse(@Param("productId") String productId, @Param("warehouseName") String warehouseName);
/** * Created by david on 2014-09-17. */ @RelationshipEntity(type = "Tag") public class Tag { @GraphId Long id; @StartNode Tweet tweet; @EndNode Keyword keyword; }
@Query("MATCH (user:User) WHERE has(user.pagerank) AND NOT has(user.screenName)\n" + "WITH user\n" + "ORDER BY user.pagerank DESC\n" + "LIMIT 1\n" + "RETURN user") User findRankedUserToCrawl();
@Query("START personNode=node({0}) " + "MATCH personNode <- [r:identityRelation] - identity " + "WHERE {1} in r.versions " + "WITH DISTINCT identity " + "OPTIONAL MATCH identity - [r:identityRelation] -> (p:personType) " + "WHERE NOT has(r.versions) " + "WITH DISTINCT identity, count(r) as count " + "WHERE count = 0 " + "MATCH identity <- [cr:contentContributionRelation] - content " + "WHERE content.status <> 'HIDDEN' " + "RETURN content.type as type, COUNT(DISTINCT content) as count") List<Map<String, Object>> countAuthorContributionsByType(PersonNode node, String version);
@Query( value = "MATCH (`user`:`User`) " + "WHERE `user`.`name` = {0} " + "RETURN `user`") Iterable<User> simulateFindByNameWhenUsingLabelBasedStrategy(String name);
@Query(value = "START sourceContent=node({0}) MATCH sourceContent - [r:similarityRelation] - targetContent " + "WHERE r.strength > {1} AND r.type = {2} " + "RETURN r", countQuery = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] - targetContent " + "WHERE r.strength > {1} AND r.type = {2} " + "RETURN count(targetContent)") public Page<SimilarityRelation> getSimilarContents(ContentNode sourceNode, Double minimumStrength, String similarityType, Pageable pageable);
@Query("START sourcePerson=node({0}) " + "MATCH sourcePerson -[toIdentity:identityRelation] - identity " + "MATCH identity -[toPerson:identityRelation] - targetPerson " + "WHERE {1} IN toPerson.versions " + "RETURN targetPerson LIMIT 1") PersonNode findCurrentPerson(PersonNode sourceNode, String requiredVersion);
@Query("START userNode=node({0}) " + "MATCH userNode <- [r:identityRelation] - identity " + "WHERE NOT has(r.versions) " + "MATCH identity <- [cr:contentContributionRelation] - content " + "WHERE content.status <> 'HIDDEN'" + "RETURN content.type as type, COUNT(DISTINCT content) as count") List<Map<String, Object>> countUserContributionsByType(UserNode node);
@Query(value = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] - targetContent " + "RETURN r", countQuery = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] - targetContent " + "RETURN count(targetContent)") public Page<SimilarityRelation> getSimilarContents(ContentNode sourceNode, Pageable pageable);
/** * Initialize the user.lastPageRank value to the current user.pagerank */ @Query("MATCH (user:User) WHERE has(user.pagerank) AND has(user.screenName) AND NOT has(user.lastPageRank)\n" + "WITH collect(user) as users\n" + "FOREACH(x in users | \n" + "SET x.lastPageRank = toFloat(x.pagerank))") void setLastPageRank();