Example #1
0
        private static void AddXMLExtractConfigurationsToImporter(IDataImporter dataImporter)
        {
            var parserFactory = new DefaultXMLParserFactory();

            var extensionValidationRule = new XMLFileNameExtensionMatchValidationRule(".xml", false);

            dataImporter.AddValidationRule(extensionValidationRule);

            var labNameValidationRule = new ElementValueMatchCriteriaValidationRule(new XMLDataSourceLocation("LabReport", "Lab_Name"), parserFactory, typeof(string), new RegexCriteria("^Lab1$"));

            dataImporter.AddValidationRule(labNameValidationRule);

            var labNameFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Lab_Name", parserFactory.GetElementParser(typeof(string)), new SimpleValueAssigner(), typeof(string), "LabName");

            var dateReportedFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Date_Reported", parserFactory.GetElementParser(typeof(DateTime)), new SimpleValueAssigner(), typeof(DateTime), "DateReported");

            var projectIDFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Project_ID", parserFactory.GetElementParser(typeof(int)), new SimpleValueAssigner(), typeof(int), "ProjectId");

            var sdgIDFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "SDG_ID", parserFactory.GetElementParser(typeof(int)), new SimpleValueAssigner(), typeof(int), "SDGID");

            var labSignatoryFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Lab_Signatory", parserFactory.GetElementParser(typeof(string)), new SimpleValueAssigner(), typeof(string), "LabSignatory");

            dataImporter.AddExtractConfiguration(labNameFieldExtractConfiguration);
            dataImporter.AddExtractConfiguration(dateReportedFieldExtractConfiguration);
            dataImporter.AddExtractConfiguration(projectIDFieldExtractConfiguration);
            dataImporter.AddExtractConfiguration(sdgIDFieldExtractConfiguration);
            dataImporter.AddExtractConfiguration(labSignatoryFieldExtractConfiguration);
        }
        public IDataImporter Build()
        {
            var parserFactory = new DefaultXMLParserFactory();
            var testImporter = new SimpleXMLDataImporter(ResultLevel.ERROR);

            var extensionValidationRule = new XMLFileNameExtensionMatchValidationRule(".xml", false);
            testImporter.AddValidationRule(extensionValidationRule);

            var labNameValidationRule = new ElementValueMatchCriteriaValidationRule(new XMLDataSourceLocation("LabReport", "Lab_Name"), parserFactory, typeof(string), new RegexCriteria("^Lab1$"));
            testImporter.AddValidationRule(labNameValidationRule);

            var labNameFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Lab_Name", parserFactory.GetElementParser(typeof(string)), new SimpleValueAssigner(), typeof(string), "LabName");

            var dateReportedFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Date_Reported", parserFactory.GetElementParser(typeof(DateTime)), new SimpleValueAssigner(), typeof(DateTime), "DateReported");

            var projectIDFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Project_ID", parserFactory.GetElementParser(typeof(int)), new SimpleValueAssigner(), typeof(int), "ProjectId");

            var sdgIDFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "SDG_ID", parserFactory.GetElementParser(typeof(int)), new SimpleValueAssigner(), typeof(int), "SDGID");

            var labSignatoryFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Lab_Signatory", parserFactory.GetElementParser(typeof(string)), new SimpleValueAssigner(), typeof(string), "LabSignatory");

            testImporter.AddExtractConfiguration(labNameFieldExtractConfiguration);
            testImporter.AddExtractConfiguration(dateReportedFieldExtractConfiguration);
            testImporter.AddExtractConfiguration(projectIDFieldExtractConfiguration);
            testImporter.AddExtractConfiguration(sdgIDFieldExtractConfiguration);
            testImporter.AddExtractConfiguration(labSignatoryFieldExtractConfiguration);

            return testImporter;
        }
Example #3
0
        private void AddXMLExtractConfigurationsToImporter(IDataImporter dataImporter)
        {
            var parserFactory = new DefaultXMLParserFactory();
            var labNameFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Lab_Name", parserFactory.GetElementParser(typeof(string)), new SimpleValueAssigner(), typeof(string), "LabName");

            var dateReportedFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Date_Reported", parserFactory.GetElementParser(typeof(DateTime)), new SimpleValueAssigner(), typeof(DateTime), "DateReported");

            var projectIDFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Project_ID", parserFactory.GetElementParser(typeof(int)), new SimpleValueAssigner(), typeof(int), "ProjectId");

            var sdgIDFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "SDG_ID", parserFactory.GetElementParser(typeof(int)), new SimpleValueAssigner(), typeof(int), "SDGID");

            var labSignatoryFieldExtractConfiguration = new SimpleXMLExtractConfiguration("", "Lab_Signatory", parserFactory.GetElementParser(typeof(string)), new SimpleValueAssigner(), typeof(string), "LabSignatory");

            dataImporter.AddExtractConfiguration(labNameFieldExtractConfiguration);
            dataImporter.AddExtractConfiguration(dateReportedFieldExtractConfiguration);
            dataImporter.AddExtractConfiguration(projectIDFieldExtractConfiguration);
            dataImporter.AddExtractConfiguration(sdgIDFieldExtractConfiguration);
            dataImporter.AddExtractConfiguration(labSignatoryFieldExtractConfiguration);
        }