Ejemplo n.º 1
0
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            chemistry.OriginalChemName = "XYZ";

            var esdatModel           = new ESDATModel();
            var sample               = new SampleFileData();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new ChemistryVariableMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var variable = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.DefaultVariableTypeCVChemistry, variable.VariableTypeCV);
            Assert.AreEqual(chemistry.ChemCode, variable.VariableCode);

            // This is temporarily hard-coded
            Assert.AreEqual("1,1,1-Trichloroethane", variable.VariableNameCV);

            Assert.AreEqual(chemistry.OriginalChemName, variable.VariableDefinition);
            Assert.AreEqual(defaultValueProvider.DefaultVariableSpeciationCV, variable.SpeciationCV);
            Assert.AreEqual(defaultValueProvider.DefaultVariableNoDataValue, variable.NoDataValue);
        }
        public void Scaffold()
        {
            var esdatModel = new ESDATModel();

            var labName = "XYZ Labs";
            var sample  = new SampleFileData();

            sample.LabName = labName;

            var chemistry = new ChemistryFileData();

            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new SampleCollectionOrganizationMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var organization = mapper.Draft(esdatModel);

            Assert.AreEqual(defaultValueProvider.OrganizationTypeCVSampleCollection, organization.OrganizationTypeCV);
            Assert.AreEqual(mapper.GetOrganizationCode(defaultValueProvider.OrganizationNameSampleCollection), organization.OrganizationCode);
            Assert.AreEqual(defaultValueProvider.OrganizationNameSampleCollection, organization.OrganizationName);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();
            chemistry.OriginalChemName = "XYZ";

            var esdatModel = new ESDATModel();
            var sample = new SampleFileData();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new ChemistryVariableMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var variable = mapper.Draft(esdatModel, chemistry);            

            Assert.AreEqual(defaultValueProvider.DefaultVariableTypeCVChemistry, variable.VariableTypeCV);
            Assert.AreEqual(chemistry.ChemCode, variable.VariableCode);

            // This is temporarily hard-coded
            Assert.AreEqual("1,1,1-Trichloroethane", variable.VariableNameCV);

            Assert.AreEqual(chemistry.OriginalChemName, variable.VariableDefinition);
            Assert.AreEqual(defaultValueProvider.DefaultVariableSpeciationCV, variable.SpeciationCV);
            Assert.AreEqual(defaultValueProvider.DefaultVariableNoDataValue, variable.NoDataValue);
        }
Ejemplo n.º 4
0
        public Organization Map(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = Draft(esdatModel, chemistry);

            entity = GetDuplicate(_wayToHandleNewData, entity);

            return(entity);
        }
        public FeatureAction Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new FeatureAction();

            Validate(entity);

            return(entity);
        }
        public SamplingFeature Map(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = Draft(esdatModel, chemistry);

            entity = GetDuplicate(_wayToHandleNewData, entity);

            return(entity);
        }
Ejemplo n.º 7
0
        public MeasurementResultValue Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new MeasurementResultValue();

            entity.DataValue     = (double)chemistry.Result;
            entity.ValueDateTime = chemistry.AnalysedDate;

            Validate(entity);

            return(entity);
        }
Ejemplo n.º 8
0
        public Core.Action Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new Core.Action();

            entity.ActionTypeCV  = _WQDefaultValueProvider.ActionTypeCVChemistry;
            entity.BeginDateTime = chemistry.ExtractionDate;
            entity.EndDateTime   = chemistry.AnalysedDate;

            Validate(entity);

            return(entity);
        }
        public Method Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new Method();

            entity.MethodTypeCV = _WQDefaultValueProvider.DefaultMethodTypeCVChemistry;
            entity.MethodCode   = chemistry.MethodType;
            entity.MethodName   = chemistry.MethodName;

            Validate(entity);

            return(entity);
        }
        public MeasurementResult Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new MeasurementResult();

            entity.CensorCodeCV           = _WQDefaultValueProvider.MeasurementResultCensorCodeCVChemistry;
            entity.QualityCodeCV          = _WQDefaultValueProvider.MeasurementResultQualityCodeCVChemistry;
            entity.AggregationStatisticCV = _WQDefaultValueProvider.MeasurementResultAggregationStatisticCVChemistry;

            Validate(entity);

            return(entity);
        }
        public SamplingFeature Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new SamplingFeature();

            entity.SamplingFeatureTypeCV = _WQDefaultValueProvider.DefaultSamplingFeatureTypeCVChemistry;
            entity.SamplingFeatureCode   = _WQDefaultValueProvider.DefaultSamplingFeatureCodeChemistry;
            entity.SamplingFeatureName   = _WQDefaultValueProvider.DefaultSamplingFeatureNameChemistry;
            entity.SamplingFeatureUUID   = _WQDefaultValueProvider.DefaultSamplingFeatureUUIDChemistry;

            Validate(entity);

            return(entity);
        }
