Exemple #1
0
        public void CreateConversionsBetweenUnitsTest()
        {
            UnitManager um = new UnitManager();

            try
            {
                var dummyDimension = um.DimensionRepo.Query().First();

                Unit km = um.Create("KilometerTest", "KmTest", "This is the Kilometer", dummyDimension, MeasurementSystem.Metric);
                Unit m  = um.Create("MeterTest", "MTest", "This is the Meter", dummyDimension, MeasurementSystem.Metric);

                ConversionMethod cm2 = um.CreateConversionMethod("s*1000", "Converts kilometer to meter", km, m);
                ConversionMethod cm3 = um.CreateConversionMethod("s/1000", "Converts meter to kilometer", m, km);

                km.ConversionsIamTheSource.First().Target.Should().BeEquivalentTo(m);
                cm3.Source.Name.Should().BeEquivalentTo(m.Name);
                cm3.Target.Name.Should().BeEquivalentTo(cm2.Source.Name);

                // cleanup the DB.
                um.DeleteConversionMethod(new List <ConversionMethod>()
                {
                    cm2, cm3
                });
                um.Delete(new List <Unit>()
                {
                    km, m
                });
            }
            finally
            {
                um.Dispose();
            }
        }
Exemple #2
0
        // create dimensions in bpp
        public void CreateDimensions(ref DataTable mappedDimensions)
        {
            UnitManager unitManager = null;

            try
            {
                unitManager = new UnitManager();

                foreach (DataRow mappedDimension in mappedDimensions.Rows)
                {
                    string dimensionName          = mappedDimension["Name"].ToString();
                    string dimensionDescription   = mappedDimension["Description"].ToString();
                    string dimensionSpecification = mappedDimension["Syntax"].ToString();

                    Dimension dimension = unitManager.DimensionRepo.Get().Where(d => d.Name.Equals(dimensionName)).FirstOrDefault();

                    if (dimension == null)
                    {
                        dimension = unitManager.Create(dimensionName, dimensionDescription, dimensionSpecification);
                    }

                    mappedDimension["DimensionId"] = dimension.Id;
                }
            }
            finally
            {
                unitManager.Dispose();
            }
        }
        internal void CreatePlayer(BoltConnection boltConnection = null)
        {
            Map       mainMap    = MapManager.FindMap(1);
            Transform spawnPoint = RandomUtils.GetRandomElement(mainMap.Settings.FindSpawnPoints(Team.Alliance));

            ClassType classType;
            string    playerName;
            string    unityId;

            if (boltConnection == null)
            {
                playerName = serverRoomToken.LocalPlayerName;
                unityId    = SystemInfo.deviceUniqueIdentifier;
                classType  = (ClassType)PlayerPrefs.GetInt(UnitUtils.PreferredClassPrefName, 0);
            }
            else
            {
                var connectionToken = (ClientConnectionToken)boltConnection.ConnectToken;
                playerName = connectionToken.Name;
                unityId    = connectionToken.UnityId;
                classType  = connectionToken.PrefferedClass;
            }

            if (!mainMap.Settings.Balance.ClassesByType.TryGetValue(classType, out ClassInfo classInfo) || !classInfo.IsAvailable)
            {
                classType = ClassType.Mage;
            }

            var playerCreateToken = new Player.CreateToken
            {
                Position        = spawnPoint.position,
                Rotation        = spawnPoint.rotation,
                DeathState      = DeathState.Alive,
                FreeForAll      = true,
                ModelId         = 1,
                ClassType       = classType,
                OriginalModelId = 1,
                FactionId       = mainMap.Settings.Balance.DefaultFaction.FactionId,
                PlayerName      = playerName
            };

            Player newPlayer = UnitManager.Create <Player>(BoltPrefabs.Player, playerCreateToken);

            newPlayer.AssignControl(boltConnection);
            newPlayer.UpdateVisibility(true);

            var newPlayerInfo = new PlayerServerInfo(boltConnection, newPlayer, unityId);

            playerInfos.Add(newPlayerInfo);
            playerInfosByPlayerId[newPlayer.Id] = newPlayerInfo;
            if (boltConnection != null)
            {
                playerInfosByConnection[boltConnection] = newPlayerInfo;
            }
            else
            {
                serverPlayerInfo = newPlayerInfo;
            }
        }
