示例#1
0
        BaseField CreateThridRow(BaseField second)
        {
            var third = second.GetField(Direction.Right, 3)
                        .AddField(Direction.Up)
                        .GetField(Direction.Up);

            third.AddField(Direction.Right);

            third.GetField(Direction.Right)
            .AddField(Direction.Right, new RestingField());

            third.GetField(Direction.Right, 2)
            .AddField(Direction.Right, 2);

            _forestField = new ForestField();

            third.GetField(Direction.Right, 2)
            .AddField(Direction.Down, _forestField);


            // Link Second & Third
            second.GetField(Direction.Right, 7)
            .AddField(Direction.Up, third.GetField(Direction.Right, 4));

            return(third);
        }
示例#2
0
        public override FieldObject Evaluate(RawRecord record)
        {
            FieldObject     checkObject = record[_checkFieldIndex];
            CollectionField arrayObject = record[_arrayFieldIndex] as CollectionField;

            if (arrayObject == null)
            {
                throw new GraphViewException("The second paramter of the WithInArray function must be located to a collection field");
            }
            if (checkObject == null)
            {
                return(new StringField("false", JsonDataType.Boolean));
            }

            foreach (FieldObject fieldObject in arrayObject.Collection)
            {
                if (fieldObject is Compose1Field)
                {
                    Compose1Field compose1Field = fieldObject as Compose1Field;
                    if (checkObject.Equals(compose1Field.Map[compose1Field.DefaultProjectionKey]))
                    {
                        return(new StringField("true", JsonDataType.Boolean));
                    }
                }
                else if (checkObject.Equals(fieldObject))
                {
                    return(new StringField("true", JsonDataType.Boolean));
                }
            }

            return(new StringField("false", JsonDataType.Boolean));
        }
示例#3
0
        public override RawRecord Next()
        {
            if (this.inputOp.State())
            {
                RawRecord r = this.inputOp.Next();
                if (r == null)
                {
                    this.Close();
                    return(null);
                }

                CollectionField path = r[this.pathIndex] as CollectionField;

                Debug.Assert(path != null);

                this.TreeState.Accumulate(path);

                if (!this.inputOp.State())
                {
                    this.Close();
                }
                return(r);
            }

            return(null);
        }
        public new void _selecttransactiontypes_CustomFormConfirmed(object sender, CustomFormConfirmedEventArgs e)
        {
            CollectionField <MultiSelectFormCOLLECTIONITEMSUIModel>          transactionTypes  = ((MultiSelectFormUIModel)e.Model).COLLECTIONITEMS;
            UIModelCollection <MultiSelectParametersTRANSACTIONTYPESUIModel> uiModelCollection = this.TRANSACTIONTYPES.Value;
            ValueListItemCollection <MultiSelectParametersTRANSACTIONTYPESUIModel.TRANSACTIONTYPES?> dataSource = this.TRANSACTIONTYPES.DefaultItem.TRANSACTIONTYPE.DataSource;

            uiModelCollection.Clear();
            int num1  = 0;
            int num2  = checked (transactionTypes.Value.Count - 1);
            int index = num1;

            while (index <= num2)
            {
                if (transactionTypes.Value[index].SELECTED.Value)
                {
                    uiModelCollection.Add(new MultiSelectParametersTRANSACTIONTYPESUIModel()
                    {
                        TRANSACTIONTYPE =
                        {
                            Value = dataSource[index].Value
                        }
                    });
                }
                checked { ++index; }
            }
        }