Ejemplo n.º 12
0
        public Organization Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new Organization();

            var organizationName = SampleFileData.LabName;

            entity.OrganizationTypeCV = _WQDefaultValueProvider.OrganizationTypeCVChemistry;
            entity.OrganizationCode   = GetOrganizationCode(organizationName);
            entity.OrganizationName   = organizationName;

            Validate(entity);

            return(entity);
        }
Ejemplo n.º 13
0
        public Unit Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new Unit();

            string resultUnit = chemistry.ResultUnit;

            entity.UnitsTypeCV       = _WQDefaultValueProvider.DefaultUnitsTypeCVChemistry;
            entity.UnitsAbbreviation = AbbereviateUnit(resultUnit);
            entity.UnitsName         = resultUnit;

            Validate(entity);

            return(entity);
        }
        public Result Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new Result();

            entity.ResultUUID      = Guid.NewGuid();
            entity.ResultTypeCV    = _WQDefaultValueProvider.ResultTypeCVChemistry;
            entity.ResultDateTime  = chemistry.AnalysedDate;
            entity.SampledMediumCV = _WQDefaultValueProvider.ResultSampledMediumCVChemistry;
            entity.ValueCount      = 1;

            Validate(entity);

            return(entity);
        }
        public Variable Draft(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = new Variable();

            entity.VariableTypeCV     = _WQDefaultValueProvider.DefaultVariableTypeCVChemistry;
            entity.VariableCode       = chemistry.ChemCode;
            entity.VariableNameCV     = "1,1,1-Trichloroethane";
            entity.VariableDefinition = chemistry.OriginalChemName;
            entity.SpeciationCV       = _WQDefaultValueProvider.DefaultVariableSpeciationCV;
            entity.NoDataValue        = _WQDefaultValueProvider.DefaultVariableNoDataValue;

            Validate(entity);

            return(entity);
        }