Exemple #4
0
        // create read units in bpp
        public void CreateUnits(ref DataTable mappedUnits)
        {
            UnitManager     unitManager    = null;
            DataTypeManager dataTypeManger = null;

            try
            {
                // Javad: The whole loop can be improved!
                var dimentionRepo = unitManager.GetUnitOfWork().GetReadOnlyRepository <Dimension>();
                foreach (DataRow mapUnitsRow in mappedUnits.Rows)
                {
                    unitManager    = new UnitManager();
                    dataTypeManger = new DataTypeManager();
                    Unit unit = new Unit(); // Javad: this can not be out of the loop. in that case, it keeps its link to the session objects and causes the previous unit to be overriden as well as creating a new one!!
                                            // values of the unit
                    unit.Name         = mapUnitsRow["Name"].ToString();
                    unit.Abbreviation = mapUnitsRow["Abbreviation"].ToString();
                    unit.Description  = mapUnitsRow["Description"].ToString();

                    if (unit.Description.Length > 255)
                    {
                        unit.Description = unit.Description.Substring(0, 255);
                    }

                    unit.Dimension = dimentionRepo.Get(Convert.ToInt64(mapUnitsRow["DimensionId"]));

                    // find measurement system
                    foreach (MeasurementSystem msCheck in Enum.GetValues(typeof(MeasurementSystem)))
                    {
                        if (msCheck.ToString().Equals(mapUnitsRow["MeasurementSystem"].ToString()))
                        {
                            unit.MeasurementSystem = msCheck;
                        }
                    }

                    // set data type to created unit or add data type to existing unit
                    List <string> Types = mapUnitsRow["DataTypes"].ToString().Split(' ').Distinct().ToList();

                    // get existing unit or create
                    Unit existU = unitManager.Repo.Get(u => u.Name.ToLower().Equals(unit.Name.ToLower())).FirstOrDefault();
                    if (existU == null)
                    {
                        unit = unitManager.Create(unit.Name, unit.Abbreviation, unit.Description, unit.Dimension, unit.MeasurementSystem);
                        addDataTypes(unit.Id, Types, unitManager, dataTypeManger);
                    }
                    else
                    {
                        addDataTypes(existU.Id, Types, unitManager, dataTypeManger);
                    }
                    // add unit-ID to the mappedUnits Table
                    mapUnitsRow["UnitId"] = unit.Id;
                }
            }
            finally
            {
                unitManager.Dispose();
                dataTypeManger.Dispose();
            }
        }
        internal void CreatePlayer(BoltConnection boltConnection = null)
        {
            Map       mainMap    = MapManager.FindMap(1);
            Transform spawnPoint = RandomUtils.GetRandomElement(mainMap.Settings.FindSpawnPoints(Team.Alliance));

            string playerName;
            string unityId;

            if (boltConnection == null)
            {
                playerName = serverRoomToken.LocalPlayerName;
                unityId    = SystemInfo.deviceUniqueIdentifier;
            }
            else
            {
                var connectionToken = (ClientConnectionToken)boltConnection.ConnectToken;
                playerName = connectionToken.Name;
                unityId    = connectionToken.UnityId;
            }

            var playerCreateToken = new Player.CreateToken
            {
                Position        = spawnPoint.position,
                Rotation        = spawnPoint.rotation,
                DeathState      = DeathState.Alive,
                FreeForAll      = true,
                ModelId         = 1,
                OriginalModelId = 1,
                FactionId       = mainMap.Settings.Balance.DefaultFaction.FactionId,
                PlayerName      = playerName
            };

            Player newPlayer = UnitManager.Create <Player>(BoltPrefabs.Player, playerCreateToken);

            newPlayer.AssignControl(boltConnection);

            var newPlayerInfo = new PlayerServerInfo(boltConnection, newPlayer, unityId);

            playerInfos.Add(newPlayerInfo);
            playerInfosByPlayerId[newPlayer.Id] = newPlayerInfo;
            if (boltConnection != null)
            {
                playerInfosByConnection[boltConnection] = newPlayerInfo;
            }
            else
            {
                serverPlayerInfo = newPlayerInfo;
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool add = txtId.Text == "" ? false : true;

            if (!add)
            {
                UnitBindingModel model = new UnitBindingModel()
                {
                    Name = txtName.Text
                };

                if (manager.Create(model))
                {
                    add = false;
                    MessageBox.Show("Thêm mới thành công !", "Thông báo");
                }
                else
                {
                    MessageBox.Show("Thêm mới không thành công!. Liên hệ với quản trị viên.", "Thông báo");
                }
            }
            else
            {
                UnitBindingModel model = new UnitBindingModel()
                {
                    Id   = int.Parse(txtId.Text),
                    Name = txtName.Text
                };

                if (manager.Update(model))
                {
                    MessageBox.Show("Sửa thành công !", "Thông báo");
                }
                else
                {
                    MessageBox.Show("Sửa không thành công!. Liên hệ với quản trị viên.", "Thông báo");
                }
            }

            LoadData(Searching, PageIndex, PageSize);
        }
Exemple #7
0
        public void CreateAMeasurementUnitTest()
        {
            UnitManager um = new UnitManager();

            try
            {
                var  dummyDimension = um.DimensionRepo.Query().First();
                Unit km             = um.Create("KilometerTest", "KmTest", "This is the Kilometer", dummyDimension, MeasurementSystem.Metric);

                km.Should().NotBeNull();
                km.Id.Should().BeGreaterThan(0);
                var fetchedKm = um.Repo.Get(km.Id);
                km.Abbreviation.Should().BeEquivalentTo(fetchedKm.Abbreviation);
                km.Name.Should().BeEquivalentTo(fetchedKm.Name);

                um.Delete(km); // cleanup the DB
            }
            finally
            {
                um.Dispose();
            }
        }
Exemple #8
0
        public ActionResult editUnit(EditUnitModel Model, string measurementSystem, long[] checkedRecords)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Manage Units", this.Session.GetTenant());

            UnitManager unitManager = null;

            try
            {
                unitManager = new UnitManager();

                Model.Unit.Name                    = cutSpaces(Model.Unit.Name);
                Model.Unit.Abbreviation            = cutSpaces(Model.Unit.Abbreviation);
                Model.Unit.Description             = cutSpaces(Model.Unit.Description);
                Model.Unit.Dimension.Name          = cutSpaces(Model.Unit.Dimension.Name);
                Model.Unit.Dimension.Specification = cutSpaces(Model.Unit.Dimension.Specification);

                if (Model.Unit.Id == 0)
                {
                    if (unitValidation(Model.Unit, checkedRecords))
                    {
                        foreach (MeasurementSystem msCheck in Enum.GetValues(typeof(MeasurementSystem)))
                        {
                            if (msCheck.ToString().Equals(measurementSystem))
                            {
                                Model.Unit.MeasurementSystem = msCheck;
                            }
                        }
                        if (Model.Unit.Dimension.Id != 0)
                        {
                            Model.Unit.Dimension = unitManager.DimensionRepo.Get(Model.Unit.Dimension.Id);
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(Model.Unit.Dimension.Name))
                            {
                                Model.Unit.Dimension.Name = "no Name";
                            }
                            Model.Unit.Dimension = unitManager.Create(Model.Unit.Dimension.Name, Model.Unit.Dimension.Name, Model.Unit.Dimension.Specification);
                        }
                        Model.Unit = unitManager.Create(Model.Unit.Name, Model.Unit.Abbreviation, Model.Unit.Description, Model.Unit.Dimension, Model.Unit.MeasurementSystem);

                        updataAssociatedDataType(Model.Unit, checkedRecords, unitManager);
                    }
                    else
                    {
                        Session["Window"] = true;

                        return(View("UnitManager", new UnitManagerModel(0)));
                    }
                }
                else
                {
                    if (unitValidation(Model.Unit, checkedRecords))
                    {
                        Unit unit = unitManager.Repo.Get(Model.Unit.Id);

                        if (!(unit.DataContainers.Count() > 0))
                        {
                            unit.Name         = Model.Unit.Name;
                            unit.Description  = Model.Unit.Description;
                            unit.Abbreviation = Model.Unit.Abbreviation;
                            foreach (MeasurementSystem msCheck in Enum.GetValues(typeof(MeasurementSystem)))
                            {
                                if (msCheck.ToString().Equals(measurementSystem))
                                {
                                    unit.MeasurementSystem = msCheck;
                                }
                            }

                            if (Model.Unit.Dimension.Id != 0)
                            {
                                unit.Dimension = unitManager.DimensionRepo.Get(Model.Unit.Dimension.Id);
                            }
                            else
                            {
                                if (!String.IsNullOrEmpty(unit.Dimension.Name))
                                {
                                    unit.Dimension.Name = "no Name";
                                }
                                unit.Dimension = unitManager.Create(Model.Unit.Dimension.Name, Model.Unit.Dimension.Name, Model.Unit.Dimension.Specification);
                            }
                            unit = unitManager.Update(unit);
                            List <long> DataTypelIdList = new List <long>();

                            updataAssociatedDataType(unit, checkedRecords, unitManager);
                        }
                    }
                    else
                    {
                        Session["Window"] = true;
                        return(View("UnitManager", new UnitManagerModel(Model.Unit.Id)));
                    }
                }
            }
            finally
            {
                unitManager.Dispose();
            }
            Session["Window"]  = false;
            Session["checked"] = null;
            return(RedirectToAction("UnitManager"));
        }