示例#5
0
        public FieldObject Terminate()
        {
            MapField result = new MapField();

            if (this.isProjectingACollection)
            {
                foreach (FieldObject key in groupedStates.Keys)
                {
                    List <FieldObject> projectFields = new List <FieldObject>();
                    foreach (RawRecord rawRecord in groupedStates[key])
                    {
                        this.groupedSourceOp.ResetState();
                        this.aggregateOp.ResetState();
                        this.tempSourceOp.ConstantSource = rawRecord;
                        this.groupedSourceOp.Next();

                        RawRecord   aggregateTraversalRecord = this.aggregateOp.Next();
                        FieldObject projectResult            = aggregateTraversalRecord?.RetriveData(0);

                        if (projectResult == null)
                        {
                            throw new GraphViewException("The property does not exist for some of the elements having been grouped.");
                        }

                        projectFields.Add(projectResult);
                    }
                    result[key] = new CollectionField(projectFields);
                }
            }
            else
            {
                foreach (KeyValuePair <FieldObject, List <RawRecord> > pair in this.groupedStates)
                {
                    FieldObject      key = pair.Key;
                    List <RawRecord> aggregatedRecords = pair.Value;
                    this.groupedSourceOp.ResetState();
                    this.aggregateOp.ResetState();

                    foreach (RawRecord record in aggregatedRecords)
                    {
                        this.tempSourceOp.ConstantSource = record;
                        this.groupedSourceOp.Next();
                    }

                    RawRecord aggregateTraversalRecord = this.aggregateOp.Next();

                    FieldObject aggregateResult = aggregateTraversalRecord?.RetriveData(0);
                    if (aggregateResult == null)
                    {
                        return(null);
                    }

                    result[key] = aggregateResult;
                }
            }

            return(result);
        }
示例#6
0
        internal override List <RawRecord> CrossApply(RawRecord record)
        {
            List <RawRecord> results = new List <RawRecord>();

            FieldObject unfoldTarget = _unfoldTarget.Evaluate(record);

            if (unfoldTarget.GetType() == typeof(CollectionField))
            {
                CollectionField cf = unfoldTarget as CollectionField;
                foreach (FieldObject fo in cf.Collection)
                {
                    if (fo == null)
                    {
                        continue;
                    }
                    RawRecord newRecord = new RawRecord();

                    // Extract only needed columns from Compose1Field
                    if (fo.GetType() == typeof(Compose1Field))
                    {
                        Compose1Field compose1Field = fo as Compose1Field;
                        foreach (string unfoldColumn in _unfoldColumns)
                        {
                            newRecord.Append(compose1Field.Map[new StringField(unfoldColumn)]);
                        }
                    }
                    else
                    {
                        newRecord.Append(fo);
                    }
                    results.Add(newRecord);
                }
            }
            else if (unfoldTarget.GetType() == typeof(MapField))
            {
                MapField mf = unfoldTarget as MapField;
                foreach (var pair in mf.Map)
                {
                    RawRecord newRecord = new RawRecord();
                    string    key       = pair.Key.ToString();
                    string    value     = pair.Value.ToString();

                    newRecord.Append(new StringField(key + "=" + value));
                    results.Add(newRecord);
                }
            }
            else
            {
                RawRecord newRecord = new RawRecord();
                newRecord.Append(unfoldTarget);
                results.Add(newRecord);
            }

            return(results);
        }
示例#7
0
        public FieldObject Terminate()
        {
            Dictionary <FieldObject, FieldObject> resultCollection = new Dictionary <FieldObject, FieldObject>(groupedStates.Count);

            if (elementPropertyProjectionIndex >= 0)
            {
                foreach (FieldObject key in groupedStates.Keys)
                {
                    List <FieldObject> projectFields = new List <FieldObject>();
                    foreach (var rawRecord in groupedStates[key])
                    {
                        FieldObject fo = rawRecord[elementPropertyProjectionIndex];
                        if (fo is PropertyField)
                        {
                            PropertyField pf = fo as PropertyField;
                            projectFields.Add(new StringField(pf.PropertyValue, pf.JsonDataType));
                        }
                        else
                        {
                            projectFields.Add(fo);
                        }
                    }
                    resultCollection[key] = new CollectionField(projectFields);
                }
            }
            else
            {
                foreach (KeyValuePair <FieldObject, List <RawRecord> > pair in groupedStates)
                {
                    FieldObject      key = pair.Key;
                    List <RawRecord> aggregatedRecords = pair.Value;
                    groupedSourceOp.ResetState();
                    aggregateOp.ResetState();

                    foreach (RawRecord record in aggregatedRecords)
                    {
                        tempSourceOp.ConstantSource = record;
                        groupedSourceOp.Next();
                    }

                    RawRecord aggregateTraversalRecord = aggregateOp.Next();

                    FieldObject aggregateResult = aggregateTraversalRecord?.RetriveData(0);
                    if (aggregateResult == null)
                    {
                        return(null);
                    }

                    resultCollection[key] = aggregateResult;
                }
            }

            return(new MapField(resultCollection));
        }
