public void GenerateSeedData()
        {
            FeatureManager   featureManager   = new FeatureManager();
            OperationManager operationManager = new OperationManager();

            try
            {
                #region SECURITY

                //Features
                List <Feature> features = featureManager.FeatureRepository.Get().ToList();

                Feature OAIPMH = features.FirstOrDefault(f => f.Name.Equals("OAI-PMH"));
                if (OAIPMH == null)
                {
                    OAIPMH = featureManager.Create("OAI-PMH", "Open Archives Initiative Protocol for Metadata Harvesting ");
                }

                Feature AdminFeature = features.FirstOrDefault(f =>
                                                               f.Name.Equals("Admin") &&
                                                               f.Parent != null &&
                                                               f.Parent.Id.Equals(OAIPMH.Id));

                if (AdminFeature == null)
                {
                    AdminFeature = featureManager.Create("Admin", "Settings and customization of the protocol", OAIPMH);
                }

                Feature ApiFeature = features.FirstOrDefault(f =>
                                                             f.Name.Equals("API") &&
                                                             f.Parent != null &&
                                                             f.Parent.Id.Equals(OAIPMH.Id));

                if (ApiFeature == null)
                {
                    ApiFeature = featureManager.Create("Api", "Api of the OAI PMH", OAIPMH);
                }

                //Operations
                operationManager.Create("OAIPMH", "Admin", "*", OAIPMH);
                operationManager.Create("OAIPMH", "Home", "*", OAIPMH);
                operationManager.Create("API", "oai", "*", OAIPMH);

                var featurePermissionManager = new FeaturePermissionManager();

                if (!featurePermissionManager.Exists(null, ApiFeature.Id, PermissionType.Grant))
                {
                    featurePermissionManager.Create(null, ApiFeature.Id, PermissionType.Grant);
                }

                #endregion SECURITY
            }
            finally
            {
                featureManager.Dispose();
                operationManager.Dispose();
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="featureId"></param>
        public void AddFeatureToPublic(long featureId)
        {
            var featurePermissionManager = new FeaturePermissionManager();

            try
            {
                if (!featurePermissionManager.Exists(null, featureId))
                {
                    featurePermissionManager.Create(null, featureId, PermissionType.Grant);
                }
            }
            finally
            {
                featurePermissionManager.Dispose();
            }
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="subjectId"></param>
        /// <param name="featureId"></param>
        /// <param name="permissionType"></param>
        public void CreateOrUpdateFeaturePermission(long?subjectId, long featureId, int permissionType)
        {
            var featurePermissionManager = new FeaturePermissionManager();

            try
            {
                var featurePermission = featurePermissionManager.Find(subjectId, featureId);

                if (featurePermission != null)
                {
                    featurePermission.PermissionType = (PermissionType)permissionType;
                    featurePermissionManager.Update(featurePermission);
                }
                else
                {
                    featurePermissionManager.Create(subjectId, featureId, (PermissionType)permissionType);
                }
            }
            finally
            {
                featurePermissionManager.Dispose();
            }
        }
Beispiel #4
0
        public void GenerateSeedData()
        {
            // Javad:
            // 1) all the create operations should check for existence of the record
            // 2) failure on creating any record should rollback the whole seed data generation. It is one transaction.
            // 3) failues should throw an exception with enough information to pin point the root cause
            // 4) only seed data related to the functions of this modules should be genereated here.
            // BUG: seed data creation is not working because of the changes that were done in the entities and services.
            // TODO: reimplement the seed data creation method.

            //#region Security

            //// Tasks
            using (OperationManager operationManager = new OperationManager())
                using (FeatureManager featureManager = new FeatureManager())
                    using (var featurePermissionManager = new FeaturePermissionManager())
                    {
                        // find root
                        var root = featureManager.FindRoots().FirstOrDefault();

                        // administration node
                        var administrationFeature = featureManager.FindByName("Administration") ?? featureManager.Create("Administration", "node for all administrative features", root);

                        // users node
                        var userFeature   = featureManager.FindByName("Users") ?? featureManager.Create("Users", "", administrationFeature);
                        var userOperation = operationManager.Find("SAM", "Users", "*") ?? operationManager.Create("SAM", "Users", "*", userFeature);

                        // groups node
                        var groupFeature   = featureManager.FindByName("Groups") ?? featureManager.Create("Groups", "", administrationFeature);
                        var groupOperation = operationManager.Find("SAM", "Groups", "*") ?? operationManager.Create("SAM", "Groups", "*", groupFeature);

                        // feature permissions
                        var featurePermissionFeature   = featureManager.FindByName("Feature Permissions") ?? featureManager.Create("Feature Permissions", "", administrationFeature);
                        var featurePermissionOperation = operationManager.Find("SAM", "FeaturePermissions", "*") ?? operationManager.Create("SAM", "FeaturePermissions", "*", featurePermissionFeature);

                        // Entity Permissions
                        var entityPermissionFeature   = featureManager.FindByName("Entity Permissions") ?? featureManager.Create("Entity Permissions", "", administrationFeature);
                        var entityPermissionOperation = operationManager.Find("SAM", "EntityPermissions", "*") ?? operationManager.Create("SAM", "EntityPermissions", "*", entityPermissionFeature);

                        // User Permissions
                        var userPermissionFeature   = featureManager.FindByName("User Permissions") ?? featureManager.Create("User Permissions", "", administrationFeature);
                        var userPermissionOperation = operationManager.Find("SAM", "UserPermissions", "*") ?? operationManager.Create("SAM", "UserPermissions", "*", userPermissionFeature);

                        // Dataset Management
                        var datasetManagementFeature   = featureManager.FindByName("Dataset Management") ?? featureManager.Create("Dataset Management", "", administrationFeature);
                        var datasetManagementOperation = operationManager.Find("SAM", "Datasets", "*") ?? operationManager.Create("SAM", "Datasets", "*", datasetManagementFeature);

                        // Document Management
                        var documentManagementFeature   = featureManager.FindByName("Document Management") ?? featureManager.Create("Document Management", "", administrationFeature);
                        var documentManagementOperation = operationManager.Find("SAM", "Files", "*") ?? operationManager.Create("SAM", "Files", "*", documentManagementFeature);

                        // Request
                        var requestManagementFeature   = featureManager.FindByName("Request Management") ?? featureManager.Create("Request Management", "", administrationFeature);
                        var requestManagementOperation = operationManager.Find("SAM", "RequestsAdmin", "*") ?? operationManager.Create("SAM", "RequestsAdmin", "*", requestManagementFeature);

                        var requestOperation = operationManager.Find("SAM", "Requests", "*") ?? operationManager.Create("SAM", "Requests", "*");

                        // Help
                        var helpOperation = operationManager.Find("SAM", "Help", "*") ?? operationManager.Create("SAM", "Help", "*");



                        if (!featurePermissionManager.Exists(null, featurePermissionFeature.Id, PermissionType.Grant))
                        {
                            featurePermissionManager.Create(null, featurePermissionFeature.Id, PermissionType.Grant);
                        }
                    }
        }
Beispiel #5
0
        public void GenerateSeedData()
        {
            FeatureManager           featureManager           = null;
            FeaturePermissionManager featurePermissionManager = new FeaturePermissionManager();
            OperationManager         operationManager         = new OperationManager();

            try
            {
                featureManager = new FeatureManager();
                List <Feature> features = featureManager.FeatureRepository.Get().ToList();

                Feature dataPlanning = features.FirstOrDefault(f => f.Name.Equals("Data Planning"));
                if (dataPlanning == null)
                {
                    dataPlanning = featureManager.Create("Data Planning", "Data Planning Management");
                }

                Feature datastructureFeature = features.FirstOrDefault(f =>
                                                                       f.Name.Equals("Datastructure Management") &&
                                                                       f.Parent != null &&
                                                                       f.Parent.Id.Equals(dataPlanning.Id));

                if (datastructureFeature == null)
                {
                    datastructureFeature = featureManager.Create("Datastructure Management", "Datastructure Management", dataPlanning);
                }

                if (!operationManager.Exists("RPM", "DataStructureSearch", "*"))
                {
                    operationManager.Create("RPM", "DataStructureSearch", "*", datastructureFeature);
                }

                if (!operationManager.Exists("RPM", "DataStructureEdit", "*"))
                {
                    operationManager.Create("RPM", "DataStructureEdit", "*", datastructureFeature);
                }

                if (!operationManager.Exists("RPM", "Structures", "*"))
                {
                    operationManager.Create("RPM", "Structures", "*", datastructureFeature);
                }

                if (!operationManager.Exists("RPM", "DataStructureIO", "*"))
                {
                    operationManager.Create("RPM", "DataStructureIO", "*", datastructureFeature);
                }

                Feature atributeFeature = features.FirstOrDefault(f =>
                                                                  f.Name.Equals("Variable Template Management") &&
                                                                  f.Parent != null &&
                                                                  f.Parent.Id.Equals(dataPlanning.Id));

                if (atributeFeature == null)
                {
                    atributeFeature = featureManager.Create("Variable Template Management", "Variable Template Management", dataPlanning);
                }
                ;

                if (!operationManager.Exists("RPM", "DataAttribute", "*"))
                {
                    operationManager.Create("RPM", "DataAttribute", "*", atributeFeature);
                }

                Feature unitFeature = features.FirstOrDefault(f =>
                                                              f.Name.Equals("Unit Management") &&
                                                              f.Parent != null &&
                                                              f.Parent.Id.Equals(dataPlanning.Id));

                if (unitFeature == null)
                {
                    unitFeature = featureManager.Create("Unit Management", "Unit Management", dataPlanning);
                }

                if (!operationManager.Exists("RPM", "Unit", "*"))
                {
                    operationManager.Create("RPM", "Unit", "*", unitFeature);
                }

                Feature dataTypeFeature = features.FirstOrDefault(f =>
                                                                  f.Name.Equals("Data Type Management") &&
                                                                  f.Parent != null &&
                                                                  f.Parent.Id.Equals(dataPlanning.Id));

                if (dataTypeFeature == null)
                {
                    dataTypeFeature = featureManager.Create("Data Type Management", "Data Type Management", dataPlanning);
                }

                if (!operationManager.Exists("RPM", "Home", "*"))
                {
                    operationManager.Create("RPM", "Home", "*", dataTypeFeature);
                }

                if (!operationManager.Exists("RPM", "Help", "*"))
                {
                    operationManager.Create("RPM", "Help", "*");
                }


                Feature api = features.FirstOrDefault(f =>
                                                      f.Name.Equals("API") &&
                                                      f.Parent != null &&
                                                      f.Parent.Id.Equals(dataPlanning.Id));

                if (api == null)
                {
                    api = featureManager.Create("API", "API", dataPlanning);
                }

                if (!operationManager.Exists("API", "Structures", "*"))
                {
                    operationManager.Create("API", "Structures", "*", api);
                }

                //set api public
                featurePermissionManager.Create(null, api.Id, Security.Entities.Authorization.PermissionType.Grant);
            }
            finally
            {
                featureManager.Dispose();
                featurePermissionManager.Dispose();
                operationManager.Dispose();
            }

            //create seed data from csv files
            MappingReader    mappingReader    = new MappingReader();
            AttributeCreator attributeCreator = new AttributeCreator();
            string           filePath         = AppConfiguration.GetModuleWorkspacePath("RPM");

            // read data types from csv file
            DataTable mappedDataTypes = mappingReader.readDataTypes(filePath);

            // create read data types in bpp
            attributeCreator.CreateDataTypes(ref mappedDataTypes);

            //// read dimensions from csv file
            DataTable mappedDimensions = mappingReader.readDimensions(filePath);

            // create dimensions in bpp
            attributeCreator.CreateDimensions(ref mappedDimensions);

            //// read units from csv file
            DataTable mappedUnits = mappingReader.readUnits(filePath);

            // create read units in bpp
            attributeCreator.CreateUnits(ref mappedUnits);

            //// read attributes from csv file
            DataTable mappedAttributes = mappingReader.readAttributes(filePath);

            // free memory
            mappedDataTypes.Clear();
            mappedDimensions.Clear();
            // create read attributes in bpp
            attributeCreator.CreateAttributes(ref mappedAttributes);

            createResearchPlan();
            //createSeedDataTypes();
            //createSIUnits();
            //createEmlDatasetAdv();
            //createABCD();


            //ImportSchema("Basic ABCD", "ABCD_2.06.XSD","Dataset","BExIS.Dlm.Entities.Data.Dataset");
            //ImportSchema("Basic Eml", "eml.xsd","dataset","BExIS.Dlm.Entities.Data.Dataset");

            DataStructureManager dsm = null;

            try
            {
                dsm = new DataStructureManager();
                foreach (StructuredDataStructure sds in dsm.StructuredDataStructureRepo.Get())
                {
                    DataStructureIO.convertOrder(sds);
                }
            }
            finally
            {
                dsm.Dispose();
            }
        }
Beispiel #6
0
        public void GenerateSeedData()
        {
            using (FeatureManager featureManager = new FeatureManager())
                using (OperationManager operationManager = new OperationManager())
                    using (var featurePermissionManager = new FeaturePermissionManager())
                    {
                        #region SECURITY
                        //workflows = größere sachen, vielen operation
                        //operations = einzelne actions

                        //1.controller -> 1.Operation
                        List <Feature> features = featureManager.FeatureRepository.Get().ToList();

                        Feature DataDiscovery = features.FirstOrDefault(f => f.Name.Equals("Data Discovery"));
                        if (DataDiscovery == null)
                        {
                            DataDiscovery = featureManager.Create("Data Discovery", "Data Discovery");
                        }

                        Feature SearchFeature = features.FirstOrDefault(f =>
                                                                        f.Name.Equals("Search") &&
                                                                        f.Parent != null &&
                                                                        f.Parent.Id.Equals(DataDiscovery.Id));

                        if (SearchFeature == null)
                        {
                            SearchFeature = featureManager.Create("Search", "Search", DataDiscovery);
                        }

                        Feature SearchManagementFeature = features.FirstOrDefault(f =>
                                                                                  f.Name.Equals("Search Managment") &&
                                                                                  f.Parent != null &&
                                                                                  f.Parent.Id.Equals(DataDiscovery.Id));

                        if (SearchManagementFeature == null)
                        {
                            SearchManagementFeature = featureManager.Create("Search Management", "Search Management", DataDiscovery);
                        }

                        Feature Dashboard = features.FirstOrDefault(f =>
                                                                    f.Name.Equals("Dashboard") &&
                                                                    f.Parent != null &&
                                                                    f.Parent.Id.Equals(DataDiscovery.Id));

                        if (Dashboard == null)
                        {
                            Dashboard = featureManager.Create("Dashboard", "Dashboard", DataDiscovery);
                        }



                        //worklfows -> create dataset ->
                        //WorkflowManager workflowManager = new WorkflowManager();

                        //var operation = new Operation();
                        //Workflow workflow = new Workflow();

                        //List<Workflow> workflows = workflowManager.WorkflowRepository.Get().ToList();

                        #region Help Workflow

                        //workflow =
                        //    workflows.FirstOrDefault(w =>
                        //    w.Name.Equals("Search Help") &&
                        //    w.Feature != null &&
                        //    w.Feature.Id.Equals(DataDiscovery.Id));

                        //if (workflow == null) workflow = workflowManager.Create("Search Help", "", DataDiscovery);

                        //operationManager.Create("DDM", "Help", "*", null, workflow);
                        operationManager.Create("DDM", "Help", "*");

                        #endregion

                        #region Search Workflow

                        // ToDo -> David, Sven
                        // [Sven / 2017-08-21]
                        // I had to remove the feature to get dashboard running without DDM feature permissions.
                        // We have to think about how we can fix it in a long run. Maybe "DDM/Home" is not the proper
                        // place for dashboard!?
                        operationManager.Create("DDM", "PublicSearch", "*");
                        operationManager.Create("DDM", "Home", "*", SearchFeature);
                        operationManager.Create("DDM", "Data", "*", SearchFeature);



                        if (!featurePermissionManager.Exists(null, SearchFeature.Id, PermissionType.Grant))
                        {
                            featurePermissionManager.Create(null, SearchFeature.Id, PermissionType.Grant);
                        }

                        #endregion

                        #region Search Admin Workflow

                        operationManager.Create("DDM", "Admin", "*", SearchManagementFeature);

                        #endregion



                        #region  Dashboard
                        operationManager.Create("DDM", "Dashboard", "*", Dashboard);

                        #endregion

                        #endregion
                    }
        }