Exemple #9
0
        public StructuredDataStructure CreateADataStructure()
        {
            var unitManager      = new UnitManager();
            var dataTypeManager  = new DataTypeManager();
            var attributeManager = new DataContainerManager();
            var dsManager        = new DataStructureManager();

            try
            {
                var dim  = unitManager.Create("TestDimnesion", "For Unit Testing", "");
                var unit = unitManager.Create("None_UT", "NoneUT", "Use in unit tsting", dim, Dlm.Entities.DataStructure.MeasurementSystem.Metric);

                var intType      = dataTypeManager.Create("Integer", "Integer", TypeCode.Int32);
                var strType      = dataTypeManager.Create("String", "String", TypeCode.String);
                var doubleType   = dataTypeManager.Create("Double", "Double", TypeCode.Double);
                var boolType     = dataTypeManager.Create("Bool", "Bool", TypeCode.Boolean);
                var dateTimeType = dataTypeManager.Create("DateTime", "DateTime", TypeCode.DateTime);

                var dataAttribute1 = attributeManager.CreateDataAttribute(
                    "att1UT", "att1UT", "Attribute for Unit testing",
                    false, false, "", Dlm.Entities.DataStructure.MeasurementScale.Nominal, Dlm.Entities.DataStructure.DataContainerType.ValueType,
                    "", intType, unit,
                    null, null, null, null, null, null
                    );

                var dataAttribute2 = attributeManager.CreateDataAttribute(
                    "att2UT", "att1UT", "Attribute for Unit testing",
                    false, false, "", Dlm.Entities.DataStructure.MeasurementScale.Nominal, Dlm.Entities.DataStructure.DataContainerType.ValueType,
                    "", strType, unit,
                    null, null, null, null, null, null
                    );

                var dataAttribute3 = attributeManager.CreateDataAttribute(
                    "att3UT", "att3UT", "Attribute for Unit testing",
                    false, false, "", Dlm.Entities.DataStructure.MeasurementScale.Nominal, Dlm.Entities.DataStructure.DataContainerType.ValueType,
                    "", doubleType, unit,
                    null, null, null, null, null, null
                    );

                var dataAttribute4 = attributeManager.CreateDataAttribute(
                    "att4UT", "att4UT", "Attribute for Unit testing",
                    false, false, "", Dlm.Entities.DataStructure.MeasurementScale.Nominal, Dlm.Entities.DataStructure.DataContainerType.ValueType,
                    "", boolType, unit,
                    null, null, null, null, null, null
                    );

                var dataAttribute5 = attributeManager.CreateDataAttribute(
                    "att5UT", "att5UT", "Attribute for Unit testing",
                    false, false, "", Dlm.Entities.DataStructure.MeasurementScale.Nominal, Dlm.Entities.DataStructure.DataContainerType.ValueType,
                    "", dateTimeType, unit,
                    null, null, null, null, null, null
                    );

                StructuredDataStructure dataStructure = dsManager.CreateStructuredDataStructure("dsForTesting", "DS for unit testing", "", "", Dlm.Entities.DataStructure.DataStructureCategory.Generic);
                dsManager.AddVariableUsage(dataStructure, dataAttribute1, true, "var1UT", "", "", "Used for unit testing");
                dsManager.AddVariableUsage(dataStructure, dataAttribute2, true, "var2UT", "", "", "Used for unit testing");
                dsManager.AddVariableUsage(dataStructure, dataAttribute3, true, "var3UT", "", "", "Used for unit testing");
                dsManager.AddVariableUsage(dataStructure, dataAttribute4, true, "var4UT", "", "", "Used for unit testing");
                dsManager.AddVariableUsage(dataStructure, dataAttribute5, true, "var5UT", "", "", "Used for unit testing");
                return(dataStructure);
            }
            catch (Exception ex) { return(null); }
            finally
            {
                unitManager.Dispose();
                dataTypeManager.Dispose();
                attributeManager.Dispose();
                dsManager.Dispose();
            }
        }
