8.1 KiB
source_files, generated_at, model, schema_version, sha256
| source_files | generated_at | model | schema_version | sha256 | |||||
|---|---|---|---|---|---|---|---|---|---|
|
2026-04-16T11:45:43.783393+00:00 | zai-org/GLM-5-FP8 | 1 | 23d838f43f91b04f |
Documentation: DTS.Common.Import.Factories
1. Purpose
This module provides factory classes for creating parsers, database locks, and persistence handlers for the DTS import system. It centralizes object creation logic for CSV parsing (tests and sensors), XML parsing across different schema versions, database locking mechanisms, and save operation variants. The factories enable version-specific parsing strategies and conditional object creation based on the presence of data in ImportObject.
2. Public Interface
CSVTestParserFactory
| Method | Signature | Description |
|---|---|---|
CreateCSVParsers |
public static IParseCSVTest[] CreateCSVParsers() |
Creates an array of CSV test parsers for versions 0, 5, and 6. Returns parsers in order: Version0, Version5, Version6. |
DatabaseLocksFactory
| Method | Signature | Description |
|---|---|---|
Create |
public static List<ILockImport> Create(ImportObject importObject, User user, double strandedLockTimeoutMinutes) |
Creates lock objects for import operations based on data present in importObject. Conditionally creates LockImportTestSetups, LockImportSensors, and LockImportGroups if corresponding data collections are non-empty. |
CSVSensorParserFactory
| Method | Signature | Description |
|---|---|---|
CreateCSVParsers |
public static IReadOnlyDictionary<int, IParseCSVSensor> CreateCSVParsers(ICalibrationImport import, ZeroMethodOptions zmOptions, IImportNotification importNotification, bool importCreateDynamicGroups, bool useISOCodeFilterMapping, bool useZeroForUnfiltered) |
Creates a dictionary of CSV sensor parsers keyed by version number. Includes versions 0, 2, 3, and 4. Each parser is initialized with the provided parameters before being added to the dictionary. |
SaveVariantFactory
| Method | Signature | Description |
|---|---|---|
CreateVariants |
public static List<IPersistImport> CreateVariants(ImportObject importObject, ImportNotification importNotification, User user, Func<bool> isCanceled, bool showCheckoutButton) |
Creates a list of persistence handlers based on data present in importObject. Handlers are created conditionally for: CustomerDetails, TestEngineerDetails, LabDetails, SensorModels, Sensors (with CSV vs non-CSV variants), Users, GlobalSettings, Hardware, GroupTemplates, Groups, and TestSetups. When showCheckoutButton is true, also creates a SaveCheckoutTestSetup. |
XmlParserFactory
| Property/Method | Signature | Description |
|---|---|---|
UIItems |
public static List<IUIItems> UIItems { get; set; } |
Static property for UI items used during XML parsing. |
ImportNotification |
public static IImportNotification ImportNotification { get; set; } |
Static property for import notifications. |
CreateXMLParsers |
public static IEnumerable<IParseVariant> CreateXMLParsers(string fileName, IImportNotification importNotification, Func<bool> isCanceled, bool skipNormalizing) |
Creates XML parsers based on the file's import version. Routes to LessThan20XMLVersion for versions below FileUtils.DataPRO20XmlVersion, otherwise uses GreaterOrEqual20XMLVersion. |
3. Invariants
-
Version-based dispatch:
XmlParserFactoryusesFileUtils.DataPRO20XmlVersionas the threshold to select between pre-2.0 and 2.0+ parsing strategies. -
Conditional creation:
DatabaseLocksFactory.CreateandSaveVariantFactory.CreateVariantsonly create handlers/locks when the corresponding data collections inImportObjectcontain elements (checked via.Any()). -
Parser version keys:
CSVSensorParserFactory.CreateCSVParsersuses each parser'sVersionproperty as the dictionary key, guaranteeing unique keys per parser type. -
Shared progress calculation:
SaveVariantFactory.CreateVariantsuses a singlePersistCalculatorinstance across all save handlers, with counts accumulated viaAddToTotal()before handlers are added to the list. -
Order-dependent processing: Save handlers are added in a specific sequence (CustomerDetails → TestEngineerDetails → LabDetails → SensorModels → Sensors → Users → GlobalSettings → Hardware → GroupTemplates → Groups → TestSetups).
-
Test setup naming convention: When
showCheckoutButtonis true, test setup names are suffixed withSerialization.RDF.File.SUFFIX_RUNTESTand checkout setups withSerialization.RDF.File.SUFFIX_CHECKOUT.
4. Dependencies
This module depends on:
DTS.Common.Import.Interfaces—IParseCSVTest,IParseCSVSensor,ILockImport,IPersistImport,IParseVariant,ICalibrationImport,IImportNotification,IUIItemsDTS.Common.Import.Parsers.CSV—Version0CSVTestParser,Version5CSVTestParser,Version6CSVTestParser,Version0CSVSensorParser,Version2CSVSensorParser,Version3CSVSensorParser,Version4CSVSensorParserDTS.Common.Import.DatabaseLocks—LockImportTestSetups,LockImportSensors,LockImportGroupsDTS.Common.Import.Persist—PersistCalculator,SaveCustomerDetails,SaveTestEngineerDetails,SaveLabDetails,SaveSensorModels,SaveCsvSourceSensor,SaveNonCsvSourceSensor,SaveUsers,SaveGlobalSettings,SaveCustomChannels,SaveHardware,SaveGroupTemplates,SaveGroups,SaveTestSetup,SaveCheckoutTestSetupDTS.Common.Import.ImportOptions—ZeroMethodOptionsDTS.Common.Import.XML—XMLParseMMECustomChannels,XMLParseMMECustomMainLocations,XMLParseDASList,XMLParseSensors,XMLParseCalibrations,XMLParseGroupTemplates,XMLParseGroups,XMLParseTestSetups,XMLParseLabDetails,XMLParseCustomerDetails,XMLParseTestEngineerDetails,XMLParseUsers,XMLPre20ParseDASList,XMLPre20ParseSensors,XMLPre20ParseCalibrations,XMLPre20ParseGroupTemplates,XMLPre20ParseGroups,XMLPre20ParseTestSetupsDTS.Common.Enums.DBExport—TopLevelFieldsDTS.Common.Utils—FileUtilsDTS.Slice.Users—UserSystem.Xml—XmlElement
Consumers of this module:
- Cannot be determined from source alone; other modules in the codebase that require parser/lock/persistence handler creation would call these factories.
5. Gotchas
-
Static mutable state in
XmlParserFactory: The propertiesUIItems,ImportNotification, and field_isCancelledare static and set duringCreateXMLParsers. This could cause thread-safety issues or stale state if called concurrently. -
Non-sequential version numbers:
CSVTestParserFactorycreates versions 0, 5, and 6 (skipping 1-4), whileCSVSensorParserFactorycreates versions 0, 2, 3, and 4 (skipping 1). The reason for these gaps is unclear from source alone. -
Misleading parameter name: In
SaveVariantFactory.CreateVariants, theshowCheckoutButtonparameter is used to determine "GM parse mode" and affects test setup naming, which is not obvious from the parameter name. (Comment references FB 38039.) -
Pre-2.0 XML wrapper pattern: For XML versions below 2.0, parsers are wrapped in
XMLPre20Parse*variants (e.g.,XMLPre20ParseSensorswrapsXMLParseSensors). This decorator-like pattern is specific to legacy format handling. -
Null-safe hardware channel counting: In
SaveVariantFactory, hardware channel counting usesh?.Channels.Length ?? 0, suggestingHardwareitems or theirChannelsproperty may be null. -
Unused
saveCustomChannelsinstance: InSaveVariantFactory,SaveCustomChannelsis instantiated unconditionally but only added to handlers if referenced bySaveTestSetup. Its standalone purpose is unclear from source alone.