示例#8
0
        private static void ConstructTree(TreeField root, int index, CollectionField path)
        {
            if (index >= path.Collection.Count)
            {
                return;
            }
            FieldObject nodeObject = path.Collection[index++];

            TreeField child;

            if (!root.Children.TryGetValue(nodeObject, out child))
            {
                child = new TreeField(nodeObject);
                root.Children[nodeObject] = child;
            }

            ConstructTree(child, index, path);
        }
示例#9
0
        public override RawRecord Next()
        {
            RawRecord inputRec;

            while (this.inputOp.State() && (inputRec = this.inputOp.Next()) != null)
            {
                List <FieldObject> path = new List <FieldObject>();
                int activeByFuncIndex   = 0;

                foreach (Tuple <ScalarFunction, bool> tuple in pathStepList)
                {
                    ScalarFunction accessPathStepFunc = tuple.Item1;
                    bool           needsUnfold        = tuple.Item2;

                    FieldObject step = accessPathStepFunc.Evaluate(inputRec);
                    if (step == null)
                    {
                        continue;
                    }

                    if (needsUnfold)
                    {
                        CollectionField subPath = step as CollectionField;
                        Debug.Assert(subPath != null, "(subPath as CollectionField) != null");

                        foreach (FieldObject subPathStep in subPath.Collection)
                        {
                            path.Add(GetStepProjectionResult(subPathStep, ref activeByFuncIndex));
                        }
                    }
                    else
                    {
                        path.Add(GetStepProjectionResult(step, ref activeByFuncIndex));
                    }
                }

                RawRecord r = new RawRecord(inputRec);
                r.Append(new CollectionField(path));
                return(r);
            }

            Close();
            return(null);
        }
示例#10
0
        public override FieldObject Evaluate(RawRecord record)
        {
            //return new CollectionField(new List<FieldObject>(targetFieldIndexes.Select(e => record[e])));

            List <FieldObject> results = new List <FieldObject>();

            foreach (var input in inputOfCompose2)
            {
                if (input == null)
                {
                    continue;
                }
                else if (input is Compose2)
                {
                    CollectionField subCompose2 = input.Evaluate(record) as CollectionField;
                    results.AddRange(subCompose2.Collection);
                }
                else if (input is Compose1)
                {
                    results.Add(input.Evaluate(record));
                }
                else
                {
                    var resultField = input.Evaluate(record);
                    if (resultField == null)
                    {
                        continue;
                    }

                    CollectionField compose2ResultField = resultField as CollectionField;
                    if (compose2ResultField == null)
                    {
                        throw new GraphViewException("A WColumnReference as the parameter of Compose2 must be located to a collection field.");
                    }
                    results.AddRange(compose2ResultField.Collection);
                }
            }

            return(new CollectionField(results));
        }
        public new void _selectrevenuefilters_InvokeAction(object sender, ShowCustomFormEventArgs e)
        {
            // collection of payment method indicator
            CollectionField <MultiSelectFormCOLLECTIONITEMSUIModel> revenueFilters = ((MultiSelectFormUIModel)e.Model).COLLECTIONITEMS;

            // enumerator for payment methods
            IEnumerator <ValueListItem <System.String> > enumerator;

            enumerator = this.REVENUEFILTERS.DefaultItem.REVENUEFILTER.DataSource.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    var current = enumerator.Current;
                    if (current.Visible)
                    {
                        revenueFilters.Value.Add(new MultiSelectFormCOLLECTIONITEMSUIModel()
                        {
                            COLLECTIONITEM =
                            {
                                Value = current.Translation
                            },
                            SELECTED =
                            {
                                //Value = this.TransactionTypeIsSelected((MultiSelectParametersTRANSACTIONTYPESUIModel.TRANSACTIONTYPES)current.Value)
                                Value = true
                            }
                        });
                    }
                }
            }
            finally
            {
                if (enumerator != null)
                {
                    enumerator.Dispose();
                }
            }
        }
