예제 #1
0
        public override void Execute()
        {
            base.Execute();

            var f = (DatabaseEntity)_factory.CreateNewFilter("New Filter " + Guid.NewGuid());

            if (_host != null && _container == null)
            {
                if (_host.RootFilterContainer_ID == null)
                {
                    _host.CreateRootContainerIfNotExists();
                }

                _container = _host.RootFilterContainer;
            }

            if (_container != null)
            {
                _container.AddChild((IFilter)f);
            }

            Publish((DatabaseEntity)_container ?? f);
            Emphasise(f);
            Activate(f);
        }
예제 #2
0
        public override void Execute()
        {
            base.Execute();

            var f = (DatabaseEntity)_factory.CreateNewFilter("New Filter " + Guid.NewGuid());

            if (_container != null)
            {
                _container.AddChild((IFilter)f);
            }

            Publish(f);
            Activate(f);
        }
예제 #3
0
파일: FilterImporter.cs 프로젝트: rkm/RDMP
        /// <summary>
        /// Creates a copy of the <paramref name="fromMaster"/> filter and any parameters it might have.  This will handle collisions on parameter name with
        /// <paramref name="existingFiltersAlreadyInScope"/> and will respect any globals this class was constructed with.
        /// </summary>
        /// <param name="fromMaster"></param>
        /// <param name="existingFiltersAlreadyInScope"></param>
        /// <returns></returns>
        public IFilter ImportFilter(IFilter fromMaster, IFilter[] existingFiltersAlreadyInScope)
        {
            var extractionFilter = fromMaster as ExtractionFilter;

            if (extractionFilter != null && extractionFilter.ExtractionInformation.ColumnInfo == null)
            {
                throw new Exception("Could not import filter " + extractionFilter + " because it could not be traced back to a ColumnInfo");
            }

            //If user is trying to publish a filter into the Catalogue as a new master top level filter, make sure it is properly documented
            if (_factory is ExtractionFilterFactory)
            {
                string reason;
                if (!IsProperlyDocumented(fromMaster, out reason))
                {
                    throw new Exception("Cannot clone filter called '" + fromMaster.Name + "' because:" + reason);
                }
            }

            //Handle problems with existing filters
            existingFiltersAlreadyInScope = existingFiltersAlreadyInScope ?? new IFilter[0];

            if (existingFiltersAlreadyInScope.Contains(fromMaster))
            {
                throw new ArgumentException("Master filter (that you are trying to import) cannot be part of the existing filters collection!");
            }

            //Ensure that the new filter has a unique name within the scope
            string name = fromMaster.Name;

            while (existingFiltersAlreadyInScope.Any(f => f.Name.Equals(name)))
            {
                name = "Copy of " + name;
            }

            //create the filter
            var newFilter = _factory.CreateNewFilter(name);

            //Now copy across all the values from the master
            newFilter.Description = fromMaster.Description;
            newFilter.IsMandatory = fromMaster.IsMandatory;
            newFilter.WhereSQL    = fromMaster.WhereSQL;

            //if we are down cloning from a master ExtractionFilter so record that the new filter is
            if (fromMaster is ExtractionFilter)
            {
                newFilter.ClonedFromExtractionFilter_ID = fromMaster.ID;//make the new filters parent the master
            }
            //if we are up cloning we are publishing a child into being a new master catalogue filter (ExtractionFilter)
            if (newFilter is ExtractionFilter)
            {
                newFilter.Description += Environment.NewLine + " Published by " + Environment.UserName + " on " + DateTime.Now + " from object " + fromMaster.GetType().Name + " with ID " + fromMaster.ID;
                fromMaster.ClonedFromExtractionFilter_ID = newFilter.ID;//Make the newly created master our parent (since we are published)
            }

            newFilter.SaveToDatabase();

            //If there are some filters already in scope then we need to take into account their parameters when it comes to importing, so fetch a union of all the parameters
            var existingFiltersParametersAlreadyInScope = existingFiltersAlreadyInScope.SelectMany(f => f.GetAllParameters()).ToArray();

            //now create parameters while respecting globals
            var parameterCreator = new ParameterCreator(_factory, _globals, AlternateValuesToUseForNewParameters ?? fromMaster.GetAllParameters());

            parameterCreator.CreateAll(newFilter, existingFiltersParametersAlreadyInScope); //Create the parameters while handling the existing parameters in scope

            return(newFilter);
        }