// create unstructured DataStructures
        private DataStructure CreateDataStructure(string fileType)
        {
            using (DataStructureManager dataStructureManager = new DataStructureManager())
            {
                UnStructuredDataStructure dataStructure = new UnStructuredDataStructure();

                // values of DataStructure
                string name        = fileType;
                string description = "" + fileType;

                UnStructuredDataStructure existDS = dataStructureManager.UnStructuredDataStructureRepo.Get(s => name.Equals(s.Name)).FirstOrDefault();
                if (existDS == null)
                {
                    // create dataStructure
                    return(dataStructureManager.CreateUnStructuredDataStructure(name, description));
                }
                else
                {
                    return(existDS);
                }
            }
        }
예제 #2
0
        public MessageModel storeDataStructure(long Id, string Name, bool isStructured, string Description = "", string cssId = "", bool inUse = false)
        {
            Name        = Server.UrlDecode(Name);
            Description = Server.UrlDecode(Description);
            MessageModel DataStructureValidation = MessageModel.validateDataStructureInUse(Id);

            if (DataStructureValidation.hasMessage && inUse == false)
            {
                return(DataStructureValidation);
            }
            else
            {
                DataStructureValidation = MessageModel.validateDataStructureName(Id, Name, cssId);
                if (DataStructureValidation.hasMessage)
                {
                    return(DataStructureValidation);
                }
                else
                {
                    DataStructureManager dataStructureManager = null;
                    try
                    {
                        dataStructureManager = new DataStructureManager();

                        DataStructure dataStructure;
                        if (isStructured)
                        {
                            if (Id == 0)
                            {
                                dataStructure = dataStructureManager.CreateStructuredDataStructure(Name.Trim(), Description.Trim(), null, null, DataStructureCategory.Generic);
                                LoggerFactory.LogData(dataStructure.Id.ToString(), typeof(DataStructure).Name, Vaiona.Entities.Logging.CrudState.Created);
                                return(new MessageModel()
                                {
                                    Message = dataStructure.Id.ToString(),
                                    hasMessage = false,
                                    CssId = "redirect"
                                });
                            }
                            else
                            {
                                StructuredDataStructure StructuredDataStructure = dataStructureManager.StructuredDataStructureRepo.Get(Id);
                                StructuredDataStructure.Name        = Name;
                                StructuredDataStructure.Description = Description;
                                dataStructure = dataStructureManager.UpdateStructuredDataStructure(StructuredDataStructure);
                                LoggerFactory.LogData(dataStructure.Id.ToString(), typeof(DataStructure).Name, Vaiona.Entities.Logging.CrudState.Created);
                                return(new MessageModel()
                                {
                                    Message = Id.ToString(),
                                    hasMessage = false,
                                    CssId = "redirect"
                                });
                            }
                        }
                        else
                        {
                            if (Id == 0)
                            {
                                dataStructure = dataStructureManager.CreateUnStructuredDataStructure(Name.Trim(), Description.Trim());
                                LoggerFactory.LogData(dataStructure.Id.ToString(), typeof(DataStructure).Name, Vaiona.Entities.Logging.CrudState.Created);
                                return(new MessageModel()
                                {
                                    Message = "refresh DataStructureResultGrid",
                                    hasMessage = false,
                                    CssId = "refresh"
                                });
                            }
                            else
                            {
                                UnStructuredDataStructure unStructuredDataStructure = dataStructureManager.UnStructuredDataStructureRepo.Get(Id);
                                unStructuredDataStructure.Name        = Name;
                                unStructuredDataStructure.Description = Description;
                                dataStructure = dataStructureManager.UpdateUnStructuredDataStructure(unStructuredDataStructure);
                                LoggerFactory.LogData(dataStructure.Id.ToString(), typeof(DataStructure).Name, Vaiona.Entities.Logging.CrudState.Created);
                                return(new MessageModel()
                                {
                                    Message = "refresh DataStructureResultGrid",
                                    hasMessage = false,
                                    CssId = "refresh"
                                });
                            }
                        }
                    }
                    finally
                    {
                        dataStructureManager.Dispose();
                    }
                }
            }
        }
예제 #3
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();
            }
        }
예제 #4
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();
            }
        }