示例#12
0
        public override FieldObject Evaluate(RawRecord record)
        {
            FieldObject checkObject = record[this.checkFieldIndex];

            if (checkObject == null)
            {
                return(new StringField("false", JsonDataType.Boolean));
            }

            CollectionField arrayObject = record[this.arrayFieldIndex] as CollectionField;

            if (arrayObject != null)
            {
                foreach (FieldObject fieldObject in arrayObject.Collection)
                {
                    if (fieldObject is CompositeField)
                    {
                        CompositeField compose1Field = fieldObject as CompositeField;
                        if (checkObject.Equals(compose1Field[compose1Field.DefaultProjectionKey]))
                        {
                            return(new StringField("true", JsonDataType.Boolean));
                        }
                    }
                    else if (checkObject.Equals(fieldObject))
                    {
                        return(new StringField("true", JsonDataType.Boolean));
                    }
                }

                return(new StringField("false", JsonDataType.Boolean));
            }

            return(checkObject.Equals(record[this.arrayFieldIndex])
                ? new StringField("true", JsonDataType.Boolean)
                : new StringField("false", JsonDataType.Boolean));
        }
示例#13
0
        internal override List <RawRecord> CrossApply(RawRecord record)
        {
            List <FieldObject> pathCollection = new List <FieldObject>();

            foreach (var tuple in _pathFieldList)
            {
                int  index       = tuple.Item1;
                bool needsUnfold = tuple.Item2;

                if (record[index] == null)
                {
                    continue;
                }
                if (needsUnfold)
                {
                    CollectionField cf = record[index] as CollectionField;
                    foreach (FieldObject fo in cf.Collection)
                    {
                        pathCollection.Add(fo);
                    }
                }
                else
                {
                    pathCollection.Add(record[index]);
                }
            }

            RawRecord       newRecord  = new RawRecord();
            CollectionField pathResult = new CollectionField(pathCollection);

            newRecord.Append(pathResult);

            return(new List <RawRecord> {
                newRecord
            });
        }
示例#14
0
 public override void Init()
 {
     this.collectionField = new CollectionField();
 }
示例#15
0
        public override RawRecord Next()
        {
            if (!this.State())
            {
                return(null);
            }

            RawRecord r = null;

            while (this.inputOp.State() && (r = this.inputOp.Next()) != null)
            {
                FieldObject groupByKey = groupByKeyFunction.Evaluate(r);

                if (groupByKey == null)
                {
                    throw new GraphViewException("The provided property name or traversal does not map to a value for some elements.");
                }

                if (!this.groupedStates.ContainsKey(groupByKey))
                {
                    this.groupedStates.Add(groupByKey, new List <RawRecord>());
                }
                this.groupedStates[groupByKey].Add(r);
            }

            MapField result = new MapField(this.groupedStates.Count);

            if (this.isProjectingACollection)
            {
                foreach (FieldObject key in this.groupedStates.Keys)
                {
                    List <FieldObject> projectFields = new List <FieldObject>();
                    foreach (RawRecord rawRecord in this.groupedStates[key])
                    {
                        this.groupedSourceOp.ResetState();
                        this.aggregateOp.ResetState();
                        this.tempSourceOp.ConstantSource = rawRecord;
                        this.groupedSourceOp.Next();

                        RawRecord   aggregateTraversalRecord = this.aggregateOp.Next();
                        FieldObject projectResult            = aggregateTraversalRecord?.RetriveData(0);

                        if (projectResult == null)
                        {
                            throw new GraphViewException("The property does not exist for some of the elements having been grouped.");
                        }

                        projectFields.Add(projectResult);
                    }
                    result[key] = new CollectionField(projectFields);
                }
            }
            else
            {
                foreach (KeyValuePair <FieldObject, List <RawRecord> > pair in this.groupedStates)
                {
                    FieldObject      key = pair.Key;
                    List <RawRecord> aggregatedRecords = pair.Value;
                    this.groupedSourceOp.ResetState();
                    this.aggregateOp.ResetState();

                    foreach (RawRecord record in aggregatedRecords)
                    {
                        this.tempSourceOp.ConstantSource = record;
                        this.groupedSourceOp.Next();
                    }

                    RawRecord aggregateTraversalRecord = this.aggregateOp.Next();

                    FieldObject aggregateResult = aggregateTraversalRecord?.RetriveData(0);
                    if (aggregateResult == null)
                    {
                        this.Close();
                        return(null);
                    }

                    result[key] = aggregateResult;
                }
            }

            RawRecord resultRecord = new RawRecord();

            for (int i = 0; i < this.carryOnCount; i++)
            {
                resultRecord.Append((FieldObject)null);
            }

            resultRecord.Append(result);

            this.Close();
            return(resultRecord);
        }
 public override void When()
 {
     var collectionField = new CollectionField();
 }
