コード例 #1
0
ファイル: IndexListTest.cs プロジェクト: Robin--/Warewolf
        public void IndexList_UnitTest_CanInitNormally()
        {

            IndexList il = new IndexList(null, 5);

            Assert.AreEqual(1, il.MinValue);
            Assert.AreEqual(5, il.MaxValue);
        }
コード例 #2
0
ファイル: IndexListTest.cs プロジェクト: Robin--/Warewolf
        public void IndexList_UnitTest_CanCountCorrectlyWhenMinValueGreaterThan1()
        {

            HashSet<int> gaps = new HashSet<int> { 1, 5 };
            IndexList il = new IndexList(gaps, 4, 3);

            Assert.AreEqual(3, il.MinValue);
            Assert.AreEqual(4, il.MaxValue);
            Assert.AreEqual(1, il.Count());
        }
コード例 #3
0
ファイル: IndexListTest.cs プロジェクト: Robin--/Warewolf
        public void IndexList_UnitTest_CanInitWithGaps()
        {

            HashSet<int> gaps = new HashSet<int> { 1, 3 };
            IndexList il = new IndexList(gaps, 5);

            Assert.AreEqual(1, il.MinValue);
            Assert.AreEqual(5, il.MaxValue);
            Assert.AreEqual(3, il.Count());
        }
コード例 #4
0
ファイル: IndexListTest.cs プロジェクト: Robin--/Warewolf
        public void IndexList_UnitTest_CanSetMaxValueWhenInGaps()
        {

            HashSet<int> gaps = new HashSet<int> { 1, 5 };
            IndexList il = new IndexList(gaps, 5);

            il.SetMaxValue(5, false);

            Assert.AreEqual(1, il.MinValue);
            Assert.AreEqual(5, il.MaxValue);
            Assert.AreEqual(3, il.Count());
        }
コード例 #5
0
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTOOld(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, Guid dlID, IDataListCompiler compiler, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            ForEachType = forEachType;
            IDev2IteratorCollection colItr = Dev2ValueObjectFactory.CreateIteratorCollection();
            IndexIterator localIndexIterator;
            IndexList indexList;

            switch(forEachType)
            {
                case enForEachType.InRecordset:
                    IBinaryDataListEntry recordset = compiler.Evaluate(dlID, enActionType.User, recordsetName, false, out errors);

                    if(recordset == null || !recordset.IsRecordset)
                    {
                        errors.AddError("When selecting a recordset only valid recordsets can be used");
                        break;
                    }


                    var isEmpty = recordset.IsEmpty();
                    if(isEmpty)
                    {
                        indexList = new IndexList(new HashSet<int> { 1 }, 0);
                        localIndexIterator = new IndexIterator(new HashSet<int> { 1 }, 0);
                    }
                    else
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = 1, MaxValue = recordset.FetchLastRecordsetIndex() };
                        localIndexIterator = new IndexIterator(new HashSet<int>(), 0);
                    }

                    localIndexIterator.IndexList = indexList;
                    IndexIterator = localIndexIterator;
                    break;

                case enForEachType.InRange:
                    if(string.IsNullOrWhiteSpace(from))
                    {
                        errors.AddError("The from field can not be left empty.");
                        break;
                    }

                    if(string.IsNullOrWhiteSpace(to))
                    {
                        errors.AddError("The to field can not be left empty.");
                        break;
                    }

                    if(from.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the From field.");
                        break;
                    }

                    var fromItr = CreateDataListEvaluateIterator(from, dlID, compiler, colItr, errors);
                    colItr.AddIterator(fromItr);

                    int intFrom;
                    if(!int.TryParse(colItr.FetchNextRow(fromItr).TheValue, out intFrom) || intFrom < 1)
                    {
                        errors.AddError("From range must be a whole number from 1 onwards.");
                        break;
                    }

                    if(to.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the To field.");
                        break;
                    }

                    var toItr = CreateDataListEvaluateIterator(to, dlID, compiler, colItr, errors);
                    colItr.AddIterator(toItr);

                    int intTo;
                    if(!int.TryParse(colItr.FetchNextRow(toItr).TheValue, out intTo) || intTo < 1)
                    {
                        errors.AddError("To range must be a whole number from 1 onwards.");
                        break;
                    }
                    if(intFrom > intTo)
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo };
                        ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet<int>(), 0) { IndexList = indexList };
                        IndexIterator = revIdxItr;
                    }
                    else
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo };
                        localIndexIterator = new IndexIterator(new HashSet<int>(), 0) { IndexList = indexList };
                        IndexIterator = localIndexIterator;
                    }

                    break;
                case enForEachType.InCSV:
                    var csvIndexedsItr = CreateDataListEvaluateIterator(csvNumbers, dlID, compiler, colItr, errors);
                    colItr.AddIterator(csvIndexedsItr);
                    ErrorResultTO allErrors;
                    List<int> listOfIndexes = SplitOutCsvIndexes(colItr.FetchNextRow(csvIndexedsItr).TheValue, out allErrors);
                    if(allErrors.HasErrors())
                    {
                        errors.MergeErrors(allErrors);
                        break;
                    }
                    ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                    ListOfIndex listOfIndex = new ListOfIndex(listOfIndexes);
                    listLocalIndexIterator.IndexList = listOfIndex;
                    IndexIterator = listLocalIndexIterator;
                    break;
                default:

                    if(numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the Numbers field.");
                        break;
                    }

                    int intExNum;
                    var numOfExItr = CreateDataListEvaluateIterator(numberOfExecutes, dlID, compiler, colItr, errors);
                    colItr.AddIterator(numOfExItr);

                    if(!int.TryParse(colItr.FetchNextRow(numOfExItr).TheValue, out intExNum))
                    {
                        errors.AddError("Number of executes must be a whole number from 1 onwards.");
                    }
                    IndexIterator = new IndexIterator(new HashSet<int>(), intExNum);
                    break;
            }

        }
