< Summary

Information
Class: ValidateLib.Metadata.Unification.MetadataUnifier
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Unification\MetadataUnifier.cs
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 74
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBlocks covered Blocks not covered
UnifyTable(...)80
UnifyTableGroup(...)140
UnifyTableWithoutMetadata(...)170

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Unification\MetadataUnifier.cs

#LineLine coverage
 1using ValidateLib.Metadata.Descriptors;
 2using ValidateLib.Metadata.Embedded;
 3using ValidateLib.Metadata.Properties;
 4using ValidateLib.TabularData.Parsing;
 5using ValidateLib.UtilityClasses;
 6
 7namespace ValidateLib.Metadata.Unification
 8{
 9    /// <summary>
 10    /// Unifies particular descriptors before proceeding to the stage of
 11    /// parsing and validating tabular data files. We normalize all types of different
 12    /// validation beginnings to one common type - when we have a table group descriptor present.
 13    /// Also create a file wrappers for every table so we do not have to concern ourselves with
 14    /// problems with the remote files.
 15    /// </summary>
 16    internal class MetadataUnifier
 17    {
 18        /// <summary>
 19        /// Transform the case when we begin from the table to the table group case.
 20        /// We simple create table group description containing one original table descriptor.
 21        /// </summary>
 22        /// <param name="tableDescriptor"> Original table description passed by user and extracted from metadata file.</
 23        /// <returns> Unified table group descriptor. The table group descriptor contains only one table in tables prope
 24        /// and that is <paramref name="tableDescriptor"/>.
 25        /// </returns>
 26        public static TableGroupDescriptor UnifyTable(TableDescriptor tableDescriptor)
 27        {
 128            var fw = new FileWrapper(tableDescriptor.url!._value!);
 129            var tableGroupDescriptor = new TableGroupDescriptor();
 130            tableGroupDescriptor.tables = new ArrayProperty<TableDescriptor>(new List<TableDescriptor>() { tableDescript
 131            tableDescriptor._fileWrapper = fw;
 132            return tableGroupDescriptor;
 33        }
 34        /// <summary>
 35        /// Unifies case when we have table group descriptor extracted from metadata
 36        /// file.
 37        /// </summary>
 38        /// <param name="tableGroupDescriptor"></param>
 39        /// <returns></returns>
 40
 41        public static TableGroupDescriptor UnifyTableGroup(TableGroupDescriptor tableGroupDescriptor)
 42        {
 143            foreach (var table in tableGroupDescriptor.tables!._value!)
 44            {
 145                table._fileWrapper = new FileWrapper(table.url!._value!);
 46            }
 147            return tableGroupDescriptor;
 48        }
 49
 50        /// <summary>
 51        /// Unifies case when we validate table without metadata and embedded metadata
 52        /// have to be used instead.
 53        /// </summary>
 54        /// <param name="fileIRI"></param>
 55        /// <returns></returns>
 56        public static TableGroupDescriptor UnifyTableWithoutMetadata(string fileIRI)
 57        {
 158            var fw = new FileWrapper(fileIRI);
 159            var defaulDialect = new DialectDescriptor();
 160            var flags = FlagsCreator.ExtractFlagsFromDialectDescriptor(defaulDialect);
 161            EmbeddedMetadataExtractor metadataExtrator = new EmbeddedMetadataExtractor(flags);
 162            using (var fs = fw.OpenNewFileStream())
 63            {
 164                var tabularDataDescriptorEmbedded = metadataExtrator.extractEmbeddedMetadataTableDescriptor(fs, defaulDi
 165                tabularDataDescriptorEmbedded._fileWrapper = fw;
 66
 167                var tableGroupDescriptor = new TableGroupDescriptor();
 168                tableGroupDescriptor.tables = new ArrayProperty<TableDescriptor>(new List<TableDescriptor>() { tabularDa
 169                return tableGroupDescriptor;
 70            }
 71
 172        }
 73    }
 74}