Beispiel #1
0
        // count tags in aggregate
        public GraphStory tagsInMyNetwork(GraphStory graphStory)
        {
            graphStory.tagsInNetwork = _graphClient.Cypher
                                       .Start(new { u = graphStory.user.noderef })
                                       .Match("u-[:FOLLOWS]->f")
                                       .With("distinct f")
                                       .Match(" f-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-c")
                                       .With("distinct c")
                                       .Match(" c-[ct:HAS]->(t)")
                                       .With("distinct ct, t")
                                       .Return(() => Return.As <MappedContentTag>("{name: t.wordPhrase, label: t.wordPhrase, " +
                                                                                  " id: count(*) }"))
                                       .OrderByDescending("count(*) ")
                                       .Results.ToList();

            graphStory.userTags = _graphClient.Cypher
                                  .Start(new { u = graphStory.user.noderef })
                                  .Match("u-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-c")
                                  .With("distinct c")
                                  .Match(" c-[ct:HAS]->(t)")
                                  .With("distinct ct, t")
                                  .Return(() => Return.As <MappedContentTag>(" {name: t.wordPhrase, label: t.wordPhrase, " +
                                                                             " id: count(*) }"))
                                  .OrderByDescending("count(*) ")
                                  .Results.ToList();


            return(graphStory);
        }
Beispiel #2
0
        public GraphStory login(GraphStory graphStory)
        {
            tempuser = getByUserName(graphStory.user.username.ToLower());
            if (tempuser != null)
            {
                graphStory.user = tempuser;
            }
            else
            {
                graphStory.haserror = true;
                graphStory.error    = "The username you entered does not exist.";
            }

            return(graphStory);
        }
        // filter locations within distance that have product
        public GraphStory returnLocationsWithinDistanceAndHasProduct(GraphStory graphStory, double lat, double lon, double distance)
        {
            string q = distanceQueryAsString(lat, lon, distance);
            List <MappedLocation> mappedLocations = _graphClient.Cypher
                                                    .Start(new { n = Node.ByIndexQuery("geom", q), p = graphStory.product.noderef })
                                                    .Match(" n-[:HAS]->p ")
                                                    .Return(() => Return.As <MappedLocation>(" { locationId: n.locationId, address: n.address , " +
                                                                                             " city: n.city , state: n.state, zip: n.zip , name: n.name, lat: n.lat , lon: n.lon} "))
                                                    .Results.ToList();

            addDistanceTo(mappedLocations, lat, lon);
            graphStory.mappedLocations = mappedLocations;

            return(graphStory);
        }
Beispiel #4
0
        public GraphStory getContent(GraphStory graphStory, string username, int page, int pagesize)
        {
            graphStory.content = _graphClient.Cypher.Match(" (u:User {username: {u} }) ")
                                 .WithParam("u", username)
                                 .With("u")
                                 .Match(" (u)-[:FOLLOWS*0..1]->f  ")
                                 .With(" DISTINCT f,u ")
                                 .Match(" f-[:CURRENTPOST]-lp-[:NEXTPOST*0..3]-p")
                                 .Return(() => Return.As <MappedContent>("{contentId: p.contentId, title: p.title, url: p.url," +
                                                                         " tagstr: p.tagstr, timestamp: p.timestamp, userNameForPost: f.username, owner: f=u}"))
                                 .OrderByDescending("p.timestamp")
                                 .Skip(page)
                                 .Limit(pagesize)
                                 .Results.ToList();

            return(graphStory);
        }
Beispiel #5
0
        // retrieve products
        public GraphStory getProducts(GraphStory graphStory, int pagenum)
        {
            graphStory.products = _graphClient.Cypher
                                  .Match("(p:Product)")
                                  .Return(() => Return.As <MappedProduct>("{nodeId: ID(p), title: p.title," +
                                                                          "  description: p.description, tagstr: p.tagstr}"))
                                  .OrderBy("p.title")
                                  .Skip(pagenum)
                                  .Limit(11)
                                  .Results.ToList();

            if (graphStory.products.Count() > 10)
            {
                graphStory.next     = true;
                graphStory.products = graphStory.products.GetRange(0, 10);
            }
            else
            {
                graphStory.next = false;
            }

            return(graphStory);
        }
Beispiel #6
0
        public GraphStory save(GraphStory graphStory)
        {
            graphStory.user.username = graphStory.user.username.ToLower();

            if (userExists(graphStory.user.username) == false)
            {
                graphStory.user.userId = Guid.NewGuid().ToString();

                User u = _graphClient.Cypher
                         .Create(" (user:User {user}) ")
                         .WithParam("user", graphStory.user)
                         .Return(user => user.As <User>())
                         .Results.Single();

                graphStory.user = u;
            }
            else
            {
                graphStory.haserror = true;
                graphStory.error    = "The username you entered already exists.";
            }

            return(graphStory);
        }
Beispiel #7
0
 public GraphStory getProduct(GraphStory graphStory)
 {
     graphStory.product = getProduct(graphStory.productNodeId);
     return(graphStory);
 }