コード例 #6
0
 public int MaxIndex()
 {
     return(IndexList.GetMaxIndex());
 }
コード例 #7
0
 public ReverseIndexIterator(HashSet <int> gaps, int maxValue)
 {
     IndexList = new IndexList(gaps, maxValue);
     _curValue = 1;
 }
コード例 #8
0
        //MO - Changed : new ctor that accepts the new arguments
        public ForEachBootstrapTO(enForEachType forEachType, string from, string to, string csvNumbers, string numberOfExecutes, string recordsetName, IExecutionEnvironment compiler, out ErrorResultTO errors, int update)
        {
            errors = new ErrorResultTO();
            ForEachType = forEachType;
            IIndexIterator localIndexIterator;

            switch(forEachType)
            {
                case enForEachType.InRecordset:
                    
                    var records = compiler.EvalRecordSetIndexes(recordsetName, update);
                    if (!compiler.HasRecordSet(recordsetName) )
                    {
                        errors.AddError("When selecting a recordset only valid recordsets can be used");
                        break;
                    }

                        localIndexIterator = new IndexListIndexIterator(records);

                    
                    IndexIterator = localIndexIterator;
                    break;

                case enForEachType.InRange:
                    if(string.IsNullOrWhiteSpace(@from))
                    {
                        errors.AddError("The from field can not be left empty.");
                        break;
                    }

                    if(string.IsNullOrWhiteSpace(to))
                    {
                        errors.AddError("The to field can not be left empty.");
                        break;
                    }

                    if(@from.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the From field.");
                        break;
                    }

                    

                    var evalledFrom = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@from, update));
                    int intFrom;
                    if (!int.TryParse(evalledFrom, out intFrom) || intFrom < 1)
                    {
                        errors.AddError("From range must be a whole number from 1 onwards.");
                        break;
                    }

                    if(to.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the To field.");
                        break;
                    }

                    var evalledTo= ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(@to, update));
               
                    int intTo;
                    if (!int.TryParse(evalledTo, out intTo) || intTo < 1)
                    {
                        errors.AddError("To range must be a whole number from 1 onwards.");
                        break;
                    }
                    IndexList indexList;
                    if(intFrom > intTo)
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo };
                        ReverseIndexIterator revIdxItr = new ReverseIndexIterator(new HashSet<int>(), 0) { IndexList = indexList };
                        IndexIterator = revIdxItr;
                    }
                    else
                    {
                        indexList = new IndexList(new HashSet<int>(), 0) { MinValue = intFrom, MaxValue = intTo };
                        localIndexIterator = new IndexIterator(new HashSet<int>(), 0) { IndexList = indexList };
                        IndexIterator = localIndexIterator;
                    }

                    break;
                case enForEachType.InCSV:
                    var csvIndexedsItr = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(csvNumbers, update));

                    ErrorResultTO allErrors;
                    List<int> listOfIndexes = SplitOutCsvIndexes(csvIndexedsItr, out allErrors);
                    if(allErrors.HasErrors())
                    {
                        errors.MergeErrors(allErrors);
                        break;
                    }
                    ListIndexIterator listLocalIndexIterator = new ListIndexIterator(listOfIndexes);
                    ListOfIndex listOfIndex = new ListOfIndex(listOfIndexes);
                    listLocalIndexIterator.IndexList = listOfIndex;
                    IndexIterator = listLocalIndexIterator;
                    break;
                default:

                    if(numberOfExecutes != null && numberOfExecutes.Contains("(*)"))
                    {
                        errors.AddError("The Star notation is not accepted in the Numbers field.");
                        break;
                    }

                    int intExNum;
                    var numOfExItr = ExecutionEnvironment.WarewolfEvalResultToString( compiler.Eval(numberOfExecutes, update));

                    if (!int.TryParse(numOfExItr, out intExNum))
                    {
                        errors.AddError("Number of executes must be a whole number from 1 onwards.");
                    }
                    IndexIterator = new IndexIterator(new HashSet<int>(), intExNum);
                    break;
            }

        }
