Example #1
0
        public void Add_Update_Remove_GroupVisitor_UnitOfWork()
        {
            //create
            List <Visitor> list     = new List <Visitor>();
            Visitor        visitor1 = new Visitor
            {
                Name         = "test1",
                Surname      = "surname test1",
                DateInSystem = DateTime.Now,
            };

            list.Add(visitor1);

            Visitor visitor2 = new Visitor
            {
                Name         = "test2",
                Surname      = "surname test2",
                DateInSystem = DateTime.Now,
            };

            list.Add(visitor2);

            GroupVisitor group = new GroupVisitor {
                PlaceOfRecidense = "test place"
            };

            group.Visitors = list;
            uow.GroupManager.Create(group);

            var findGroup = uow.GroupManager.GetAll().Where(g => g.Id == group.Id).FirstOrDefault();

            Assert.IsNotNull(findGroup);
            Assert.IsTrue(findGroup.Visitors.Count == 2);
            ////


            //edit
            List <Visitor> newList = new List <Visitor>();

            visitor1.Name = "new Name";
            newList.Add(visitor1);
            newList.Add(new Visitor {
                Name = "Name in test"
            });
            group.PlaceOfRecidense = "new place";
            group.Visitors         = newList;

            uow.GroupManager.Update(group);
            findGroup = uow.GroupManager.GetAll().Where(g => g.Id == group.Id).FirstOrDefault();
            Assert.AreEqual("new place", findGroup.PlaceOfRecidense);
            Assert.AreEqual(2, findGroup.Visitors.Count);
            ///

            //uow.VisitorManager.Delete(visitor1.Id);
            uow.VisitorManager.Delete(visitor2.Id);
            uow.GroupManager.Delete(findGroup.Id);
            findGroup = uow.GroupManager.GetAll().Where(g => g.Id == group.Id).FirstOrDefault();

            Assert.IsNull(findGroup);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldObserveFirstRelationshipAsEmptyInEachDirection()
        public virtual void ShouldObserveFirstRelationshipAsEmptyInEachDirection()
        {
            // GIVEN
            _cache = new NodeRelationshipCache(NumberArrayFactory_Fields.AutoWithoutPagecache, 1, 100, Base);
            int nodes  = 100;
            int typeId = 5;

            Direction[]  directions   = Direction.values();
            GroupVisitor groupVisitor = mock(typeof(GroupVisitor));

            _cache.setForwardScan(true, true);
            _cache.NodeCount = nodes + 1;
            for (int i = 0; i < nodes; i++)
            {
                assertEquals(-1L, _cache.getFirstRel(nodes, groupVisitor));
                _cache.incrementCount(i);
                long previous = _cache.getAndPutRelationship(i, typeId, directions[i % directions.Length], Random.Next(1_000_000), true);
                assertEquals(-1L, previous);
            }

            // WHEN
            _cache.setForwardScan(false, true);
            for (int i = 0; i < nodes; i++)
            {
                long previous = _cache.getAndPutRelationship(i, typeId, directions[i % directions.Length], Random.Next(1_000_000), false);
                assertEquals(-1L, previous);
            }

            // THEN
            _cache.setForwardScan(true, true);
            for (int i = 0; i < nodes; i++)
            {
                assertEquals(-1L, _cache.getFirstRel(nodes, groupVisitor));
            }
        }
        public ProfileGroupDtoToDao(IUnitOfWork _database, GroupVisitor model)
        {
            this._database = _database;

            CreateMap <GroupVisitorDTO, GroupVisitor>().ConstructUsing(v => model).
            ForMember(dest => dest.CheckPoint, opt => opt.MapFrom(src => _database.CheckPoints.GetAll().SingleOrDefault(n => n.Name == src.CheckPoint))).
            ForMember(d => d.Visitors, opt => opt.MapFrom(src => GetVisitors(model.Visitors, src.Visitors)));
        }
Example #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldKeepNextGroupIdForNextRound()
        public virtual void ShouldKeepNextGroupIdForNextRound()
        {
            // GIVEN
            _cache = new NodeRelationshipCache(NumberArrayFactory.HEAP, 1, 100, Base);
            long nodeId = 0;
            int  typeId = 10;

            _cache.NodeCount = nodeId + 1;
            _cache.incrementCount(nodeId);
            GroupVisitor groupVisitor = mock(typeof(GroupVisitor));

            when(groupVisitor.Visit(anyLong(), anyInt(), anyLong(), anyLong(), anyLong())).thenReturn(1L, 2L, 3L);

            long firstRelationshipGroupId;
            {
                // WHEN importing the first type
                long relationshipId = 10;
                _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, true);
                firstRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor);

                // THEN
                assertEquals(1L, firstRelationshipGroupId);
                verify(groupVisitor).visit(nodeId, typeId, relationshipId, -1L, -1L);

                // Also simulate going back again ("clearing" of the cache requires this)
                _cache.setForwardScan(false, true);
                _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, false);
                _cache.setForwardScan(true, true);
            }

            long secondRelationshipGroupId;
            {
                // WHEN importing the second type
                long relationshipId = 11;
                _cache.getAndPutRelationship(nodeId, typeId, INCOMING, relationshipId, true);
                secondRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor);

                // THEN
                assertEquals(2L, secondRelationshipGroupId);
                verify(groupVisitor).visit(nodeId, typeId, -1, relationshipId, -1L);

                // Also simulate going back again ("clearing" of the cache requires this)
                _cache.setForwardScan(false, true);
                _cache.getAndPutRelationship(nodeId, typeId, OUTGOING, relationshipId, false);
                _cache.setForwardScan(true, true);
            }

            {
                // WHEN importing the third type
                long relationshipId = 10;
                _cache.getAndPutRelationship(nodeId, typeId, BOTH, relationshipId, true);
                long thirdRelationshipGroupId = _cache.getFirstRel(nodeId, groupVisitor);
                assertEquals(3L, thirdRelationshipGroupId);
                verify(groupVisitor).visit(nodeId, typeId, -1L, -1L, relationshipId);
            }
        }