Ejemplo n.º 16
0
        private static ChemistryFileData MapChemistryFileData(Hatfield.EnviroData.Core.Action action, Result result, MeasurementResultValue measurementResultValue)
        {
            var chemistryFileData = new ChemistryFileData();

            chemistryFileData.ExtractionDate   = action.BeginDateTime;
            chemistryFileData.AnalysedDate     = action.EndDateTime.HasValue ? action.EndDateTime.Value : DateTime.MinValue;
            chemistryFileData.Result           = measurementResultValue.DataValue;
            chemistryFileData.ResultUnit       = result.MeasurementResult.Unit.UnitsName;
            chemistryFileData.OriginalChemName = result.Variable.VariableDefinition;
            chemistryFileData.ChemCode         = result.Variable.VariableCode;
            chemistryFileData.MethodName       = action.Method.MethodName;
            chemistryFileData.MethodType       = action.Method.MethodDescription;

            var propertyValueDictionary = result.ResultExtensionPropertyValues.ToDictionary(x => x.ExtensionProperty.PropertyName, x => x.PropertyValue);

            chemistryFileData.SampleCode = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeySampleCode) ?
                                           propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeySampleCode] :
                                           string.Empty;

            chemistryFileData.Prefix = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyPrefix) ?
                                       propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyPrefix] :
                                       string.Empty;

            chemistryFileData.TotalOrFiltered = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyTotalOrFiltered) ?
                                                propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyTotalOrFiltered] :
                                                string.Empty;

            chemistryFileData.ResultType = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyResultType) ?
                                           propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyResultType] :
                                           string.Empty;

            chemistryFileData.EQL = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQL) ?
                                    MappingHelper.ToNullableDouble(propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQL]) :
                                    null;

            chemistryFileData.EQLUnits = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQLUnits) ?
                                         propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQLUnits] :
                                         string.Empty;

            chemistryFileData.Comments = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyComments) ? propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyComments] : string.Empty;
            chemistryFileData.UCL      = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyUCL) ? MappingHelper.ToNullableDouble(propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyUCL]) : null;
            chemistryFileData.LCL      = propertyValueDictionary.ContainsKey(ESDATChemistryConstants.ResultExtensionPropertyValueKeyLCL) ? MappingHelper.ToNullableDouble(propertyValueDictionary[ESDATChemistryConstants.ResultExtensionPropertyValueKeyLCL]) : null;

            return(chemistryFileData);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel           = new ESDATModel();
            var sample               = new SampleFileData();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new ChemistryMeasurementResultMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var measurementResult = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.MeasurementResultCensorCodeCVChemistry, measurementResult.CensorCodeCV);
            Assert.AreEqual(defaultValueProvider.MeasurementResultQualityCodeCVChemistry, measurementResult.QualityCodeCV);
            Assert.AreEqual(defaultValueProvider.MeasurementResultAggregationStatisticCVChemistry, measurementResult.AggregationStatisticCV);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel = new ESDATModel();
            var sample = new SampleFileData();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new ChemistrySamplingFeatureMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var samplingFeature = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.DefaultSamplingFeatureTypeCVChemistry, samplingFeature.SamplingFeatureTypeCV);
            Assert.AreEqual(string.Empty, samplingFeature.SamplingFeatureCode);
            Assert.AreEqual(new Guid(), samplingFeature.SamplingFeatureUUID);
        }
Ejemplo n.º 19
0
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel           = new ESDATModel();
            var sample               = new SampleFileData();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new ChemistrySamplingFeatureMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var samplingFeature = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.DefaultSamplingFeatureTypeCVChemistry, samplingFeature.SamplingFeatureTypeCV);
            Assert.AreEqual("Unknown", samplingFeature.SamplingFeatureCode);
            Assert.AreEqual(new Guid(), samplingFeature.SamplingFeatureUUID);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel = new ESDATModel();
            var sample = new SampleFileData();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new ChemistryMethodMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var method = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.DefaultMethodTypeCVChemistry, method.MethodTypeCV);
            Assert.AreEqual(chemistry.MethodType, method.MethodCode);
            Assert.AreEqual(chemistry.MethodName, method.MethodName);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel = new ESDATModel();
            var sample = new SampleFileData();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new ChemistryMeasurementResultMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var measurementResult = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.MeasurementResultCensorCodeCVChemistry, measurementResult.CensorCodeCV);
            Assert.AreEqual(defaultValueProvider.MeasurementResultQualityCodeCVChemistry, measurementResult.QualityCodeCV);
            Assert.AreEqual(defaultValueProvider.MeasurementResultAggregationStatisticCVChemistry, measurementResult.AggregationStatisticCV);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel           = new ESDATModel();
            var sample               = new SampleFileData();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new ChemistryFeatureActionMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var featureAction = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(0, featureAction.FeatureActionID);
            Assert.AreEqual(0, featureAction.SamplingFeatureID);
            Assert.AreEqual(0, featureAction.ActionID);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel = new ESDATModel();
            var sample = new SampleFileData();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new ChemistryFeatureActionMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var featureAction = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(0, featureAction.FeatureActionID);
            Assert.AreEqual(0, featureAction.SamplingFeatureID);
            Assert.AreEqual(0, featureAction.ActionID);
        }