示例#17
0
        public override RawRecord Next()
        {
            if (!State())
            {
                return(null);
            }

            RawRecord r = null;

            while (inputOp.State() && (r = inputOp.Next()) != null)
            {
                FieldObject groupByKey = groupByKeyFieldIndex >= 0
                    ? new StringField(r[groupByKeyFieldIndex].ToValue)
                    : groupByKeyFunction.Evaluate(r);

                if (!groupedStates.ContainsKey(groupByKey))
                {
                    groupedStates.Add(groupByKey, new List <RawRecord>());
                }
                groupedStates[groupByKey].Add(r);
            }

            Dictionary <FieldObject, FieldObject> resultCollection = new Dictionary <FieldObject, FieldObject>(groupedStates.Count);

            if (elementPropertyProjectionIndex >= 0)
            {
                foreach (FieldObject key in groupedStates.Keys)
                {
                    List <FieldObject> projectFields = new List <FieldObject>();
                    foreach (var rawRecord in groupedStates[key])
                    {
                        FieldObject fo = rawRecord[elementPropertyProjectionIndex];
                        if (fo is PropertyField)
                        {
                            PropertyField pf = fo as PropertyField;
                            projectFields.Add(new StringField(pf.PropertyValue, pf.JsonDataType));
                        }
                        else
                        {
                            projectFields.Add(fo);
                        }
                    }
                    resultCollection[key] = new CollectionField(projectFields);
                }
            }
            else
            {
                foreach (KeyValuePair <FieldObject, List <RawRecord> > pair in groupedStates)
                {
                    FieldObject      key = pair.Key;
                    List <RawRecord> aggregatedRecords = pair.Value;
                    groupedSourceOp.ResetState();
                    aggregateOp.ResetState();

                    foreach (RawRecord record in aggregatedRecords)
                    {
                        tempSourceOp.ConstantSource = record;
                        groupedSourceOp.Next();
                    }

                    RawRecord aggregateTraversalRecord = aggregateOp.Next();

                    FieldObject aggregateResult = aggregateTraversalRecord?.RetriveData(0);
                    if (aggregateResult == null)
                    {
                        Close();
                        return(null);
                    }

                    resultCollection[key] = aggregateResult;
                }
            }

            RawRecord resultRecord = new RawRecord();

            for (int i = 0; i < carryOnCount; i++)
            {
                resultRecord.Append((FieldObject)null);
            }

            resultRecord.Append(new MapField(resultCollection));

            Close();
            return(resultRecord);
        }
示例#18
0
 public CollectionState(string tableAlias) : base(tableAlias)
 {
     this.collectionField = new CollectionField();
 }
示例#19
0
 public CollectionFunction()
 {
     CollectionField = new CollectionField();
 }
示例#20
0
 public void Init()
 {
     CollectionField = new CollectionField();
 }