コード例 #9
0
ファイル: IndexIterator.cs プロジェクト: Spharah/Warewolf-ESB
 /// <summary>
 /// Initializes a new instance of the <see cref="IndexIterator"/> class.
 /// </summary>
 /// <param name="gaps">The gaps.</param>
 /// <param name="maxValue">The maximum value.</param>
 /// <param name="minValue">The minimum value.</param>
 public IndexIterator(HashSet <int> gaps, int maxValue, int minValue = 1)
 {
     IndexList = new IndexList(gaps, maxValue, minValue);
     _curValue = minValue;
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IndexIterator"/> class.
 /// </summary>
 /// <param name="gaps">The gaps.</param>
 /// <param name="maxValue">The maximum value.</param>
 /// <param name="minValue">The minimum value.</param>
 public IndexIterator(HashSet<int> gaps, int maxValue, int minValue = 1)
 {
     IndexList = new IndexList(gaps, maxValue, minValue);
     _curValue = minValue;
 }
コード例 #11
0
        /// <summary>
        /// Inits this instance.
        /// </summary>
        public void Init(int colCnt, bool createNewStorage = true)
        {
            if(createNewStorage)
            {
                _itemStorage = new BinaryDataListStorageLayer();
            }

            // Construct the alias map for this entry ;)
            _keyToAliasMap = new Dictionary<string, BinaryDataListAlias>();

            _myKeys = new IndexList(null, 1);

            _isEmpty = true;
            _internalReturnValue = new List<IBinaryDataListItem>(colCnt); // build the object we require to return data in ;)

            for(int i = 0; i < colCnt; i++)
            {
                _internalReturnValue.Add(new BinaryDataListItem(null, string.Empty));

                if(Columns != null)
                {
                    // Handle recordset
                    _internalReturnValue[i].UpdateRecordset(Namespace); // always the same namespace ;)
                    _internalReturnValue[i].UpdateField(Columns[i].ColumnName); // always the same column for this entry ;)
                }
                else
                {
                    // Handle scalars
                    _internalReturnValue[i].UpdateField(Namespace); // always the same namespace ;)
                }
            }

            // boot strap column cache ;)
            short cnt = 1;
            if(Columns != null)
            {
                cnt = (short)Columns.Count;
            }
            _strToColIdx = new Dictionary<string, int>(cnt);

        }
コード例 #12
0
 public ReverseIndexIterator(HashSet<int> gaps, int maxValue)
 {
     IndexList = new IndexList(gaps, maxValue);
     _curValue = 1;
 }
コード例 #13
0
        /// <summary>
        /// Copies the data from the clonable instance into the cloned instance ;)
        /// </summary>
        /// <param name="thisObj">The this object.</param>
        public void CopyTo(SBinaryDataListEntry thisObj)
        {

            // This is dangerous. We need to check for alias keys and use them instead ;)
            var keys = thisObj._myKeys;

            HashSet<int> gaps = keys.Gaps;
            int min = keys.MinValue;
            int max = keys.MaxValue;

            Columns = thisObj.Columns;
            _itemStorage = thisObj._itemStorage;
            // avoid referencing issues ;)
            _myKeys = new IndexList(gaps, max, min);
            DataListKey = thisObj.DataListKey;
            IsEmtpy = thisObj.IsEmtpy;
            IsRecordset = thisObj.IsRecordset;
            IsEvaluationScalar = thisObj.IsEvaluationScalar;
            Namespace = thisObj.Namespace;
            IsManagmentServicePayload = thisObj.IsManagmentServicePayload;
            _strToColIdx = thisObj._strToColIdx;
            _keyToAliasMap = thisObj._keyToAliasMap;


        }
コード例 #14
0
 public bool HasMore()
 {
     bool result = _curPos < IndexList.Count();
     return result;
 }
コード例 #15
0
ファイル: IndexListTest.cs プロジェクト: Robin--/Warewolf
        public void IndexList_UnitTest_ContainsOperatesAsExpected()
        {

            HashSet<int> gaps = new HashSet<int> { 1, 5 };
            IndexList il = new IndexList(gaps, 5);

            Assert.IsFalse(il.Contains(1));
            Assert.IsTrue(il.Contains(4));
        }
コード例 #16
0
 public int MinIndex()
 {
     return IndexList.GetMinIndex();
 }
コード例 #17
0
        public void AddAlias(Guid dlId, string parentColumn, string parentNamespace, string childColumn, out ErrorResultTO errors)
        {
            errors = new ErrorResultTO();
            // TODO : This needs to change so we can track at all levels what the root alias is ;)
            IDataListCompiler compiler = DataListFactory.CreateDataListCompiler();

            Guid masterId = dlId;
            string masterRs = parentNamespace;
            string masterCol = parentColumn;
            Guid searchId = dlId;

            IBinaryDataListEntry masterEntry = null;

            int aliasSearchRounds = 0;
            BinaryDataListAlias binaryDataListAlias = null;

            while(searchId != Guid.Empty)
            {
                ErrorResultTO invokeErrors;
                var bdl = compiler.FetchBinaryDataList(searchId, out invokeErrors);
                errors.MergeErrors(invokeErrors);


                if(bdl != null)
                {
                    string error;
                    bdl.TryGetEntry(masterRs, out masterEntry, out error);
                    errors.AddError(error);

                    if(masterEntry != null)
                    {
                        var aliases = masterEntry.FetchAlias();

                        if(aliases.TryGetValue(masterCol, out binaryDataListAlias))
                        {
                            // we have a hit ;)
                            masterId = binaryDataListAlias.MasterKeyID;
                            searchId = masterId;
                            masterRs = binaryDataListAlias.MasterNamespace;
                            masterCol = binaryDataListAlias.MasterColumn;
                            aliasSearchRounds++;
                        }
                        else
                        {
                            // ensure we copy over the alias entry's keys ;)
                            if(IsEmtpy)
                            {
                                var keyItr = masterEntry.FetchRecordsetIndexes();

                                _myKeys = new IndexList(keyItr.FetchGaps(), keyItr.MaxIndex(), keyItr.MinIndex());

                                IsEmtpy = false;
                            }

                            searchId = Guid.Empty; // signal end ;)
                        }
                    }
                    else
                    {
                        if(aliasSearchRounds == 0)
                        {
                            throw new Exception("Missing Entry");
                        }
                        // we hit the bottom earlier, handle it ;)
                        if(binaryDataListAlias != null)
                        {
                            masterEntry = binaryDataListAlias.MasterEntry;
                        }
                        searchId = Guid.Empty; // signal end ;)
                    }

                }
                else
                {
                    throw new Exception("Missing DataList");
                }
            }


            // Check MasterKeyID to see if it contains an alias, if so keep bubbling until we at end ;)
            _keyToAliasMap[childColumn] = new BinaryDataListAlias { MasterKeyID = masterId, ChildKey = GenerateKeyPrefix(Namespace, DataListKey), MasterKey = GenerateKeyPrefix(masterRs, masterId), MasterColumn = masterCol, MasterNamespace = masterRs, MasterEntry = masterEntry };
        }