This module provides a collection of factory classes responsible for creating and configuring parsers, persisters, and database locks for the DTS import system. The factories abstract the instantiation logic for versioned CSV parsers (tests and sensors), XML parsers (with version-specific handling), save handlers for various import entity types, and database locking mechanisms. This design centralizes object creation, enabling consistent initialization and easier maintenance of the import pipeline.
public static List<ILockImport> Create(ImportObject importObject, User user, double strandedLockTimeoutMinutes)
Creates a list of lock import objects based on the contents of the provided ImportObject. Only creates locks for entity types that have data (TestSetups, Sensors, StaticGroups).
Creates a read-only dictionary mapping version numbers to CSV sensor parsers. Initializes parsers for versions 0, 2, 3, and 4 with the provided configuration parameters.
public static List<IPersistImport> CreateVariants(ImportObject importObject, ImportNotification importNotification, User user, Func<bool> isCanceled, bool showCheckoutButton)
Creates a list of save handlers (IPersistImport) for all entity types present in the ImportObject. Handles CustomerDetails, TestEngineerDetails, LabDetails, SensorModels, Sensors, Users, GlobalSettings, Hardware, GroupTemplates, Groups, and TestSetups. Conditionally creates checkout test setups when showCheckoutButton is true.
XmlParserFactory
Class:DTS.Common.Import.XmlParserFactory (static)
Property
Type
Description
UIItems
List<IUIItems>
Static property for UI items used during XML parsing.
Creates parsers for XML versions 2.0 and above. Handles LabDetails, CustomerDetails, TestEngineerDetails, DASList, Sensors, Calibrations, GroupTemplates, Groups, TestSetups, and Users.
3. Invariants
CSVTestParserFactory: Always returns parsers in the order: Version0, Version5, Version6. The array length is always 3.
CSVSensorParserFactory: The returned dictionary is keyed by the parser's Version property (accessed via v0.Version, v2.Version, etc.). Versions 0, 2, 3, and 4 are always included.
DatabaseLocksFactory: Only creates lock objects for entity types where importObject.<Entities>().Any() returns true. An empty list is returned if no entities are present.
SaveVariantFactory:
A single shared PersistCalculator instance is used across all save handlers.
SaveCustomChannels and SaveHardware are instantiated regardless of whether data exists, but only added to saveHandlers if Hardware().Any() is true for SaveHardware.
SaveGroups is only added to saveHandlers if Groups().Any() or StaticGroups().Any() is true.
When showCheckoutButton is true, both SaveTestSetup and SaveCheckoutTestSetup are created for test setups.
XmlParserFactory:
The version threshold is FileUtils.DataPRO20XmlVersion. Versions below this use LessThan20XMLVersion; versions at or above use GreaterOrEqual20XMLVersion.
LessThan20XMLVersion returns an empty list if node or node.ChildNodes is null.