public void DP002ResolveSchemaDependenciesWithWarnings(DP002TransformDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given a source model"
            .x(() =>
            {
                model = TestHelper.CreateDefaultModelForAnalyzing();

                foreach (var application in model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications)
                {
                    application.Application.Schemas.Clear();
                }
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an analyzer"
            .x(() => analyzer = new DP002TransformDependencyAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be no context errors"
            .x(() => context.Errors.Should().HaveCount(0));

            "And report resource node should have warnings"
            .x(() =>
            {
                // Get the maps
                var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

                var map1 = group.Applications[0].Application.Transforms[0];
                map1.Should().NotBeNull();
                map1.Name.Should().Be("Transform1");
                map1.Resource.ReportMessages.Should().HaveCount(2);
                map1.Resource.ResourceRelationships.Should().HaveCount(2);

                var map2 = group.Applications[0].Application.Transforms[1];
                map2.Should().NotBeNull();
                map2.Name.Should().Be("Transform2");
                map2.Resource.ReportMessages.Should().HaveCount(2);
                map2.Resource.ResourceRelationships.Should().HaveCount(2);
            });
        }
Ejemplo n.º 2
0
        private void DiscoverAssemblyContents(AzureIntegrationServicesModel model, MigrationContext context)
        {
            // Iterate through the applications and discover the contents of the assemblies.
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingDiscoveryAsTheSourceModelIsMissing, nameof(AssemblyDiscoverer));
            }
            else
            {
                foreach (var application in group.Applications)
                {
                    _logger.LogDebug(TraceMessages.DiscoveringAssemblyContentsInResourceContainer, application.ResourceContainerKey);

                    // Find assemblies associated with this application
                    var assemblies = from msiResourceContainer in model.MigrationSource.ResourceContainers
                                     from cabResourceContainer in msiResourceContainer.ResourceContainers
                                     from assemblyResourceContainers in cabResourceContainer.ResourceContainers
                                     from assembly in application.Application.Assemblies
                                     where assembly.ResourceContainerKey == assemblyResourceContainers.Key &&
                                     assemblyResourceContainers.Type == ModelConstants.ResourceContainerAssembly
                                     select assemblyResourceContainers;

                    // Iterate through the assemblies discovered for each application.
                    foreach (var assembly in assemblies)
                    {
                        try
                        {
                            _logger.LogDebug(TraceMessages.DiscoveringTheResourcesInAssemblyCointainer, assembly.Name);

                            // Check to ensure the assembly is a managed (.Net) assembly
                            if (IsManagedAssembly(assembly.ContainerLocation))
                            {
                                using (var assemblyDefinition = AssemblyDefinition.ReadAssembly(assembly.ContainerLocation))
                                {
                                    // Loads the components that are packaged into a BizTalk assembly, adding them to the assembly container.
                                    LoadSchemas(assemblyDefinition, application, assembly);
                                    LoadTransforms(assemblyDefinition, application, assembly);
                                    LoadReceivePipelines(assemblyDefinition, application, assembly);
                                    LoadSendPipelines(assemblyDefinition, application, assembly);
                                    LoadOrchestrations(assemblyDefinition, application, assembly);
                                }
                            }
                            else
                            {
                                // Log and skip
                                _logger.LogInformation(InformationMessages.UnmanagedAssemblyDiscovered, assembly.Name);
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToLoadAssembly, assembly.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses the receive pipeline data stored as XML in the bindings.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The migration context.</param>
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(ReceivePortPipelineDataParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(ReceivePortPipelineDataParser));

                foreach (var application in group.Applications)
                {
                    // Defensive check
                    if (application.Application.Bindings == null)
                    {
                        _logger.LogWarning(WarningMessages.BindingInfoNotFound, application.Application.Name);
                        continue;
                    }

                    if (application.Application.Bindings.BindingInfo.ReceivePortCollection != null)
                    {
                        foreach (var receivePort in application.Application.Bindings.BindingInfo.ReceivePortCollection)
                        {
                            _logger.LogDebug(TraceMessages.ParsingBizTalkSendPipelineCustomConfigurationForReceivePort, receivePort.Name);

                            receivePort.SendPipelineCustomConfiguration = ParsePipelineData(application, receivePort.Name, receivePort.SendPipelineData, PipelineDirection.Send, context.Errors);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(ReceivePortPipelineDataParser));
            }
        }
Ejemplo n.º 4
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(PipelineComponentParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(PipelineComponentParser));

                foreach (var pipeline in group.Applications.SelectMany(a => a.Application.Pipelines).Where(p => p.Components != null))
                {
                    var pipelineType = pipeline.Direction == Types.Enumerations.PipelineDirection.Send ? ModelConstants.ResourceDefinitionSendPipeline : ModelConstants.ResourceReceivePipeline;

                    // Find the resource for the pipeline.
                    var pipelineResource = model.FindResourceByKey(pipeline.ResourceKey);

                    if (pipelineResource != null)
                    {
                        // Loop through all of the components.
                        var stageComponents = Document.FindStageComponents(pipeline.Document);
                        foreach (var stageComponent in stageComponents)
                        {
                            var resourceName = stageComponent.ComponentName;
                            var resourceKey  = string.Concat(pipelineResource.Key, ":", resourceName);

                            // Create the component resource.
                            var pipelineComponentResource = new ResourceItem
                            {
                                Name        = resourceName,
                                Key         = resourceKey,
                                Type        = ModelConstants.ResourcePipelineComponent,
                                Description = stageComponent.Description,
                                ParentRefId = pipelineResource.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            stageComponent.Resource = pipelineComponentResource;     // Maintain pointer to the resource.
                            pipelineComponentResource.SourceObject = stageComponent; // Maintain backward pointer.
                            stageComponent.ResourceKey             = resourceKey;
                            pipelineResource.Resources.Add(pipelineComponentResource);

                            _logger.LogDebug(TraceMessages.ResourceCreated, nameof(PipelineComponentParser), pipelineComponentResource.Key, pipelineComponentResource.Name, pipelineComponentResource.Type, pipelineResource.Key);
                        }
                    }
                    else
                    {
                        var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResource, pipelineType, pipeline.ResourceKey);
                        _logger.LogError(error);
                        context.Errors.Add(new ErrorMessage(error));
                    }
                }
                _logger.LogDebug(TraceMessages.CompletedParser, nameof(PipelineComponentParser));
            }
        }
Ejemplo n.º 5
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            // Null check
            _ = context ?? throw new ArgumentNullException(nameof(context));

            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(BindingFileParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(BindingFileParser));

                foreach (var application in group.Applications)
                {
                    try
                    {
                        // Defensive check
                        if (application.Application.Bindings == null)
                        {
                            _logger.LogWarning(WarningMessages.BindingInfoNotFound, application.Application.Name);
                            continue;
                        }

                        _logger.LogDebug(TraceMessages.ParsingBizTalkBindingFileFromResourceContainer, application.Application.Bindings.ResourceContainerKey);

                        var bindingResourceDefinition = model.FindResourceDefinitionByKey(application.Application.Bindings.ResourceDefinitionKey, ModelConstants.ResourceDefinitionBindings);

                        if (bindingResourceDefinition != null)
                        {
                            var bindingInfo = BindingInfo.FromXml((string)bindingResourceDefinition.ResourceContent);
                            application.Application.Bindings.BindingInfo = bindingInfo;

                            ParseServiceBindings(bindingInfo, bindingResourceDefinition);
                        }
                        else
                        {
                            var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionBindings, application.Application.Bindings.ResourceDefinitionKey);
                            _logger.LogError(error);
                            context.Errors.Add(new ErrorMessage(error));
                        }
                    }
                    catch (Exception ex)
                    {
                        var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorReadingBindingInfo, application.Application.Name, ex.Message);
                        context.Errors.Add(new ErrorMessage(message));
                        _logger.LogError(message);
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(BindingFileParser));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Implements the internal parsing logic.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The migration context.</param>
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications != null)
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(OrchestrationServiceLinkTypeParser));

                foreach (var application in group.Applications)
                {
                    // Loop through all of the orchestrations.
                    foreach (var orchestration in application.Application.Orchestrations)
                    {
                        // Find the module for the orchestration.
                        var moduleResource = orchestration.Model?.Resource?.FindResourcesByType(ModelConstants.ResourceModule).SingleOrDefault();
                        if (moduleResource != null)
                        {
                            foreach (var serviceLinkType in orchestration.FindServiceLinkTypes())
                            {
                                var resourceName = serviceLinkType.FindPropertyValue(MetaModelConstants.PropertyKeyName);
                                var resourceKey  = string.Concat(moduleResource.Key, ":", resourceName);

                                var serviceLinkTypeResource = new ResourceItem
                                {
                                    Name        = resourceName,
                                    Key         = resourceKey,
                                    Type        = ModelConstants.ResourceServiceLinkType,
                                    ParentRefId = moduleResource.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                serviceLinkType.Resource             = serviceLinkTypeResource; // Maintain pointer to resource.
                                serviceLinkTypeResource.SourceObject = serviceLinkType;         // Maintain backward pointer.
                                moduleResource.Resources.Add(serviceLinkTypeResource);

                                _logger.LogTrace(TraceMessages.ResourceCreated, nameof(OrchestrationServiceLinkTypeParser), serviceLinkTypeResource.Key, serviceLinkTypeResource.Name, serviceLinkTypeResource.Type, moduleResource.Key);
                            }
                        }
                        else
                        {
                            var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResource, ModelConstants.ResourceModule, orchestration.ResourceDefinitionKey);
                            _logger.LogError(error);
                            context.Errors.Add(new ErrorMessage(error));
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(OrchestrationServiceLinkTypeParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(OrchestrationServiceLinkTypeParser));
            }
        }
Ejemplo n.º 7
0
        public void GetIncorrectlyTypedModelWithSuccess(AzureIntegrationServicesModel model, Collection sourceModel, Exception e)
        {
            "Given a model"
            .x(() => model = _model);

            "When getting the source model"
            .x(() => e = Record.Exception(() => sourceModel = model.GetSourceModel <Collection>()));

            "Then getting the source model should succeed"
            .x(() => e.Should().BeNull());

            "And the source model contains a null value"
            .x(() => sourceModel.Should().BeNull());
        }
Ejemplo n.º 8
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(ApplicationDefinitionParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(ApplicationDefinitionParser));

                foreach (var application in group.Applications)
                {
                    try
                    {
                        // Defensive check
                        if (application.Application.ApplicationDefinition == null)
                        {
                            _logger.LogWarning(WarningMessages.ApplicationDefinitionNotFound, application.Application.Name);
                            continue;
                        }

                        _logger.LogDebug(TraceMessages.ParsingBizTalkApplicationDefinitionFileFromResourceContainer, application.Application.ApplicationDefinition.ResourceContainerKey);

                        var adf = from resourceContainer in model.MigrationSource.ResourceContainers
                                  from resourceDefinition in resourceContainer.ResourceDefinitions
                                  where resourceContainer.Key == application.ResourceContainerKey &&
                                  application.Application.ApplicationDefinition.ResourceContainerKey == resourceContainer.Key &&
                                  application.Application.ApplicationDefinition.ResourceDefinitionKey == resourceDefinition.Key &&
                                  resourceDefinition.Type == ModelConstants.ResourceDefinitionApplicationDefinition
                                  select resourceDefinition;

                        var adfResourceDefinition = adf.Single();
                        var applicationDefinition = ApplicationDefinition.FromXml((string)adfResourceDefinition.ResourceContent);
                        application.Application.ApplicationDefinition.ApplicationDefinition = applicationDefinition;
                    }
                    catch (Exception ex)
                    {
                        var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorReadingApplicationDefinition, application.Application.Name, ex.Message);
                        context.Errors.Add(new ErrorMessage(message));
                        _logger.LogError(message);
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(ApplicationDefinitionParser));
            }
        }
        public void DP004ResolveApplicationDependenciesWithSuccess(DP004ApplicationDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given a source model"
            .x(() =>
            {
                model = TestHelper.CreateDefaultModelForAnalyzing();
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an analyzer"
            .x(() => analyzer = new DP004ApplicationDependencyAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be no context errors"
            .x(() => context.Errors.Should().HaveCount(0));

            "And report resource node should have the expected relationships created"
            .x(() =>
            {
                // Test the applications
                var applications = model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications;
                applications.Should().NotBeNull().And.HaveCount(3);

                applications[0].Application.ApplicationDefinition.Resource.ReportMessages.Should().HaveCount(0);
                applications[0].Application.ApplicationDefinition.Resource.ResourceRelationships.Should().HaveCount(0);

                applications[1].Application.ApplicationDefinition.Resource.ReportMessages.Should().HaveCount(0);
                applications[1].Application.ApplicationDefinition.Resource.ResourceRelationships.Should().HaveCount(1);
                applications[1].Application.ApplicationDefinition.Resource.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencesTo);
                applications[1].Application.ApplicationDefinition.Resource.ResourceRelationships[0].ResourceRefId.Should().Be(applications[2].Application.ApplicationDefinition.Resource.RefId);

                applications[2].Application.ApplicationDefinition.Resource.ReportMessages.Should().HaveCount(0);
                applications[2].Application.ApplicationDefinition.Resource.ResourceRelationships.Should().HaveCount(1);
                applications[2].Application.ApplicationDefinition.Resource.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencedBy);
                applications[2].Application.ApplicationDefinition.Resource.ResourceRelationships[0].ResourceRefId.Should().Be(applications[1].Application.ApplicationDefinition.Resource.RefId);
            });
        }
        public void DP005ResolveDistributionListDependenciesWithSuccess(DP005DistributionListDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given a source model"
            .x(() =>
            {
                model = TestHelper.CreateDefaultModelForAnalyzing();
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an analyzer"
            .x(() => analyzer = new DP005DistributionListDependencyAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be no context errors"
            .x(() => context.Errors.Should().HaveCount(0));

            "And resources should have the expected relationships created"
            .x(() =>
            {
                // Test the applications
                var applications = model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications;
                applications.Should().NotBeNull().And.HaveCount(3);

                var distributionList = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceDistributionList).Single();
                var sendPort         = model.FindAllResources().Where(r => r.Type == ModelConstants.ResourceSendPort).Single();

                // Check that the DL has a relationship to the send port
                distributionList.ResourceRelationships.Count.Should().Be(1);
                distributionList.ResourceRelationships[0].ResourceRefId.Should().Be(sendPort.RefId);
                distributionList.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.CallsTo);

                // Check that the SP has a relationship to the DL
                sendPort.ResourceRelationships.Count.Should().Be(1);
                sendPort.ResourceRelationships[0].ResourceRefId.Should().Be(distributionList.RefId);
                sendPort.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.CalledBy);
            });
        }
        public void DP001ResolveContextPropertyDependenciesWithWarnings(DP001SchemaDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given a source model"
            .x(() =>
            {
                model = TestHelper.CreateDefaultModelForAnalyzing();

                var schemas = model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications.SelectMany(a => a.Application.Schemas);
                foreach (var schema in schemas)
                {
                    if (schema.SchemaType == Types.Enumerations.BizTalkSchemaType.Property)
                    {
                        schema.ContextProperties.Clear();
                    }
                }
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an analyzer"
            .x(() => analyzer = new DP001SchemaDependencyAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be no context errors"
            .x(() => context.Errors.Should().HaveCount(0));

            "And report resource node should have warnings"
            .x(() =>
            {
                // Check the application resource has been created.
                var group   = (ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel;
                var schemas = group.Applications[0].Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Document).ToList();
                schemas.Should().HaveCount(3);
                schemas[0].Resource.ReportMessages.Should().HaveCountGreaterThan(0);
                schemas[1].Resource.ReportMessages.Should().HaveCount(0);
            });
        }
Ejemplo n.º 12
0
        public void GetTypedModelWithSuccess(AzureIntegrationServicesModel model, string sourceModel, Exception e)
        {
            "Given a model"
            .x(() => model = _model);

            "When getting the source model"
            .x(() => e = Record.Exception(() => sourceModel = model.GetSourceModel <string>()));

            "Then getting the source model should succeed"
            .x(() => e.Should().BeNull());

            "And the source model contains the expected value"
            .x(() =>
            {
                sourceModel.Should().NotBeNullOrEmpty();
                sourceModel.Should().Be("My Source Model Object");
            });
        }
        public void DP002ResolveSchemaDependenciesWithNoSchemaResourcesWithErrors(DP002TransformDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            var invalidKey = "invalidkey";

            "Given a source model"
            .x(() =>
            {
                model = TestHelper.CreateDefaultModelForAnalyzing();

                // Corrupt the keys for the schemas.
                var parsedApplicationGroup = model.GetSourceModel <ParsedBizTalkApplicationGroup>();
                var schemas = parsedApplicationGroup.Applications.Where(a => a.Application.Schemas != null).SelectMany(a => a.Application.Schemas);
                foreach (var schema in schemas)
                {
                    schema.ResourceKey = string.Concat(invalidKey, Guid.NewGuid());
                    schema.Resource    = null;
                }
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an analyzer"
            .x(() => analyzer = new DP002TransformDependencyAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be 2 context errors"
            .x(() =>
            {
                context.Errors.Should().HaveCount(4);
                context.Errors[0].Message.Should().Contain(invalidKey);
                context.Errors[1].Message.Should().Contain(invalidKey);
                context.Errors[2].Message.Should().Contain(invalidKey);
                context.Errors[3].Message.Should().Contain(invalidKey);
            });
        }
Ejemplo n.º 14
0
        public void GetValueTypedModelWithSuccess(AzureIntegrationServicesModel model, int sourceModel, Exception e)
        {
            "Given a model"
            .x(() =>
            {
                model = _model;
                model.MigrationSource.MigrationSourceModel = 12;
            });

            "When getting the source model"
            .x(() => e = Record.Exception(() => sourceModel = model.GetSourceModel <int>()));

            "Then getting the source model should succeed"
            .x(() => e.Should().BeNull());

            "And the source model contains the expected integer value"
            .x(() =>
            {
                sourceModel.Should().Be(12);
            });
        }
        public void DP002ResolveSchemaDependenciesWithNoTransformResourceDefinitionWithErrors(DP002TransformDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            var invalidKey = "invalidkey";

            "Given a source model"
            .x(() => model = TestHelper.CreateDefaultModelForAnalyzing());

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an analyzer"
            .x(() => analyzer = new DP002TransformDependencyAnalyzer(model, context, logger));

            "And transform resource definition has incorrect key"
            .x(() =>
            {
                var transform         = model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications[0].Application.Transforms[0];
                transform.Resource    = null;
                transform.ResourceKey = invalidKey;
            });

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be an error in the migration context"
            .x(() => context.Errors.Should().HaveCount(1));

            "And report node should not have the expected relationships created"
            .x(() =>
            {
                context.Errors.Should().HaveCount(1);
                context.Errors[0].Message.Should().Contain(invalidKey);
            });
        }
        public void DP004ResolveApplicationDependenciesWithNoReferencingApplicationResourceWithErrors(DP004ApplicationDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given a source model with an application resource with the wrong key"
            .x(() =>
            {
                model     = TestHelper.CreateDefaultModelForAnalyzing();
                var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();
                group.Applications[1].Application.ApplicationDefinition.Resource = null;      // Lose pointer to the resource.
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an analyzer"
            .x(() => analyzer = new DP004ApplicationDependencyAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be an error"
            .x(() => context.Errors.Should().HaveCount(1));

            "And report resource node should not have the expected relationships created"
            .x(() =>
            {
                // Test the errors
                context.Errors.Count.Should().Be(1);
                context.Errors[0].Message.Should().Contain("app-resource-2");
            });
        }
        /// <summary>
        /// Implements the internal logic of the parser.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The migration context.</param>
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            // Get the applications from the source model.
            var parsedApplications = model.GetSourceModel <ParsedBizTalkApplicationGroup>()?.Applications;

            if (parsedApplications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(DocumentSchemaParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(DocumentSchemaParser));

                // Iterate through the applications and then through the parsed schemas.
                foreach (var application in parsedApplications)
                {
                    var applicationResource = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    foreach (var schema in application.Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Document))
                    {
                        _logger.LogDebug(TraceMessages.ParsingBizTalkDocumentSchema, schema.Name);

                        // Find resource definition
                        var resourceDefinition = model.FindResourceDefinitionByKey(schema.ResourceDefinitionKey, ModelConstants.ResourceDefinitionSchema);
                        if (resourceDefinition != null)
                        {
                            var schemaResource = new ResourceItem()
                            {
                                Name        = schema.Name,
                                Description = schema.XmlNamespace,
                                Type        = ModelConstants.ResourceDocumentSchema,
                                Key         = schema.ResourceKey,
                                ParentRefId = resourceDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            schema.Resource             = schemaResource; // Maintain pointer to the resource.
                            schemaResource.SourceObject = schema;         // Maintain backward pointer.
                            schemaResource.Properties.Add(ResourceItemProperties.XmlNamespaceProperty, schema.XmlNamespace);
                            schemaResource.Properties.Add(ResourceItemProperties.DotnetTypeNameProperty, schema.FullName);
                            schemaResource.Properties.Add(ResourceItemProperties.NumberOfRootNodesProperty, schema.MessageDefinitions.Count.ToString(CultureInfo.CurrentCulture));
                            schemaResource.Properties.Add(ResourceItemProperties.IsEnvelopeProperty, schema.IsEnvelope.ToString());

                            if (schema.IsEnvelope)
                            {
                                schemaResource.Properties.Add(ResourceItemProperties.BodyXPathProperty, schema.BodyXPath);
                            }

                            // Add the message definitions.
                            foreach (var messageDefinition in schema.MessageDefinitions)
                            {
                                _logger.LogDebug(TraceMessages.ParsingMessageTypeDefinition, messageDefinition.MessageType);

                                var messageDefResource = new ResourceItem()
                                {
                                    Name        = messageDefinition.RootElementName,
                                    Description = messageDefinition.MessageType,
                                    Type        = ModelConstants.ResourceMessageType,
                                    Key         = messageDefinition.ResourceKey,
                                    ParentRefId = schemaResource.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                messageDefinition.Resource      = messageDefResource; // Maintain pointer to the resource.
                                messageDefResource.SourceObject = messageDefinition;  // Maintain backward pointer.
                                messageDefResource.Properties.Add(ResourceItemProperties.RootNodeNameProperty, messageDefinition.RootElementName);
                                messageDefResource.Properties.Add(ResourceItemProperties.XmlNamespaceProperty, messageDefinition.XmlNamespace);

                                schemaResource.Resources.Add(messageDefResource);
                            }

                            resourceDefinition.Resources.Add(schemaResource);

                            if (applicationResource != null)
                            {
                                applicationResource.AddRelationship(new ResourceRelationship(schemaResource.RefId, ResourceRelationshipType.Child));
                                schemaResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }
                        }
                        else
                        {
                            _logger.LogError(ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionSchema, schema.ResourceDefinitionKey);
                            context.Errors.Add(new ErrorMessage(string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionSchema, schema.ResourceDefinitionKey)));
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(DocumentSchemaParser));
            }
        }
Ejemplo n.º 18
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(BizTalkApplicationParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(BizTalkApplicationParser));

                foreach (var application in group.Applications)
                {
                    try
                    {
                        // Defensive check
                        if (application.Application.ApplicationDefinition == null)
                        {
                            _logger.LogWarning(WarningMessages.ApplicationDefinitionNotFound, application.Application.Name);
                            continue;
                        }

                        _logger.LogDebug(TraceMessages.ParsingBizTalkApplicationFromResourceContainer, application.Application.ApplicationDefinition.ResourceContainerKey);

                        var adf = from resourceContainer in model.MigrationSource.ResourceContainers
                                  from resourceDefinition in resourceContainer.ResourceDefinitions
                                  where resourceContainer.Key == application.ResourceContainerKey &&
                                  application.Application.ApplicationDefinition.ResourceContainerKey == resourceContainer.Key &&
                                  application.Application.ApplicationDefinition.ResourceDefinitionKey == resourceDefinition.Key &&
                                  resourceDefinition.Type == ModelConstants.ResourceDefinitionApplicationDefinition
                                  select resourceDefinition;

                        var applicationResourceDefinition = adf.SingleOrDefault();
                        if (applicationResourceDefinition == null)
                        {
                            _logger.LogWarning(WarningMessages.ApplicationDefinitionNotFound, application.Application.Name);
                            continue;
                        }

                        var applicationDefinition = application.Application.ApplicationDefinition.ApplicationDefinition ?? ApplicationDefinition.FromXml((string)applicationResourceDefinition.ResourceContent); // Only parse if not already deserialized.
                        var applicationName       = applicationDefinition.Properties.Where(p => p.Name == BizTalkApplicationParser.ApplicationDisplayNameProperty).SingleOrDefault();

                        if (applicationName != null && !string.IsNullOrWhiteSpace(applicationName.Value))
                        {
                            // Check to see if there is already an application in the source with this name (duplicate names can occur is passing multiple unrelated
                            // MSI files).
                            var duplicateApplication = model.FindResourcesByType(ModelConstants.ResourceApplication).Any(a => a.Name == applicationName.Value);

                            // Set application name
                            application.Application.Name = applicationName.Value;
                            if (duplicateApplication)
                            {
                                application.Application.Name = $"{application.Application.Name} {ResourceItemProperties.Duplicate}";
                            }

                            // Define resource key for application.
                            var resourceKey = string.Concat(applicationResourceDefinition.Key, ":", applicationName);
                            application.Application.ApplicationDefinition.ResourceKey = resourceKey;

                            // Create the application resource under the application definition resource.
                            var applicationResource = new ResourceItem
                            {
                                Name        = applicationName.Value,
                                Description = applicationDefinition.Properties.Where(p => p.Name == BizTalkApplicationParser.ApplicationDescriptionProperty).SingleOrDefault()?.Value,
                                Key         = resourceKey,
                                Type        = ModelConstants.ResourceApplication,
                                ParentRefId = applicationResourceDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            application.Application.ApplicationDefinition.Resource = applicationResource; // Maintain pointer to the resource.
                            applicationResource.SourceObject = applicationDefinition;                     // Maintain backward pointer.
                            applicationResourceDefinition.Resources.Add(applicationResource);

                            _logger.LogTrace(TraceMessages.ResourceCreated, nameof(BizTalkApplicationParser), applicationResource.Key, applicationResource.Name, applicationResource.Type, applicationResource.Key);

                            // If this does not exist then update on the source model.
                            if (application.Application.ApplicationDefinition.ApplicationDefinition == null)
                            {
                                application.Application.ApplicationDefinition.ApplicationDefinition = applicationDefinition;
                            }

                            _logger.LogDebug(TraceMessages.ParsedTheBizTalkApplicationWithName, application.Application.Name);

                            // Raise an error if this was a duplicate application
                            if (duplicateApplication)
                            {
                                // Raise an error that there is already an application with this name
                                var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.DuplicateApplicationFound, applicationName.Value);
                                context.Errors.Add(new ErrorMessage(message));
                                _logger.LogError(message);
                            }
                        }
                        else
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ApplicationNameNotFound, applicationResourceDefinition.Key);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                    catch (Exception ex)
                    {
                        var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorReadingApplicationFromAdf, application.Application.ApplicationDefinition.ResourceDefinitionKey, ex.Message);
                        context.Errors.Add(new ErrorMessage(message));
                        _logger.LogError(message);
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(BizTalkApplicationParser));
            }
        }
        public void DP002ResolveSchemaAndNoPortDependenciesWithSuccess(DP002TransformDependencyAnalyzer analyzer, ILogger logger, AzureIntegrationServicesModel model, MigrationContext context, Exception e)
        {
            "Given a source model"
            .x(() =>
            {
                model = TestHelper.CreateDefaultModelForAnalyzing();

                foreach (var application in model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications)
                {
                    if (application.Application.Bindings.BindingInfo.ReceivePortCollection != null)
                    {
                        foreach (var receivePort in application.Application.Bindings.BindingInfo.ReceivePortCollection)
                        {
                            receivePort.Transforms         = null;
                            receivePort.OutboundTransforms = null;
                        }
                    }

                    if (application.Application.Bindings.BindingInfo.SendPortCollection != null)
                    {
                        foreach (var sendPort in application.Application.Bindings.BindingInfo.SendPortCollection)
                        {
                            sendPort.Transforms        = null;
                            sendPort.InboundTransforms = null;
                        }
                    }
                }
            });

            "And a context"
            .x(() => context = TestHelper.BuildContext());

            "And a logger"
            .x(() => logger = _mockLogger.Object);

            "And an analyzer"
            .x(() => analyzer = new DP002TransformDependencyAnalyzer(model, context, logger));

            "When analyzing"
            .x(async() => e = await Record.ExceptionAsync(async() => await analyzer.AnalyzeAsync(CancellationToken.None).ConfigureAwait(false)).ConfigureAwait(false));

            "Then there should be no exception"
            .x(() => e.Should().BeNull());

            "And there should be no context errors"
            .x(() => context.Errors.Should().HaveCount(0));

            "And report resource node should have the expected relationships created"
            .x(() =>
            {
                // Get the map
                var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();
                var map   = group.Applications[0].Application.Transforms[0];

                // Test the relationships
                var schemas = group.Applications[0].Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Document).ToList();
                schemas.Should().NotBeNull();
                schemas.Should().HaveCountGreaterOrEqualTo(2);

                map.Resource.ResourceRelationships[0].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencedBy);
                map.Resource.ResourceRelationships[0].ResourceRefId.Should().Be(schemas[0].Resource.RefId);

                map.Resource.ResourceRelationships[1].ResourceRelationshipType.Should().Be(ResourceRelationshipType.ReferencesTo);
                map.Resource.ResourceRelationships[1].ResourceRefId.Should().Be(schemas[1].Resource.RefId);
            });
        }
Ejemplo n.º 20
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(BizTalkPipelineParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(BizTalkPipelineParser));

                foreach (var application in group.Applications)
                {
                    _logger.LogDebug(TraceMessages.ParsingBizTalkPipelinesInApplication, application.Application.Name);

                    var applicationResource = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    // Loop through all of the pipelines.
                    foreach (var pipeline in application.Application.Pipelines)
                    {
                        try
                        {
                            var pipelineResourceDefinition = model.FindResourceDefinitionByKey(pipeline.ResourceDefinitionKey, pipeline.Direction == PipelineDirection.Receive ? ModelConstants.ResourceDefinitionReceivePipeline : ModelConstants.ResourceDefinitionSendPipeline);

                            pipeline.Document = Document.FromXml((string)pipelineResourceDefinition.ResourceContent);

                            pipeline.ResourceKey = string.Concat(pipelineResourceDefinition.Key, ":", "pipelineresource");

                            // Create the resource.
                            var pipelineResource = new ResourceItem
                            {
                                Name        = pipeline.Name,
                                Key         = pipeline.ResourceKey,
                                Type        = pipeline.Direction == PipelineDirection.Send ? ModelConstants.ResourceSendPipeline : ModelConstants.ResourceReceivePipeline,
                                Description = pipeline.Description,
                                ParentRefId = pipelineResourceDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            pipeline.Resource             = pipelineResource; // Maintain reference to the resource.
                            pipelineResource.SourceObject = pipeline;         // Maintain backward pointer.

                            pipelineResourceDefinition.Resources.Add(pipelineResource);

                            if (applicationResource != null)
                            {
                                applicationResource.AddRelationship(new ResourceRelationship(pipelineResource.RefId, ResourceRelationshipType.Child));
                                pipelineResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }

                            _logger.LogDebug(TraceMessages.ParsedBizTalkPipeline, pipeline.FullName);
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingPipelineDocument, pipeline.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(BizTalkPipelineParser));
            }
        }
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            // Null check
            _ = context ?? throw new ArgumentNullException(nameof(context));

            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(PropertySchemaPropertyParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(PropertySchemaPropertyParser));

                foreach (var application in group.Applications)
                {
                    _logger.LogDebug(TraceMessages.ParsingBizTalkSchemasInApplication, application.Application.Name);

                    foreach (var schema in application.Application.Schemas.Where(s => s.SchemaType == BizTalkSchemaType.Property))
                    {
                        try
                        {
                            // Find resource definition
                            var resourceDefinition = model.FindResourceDefinitionByKey(schema.ResourceDefinitionKey, ModelConstants.ResourceDefinitionSchema);

                            // If the schema is empty then error and continue.
                            if (resourceDefinition == null || string.IsNullOrEmpty((string)resourceDefinition.ResourceContent))
                            {
                                var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorSchemaXmlEmpty, schema.Name, application.Application.Name);
                                context.Errors.Add(new ErrorMessage(message));
                                _logger.LogError(message);
                                continue;
                            }

                            _logger.LogDebug(TraceMessages.ParsingBizTalkPropertySchema, schema.FullName);

                            // Create the resource under the property schema's resource definition.
                            var propertySchemaResource = new ResourceItem
                            {
                                Key         = schema.ResourceKey,
                                Name        = schema.Name,
                                Description = schema.FullName,
                                Type        = ModelConstants.ResourcePropertySchema,
                                ParentRefId = resourceDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            schema.Resource = propertySchemaResource;     // Maintain pointer to the resource.
                            propertySchemaResource.SourceObject = schema; // Maintain backward pointer.
                            propertySchemaResource.Properties.Add(ResourceItemProperties.DotnetTypeNameProperty, schema.FullName);
                            propertySchemaResource.Properties.Add(ResourceItemProperties.ModuleNameProperty, schema.ModuleName);
                            resourceDefinition.Resources.Add(propertySchemaResource);

                            var xml = new XmlDocument()
                            {
                                XmlResolver = null
                            };
                            using (var sReader = new StringReader((string)resourceDefinition.ResourceContent))
                            {
                                using (var reader = XmlReader.Create(sReader, new XmlReaderSettings()
                                {
                                    XmlResolver = null
                                }))
                                {
                                    xml.Load(reader);
                                }
                            }

                            var nodes = xml.SelectNodes(@"/*[local-name()='schema']/*[local-name()='element']");

                            foreach (XmlNode propertyNode in nodes)
                            {
                                var property = new ContextProperty()
                                {
                                    PropertyName = GetAttributeValue(propertyNode, "name"),
                                    Namespace    = schema.Namespace,
                                    DataType     = GetAttributeValue(propertyNode, "type")
                                };

                                property.FullyQualifiedName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", property.Namespace, property.PropertyName);
                                property.ResourceKey        = schema.ResourceKey + ":" + property.PropertyName;
                                schema.ContextProperties.Add(property);

                                // Create the resource under the property schema's resource.
                                var contextPropertyResource = new ResourceItem
                                {
                                    Key         = property.ResourceKey,
                                    Name        = property.PropertyName,
                                    Description = property.FullyQualifiedName,
                                    Type        = ModelConstants.ResourceContextProperty,
                                    ParentRefId = propertySchemaResource.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                property.Resource = contextPropertyResource;     // Maintain pointer to the resource.
                                contextPropertyResource.SourceObject = property; // Maintain backward pointer.
                                contextPropertyResource.Properties.Add(ResourceItemProperties.DotnetTypeNameProperty, property.FullyQualifiedName);
                                contextPropertyResource.Properties.Add(ResourceItemProperties.ContextPropertyDataTypeProperty, property.DataType);
                                contextPropertyResource.Properties.Add(ResourceItemProperties.XmlNamespaceProperty, property.Namespace);
                                propertySchemaResource.Resources.Add(contextPropertyResource);

                                _logger.LogDebug(TraceMessages.ParsedTheBizTalkContextPropertyInSchema, property.FullyQualifiedName, schema.FullName);
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingSchemaXml, schema.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(PropertySchemaPropertyParser));
            }
        }
Ejemplo n.º 22
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(BizTalkOrchestrationParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(BizTalkOrchestrationParser));

                foreach (var application in group.Applications)
                {
                    _logger.LogDebug(TraceMessages.ParsingBizTalkOrchestrationsInApplication, application.Application.Name);

                    // Loop through all of the orchestrations.
                    foreach (var orchestration in application.Application.Orchestrations)
                    {
                        var applicationResource = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                        try
                        {
                            var orchestrationResourceDefinition = model.FindResourceDefinitionByKey(orchestration.ResourceDefinitionKey, ModelConstants.ResourceDefinitionOrchestration);
                            if (orchestrationResourceDefinition != null)
                            {
                                // Load metamodel
                                orchestration.Model = MetaModel.FromXml((string)orchestrationResourceDefinition.ResourceContent);

                                _logger.LogDebug(TraceMessages.ParsedBizTalkOrchestration, orchestration.FullName);

                                // Create resource for metamodel
                                var metaModelResource = new ResourceItem()
                                {
                                    Name        = orchestration.Name,
                                    Key         = string.Concat(orchestrationResourceDefinition.Key, ":", MetaModelConstants.MetaModelRootElement),
                                    Type        = ModelConstants.ResourceMetaModel,
                                    ParentRefId = orchestrationResourceDefinition.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                orchestration.Model.Resource   = metaModelResource;   // Maintain pointer to resource.
                                metaModelResource.SourceObject = orchestration.Model; // Maintain backward pointer.
                                orchestrationResourceDefinition.Resources.Add(metaModelResource);

                                if (applicationResource != null)
                                {
                                    applicationResource.AddRelationship(new ResourceRelationship(metaModelResource.RefId, ResourceRelationshipType.Child));
                                    metaModelResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                                }
                                else
                                {
                                    var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                    _logger.LogError(error);
                                    context.Errors.Add(new ErrorMessage(error));
                                }

                                _logger.LogTrace(TraceMessages.ResourceCreated, nameof(BizTalkOrchestrationParser), metaModelResource.Key, metaModelResource.Name, metaModelResource.Type, orchestrationResourceDefinition.Key);

                                var module = orchestration.FindModule();
                                if (module != null)
                                {
                                    var resourceName = module.FindPropertyValue(MetaModelConstants.PropertyKeyName);
                                    var resourceKey  = string.Concat(metaModelResource.Key, ":", resourceName);

                                    // Create resource for module
                                    var moduleResource = new ResourceItem()
                                    {
                                        Name        = resourceName,
                                        Key         = resourceKey,
                                        Type        = ModelConstants.ResourceModule,
                                        ParentRefId = metaModelResource.RefId,
                                        Rating      = ConversionRating.NotSupported
                                    };

                                    module.Resource             = moduleResource; // Maintain pointer to resource.
                                    moduleResource.SourceObject = module;         // Maintain backward pointer.
                                    metaModelResource.Resources.Add(moduleResource);

                                    _logger.LogTrace(TraceMessages.ResourceCreated, nameof(BizTalkOrchestrationParser), moduleResource.Key, moduleResource.Name, moduleResource.Type, metaModelResource.Key);
                                }
                                else
                                {
                                    var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindModuleInOrchestrationModel, orchestration.ResourceContainerKey, orchestration.FullName);
                                    _logger.LogError(error);
                                    context.Errors.Add(new ErrorMessage(error));
                                }
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionOrchestration, orchestration.ResourceDefinitionKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingMetaModel, orchestration.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(BizTalkOrchestrationParser));
            }
        }
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(DistributionListParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(DistributionListParser));

                foreach (var application in group.Applications)
                {
                    // Defensive check
                    if (application.Application.Bindings == null)
                    {
                        _logger.LogWarning(WarningMessages.BindingInfoNotFound, application.Application.Name);
                        continue;
                    }

                    _logger.LogDebug(TraceMessages.ParsingBizTalkSendPortGroupFilterForApplication, application.Application.Name);

                    var bindingFileDefinition = model.FindResourceDefinitionByKey(application.Application.Bindings.ResourceDefinitionKey, ModelConstants.ResourceDefinitionBindings);
                    var applicationResource   = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    foreach (var distributionList in application.Application.Bindings.BindingInfo.DistributionListCollection)
                    {
                        _logger.LogDebug(TraceMessages.ParsingBizTalkSendPortGroupFilterForDistributionList, distributionList.Name);

                        // Set the resource key for the distribution list.
                        distributionList.ResourceKey = string.Concat(application.Application.Bindings.ResourceDefinitionKey, ":", distributionList.Name);

                        // Create the resource under the application.
                        var distributionListResource = new ResourceItem
                        {
                            Key         = distributionList.ResourceKey,
                            Name        = distributionList.Name,
                            Description = distributionList.Description,
                            Type        = ModelConstants.ResourceDistributionList,
                            ParentRefId = bindingFileDefinition.RefId,
                            Rating      = ConversionRating.NotSupported
                        };

                        distributionList.Resource             = distributionListResource; // Maintain pointer to the resource.
                        distributionListResource.SourceObject = distributionList;         // Maintain backward pointer.

                        bindingFileDefinition.Resources.Add(distributionListResource);

                        if (applicationResource != null)
                        {
                            applicationResource.AddRelationship(new ResourceRelationship(distributionListResource.RefId, ResourceRelationshipType.Child));
                            distributionListResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                        }
                        else
                        {
                            var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                            _logger.LogError(error);
                            context.Errors.Add(new ErrorMessage(error));
                        }

                        try
                        {
                            if (!string.IsNullOrEmpty(distributionList.Filter))
                            {
                                distributionList.FilterExpression             = Filter.FromXml(distributionList.Filter);
                                distributionList.FilterExpression.ResourceKey = string.Concat(distributionList.Name, ":", "filter");

                                // Create the distribution filter resource.
                                var filterReportResource = new ResourceItem
                                {
                                    Key         = distributionList.FilterExpression.ResourceKey,
                                    Name        = distributionListResource.Name + " filter expression",
                                    Type        = ModelConstants.ResourceFilterExpression,
                                    ParentRefId = distributionListResource.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                distributionList.FilterExpression.Resource = filterReportResource;              // Maintain pointer to the resource.
                                filterReportResource.SourceObject          = distributionList.FilterExpression; // Maintain backward pointer.
                                distributionListResource.Resources.Add(filterReportResource);
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingDistributionListFilter, distributionList.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(DistributionListParser));
            }
        }
Ejemplo n.º 24
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(SendPortParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(SendPortParser));

                foreach (var application in group.Applications)
                {
                    // Defensive check
                    if (application.Application.Bindings == null)
                    {
                        _logger.LogWarning(WarningMessages.BindingInfoNotFound, application.Application.Name);
                        continue;
                    }

                    _logger.LogDebug(TraceMessages.ParsingBizTalkSendPortFiltersInApplication, application.Application.Name);

                    var bindingFileDefinition = model.FindResourceDefinitionByKey(application.Application.Bindings.ResourceDefinitionKey, ModelConstants.ResourceDefinitionBindings);
                    var applicationResource   = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    foreach (var sendPort in application.Application.Bindings.BindingInfo.SendPortCollection)
                    {
                        try
                        {
                            sendPort.ResourceKey = string.Concat(application.Application.Bindings.ResourceDefinitionKey, ":", sendPort.Name);

                            // Create the resource under the binding file.
                            var sendPortResource = new ResourceItem
                            {
                                Key         = sendPort.ResourceKey,
                                Name        = sendPort.Name,
                                Description = sendPort.Description,
                                Type        = ModelConstants.ResourceSendPort,
                                ParentRefId = bindingFileDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            sendPort.Resource             = sendPortResource; // Maintain pointer to the resource.
                            sendPortResource.SourceObject = sendPort;         // Maintain backward pointer.

                            // Static or dynamic port?
                            if (sendPort.IsStatic)
                            {
                                // Static port
                                sendPortResource.Properties.Add(ResourceItemProperties.SendPortTypeProperty, ResourceItemProperties.StaticSendPortType);
                                sendPortResource.Properties.Add(ResourceItemProperties.SendPortPrimaryTransportTypeProperty, sendPort.PrimaryTransport.TransportType?.Name);
                                sendPortResource.Properties.Add(ResourceItemProperties.SendPortPrimaryAddressProperty, sendPort.PrimaryTransport.Address);
                                if (sendPort.SecondaryTransport != null && !string.IsNullOrEmpty(sendPort.SecondaryTransport.Address))
                                {
                                    sendPortResource.Properties.Add(ResourceItemProperties.SendPortSecondaryTransportTypeProperty, sendPort.SecondaryTransport.TransportType?.Name);
                                    sendPortResource.Properties.Add(ResourceItemProperties.SendPortSecondaryAddressProperty, sendPort.SecondaryTransport.Address);
                                }
                            }
                            else
                            {
                                // Dynamic port
                                sendPortResource.Properties.Add(ResourceItemProperties.SendPortTypeProperty, ResourceItemProperties.DynamicSendPortType);
                            }

                            sendPortResource.Properties.Add(ResourceItemProperties.PortDirectionProperty, sendPort.IsTwoWay ? ResourceItemProperties.PortDirectionTwoWay : ResourceItemProperties.PortDirectionOneWay);

                            bindingFileDefinition.Resources.Add(sendPortResource);

                            if (applicationResource != null)
                            {
                                applicationResource.AddRelationship(new ResourceRelationship(sendPortResource.RefId, ResourceRelationshipType.Child));
                                sendPortResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }

                            if (!string.IsNullOrEmpty(sendPort.Filter))
                            {
                                sendPort.FilterExpression             = Filter.FromXml(sendPort.Filter);
                                sendPort.FilterExpression.ResourceKey = string.Concat(sendPort.Name, ":", "filter");

                                var filterResource = new ResourceItem
                                {
                                    Key         = sendPort.FilterExpression.ResourceKey,
                                    Name        = sendPortResource.Name + " filter expression",
                                    Type        = ModelConstants.ResourceFilterExpression,
                                    ParentRefId = sendPortResource.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                sendPort.FilterExpression.Resource = filterResource;            // Maintain pointer to the resource.
                                filterResource.SourceObject        = sendPort.FilterExpression; // Maintain backward pointer.
                                sendPortResource.Resources.Add(filterResource);

                                _logger.LogDebug(TraceMessages.ParsedBizTalkSendPortFilterExpression, sendPort.Name);
                            }
                        }
                        catch (Exception ex)
                        {
                            var message = string.Format(CultureInfo.CurrentCulture, ErrorMessages.ErrorParsingSendPort, sendPort.Name, application.Application.Name, ex.Message);
                            context.Errors.Add(new ErrorMessage(message));
                            _logger.LogError(message);
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(SendPortParser));
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Copies the source model to the target model.
        /// </summary>
        /// <param name="model">The model containing the source and target.</param>
        public static void CopySourceToTarget(AzureIntegrationServicesModel model, bool includeFtpReceive = false, bool includeFtpSend = false)
        {
            model = model ?? throw new ArgumentNullException(nameof(model));

            model.MigrationTarget.MessageBus = new ApplicationModel.Target.MessageBus
            {
                Name           = "nameMessageBus",
                Key            = ModelConstants.MessageBusLeafKey,
                ResourceMapKey = "resourceMapKeyMessageBus",
            };

            foreach (var application in model.GetSourceModel <ParsedBizTalkApplicationGroup>().Applications)
            {
                var targetApplication = new ApplicationModel.Target.Application
                {
                    Name           = application.Application.Name,
                    Key            = $"{model.MigrationTarget.MessageBus.Key}:{application.Application.Name.FormatKey()}",
                    ResourceMapKey = "application",
                };

                var schemaMessages = from schema in application.Application.Schemas
                                     from messageDefintion in schema.MessageDefinitions
                                     where schema.SchemaType == BizTalkSchemaType.Document
                                     select new { Schema = schema, MessageDefinition = messageDefintion };

                foreach (var schemaMessage in schemaMessages)
                {
                    var resourceMapKey = $"applicationMessage{application.Application.Name}{schemaMessage.MessageDefinition.LocalName}";

                    targetApplication.Messages.Add(new DocumentMessage
                    {
                        Name          = schemaMessage.MessageDefinition.LocalName,
                        MessageSchema = new MessageSchema
                        {
                            ResourceKeyRef = schemaMessage.MessageDefinition.ResourceKey,
                            Name           = schemaMessage.Schema.Name
                        },
                        Key            = $"{targetApplication.Key}:{schemaMessage.MessageDefinition.LocalName}",
                        ContentType    = MessageContentType.Xml,
                        ResourceMapKey = resourceMapKey,
                        Description    = "Schema description"
                    });
                }

                if (includeFtpReceive)
                {
                    var ftpReceiveAdapter = new AdapterEndpoint()
                    {
                        Name                   = "FTP Receive Adapter",
                        Description            = "Test FTP receive adapter",
                        Key                    = $"{targetApplication.Key}:ReceivePort1:ReceiveLocation1:{ModelConstants.AdapterEndpointLeafKey}",
                        Activator              = true,
                        AdapterProtocol        = "FTP",
                        MessageExchangePattern = MessageExchangePattern.Accept
                    };

                    ftpReceiveAdapter.Properties.Add(ModelConstants.ScenarioName, $"{targetApplication.Name}:ReceivePort1:ReceiveLocation1");
                    targetApplication.Endpoints.Add(ftpReceiveAdapter);
                }

                if (includeFtpSend)
                {
                    var ftpSendAdapter = new AdapterEndpoint()
                    {
                        Name                   = "FTP Send Adapter",
                        Description            = "Test Send receive adapter",
                        Key                    = $"{targetApplication.Key}:Test.SendPorts.SendPort1:{ModelConstants.AdapterEndpointLeafKey}",
                        Activator              = true,
                        AdapterProtocol        = "FTP",
                        MessageExchangePattern = MessageExchangePattern.Send
                    };

                    ftpSendAdapter.Properties.Add(ModelConstants.ScenarioName, $"{targetApplication.Name}:Test.SendPorts.SendPort1");
                    targetApplication.Endpoints.Add(ftpSendAdapter);
                }

                model.MigrationTarget.MessageBus.Applications.Add(targetApplication);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Parses the receive location data stored as XML in the bindings.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="context">The migration context.</param>
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(ReceivePortParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(ReceivePortParser));

                foreach (var application in group.Applications)
                {
                    // Defensive check
                    if (application.Application.Bindings == null)
                    {
                        _logger.LogWarning(WarningMessages.BindingInfoNotFound, application.Application.Name);
                        continue;
                    }

                    if (application.Application.Bindings.BindingInfo.ReceivePortCollection != null)
                    {
                        _logger.LogDebug(TraceMessages.ParsingBizTalkReceivePortCollectionInApplication, application.Application.Name);

                        var bindingFileDefinition = model.FindResourceDefinitionByKey(application.Application.Bindings.ResourceDefinitionKey, ModelConstants.ResourceDefinitionBindings);
                        var applicationResource   = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                        foreach (var receivePort in application.Application.Bindings.BindingInfo.ReceivePortCollection)
                        {
                            _logger.LogDebug(TraceMessages.ParsingBizTalkReceivePort, receivePort.Name);

                            receivePort.ResourceKey = string.Concat(application.Application.Bindings.ResourceDefinitionKey, ":", receivePort.Name);

                            // Create the resource under the binding file.
                            var receivePortResource = new ResourceItem
                            {
                                Key         = receivePort.ResourceKey,
                                Name        = receivePort.Name,
                                Description = receivePort.Description,
                                Type        = ModelConstants.ResourceReceivePort,
                                ParentRefId = bindingFileDefinition.RefId,
                                Rating      = ConversionRating.NotSupported
                            };

                            receivePort.Resource             = receivePortResource; // Maintain pointer to the resource.
                            receivePortResource.SourceObject = receivePort;         // Maintain backward pointer.
                            bindingFileDefinition.Resources.Add(receivePortResource);
                            receivePortResource.Properties.Add(ResourceItemProperties.PortDirectionProperty, receivePort.IsTwoWay ? ResourceItemProperties.PortDirectionTwoWay : ResourceItemProperties.PortDirectionOneWay);

                            if (applicationResource != null)
                            {
                                applicationResource.AddRelationship(new ResourceRelationship(receivePortResource.RefId, ResourceRelationshipType.Child));
                                receivePortResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }

                            if (receivePort.ReceiveLocations != null)
                            {
                                foreach (var receiveLocation in receivePort.ReceiveLocations)
                                {
                                    _logger.LogDebug(TraceMessages.ParsingBizTalkReceiveLocationPipelineData, receiveLocation.Name);

                                    // Extract the send pipeline custom config.
                                    receiveLocation.SendPipelineCustomConfiguration = ParsePipelineData(application, receiveLocation.Name, receiveLocation.SendPipelineData, PipelineDirection.Send, context.Errors);

                                    // Extract the receive pipeline custom config.
                                    receiveLocation.ReceivePipelineCustomConfiguration = ParsePipelineData(application, receiveLocation.Name, receiveLocation.ReceivePipelineData, PipelineDirection.Receive, context.Errors);

                                    receiveLocation.ResourceKey = string.Concat(receivePort.Name, ":", receiveLocation.Name);

                                    // Create the resource item for the receive location.
                                    var receiveLocationResource = new ResourceItem
                                    {
                                        Key         = receiveLocation.ResourceKey,
                                        Name        = receiveLocation.Name,
                                        Description = receiveLocation.Description,
                                        Type        = ModelConstants.ResourceReceiveLocation,
                                        ParentRefId = receivePortResource.RefId,
                                        Rating      = ConversionRating.NotSupported
                                    };

                                    receiveLocation.Resource             = receiveLocationResource; // Maintain pointer to the resource.
                                    receiveLocationResource.SourceObject = receiveLocation;         // Maintain backward pointer.
                                    receiveLocationResource.Properties.Add(ResourceItemProperties.PortTransportTypeProperty, receiveLocation.ReceiveLocationTransportType.Name);
                                    receiveLocationResource.Properties.Add(ResourceItemProperties.ReceiveLocationAddressProperty, receiveLocation.Address);

                                    receivePortResource.Resources.Add(receiveLocationResource);
                                }
                            }
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(ReceivePortParser));
            }
        }
Ejemplo n.º 27
0
        protected override void ParseInternal(AzureIntegrationServicesModel model, MigrationContext context)
        {
            var group = model.GetSourceModel <ParsedBizTalkApplicationGroup>();

            if (group?.Applications == null)
            {
                _logger.LogDebug(TraceMessages.SkippingParserAsTheSourceModelIsMissing, nameof(TransformParser));
            }
            else
            {
                _logger.LogDebug(TraceMessages.RunningParser, nameof(TransformParser));

                // Find all transforms in source model
                foreach (var application in group.Applications)
                {
                    var applicationResource = model.FindResourceByKey(application.Application?.ApplicationDefinition?.ResourceKey);

                    var transforms = application.Application.Transforms;
                    if (transforms != null && transforms.Any())
                    {
                        foreach (var transform in transforms)
                        {
                            // Find transform resource definition
                            var transformResourceDefinition = model.FindResourceDefinitionByKey(transform.ResourceDefinitionKey, ModelConstants.ResourceDefinitionMap);
                            if (transformResourceDefinition != null)
                            {
                                // Add transform resource to source
                                var transformResource = new ResourceItem()
                                {
                                    Name        = transform.Name,
                                    Description = transform.FullName,
                                    Key         = transformResourceDefinition.Key + ":map",
                                    Type        = ModelConstants.ResourceMap,
                                    ParentRefId = transformResourceDefinition.RefId,
                                    Rating      = ConversionRating.NotSupported
                                };

                                transform.Resource             = transformResource; // Maintain pointer to the resource.
                                transformResource.SourceObject = transform;         // Maintain backward pointer.
                                transformResourceDefinition.Resources.Add(transformResource);

                                if (applicationResource != null)
                                {
                                    applicationResource.AddRelationship(new ResourceRelationship(transformResource.RefId, ResourceRelationshipType.Child));
                                    transformResource.AddRelationship(new ResourceRelationship(applicationResource.RefId, ResourceRelationshipType.Parent));
                                }
                                else
                                {
                                    var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceApplication, application.Application?.ApplicationDefinition?.ResourceKey);
                                    _logger.LogError(error);
                                    context.Errors.Add(new ErrorMessage(error));
                                }

                                _logger.LogTrace(TraceMessages.ResourceCreated, nameof(TransformParser), transformResource.Key, transformResource.Name, transformResource.Type, transformResourceDefinition.Key);
                            }
                            else
                            {
                                var error = string.Format(CultureInfo.CurrentCulture, ErrorMessages.UnableToFindResourceDefinition, ModelConstants.ResourceDefinitionMap, transform.ResourceDefinitionKey);
                                _logger.LogError(error);
                                context.Errors.Add(new ErrorMessage(error));
                            }
                        }
                    }
                }

                _logger.LogDebug(TraceMessages.CompletedParser, nameof(TransformParser));
            }
        }