Example #5
0
    public void Visit(GroupB group)
    {
        group.ParentGroup = _parent;
        var visitor = new GroupVisitor(group);

        foreach (var item in group.Groups)
        {
            item.Accept(visitor);
        }
    }
Example #6
0
 private void DateAndUserCreate(GroupVisitor model, string user)
 {
     model.DateInSystem = DateTime.Now;
     foreach (var visitor in model.Visitors)
     {
         if (visitor != null)
         {
             visitor.DateInSystem = DateTime.Now;
             visitor.UserInSystem = user;
         }
     }
 }
        private void ListForVisitorService()
        {
            visitor1 = new Visitor
            {
                Id              = 1,
                Surname         = "surname1",
                BithDate        = new DateTime(1987, 07, 01),
                SerialAndNumber = "aa1234567",
                Nationality     = nat1,
                Gender          = gender1,
                DateInSystem    = new DateTime(2018, 07, 01),
                UserInSystem    = "Test"
            };

            visitor2 = new Visitor
            {
                Id              = 2,
                Surname         = "surname2",
                Name            = "Name2",
                Gender          = gender2,
                BithDate        = new DateTime(2005, 1, 1),
                SerialAndNumber = "aa9999999",
                Nationality     = nat2,
                DateInSystem    = new DateTime(2018, 07, 02),
                UserInSystem    = "Test"
            };

            group1 = new GroupVisitor
            {
                Id               = 1,
                Group            = false,
                PlaceOfRecidense = "place 1",
                CheckPoint       = check1,
                DaysOfStay       = 4,
                DateArrival      = new DateTime(2018, 6, 1),
                Visitors         = new List <Visitor> {
                    visitor1
                },

                DateInSystem   = new DateTime(2018, 07, 02),
                TranscriptUser = "******",
                UserInSystem   = "Test1"
            };

            visitor1.Group = group1;
            visitor2.Group = group1;

            listOfVisitorsForVisitorService = new List <Visitor> {
                visitor1, visitor2
            };
        }
Example #8
0
        /// <summary>
        /// Used when setting node nextRel fields. Gets the first relationship for this node,
        /// or the relationship group id. As a side effect this method also creates a relationship group
        /// if this node is dense, and returns that relationship group record id.
        /// </summary>
        /// <param name="nodeId"> id to get first relationship for. </param>
        /// <param name="visitor"> <seealso cref="GroupVisitor"/> which will be notified with data about group to be created.
        /// This visitor is expected to create the group. </param>
        /// <returns> the first relationship if node is sparse, or the result of <seealso cref="GroupVisitor"/> if dense. </returns>
        public virtual long GetFirstRel(long nodeId, GroupVisitor visitor)
        {
            Debug.Assert(_forward, "This should only be done at forward scan");

            ByteArray array = this._array.at(nodeId);
            long      id    = GetRelationshipId(array, nodeId);

            if (id != EMPTY && IsDense(array, nodeId))
            {               // Indirection into rel group cache
                return(_relGroupCache.visitGroup(nodeId, id, visitor));
            }

            return(id);
        }