Exemple #10
0
        public void GenerateSeedData()
        {
            ResearchPlanManager      researchPlanManager      = new ResearchPlanManager();
            DataStructureManager     dataStructureManager     = new DataStructureManager();
            UnitManager              unitManager              = new UnitManager();
            EntityManager            entityManager            = new EntityManager();
            FeatureManager           featureManager           = new FeatureManager();
            OperationManager         operationManager         = new OperationManager();
            MetadataStructureManager metadataStructureManager = new MetadataStructureManager();

            try
            {
                #region create none researchPlan

                if (!researchPlanManager.Repo.Get().Any(r => r.Title.Equals("none")))
                {
                    researchPlanManager.Create("none", "If no research plan is used.");
                }

                #endregion create none researchPlan

                #region create none structure

                if (!dataStructureManager.AllTypesDataStructureRepo.Get().Any(d => d.Name.Equals("none")))
                {
                    dataStructureManager.CreateUnStructuredDataStructure("none", "If no data strutcure is used.");
                }

                #endregion create none structure

                #region create none unit

                Dimension dimension = null;

                if (!unitManager.DimensionRepo.Get().Any(d => d.Name.ToLower().Equals("none")))
                {
                    dimension = unitManager.Create("none", "none", "If no unit is used."); // the null dimension should be replaced bz a proper valid one. Javad 11.06
                }
                else
                {
                    dimension = unitManager.DimensionRepo.Get().Where(d => d.Name.ToLower().Equals("none")).FirstOrDefault();
                }

                if (!unitManager.Repo.Get().Any(u => u.Name.ToLower().Equals("none")))
                {
                    unitManager.Create("none", "none", "If no unit is used.", dimension, MeasurementSystem.Unknown);
                }

                #endregion create none unit

                #region create entities

                // Entities
                Entity entity = entityManager.Entities.Where(e => e.Name.ToUpperInvariant() == "Dataset".ToUpperInvariant()).FirstOrDefault();

                if (entity == null)
                {
                    entity                 = new Entity();
                    entity.Name            = "Dataset";
                    entity.EntityType      = typeof(Dataset);
                    entity.EntityStoreType = typeof(Xml.Helpers.DatasetStore);
                    entity.UseMetadata     = true;
                    entity.Securable       = true;

                    //add to Extra

                    XmlDocument      xmlDoc           = new XmlDocument();
                    XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper();
                    xmlDatasetHelper.AddReferenceToXml(xmlDoc, AttributeNames.name.ToString(), "ddm", AttributeType.parameter.ToString(), "extra/modules/module");

                    entity.Extra = xmlDoc;

                    entityManager.Create(entity);
                }
                else
                {
                    XmlDocument xmlDoc = new XmlDocument();

                    if (entity.Extra != null)
                    {
                        xmlDoc.AppendChild(entity.Extra);
                    }

                    //update to Extra
                    XmlDatasetHelper xmlDatasetHelper = new XmlDatasetHelper();
                    xmlDatasetHelper.AddReferenceToXml(xmlDoc, AttributeNames.name.ToString(), "ddm", AttributeType.parameter.ToString(), "extra/modules/module");

                    entity.Extra = xmlDoc;

                    entityManager.Update(entity);
                }

                #endregion create entities

                #region SECURITY

                //workflows = größere sachen, vielen operation
                //operations = einzelne actions

                //1.controller-> 1.Operation

                Feature DataCollectionFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Data Collection"));
                if (DataCollectionFeature == null)
                {
                    DataCollectionFeature = featureManager.Create("Data Collection", "Data Collection");
                }

                Feature DatasetCreationFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Data Creation"));
                if (DatasetCreationFeature == null)
                {
                    DatasetCreationFeature = featureManager.Create("Data Creation", "Data Creation", DataCollectionFeature);
                }

                Feature DatasetUploadFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Dataset Upload"));
                if (DatasetUploadFeature == null)
                {
                    DatasetUploadFeature = featureManager.Create("Dataset Upload", "Dataset Upload", DataCollectionFeature);
                }

                Feature ImportDataFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Import Data"));
                if (ImportDataFeature == null)
                {
                    ImportDataFeature = featureManager.Create("Import Data", "Easy way to load data into bexis", DataCollectionFeature);
                }

                Feature MetadataManagementFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Metadata Management"));
                if (MetadataManagementFeature == null)
                {
                    MetadataManagementFeature = featureManager.Create("Metadata Management", "Metadata Management", DataCollectionFeature);
                }

                #region Help Workflow

                operationManager.Create("DCM", "Help", "*");

                #endregion Help Workflow

                #region Create Dataset Workflow

                operationManager.Create("DCM", "CreateDataset", "*", DatasetCreationFeature);
                operationManager.Create("DCM", "Form", "*");
                operationManager.Create("Api", "DatasetIn", "*", DatasetCreationFeature);
                operationManager.Create("Api", "Dataset", "*", DatasetCreationFeature);
                operationManager.Create("Api", "MetadataIn", "*", DatasetCreationFeature);
                operationManager.Create("Api", "Metadata", "*", DatasetCreationFeature);

                #endregion Create Dataset Workflow

                #region Update Dataset Workflow

                operationManager.Create("DCM", "Submit", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitChooseUpdateMethod", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitGetFileInformation", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitSelectAFile", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitSpecifyDataset", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitSummary", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitValidation", "*", DatasetUploadFeature);

                //Load files to server
                operationManager.Create("DCM", "Push", "*", DatasetUploadFeature);

                operationManager.Create("Api", "DataIn", "*", DatasetUploadFeature);
                operationManager.Create("Api", "Data", "*", DatasetUploadFeature);
                operationManager.Create("Api", "AttachmentIn", "*", DatasetUploadFeature);
                operationManager.Create("Api", "Attachment", "*", DatasetUploadFeature);

                #endregion Update Dataset Workflow

                #region Easy Upload

                operationManager.Create("DCM", "EasyUpload", "*", ImportDataFeature);
                operationManager.Create("DCM", "EasyUploadSelectAFile", "*", ImportDataFeature);
                operationManager.Create("DCM", "EasyUploadSelectAreas", "*", ImportDataFeature);
                operationManager.Create("DCM", "EasyUploadSheetDataStructure", "*", ImportDataFeature);
                operationManager.Create("DCM", "EasyUploadSheetSelectMetaData", "*", ImportDataFeature);
                operationManager.Create("DCM", "EasyUploadSummary", "*", ImportDataFeature);
                operationManager.Create("DCM", "EasyUploadVerification", "*", ImportDataFeature);

                #endregion Easy Upload

                #region Metadata Managment Workflow

                operationManager.Create("DCM", "ImportMetadataStructure", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ImportMetadataStructureReadSource", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ImportMetadataStructureSelectAFile", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ImportMetadataStructureSetParameters", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ImportMetadataStructureSummary", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ManageMetadataStructure", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "SubmitSpecifyDataset", "*", MetadataManagementFeature);

                #endregion Metadata Managment Workflow

                #region public available

                //because of reuse in ddm this controller must be public
                // but the funktions should be secured
                operationManager.Create("DCM", "Form", "*");
                operationManager.Create("DCM", "EntityReference", "*");
                //Attachments
                operationManager.Create("DCM", "Attachments", "*");

                #endregion public available

                #endregion SECURITY

                #region Add Metadata


                if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Basic ABCD")))
                {
                    string titleXPath =
                        "Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Title/TitleType";
                    string descriptionXpath =
                        "Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Details/DetailsType";

                    ImportSchema("Basic ABCD", "ABCD_2.06.XSD", "DataSet", entity.Name, entity.EntityType.FullName,
                                 titleXPath, descriptionXpath);
                }

                //if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Full ABCD")))
                //{
                //    string titleXPath =
                //        "Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Title/TitleType";
                //    string descriptionXpath =
                //        "Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Details/DetailsType";

                //    ImportSchema("Full ABCD", "ABCD_2.06.XSD", "DataSet", entity.Name, entity.EntityType.FullName,
                //        titleXPath, descriptionXpath);

                //}

                if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("GBIF")))
                {
                    string titleXPath       = "Metadata/Basic/BasicType/title/titleType";
                    string descriptionXpath = "Metadata/abstract/abstractType/para/paraType";

                    ImportSchema("GBIF", "eml.xsd", "Dataset", entity.Name, entity.EntityType.FullName, titleXPath,
                                 descriptionXpath);
                }
                //if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Basic Eml")))
                //    ImportSchema("Basic Eml", "eml-dataset.xsd", entity.Name, entity.Name, entity.EntityType.FullName);

                #endregion Add Metadata
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                researchPlanManager.Dispose();
                dataStructureManager.Dispose();
                unitManager.Dispose();
                entityManager.Dispose();
                featureManager.Dispose();
                operationManager.Dispose();
                metadataStructureManager.Dispose();
            }
        }
