Exemplo n.º 1
0
 private static bool TagRulesEqual(AnnotationTagRelationRule actual, RelationUpdateModel expected)
 {
     return(actual.SourceTagId == expected.SourceId &&
            actual.TargetTagId == expected.TargetId &&
            actual.Title == expected.Title &&
            actual.Description == expected.Description &&
            actual.Color == expected.Color &&
            actual.ArrowStyle == expected.ArrowStyle);
 }
Exemplo n.º 2
0
        public bool AddTagRelationRule(RelationFormModel model)
        {
            if (!(DbContext.AnnotationTags.Any(t => t.Id == model.SourceId) &&
                  DbContext.AnnotationTags.Any(t => t.Id == model.TargetId)))
            {
                return(false);
            }
            var rule = new AnnotationTagRelationRule()
            {
                SourceTagId = model.SourceId,
                TargetTagId = model.TargetId,
                Title       = model.Title,
                Description = model.Description,
                Color       = model.Color,
                ArrowStyle  = model.ArrowStyle
            };

            DbContext.TagRelationRules.Add(rule);
            DbContext.SaveChanges();
            return(true);
        }
Exemplo n.º 3
0
 public RelationResult(AnnotationTagRelationRule rule)
     : base(rule.SourceTagId, rule.TargetTagId, rule)
 {
     SourceName = rule.SourceTag.Name;
     TargetName = rule.TargetTag.Name;
 }
Exemplo n.º 4
0
 public AnnotationTagRelationResult(AnnotationTagRelationRule relation)
 {
     Title     = relation.Title;
     FirstTag  = new TagResult(relation.SourceTag);
     SecondTag = new TagResult(relation.TargetTag);
 }
Exemplo n.º 5
0
 private RelationFormModel RelationFormModelFromRelationRule(AnnotationTagRelationRule rel)
 {
     return(new RelationFormModel(rel.SourceTagId, rel.TargetTagId, rel));
 }
        public ControllerTester()
        {
            Admin = new User
            {
                Id    = 1,
                UId   = AdminUId,
                Email = "*****@*****.**",
                Role  = "Administrator"
            };
            Student = new User
            {
                Id    = 2,
                UId   = StudentUId,
                Email = "*****@*****.**",
                Role  = "Student"
            };
            Supervisor = new User
            {
                Id    = 3,
                UId   = SupervisorUId,
                Email = "*****@*****.**",
                Role  = "Supervisor"
            };
            Reviewer = new User
            {
                Id    = 6,
                UId   = ReviewerUId,
                Email = "*****@*****.**",
                Role  = "Reviewer"
            };

            /*
             * Layer1   Layer2
             * |-tag1   |-tag2
             * |-tag3   |-tag4
             *
             * Layer Relation Rules:
             * Layer1 -> Layer2
             *
             * Annotation AnnotationTag Relations:
             * tag1 -> tag2
             * tag3 -> tag2
             * tag3 -> tag4
             */
            Layer1 = new Layer()
            {
                Id = 1, Name = "Time"
            };
            Layer2 = new Layer()
            {
                Id = 2, Name = "Perspective"
            };
            Tag1 = new AnnotationTag()
            {
                Id = 1, Layer = Layer1.Name
            };
            Tag2 = new AnnotationTag()
            {
                Id = 2, Layer = Layer2.Name
            };
            Tag3 = new AnnotationTag()
            {
                Id = 3, Layer = Layer1.Name
            };
            Tag4 = new AnnotationTag()
            {
                Id = 4, Layer = Layer2.Name
            };
            Tag1.ChildTags = new List <AnnotationTag>()
            {
                Tag3
            };
            Tag2.ChildTags = new List <AnnotationTag>()
            {
                Tag4
            };
            RelationRule12 = new AnnotationTagRelationRule()
            {
                Id = 3, SourceTagId = Tag1.Id, TargetTagId = Tag2.Id, Title = "Tag Relation Rule 1->2"
            };
            RelationRule32 = new AnnotationTagRelationRule()
            {
                Id = 5, SourceTagId = Tag3.Id, TargetTagId = Tag2.Id, Title = "Tag Relation Rule 3->2"
            };
            RelationRule34 = new AnnotationTagRelationRule()
            {
                Id = 7, SourceTagId = Tag3.Id, TargetTagId = Tag4.Id, Title = "Tag Relation Rule 3->4"
            };
            TagInstance1 = new AnnotationTagInstance(Tag1)
            {
                Id = 1
            };
            TagInstance2 = new AnnotationTagInstance(Tag2)
            {
                Id = 2
            };
            TagInstance3 = new AnnotationTagInstance(Tag3)
            {
                Id = 3
            };
            TagInstance4 = new AnnotationTagInstance(Tag4)
            {
                Id = 4
            };
            Relation12 = new AnnotationTagInstanceRelation(TagInstance1, TagInstance2)
            {
                Id = 3
            };
            Relation32 = new AnnotationTagInstanceRelation(TagInstance3, TagInstance2)
            {
                Id = 5
            };
            Relation34 = new AnnotationTagInstanceRelation(TagInstance3, TagInstance4)
            {
                Id = 7
            };
            LayerRelationRule = new LayerRelationRule()
            {
                Id            = 3,
                SourceLayer   = Layer1,
                SourceLayerId = Layer1.Id,
                TargetLayer   = Layer2,
                TargetLayerId = Layer2.Id,
                Color         = "test-color",
                ArrowStyle    = "test-style"
            };
            TopicOne = new Topic
            {
                Id          = 1,
                Title       = "Paderborner Dom",
                Status      = "InReview",
                Deadline    = new DateTime(2017, 5, 04),
                CreatedById = Supervisor.Id,
                Description = "Church"
            };
            TopicTwo = new Topic
            {
                Id          = 2,
                Title       = "Westerntor",
                Status      = "InProgress",
                Deadline    = new DateTime(2017, 4, 18),
                CreatedById = Supervisor.Id,
                Description = "Shopping"
            };
            UnreadNotification = new Notification
            {
                NotificationId = 1,
                UserId         = Student.Id,
                UpdaterId      = Supervisor.Id,
                Type           = NotificationType.TOPIC_ASSIGNED_TO,
                TopicId        = TopicOne.Id,
                IsRead         = false
            };
            ReadNotification = new Notification
            {
                NotificationId = 2,
                UserId         = Student.Id,
                UpdaterId      = Supervisor.Id,
                Type           = NotificationType.TOPIC_ASSIGNED_TO,
                TopicId        = TopicTwo.Id,
                IsRead         = true
            };
            Subscription = new Subscription // Adding a new subscription
            {
                SubscriptionId = 1,
                SubscriberId   = Student.Id,
                Subscriber     = Student,
                Type           = NotificationType.TOPIC_ASSIGNED_TO
            };
            SupervisorUser = new TopicUser
            {
                TopicId = TopicOne.Id,
                UserId  = Supervisor.Id,
                Role    = Supervisor.Role
            };
            StudentUser = new TopicUser
            {
                TopicId = TopicOne.Id,
                UserId  = Student.Id,
                Role    = Student.Role
            };
            ReviewerUser = new TopicUser
            {
                TopicId = TopicOne.Id,
                UserId  = Reviewer.Id,
                Role    = Reviewer.Role
            };
            FirstDocument = new Document
            {
                TopicId   = TopicOne.Id,
                UpdaterId = Admin.Id,
                Content   = "Hello"
            };
            TagInstanceForDocument = new AnnotationTagInstance
            {
                Id         = 5,
                TagModelId = Tag1.Id,
                Document   = FirstDocument
            };
        }