Ejemplo n.º 24
0
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel           = new ESDATModel();
            var sample               = new SampleFileData();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new ChemistryMethodMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var method = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.DefaultMethodTypeCVChemistry, method.MethodTypeCV);
            Assert.AreEqual(chemistry.MethodType, method.MethodCode);
            Assert.AreEqual(chemistry.MethodName, method.MethodName);
        }
        public void ChemistryFileDataConstructorTest()
        {
            var chemistryFileData = new ChemistryFileData("test sample code",
                                                          "test original chemistry name",
                                                          "test chem code",
                                                          "test prefix",
                                                          1.1,
                                                          "test result unit",
                                                          "Total",
                                                          "test result type",
                                                          "test method type",
                                                          "test method name",
                                                          new DateTime(2014, 1, 2),
                                                          new DateTime(2014, 2, 3),
                                                          2.2,
                                                          "%",
                                                          "good data",
                                                          "Good",
                                                          3.3,
                                                          4.4);

            Assert.NotNull(chemistryFileData);
            Assert.AreEqual("test sample code", chemistryFileData.SampleCode);
            Assert.AreEqual("test original chemistry name", chemistryFileData.OriginalChemName);
            Assert.AreEqual("test chem code", chemistryFileData.ChemCode);
            Assert.AreEqual("test prefix", chemistryFileData.Prefix);
            Assert.AreEqual(1.1, chemistryFileData.Result);
            Assert.AreEqual("test result unit", chemistryFileData.ResultUnit);
            Assert.AreEqual("Total", chemistryFileData.TotalOrFiltered);
            Assert.AreEqual("test result type", chemistryFileData.ResultType);
            Assert.AreEqual("test method type", chemistryFileData.MethodType);
            Assert.AreEqual("test method name", chemistryFileData.MethodName);
            Assert.AreEqual(new DateTime(2014, 1, 2), chemistryFileData.ExtractionDate);
            Assert.AreEqual(new DateTime(2014, 2, 3), chemistryFileData.AnalysedDate);
            Assert.AreEqual(2.2, chemistryFileData.EQL);
            Assert.AreEqual("%", chemistryFileData.EQLUnits);
            Assert.AreEqual("good data", chemistryFileData.Comments);
            Assert.AreEqual("Good", chemistryFileData.LabQualifier);
            Assert.AreEqual(3.3, chemistryFileData.UCL);
            Assert.AreEqual(4.4, chemistryFileData.LCL);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();
            chemistry.AnalysedDate = DateTime.Now;

            var esdatModel = new ESDATModel();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var factory = new ESDATChemistryMapperFactory(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);
            var mapper = new ChemistryActionMapper(duplicateChecker, factory, defaultValueProvider, wayToHandleNewData, results);

            var action = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.ActionTypeCVChemistry, action.ActionTypeCV);
            Assert.AreEqual(chemistry.ExtractionDate, action.BeginDateTime);
            Assert.AreEqual(chemistry.AnalysedDate, action.EndDateTime);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();
            chemistry.ResultUnit = "Unit";

            var esdatModel = new ESDATModel();
            var sample = new SampleFileData();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new ChemistryUnitMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var unit = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.DefaultUnitsTypeCVChemistry, unit.UnitsTypeCV);
            Assert.AreEqual(mapper.AbbereviateUnit(chemistry.ResultUnit), unit.UnitsAbbreviation);
            Assert.AreEqual(chemistry.ResultUnit, unit.UnitsName);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel = new ESDATModel();
            var sample = new SampleFileData();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new ChemistryResultMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var result = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.ResultTypeCVChemistry, result.ResultTypeCV);
            Assert.AreEqual(chemistry.AnalysedDate, result.ResultDateTime);
            Assert.AreEqual(defaultValueProvider.ResultSampledMediumCVChemistry, result.SampledMediumCV);
            Assert.AreEqual(1, result.ValueCount);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            var esdatModel           = new ESDATModel();
            var sample               = new SampleFileData();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new ChemistryResultMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var result = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.ResultTypeCVChemistry, result.ResultTypeCV);
            Assert.AreEqual(chemistry.AnalysedDate, result.ResultDateTime);
            Assert.AreEqual(defaultValueProvider.ResultSampledMediumCVChemistry, result.SampledMediumCV);
            Assert.AreEqual(1, result.ValueCount);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();
            chemistry.Result = 101;
            chemistry.AnalysedDate = DateTime.Now;

            var esdatModel = new ESDATModel();
            var sample = new SampleFileData();
            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new ChemistryMeasurementResultValueMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var measurementResultValue = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(chemistry.Result, measurementResultValue.DataValue);
            Assert.AreEqual(chemistry.AnalysedDate, measurementResultValue.ValueDateTime);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            chemistry.Result       = 101;
            chemistry.AnalysedDate = DateTime.Now;

            var esdatModel           = new ESDATModel();
            var sample               = new SampleFileData();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new ChemistryMeasurementResultValueMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var measurementResultValue = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(chemistry.Result, measurementResultValue.DataValue);
            Assert.AreEqual(chemistry.AnalysedDate, measurementResultValue.ValueDateTime);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            chemistry.AnalysedDate = DateTime.Now;

            var esdatModel           = new ESDATModel();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var factory              = new ESDATChemistryMapperFactory(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);
            var mapper               = new ChemistryActionMapper(duplicateChecker, factory, defaultValueProvider, wayToHandleNewData, results);

            var action = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.ActionTypeCVChemistry, action.ActionTypeCV);
            Assert.AreEqual(chemistry.ExtractionDate, action.BeginDateTime);
            Assert.AreEqual(chemistry.AnalysedDate, action.EndDateTime);
        }
        public void ScaffoldTest()
        {
            var chemistry = new ChemistryFileData();

            chemistry.ResultUnit = "Unit";

            var esdatModel           = new ESDATModel();
            var sample               = new SampleFileData();
            var mockDb               = new Mock <IDbContext>();
            var mockDbContext        = mockDb.Object;
            var duplicateChecker     = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData   = WayToHandleNewData.ThrowExceptionForNewData;
            var results              = new List <IResult>();
            var mapper               = new ChemistryUnitMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var unit = mapper.Draft(esdatModel, chemistry);

            Assert.AreEqual(defaultValueProvider.DefaultUnitsTypeCVChemistry, unit.UnitsTypeCV);
            Assert.AreEqual(mapper.AbbereviateUnit(chemistry.ResultUnit), unit.UnitsAbbreviation);
            Assert.AreEqual(chemistry.ResultUnit, unit.UnitsName);
        }
        public void Scaffold()
        {
            var esdatModel = new ESDATModel();

            var labName = "XYZ Labs";
            var sample = new SampleFileData();
            sample.LabName = labName;

            var chemistry = new ChemistryFileData();

            var mockDb = new Mock<IDbContext>();
            var mockDbContext = mockDb.Object;
            var duplicateChecker = new ODM2DuplicateChecker(mockDbContext);
            var defaultValueProvider = new StaticWQDefaultValueProvider();
            var wayToHandleNewData = WayToHandleNewData.ThrowExceptionForNewData;
            var results = new List<IResult>();
            var mapper = new SampleCollectionOrganizationMapper(duplicateChecker, defaultValueProvider, wayToHandleNewData, results);

            var organization = mapper.Draft(esdatModel);

            Assert.AreEqual(defaultValueProvider.OrganizationTypeCVSampleCollection, organization.OrganizationTypeCV);
            Assert.AreEqual(mapper.GetOrganizationCode(defaultValueProvider.OrganizationNameSampleCollection), organization.OrganizationCode);
            Assert.AreEqual(defaultValueProvider.OrganizationNameSampleCollection, organization.OrganizationName);
        }
        public FeatureAction Map(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = Draft(esdatModel, chemistry);

            return(entity);
        }
        public MeasurementResult Map(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = Draft(esdatModel, chemistry);

            return(entity);
        }
