Example #1
0
        public DataBaseManager()
        {
            DbContext = new Context();

            User = new UserManager(this);
            Authentication = new AuthenticationManager(this);
            Container = new ContainerManager(this);
            ContainerType = new ContainerTypeManager(this);
            Role = new RoleManager(this);
            RoleType = new RoleTypeManager(this);
            Rule = new RuleManager(this);
            ServiceType = new ServiceTypeManager(this);
            Structure = new StructureManager(this);
            WorkSpaceType = new WorkSpaceTypeManager(this);
        }
Example #2
0
        public void ShouldTestBasicFeatures()
        {
            DataBaseManager.Initializer();
            using (var dataBaseManager = new DataBaseManager())
            {
                #region CREATE_SERVICES

                var serviceManager = new ServiceManager(dataBaseManager);

                var serviceGit = new ServiceView()
                                     {
                                         Name = "Git",
                                         Description = "System Version Control (decentralized)"
                                     };

                serviceManager.Create(serviceGit, new[] {"r", "rw"});

                var serviceSvn = new ServiceView()
                                     {
                                         Name = "Svn",
                                         Description = "System Version Control (Centralized)"
                                     };

                serviceManager.Create(serviceSvn, new[] {"r", "rw"});

                #endregion

                #region CREATE_USERS

                var userManager = new UserManager(dataBaseManager);

                var userFaustino = new UserView()
                                       {
                                           Name = "FaustinoLeiras",
                                           Email = "*****@*****.**",
                                           Password = "******"
                                       };

                userManager.Create(userFaustino);

                var userSamir = new UserView()
                                    {
                                        Name = "SamirHafez",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userSamir);

                var userRicardo = new UserView()
                                      {
                                          Name = "Ricardo",
                                          Email = "*****@*****.**",
                                          Password = "******"
                                      };

                userManager.Create(userRicardo);

                var userGeada = new UserView()
                                    {
                                        Name = "Gueada",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userGeada);

                var userFelix = new UserView()
                                    {
                                        Name = "Felix",
                                        Email = "*****@*****.**",
                                        Password = "******"
                                    };

                userManager.Create(userFelix);

                var userGuedes = new UserView()
                                     {
                                         Name = "Guedes",
                                         Email = "*****@*****.**",
                                         Password = "******"
                                     };

                userManager.Create(userGuedes);

                #endregion

                #region CREATE_STRUCTURE

                var structureManager = new StructureManager(dataBaseManager);

                var structure = new StructureView()
                                    {
                                        Name = "AcademicStructure",
                                        Description = "My Academic Structure :)"
                                    };

                structureManager.Create(structure, userFaustino.Name);

                #endregion

                #region CREATE_WORKSPACE_TYPE

                var workspaceType = new WorkSpaceTypeManager(dataBaseManager);

                var workspacePublic = new WorkSpaceTypeView()
                                          {
                                              Name = "public"
                                          };

                workspaceType.Create(workspacePublic, structure.Id, new[] {serviceGit.Name, serviceSvn.Name});

                var workspacePrivate = new WorkSpaceTypeView()
                                           {
                                               Name = "private"
                                           };

                workspaceType.Create(workspacePrivate, structure.Id, new[] {serviceGit.Name, serviceSvn.Name});

                #endregion

                #region CREATE_CONTAINER_PROTOTYPE

                var containerPrototype = new ContainerPrototypeManager(dataBaseManager);

                var prototypeGraduation = new ContainerPrototypeView()
                                              {
                                                  Name = "Graduation"
                                              };

                containerPrototype.Create(prototypeGraduation, structure.Id);

                var prototypeCourse = new ContainerPrototypeView()
                                          {
                                              Name = "Course"
                                          };

                containerPrototype.Create(prototypeCourse, structure.Id, prototypeGraduation.Name);

                var prototypeClass = new ContainerPrototypeView()
                                         {
                                             Name = "Class"
                                         };

                containerPrototype.Create(prototypeClass, structure.Id, prototypeCourse.Name);

                var prototypeGroup = new ContainerPrototypeView()
                                         {
                                             Name = "Group"
                                         };

                containerPrototype.Create(prototypeGroup, structure.Id, prototypeClass.Name);

                #endregion

                #region ADD_WORKSPACE_TYPES_INTO_CONTAINER_PROTOTYPE

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeGraduation.Name, workspacePublic.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeCourse.Name, workspacePublic.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePublic.Name);
                containerPrototype.AddWorkSpaceType(structure.Id, prototypeClass.Name, workspacePrivate.Name);

                containerPrototype.AddWorkSpaceType(structure.Id, prototypeGroup.Name, workspacePublic.Name);

                #endregion

                #region CREATE_ROLETYPE

                var roleType = new RoleTypeManager(dataBaseManager);

                var roleTypeTeacher = new RoleTypeView()
                                          {
                                              Name = "teacher"
                                          };

                roleType.Create(roleTypeTeacher, structure.Id);

                var roleTypeDirector = new RoleTypeView()
                                           {
                                               Name = "director"
                                           };

                roleType.Create(roleTypeDirector, structure.Id);

                var roleTypeStudant = new RoleTypeView()
                                          {
                                              Name = "studant"
                                          };

                roleType.Create(roleTypeStudant, structure.Id);

                #endregion

                #region CREATE_RULE

                var rule = new RuleManager(dataBaseManager);

                var ruleReaders = new RuleView()
                                      {
                                          Name = "readers"
                                      };

                rule.Create(ruleReaders, structure.Id, new[]
                                                           {
                                                               new KeyValuePair<string, string>(serviceGit.Name, "r"),
                                                               new KeyValuePair<string, string>(serviceSvn.Name, "r")
                                                           });

                var ruleReadersAndWriters = new RuleView()
                                                {
                                                    Name = "ReadersAndWriters"
                                                };

                rule.Create(ruleReadersAndWriters, structure.Id, new[]
                                                                     {
                                                                         new KeyValuePair<string, string>(
                                                                             serviceGit.Name,
                                                                             "rw"),
                                                                         new KeyValuePair<string, string>(
                                                                             serviceSvn.Name,
                                                                             "rw")
                                                                     });

                #endregion

                #region CREATE_ROLE

                var role = new RoleManager(dataBaseManager);

                #region ADD_ROLES_COURSE_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeCourse.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReaders.Name
                    );

                #endregion

                #region ADD_ROLES_CLASS_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReaders.Name
                    );

                #endregion

                #region ADD_ROLES_CLASS_WORKSPACE_PRIVATE

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePrivate.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeClass.Name,
                    workspacePrivate.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                #endregion

                #region ADD_ROLES_GROUP_WORKSPACE_PUBLIC

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeDirector.Name,
                    ruleReaders.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeTeacher.Name,
                    ruleReadersAndWriters.Name
                    );

                role.Create(
                    structure.Id,
                    prototypeGroup.Name,
                    workspacePublic.Name,
                    roleTypeStudant.Name,
                    ruleReadersAndWriters.Name
                    );

                #endregion

                #endregion

                #region CREATE_CONTAINERS

                var container = new ContainerManager(dataBaseManager);

                var containerLeic = new ContainerView()
                                        {
                                            Name = "LEIC",
                                            Description = "Licencitura Egenharia informatica e de computadores"
                                        };

                container.Create(containerLeic, structure.Id, prototypeGraduation.Name);

                #region CREATE_COURSE_MPD

                var containerMpd = new ContainerView()
                                       {
                                           Name = "MPD",
                                           Description = "Modelo de padoes de desenho"
                                       };

                container.Create(containerMpd, structure.Id, prototypeCourse.Name, containerLeic.Id);

                var containerMpdLi31D = new ContainerView()
                                            {
                                                Name = "LI31D",
                                                Description = "Turma 1 de terceiro semestre diurno"
                                            };

                container.Create(containerMpdLi31D, structure.Id, prototypeClass.Name, containerMpd.Id);

                var containerMpdG1 = new ContainerView()
                                         {
                                             Name = "Grupo1",
                                             Description = "Grupo de MPD"
                                         };

                container.Create(containerMpdG1, structure.Id, prototypeGroup.Name, containerMpdLi31D.Id);

                var containerMpdG2 = new ContainerView()
                                         {
                                             Name = "Grupo2",
                                             Description = "Grupo de MPD"
                                         };

                container.Create(containerMpdG2, structure.Id, prototypeGroup.Name, containerMpdLi31D.Id);

                #endregion

                #region CREATE_COURSE_SD

                var containerSd = new ContainerView()
                                      {
                                          Name = "SD",
                                          Description = "Sistemas distribuidos"
                                      };

                container.Create(containerSd, structure.Id, prototypeCourse.Name, containerLeic.Id);

                var containerSdLi31D = new ContainerView()
                                           {
                                               Name = "LI31D",
                                               Description = "Turma 1 de terceiro semestre diurno"
                                           };

                container.Create(containerSdLi31D, structure.Id, prototypeClass.Name, containerSd.Id);

                var containerSdG1 = new ContainerView()
                                        {
                                            Name = "Grupo1",
                                            Description = "Grupo de SD"
                                        };

                container.Create(containerSdG1, structure.Id, prototypeGroup.Name, containerSdLi31D.Id);

                var containerSdG2 = new ContainerView()
                                        {
                                            Name = "Grupo2",
                                            Description = "Grupo de SD"
                                        };

                container.Create(containerSdG2, structure.Id, prototypeGroup.Name, containerSdLi31D.Id);

                #endregion

                #endregion

                #region ENROLL_USER

                userManager.Enroll(userFelix.Name, structure.Id, containerLeic.Id, roleTypeDirector.Name);

                userManager.Enroll(userFelix.Name, structure.Id, containerMpd.Id, roleTypeDirector.Name);
                userManager.Enroll(userGuedes.Name, structure.Id, containerSd.Id, roleTypeDirector.Name);

                userManager.Enroll(userFelix.Name, structure.Id, containerSdLi31D.Id, roleTypeTeacher.Name);
                userManager.Enroll(userGuedes.Name, structure.Id, containerMpdLi31D.Id, roleTypeTeacher.Name);

                userManager.Enroll(userFaustino.Name, structure.Id, containerMpdG1.Id, roleTypeStudant.Name);
                userManager.Enroll(userSamir.Name, structure.Id, containerMpdG1.Id, roleTypeStudant.Name);

                userManager.Enroll(userRicardo.Name, structure.Id, containerMpdG2.Id, roleTypeStudant.Name);
                userManager.Enroll(userGeada.Name, structure.Id, containerMpdG2.Id, roleTypeStudant.Name);

                userManager.Enroll(userFaustino.Name, structure.Id, containerSdG1.Id, roleTypeStudant.Name);
                userManager.Enroll(userRicardo.Name, structure.Id, containerSdG1.Id, roleTypeStudant.Name);

                userManager.Enroll(userGeada.Name, structure.Id, containerSdG2.Id, roleTypeStudant.Name);
                userManager.Enroll(userSamir.Name, structure.Id, containerSdG2.Id, roleTypeStudant.Name);

                #endregion

                //AuthorizationTestes aut = new AuthorizationTestes();
                //AuthorizationManager authorizationManager = new AuthorizationManager(dataBaseManager);

                //authorizationManager.CreateServiceAuthorizationStruct(aut, serviceSvn.Name);
            }
        }