Exemple #1
0
        private void AddAdvertisedComponent(DragEventArgs e, DividerLineControl divider)
        {
            var advert = GetAdvertisedObjectFromDragOperation(e);

            if (
                //if user is trying to add a source
                advert.GetRole() == DataFlowComponentVisualisation.Role.Source
                //and there is already an explicit source or a configured one
                && (_useCase.ExplicitSource != null || _pipeline.SourcePipelineComponent_ID != null))
            {
                MessageBox.Show("There is already a source in this pipeline");
                return;
            }

            if (
                //if user is trying to add a destination
                advert.GetRole() == DataFlowComponentVisualisation.Role.Destination
                //and there is already an explicit destination or a configured one
                && (_useCase.ExplicitDestination != null || _pipeline.DestinationPipelineComponent_ID != null))
            {
                MessageBox.Show("There is already a destination in this pipeline");
                return;
            }

            Type underlyingComponentType = advert.GetComponentType();

            //add the component to the pipeline
            var repository = (ICatalogueRepository)_pipeline.Repository;
            var newcomp    = new PipelineComponent(repository, _pipeline, underlyingComponentType, -999, advert.ToString())
            {
                Order = GetOrderMakingSpaceIfNessesary(null, divider)
            };


            newcomp.CreateArgumentsForClassIfNotExists(underlyingComponentType);

            newcomp.SaveToDatabase();

            if (advert.GetRole() == DataFlowComponentVisualisation.Role.Source)
            {
                _pipeline.SourcePipelineComponent_ID = newcomp.ID;
                _pipeline.SaveToDatabase();
            }

            if (advert.GetRole() == DataFlowComponentVisualisation.Role.Destination)
            {
                _pipeline.DestinationPipelineComponent_ID = newcomp.ID;
                _pipeline.SaveToDatabase();
            }

            RefreshUIFromDatabase();


            var viz = flpPipelineDiagram.Controls.OfType <PipelineComponentVisualisation>().Single(v => Equals(v.PipelineComponent, newcomp));

            component_Selected(viz, newcomp);
        }
Exemple #2
0
        public void TestPipelineContextIsNOTAllowable()
        {
            var contextFactory = new DataFlowPipelineContextFactory <DataTable>();
            var context        = contextFactory.Create(PipelineUsage.FixedDestination);

            var pipeline  = new Pipeline(CatalogueRepository, "DeleteMePipeline");
            var component = new PipelineComponent(CatalogueRepository, pipeline, typeof(TestObject_RequiresTableInfo), 0);

            component.Name = "TestPipeComponent";
            component.SaveToDatabase();

            string reason;
            bool   rejection = context.IsAllowable(pipeline, out reason);

            Console.WriteLine(reason);

            Assert.IsFalse(rejection, reason);

            Assert.AreEqual("Component TestPipeComponent implements a forbidden type (IPipelineRequirement<TableInfo>) under the pipeline usage context", reason);

            pipeline.DeleteInDatabase();
        }