Exemple #11
0
        public void GenerateSeedData()
        {
            ResearchPlanManager  researchPlanManager  = new ResearchPlanManager();
            DataStructureManager dataStructureManager = new DataStructureManager();
            UnitManager          unitManager          = new UnitManager();
            EntityManager        entityManager        = new EntityManager();
            FeatureManager       featureManager       = new FeatureManager();
            OperationManager     operationManager     = new OperationManager();

            try
            {
                #region create none researchPlan

                if (!researchPlanManager.Repo.Get().Any(r => r.Title.Equals("none")))
                {
                    researchPlanManager.Create("none", "If no research plan is used.");
                }



                #endregion

                #region create none structure


                if (!dataStructureManager.AllTypesDataStructureRepo.Get().Any(d => d.Name.Equals("none")))
                {
                    dataStructureManager.CreateUnStructuredDataStructure("none", "If no data strutcure is used.");
                }



                #endregion

                #region create none unit

                Dimension dimension = null;

                if (!unitManager.DimensionRepo.Get().Any(d => d.Name.ToLower().Equals("none")))
                {
                    dimension = unitManager.Create("none", "none", "If no unit is used."); // the null dimension should be replaced bz a proper valid one. Javad 11.06
                }
                else
                {
                    dimension = unitManager.DimensionRepo.Get().Where(d => d.Name.ToLower().Equals("none")).FirstOrDefault();
                }

                if (!unitManager.Repo.Get().Any(u => u.Name.ToLower().Equals("none")))
                {
                    unitManager.Create("none", "none", "If no unit is used.", dimension, MeasurementSystem.Unknown);
                }

                #endregion

                #region create entities

                // Entities
                Entity entity = entityManager.Entities.Where(e => e.Name.ToUpperInvariant() == "Dataset".ToUpperInvariant()).FirstOrDefault();

                if (entity == null)
                {
                    entity                 = new Entity();
                    entity.Name            = "Dataset";
                    entity.EntityType      = typeof(Dataset);
                    entity.EntityStoreType = typeof(Xml.Helpers.DatasetStore);
                    entity.UseMetadata     = true;
                    entity.Securable       = true;

                    entityManager.Create(entity);
                }



                #endregion

                #region SECURITY
                //workflows = größere sachen, vielen operation
                //operations = einzelne actions

                //1.controller-> 1.Operation



                Feature DataCollectionFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Data Collection"));
                if (DataCollectionFeature == null)
                {
                    DataCollectionFeature = featureManager.Create("Data Collection", "Data Collection");
                }

                Feature DatasetCreationFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Data Creation"));
                if (DatasetCreationFeature == null)
                {
                    DatasetCreationFeature = featureManager.Create("Data Creation", "Data Creation", DataCollectionFeature);
                }

                Feature DatasetUploadFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Dataset Upload"));
                if (DatasetUploadFeature == null)
                {
                    DatasetUploadFeature = featureManager.Create("Dataset Upload", "Dataset Upload", DataCollectionFeature);
                }

                Feature MetadataManagementFeature = featureManager.FeatureRepository.Get().FirstOrDefault(f => f.Name.Equals("Metadata Management"));
                if (MetadataManagementFeature == null)
                {
                    MetadataManagementFeature = featureManager.Create("Metadata Management", "Metadata Management", DataCollectionFeature);
                }


                #region Help Workflow

                operationManager.Create("DCM", "Help", "*");

                #endregion

                #region Create Dataset Workflow

                operationManager.Create("DCM", "CreateDataset", "*", DatasetCreationFeature);
                operationManager.Create("DCM", "Form", "*");

                #endregion

                #region Update Dataset Workflow

                operationManager.Create("DCM", "Push", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "Submit", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitDefinePrimaryKey", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitGetFileInformation", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitSelectAFile", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitSpecifyDataset", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitSummary", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "SubmitValidation", "*", DatasetUploadFeature);

                #endregion

                #region Easy Upload

                operationManager.Create("DCM", "EasyUpload", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "EasyUploadSelectAFile", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "EasyUploadSelectAreas", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "EasyUploadSheetDataStructure", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "EasyUploadSheetSelectMetaData", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "EasyUploadSummary", "*", DatasetUploadFeature);
                operationManager.Create("DCM", "EasyUploadVerification", "*", DatasetUploadFeature);

                #endregion

                #region Metadata Managment Workflow

                operationManager.Create("DCM", "ImportMetadataStructure", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ImportMetadataStructureReadSource", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ImportMetadataStructureSelectAFile", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ImportMetadataStructureSetParameters", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ImportMetadataStructureSummary", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "ManageMetadataStructure", "*", MetadataManagementFeature);
                operationManager.Create("DCM", "SubmitSpecifyDataset", "*", MetadataManagementFeature);

                #endregion

                #region public available

                operationManager.Create("DCM", "Form", "*");

                #endregion

                #endregion

                #region Add Metadata
                MetadataStructureManager metadataStructureManager = new MetadataStructureManager();

                if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Basic ABCD")))
                {
                    string titleXPath =
                        "Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Title/TitleType";
                    string descriptionXpath =
                        "Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Details/DetailsType";


                    ImportSchema("Basic ABCD", "ABCD_2.06.XSD", "DataSet", entity.Name, entity.EntityType.FullName,
                                 titleXPath, descriptionXpath);
                }

                //if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Full ABCD")))
                //{
                //    string titleXPath =
                //        "Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Title/TitleType";
                //    string descriptionXpath =
                //        "Metadata/Metadata/MetadataType/Description/DescriptionType/Representation/MetadataDescriptionRepr/Details/DetailsType";


                //    ImportSchema("Full ABCD", "ABCD_2.06.XSD", "DataSet", entity.Name, entity.EntityType.FullName,
                //        titleXPath, descriptionXpath);

                //}

                if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("GBIF")))
                {
                    string titleXPath       = "Metadata/Basic/BasicType/title/titleType";
                    string descriptionXpath = "Metadata/abstract/abstractType/para/paraType";

                    ImportSchema("GBIF", "eml.xsd", "Dataset", entity.Name, entity.EntityType.FullName, titleXPath,
                                 descriptionXpath);
                }
                //if (!metadataStructureManager.Repo.Get().Any(m => m.Name.Equals("Basic Eml")))
                //    ImportSchema("Basic Eml", "eml-dataset.xsd", entity.Name, entity.Name, entity.EntityType.FullName);
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                researchPlanManager.Dispose();
                dataStructureManager.Dispose();
                unitManager.Dispose();
                entityManager.Dispose();
                featureManager.Dispose();
                operationManager.Dispose();
            }
        }