Example #9
0
        public void TestGroupVisitor()
        {
            var visitor = new GroupVisitor(provider, option, new List <IFuncVisit>());
            Expression <Func <Peoples, object> > ex = t => new { t.Age, t.BirthDay };
            var a   = visitor.Visit(ex);
            var sql = new StringBuilder(visitor.GetSql().ToString().Trim());

            _queryBuilder.RenameTableType(sql, visitor.GetTableDic(), null, visitor.GroupDic);
            Assert.AreEqual("group by `Peoples`.`Age`,`Peoples`.`BirthDay`", sql.ToString());

            ex  = t => t.Age;
            a   = visitor.Visit(ex);
            sql = new StringBuilder(visitor.GetSql().ToString().Trim());

            _queryBuilder.RenameTableType(sql, visitor.GetTableDic(), null, visitor.GroupDic);
            Assert.AreEqual("group by `Peoples`.`Age`", sql.ToString());
        }
Example #10
0
 private void DateAndUserUpdate(GroupVisitorDTO model, GroupVisitor oldModel, string userEdit)
 {
     model.DateInSystem   = oldModel.DateInSystem;
     model.UserInSystem   = oldModel.UserInSystem;
     model.TranscriptUser = oldModel.TranscriptUser;
     model.UserEdit       = userEdit;
     model.DateEdit       = DateTime.Now;
     model.Group          = oldModel.Group;
     foreach (var visitor in model.Visitors)
     {
         if (visitor != null)
         {
             visitor.DateInSystem = oldModel.DateInSystem;
             visitor.UserInSystem = oldModel.UserInSystem;
             visitor.DateEdit     = DateTime.Now;
             visitor.UserEdit     = userEdit;
         }
     }
 }
Example #11
0
            internal virtual long VisitGroup(long nodeId, long relGroupIndex, GroupVisitor visitor)
            {
                long currentIndex = Rebase(relGroupIndex);
                long first        = EMPTY;

                while (currentIndex != EMPTY)
                {
                    ByteArray array  = this.Array.at(currentIndex);
                    long      @out   = All48Bits(array, currentIndex, IdOffset(Direction.OUTGOING));
                    int       typeId = GetTypeId(array, currentIndex);
                    long      @in    = All48Bits(array, currentIndex, IdOffset(Direction.INCOMING));
                    long      loop   = All48Bits(array, currentIndex, IdOffset(Direction.BOTH));
                    long      next   = GetNext(array, currentIndex);
                    long      nextId = @out == EMPTY && @in == EMPTY && loop == EMPTY ? EMPTY : visitor.Visit(nodeId, typeId, @out, @in, loop);
                    if (first == EMPTY)
                    {                              // This is the one we return
                        first = nextId;
                    }
                    currentIndex = next;
                }
                return(first);
            }
        public async Task Test_Unload_Edit_Item_with_one_argument()
        {
            Visitor visitor = new Visitor
            {
                Id       = 3,
                Name     = "testName",
                Surname  = "testSurname",
                BithDate = new DateTime(1965, 1, 1)
            };

            GroupVisitor group = new GroupVisitor
            {
                ExtraSend   = true,
                DaysOfStay  = 1,
                DateArrival = new DateTime(2018, 9, 1),
                Visitors    = new List <Visitor> {
                    visitor
                },
                UserInSystem = "Test1"
            };

            visitor.Group = group;
            repo.VisitorManager.Create(visitor);
            repo.GroupManager.Create(group);
            repo.XMLDispatchManager.Create(new XMLDispatch {
                Id = 3, Operation = Operation.Edit, Status = Status.Send
            });

            var visitors1 = _xmlDispatcher.GetUpdated().ToList();
            var result1   = await _service.SaveNew("test.xml");

            var visitors2 = _xmlDispatcher.GetUpdated().ToList();

            Assert.AreEqual(1, visitors1.Count());
            Assert.AreEqual(0, visitors2.Count());
            Assert.IsTrue(result1.Succedeed);
        }