Ejemplo n.º 37
0
        public Core.Action Map(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var entity = Draft(esdatModel, chemistry);

            // Feature Actions
            var featureAction = _chemistryFactory.FeatureActionMapper.Map(esdatModel, chemistry);

            ODM2EntityLinker.Link(entity, featureAction);

            // Sampling Feature
            var samplingFeature = _chemistryFactory.SamplingFeatureMapper.Map(esdatModel, chemistry);

            ODM2EntityLinker.Link(featureAction, samplingFeature);

            // Result
            // Each Feature Action contains 1 Result (Chemistry)
            {
                var result = _chemistryFactory.ResultMapper.Map(esdatModel, chemistry);
                ODM2EntityLinker.Link(featureAction, result);

                // Unit
                var unit = _chemistryFactory.UnitMapper.Map(esdatModel, chemistry);
                ODM2EntityLinker.Link(result, unit);

                // Variable
                var variable = _chemistryFactory.VariableMapper.Map(esdatModel, chemistry);
                ODM2EntityLinker.Link(result, variable);

                // Datasets Result
                {
                    var datasetsResult = _chemistryFactory.DatasetsResultMapper.Map(esdatModel);
                    ODM2EntityLinker.Link(result, datasetsResult);

                    var dataset = _chemistryFactory.DatasetMapper.Map(esdatModel);
                    ODM2EntityLinker.Link(datasetsResult, dataset);
                }

                // Processing Level
                var processingLevel = _chemistryFactory.ProcessingLevelMapper.Map(esdatModel);
                ODM2EntityLinker.Link(result, processingLevel);

                // Measurement Result
                {
                    var measurementResult = _chemistryFactory.MeasurementResultMapper.Map(esdatModel, chemistry);
                    ODM2EntityLinker.Link(result, measurementResult);

                    ODM2EntityLinker.Link(measurementResult, unit);

                    var measurementResultValue = _chemistryFactory.MeasurementResultValueMapper.Map(esdatModel, chemistry);
                    ODM2EntityLinker.Link(measurementResult, measurementResultValue);
                }

                // Result Extension Property Values
                {
                    var properties = new Dictionary <string, string>();

                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeySampleCode]      = chemistry.SampleCode;
                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyPrefix]          = chemistry.Prefix;
                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyTotalOrFiltered] = chemistry.TotalOrFiltered;
                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyResultType]      = chemistry.ResultType;
                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQL]             = chemistry.EQL.ToString();
                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyEQLUnits]        = chemistry.EQLUnits;
                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyComments]        = chemistry.Comments;
                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyUCL]             = chemistry.UCL.ToString();
                    properties[ESDATChemistryConstants.ResultExtensionPropertyValueKeyLCL]             = chemistry.LCL.ToString();

                    foreach (var property in properties)
                    {
                        var extensionProperty = _chemistryFactory.ExtensionPropertyMapper.Map(property.Key);

                        var propertyID    = extensionProperty.PropertyID;
                        var propertyValue = property.Value;
                        var resultExtensionPropertyValue = _chemistryFactory.ResultExtensionPropertyValueMapper.Map(propertyID, propertyValue);

                        ODM2EntityLinker.Link(result, resultExtensionPropertyValue);
                    }
                }
            }

            // Action Bies
            {
                ActionBy actionBy = _chemistryFactory.ActionByMapper.Map(esdatModel);
                ODM2EntityLinker.Link(entity, actionBy);

                var person = _chemistryFactory.PersonMapper.Map(esdatModel);
                _chemistryFactory.AffiliationMapper.Person = person;

                var affiliation = _chemistryFactory.AffiliationMapper.Map(esdatModel);

                ODM2EntityLinker.Link(actionBy, affiliation);
            }

            // Method
            {
                var method = _chemistryFactory.MethodMapper.Map(esdatModel, chemistry);
                ODM2EntityLinker.Link(entity, method);

                _chemistryFactory.OrganizationMapper.SampleFileData = SampleFileData;
                var organization = _chemistryFactory.OrganizationMapper.Map(esdatModel, chemistry);
                ODM2EntityLinker.Link(method, organization);
            }

            // Related Actions
            _chemistryFactory.RelatedActionMapper.SetRelationship(entity, _WQDefaultValueProvider.ActionRelationshipTypeCVChemistry, ParentAction);
            RelatedAction relatedAction = _chemistryFactory.RelatedActionMapper.Map(esdatModel);

            ODM2EntityLinker.Link(entity, relatedAction);

            return(entity);
        }
        public Result Map(ESDATModel esdatModel, ChemistryFileData chemistry)
        {
            var result = Draft(esdatModel, chemistry);

            return(result);
        }