示例#21
0
        internal override List <RawRecord> CrossApply(RawRecord record)
        {
            List <RawRecord> results = new List <RawRecord>();

            FieldObject unfoldTarget = getUnfoldTargetFunc.Evaluate(record);

            if (unfoldTarget is CollectionField)
            {
                CollectionField cf = unfoldTarget as CollectionField;
                foreach (FieldObject singleObj in cf.Collection)
                {
                    if (singleObj == null)
                    {
                        continue;
                    }
                    RawRecord newRecord = new RawRecord();

                    // Extract only needed columns from Compose1Field
                    if (singleObj is Compose1Field)
                    {
                        Compose1Field compose1Field = singleObj as Compose1Field;
                        foreach (string unfoldColumn in unfoldCompose1Columns)
                        {
                            newRecord.Append(compose1Field.CompositeFieldObject[unfoldColumn]);
                        }
                    }
                    else
                    {
                        foreach (string columnName in this.unfoldCompose1Columns)
                        {
                            if (columnName.Equals(GremlinKeyword.TableDefaultColumnName))
                            {
                                newRecord.Append(singleObj);
                            }
                            else
                            {
                                newRecord.Append((FieldObject)null);
                            }
                        }
                    }

                    results.Add(newRecord);
                }
            }
            else if (unfoldTarget is MapField)
            {
                MapField mf = unfoldTarget as MapField;
                foreach (KeyValuePair <FieldObject, FieldObject> pair in mf)
                {
                    RawRecord newRecord = new RawRecord();
                    string    key       = pair.Key.ToString();
                    string    value     = pair.Value.ToString();

                    foreach (string columnName in this.unfoldCompose1Columns)
                    {
                        if (columnName.Equals(GremlinKeyword.TableDefaultColumnName))
                        {
                            newRecord.Append(new StringField(key + "=" + value));
                        }
                        else
                        {
                            newRecord.Append((FieldObject)null);
                        }
                    }

                    results.Add(newRecord);
                }
            }
            else
            {
                RawRecord newRecord = new RawRecord();
                foreach (string columnName in this.unfoldCompose1Columns)
                {
                    if (columnName.Equals(GremlinKeyword.TableDefaultColumnName))
                    {
                        newRecord.Append(unfoldTarget);
                    }
                    else
                    {
                        newRecord.Append((FieldObject)null);
                    }
                }
                results.Add(newRecord);
            }

            return(results);
        }
示例#22
0
        internal override List <RawRecord> CrossApply(RawRecord record)
        {
            List <RawRecord> results = new List <RawRecord>();

            FieldObject unfoldTarget = getUnfoldTargetFunc.Evaluate(record);

            if (unfoldTarget is PathField)
            {
                PathField path = (PathField)unfoldTarget;
                foreach (PathStepField pathStep in path.Path.Cast <PathStepField>())
                {
                    if (pathStep == null)
                    {
                        continue;
                    }
                    RawRecord flatRecord = new RawRecord();

                    Compose1Field compose1StepField = pathStep.StepFieldObject as Compose1Field;
                    Debug.Assert(compose1StepField != null, "compose1StepField != null");
                    //
                    // Extract only needed columns from Compose1Field
                    //
                    foreach (string unfoldColumn in populateColumns)
                    {
                        flatRecord.Append(compose1StepField[unfoldColumn]);
                    }

                    results.Add(flatRecord);
                }
            }
            else if (unfoldTarget is CollectionField)
            {
                CollectionField inputCollection = (CollectionField)unfoldTarget;
                foreach (FieldObject singleObj in inputCollection.Collection)
                {
                    if (singleObj == null)
                    {
                        continue;
                    }
                    RawRecord flatRecord = new RawRecord();

                    Compose1Field compose1ObjField = singleObj as Compose1Field;
                    Debug.Assert(compose1ObjField != null, "compose1ObjField != null");
                    //
                    // Extract only needed columns from Compose1Field
                    //
                    foreach (string unfoldColumn in populateColumns)
                    {
                        flatRecord.Append(compose1ObjField[unfoldColumn]);
                    }

                    results.Add(flatRecord);
                }
            }
            else if (unfoldTarget is MapField)
            {
                MapField inputMap = (MapField)unfoldTarget;
                foreach (EntryField entry in inputMap)
                {
                    RawRecord entryRecord = new RawRecord();

                    foreach (string columnName in this.populateColumns)
                    {
                        entryRecord.Append(columnName.Equals(GraphViewKeywords.KW_TABLE_DEFAULT_COLUMN_NAME)
                            ? entry
                            : (FieldObject)null);
                    }

                    results.Add(entryRecord);
                }
            }
            else
            {
                RawRecord flatRecord = unfoldTarget.FlatToRawRecord(this.populateColumns);
                results.Add(flatRecord);
            }

            return(results);
        }