Example #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCacheMultipleDenseNodeRelationshipHeads()
        public virtual void ShouldCacheMultipleDenseNodeRelationshipHeads()
        {
            // GIVEN
            _cache           = new NodeRelationshipCache(NumberArrayFactory.HEAP, 1);
            _cache.NodeCount = 10;
            long nodeId = 3;

            _cache.setCount(nodeId, 10, 0, OUTGOING);

            // WHEN
            IDictionary <Pair <int, Direction>, long> firstRelationshipIds = new Dictionary <Pair <int, Direction>, long>();
            int typeCount = 3;

            for (int typeId = 0, relationshipId = 0; typeId < typeCount; typeId++)
            {
                foreach (Direction direction in Direction.values())
                {
                    long firstRelationshipId = relationshipId++;
                    _cache.getAndPutRelationship(nodeId, typeId, direction, firstRelationshipId, true);
                    firstRelationshipIds[Pair.of(typeId, direction)] = firstRelationshipId;
                }
            }
            AtomicInteger visitCount = new AtomicInteger();
            GroupVisitor  visitor    = (nodeId1, typeId, @out, @in, loop) =>
            {
                visitCount.incrementAndGet();
                assertEquals(firstRelationshipIds[Pair.of(typeId, OUTGOING)], @out);
                assertEquals(firstRelationshipIds[Pair.of(typeId, INCOMING)], @in);
                assertEquals(firstRelationshipIds[Pair.of(typeId, BOTH)], loop);
                return(0);
            };

            _cache.getFirstRel(nodeId, visitor);

            // THEN
            assertEquals(typeCount, visitCount.get());
        }
        private void ListForGroupVisitorService()
        {
            visitor1 = new Visitor
            {
                Id           = 1,
                Group        = group1,
                Surname      = "surname1",
                BithDate     = new DateTime(1987, 07, 01),
                Nationality  = nat1,
                Gender       = gender1,
                DateInSystem = new DateTime(2018, 07, 01),
                UserInSystem = "Test1",
                Arrived      = true
            };

            visitor2 = new Visitor
            {
                Id           = 2,
                Group        = group2,
                Surname      = "surname2",
                Name         = "Name2",
                Gender       = gender2,
                BithDate     = new DateTime(2005, 1, 1),
                Nationality  = nat2,
                DateInSystem = new DateTime(2018, 07, 02),
                UserInSystem = "Test1",
                Arrived      = true
            };

            visitor3 = new Visitor
            {
                Id           = 3,
                Group        = group2,
                Surname      = "surname3",
                Name         = "Name3",
                Gender       = gender1,
                BithDate     = new DateTime(2000, 1, 1),
                Nationality  = nat2,
                DateInSystem = new DateTime(2017, 01, 01),
                UserInSystem = "Test2"
            };

            group1 = new GroupVisitor
            {
                Id               = 1,
                Group            = false,
                PlaceOfRecidense = "place 1",
                CheckPoint       = check1,
                DateArrival      = new DateTime(2018, 6, 1),
                Visitors         = new List <Visitor> {
                    visitor1
                },

                DateInSystem   = new DateTime(2018, 07, 02),
                TranscriptUser = "******",
                UserInSystem   = "Test1"
            };

            group2 = new GroupVisitor
            {
                Id               = 2,
                Group            = true,
                PlaceOfRecidense = "place 2",
                CheckPoint       = check2,
                DateArrival      = new DateTime(2018, 7, 30),
                Visitors         = new List <Visitor> {
                    visitor2, visitor3
                },

                DateInSystem   = new DateTime(2018, 05, 02),
                TranscriptUser = "******",
                UserInSystem   = "Test1"
            };

            visitor1.Group = group1;
            visitor2.Group = group2;
            visitor3.Group = group2;

            listOfVisitorsForGroupService = new List <Visitor> {
                visitor1, visitor2, visitor3
            };
            listOfGroupsForGroupService = new List <GroupVisitor> {
                group1, group2
            };
        }
Example #15
0
 public override void Accept(GroupVisitor visitor)
 {
     visitor.Visit(this);
 }
Example #16
0
 public abstract void Accept(GroupVisitor visitor);