Example #1
0
        /// <summary>
        /// Converts to selected Type from binary
        /// </summary>
        /// <param name="curDlid">The cur DLID.</param>
        /// <param name="typeOf">The type of.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        public StringBuilder ConvertFrom(Guid curDlid, DataListFormat typeOf, enTranslationDepth depth, out ErrorResultTO errors)
        {
            DataListTranslatedPayloadTO tmp = _svrCompiler.ConvertFrom(null, curDlid, depth, typeOf, out errors);

            if (tmp != null)
            {
                return(tmp.FetchAsString());
            }

            return(new StringBuilder());
        }
Example #2
0
        /// <summary>
        /// Clones the specified type of.
        /// </summary>
        /// <param name="depth">The depth.</param>
        /// <param name="errorResult">The error result.</param>
        /// <param name="onlySystemTags">if set to <c>true</c> [only system tags].</param>
        /// <returns></returns>
        public IBinaryDataList Clone(enTranslationDepth depth, out ErrorResultTO errorResult, bool onlySystemTags)
        {
            // set parent child reference
            BinaryDataList result = new BinaryDataList {
                ParentUID = ParentUID
            };

            errorResult = new ErrorResultTO();

            // clone the dictionary
            foreach (string e in _templateDict.Keys)
            {
                if ((onlySystemTags && e.IndexOf(GlobalConstants.SystemTagNamespaceSearch, StringComparison.Ordinal) >= 0) || !onlySystemTags)
                {
                    string error;
                    // fetch this instance via clone, fetch toClone instance and merge the data
                    IBinaryDataListEntry cloned = _templateDict[e].Clone(depth, UID, out error);
                    // Copy over the intellisesne parts ;)
                    result._intellisenseParts = _intellisenseParts;
                    errorResult.AddError(error);
                    if (error == string.Empty)
                    {
                        // safe to add
                        result._templateDict[e] = cloned;
                    }
                }
            }

            // if only system tags, clean the intellisense parts out ;)
            if (onlySystemTags)
            {
                var parts =
                    result._intellisenseParts.Where(
                        c => c.Name.IndexOf(GlobalConstants.SystemTagNamespaceSearch, StringComparison.Ordinal) >= 0);
                result._intellisenseParts = parts.ToList();
            }


            return(result);
        }
Example #3
0
 /// <summary>
 /// Conditionals the merge.
 /// </summary>
 /// <param name="conditions">The conditions.</param>
 /// <param name="destinationDatalistID">The destination datalist ID.</param>
 /// <param name="sourceDatalistID">The source datalist ID.</param>
 /// <param name="datalistMergeFrequency">The datalist merge frequency.</param>
 /// <param name="datalistMergeType">Type of the datalist merge.</param>
 /// <param name="datalistMergeDepth">The datalist merge depth.</param>
 public void ConditionalMerge(DataListMergeFrequency conditions,
                              Guid destinationDatalistID, Guid sourceDatalistID, DataListMergeFrequency datalistMergeFrequency,
                              enDataListMergeTypes datalistMergeType, enTranslationDepth datalistMergeDepth)
 {
     _svrCompiler.ConditionalMerge(null, conditions, destinationDatalistID, sourceDatalistID, datalistMergeFrequency, datalistMergeType, datalistMergeDepth);
 }
Example #4
0
 /// <summary>
 /// Merges the specified left.
 /// </summary>
 /// <param name="left">The left.</param>
 /// <param name="right">The right.</param>
 /// <param name="mergeType">Type of the merge.</param>
 /// <param name="depth">The depth.</param>
 /// <param name="createNewList">if set to <c>true</c> [create new list].</param>
 /// <param name="errors">The errors.</param>
 /// <returns></returns>
 public IBinaryDataList Merge(IBinaryDataList left, IBinaryDataList right, enDataListMergeTypes mergeType, enTranslationDepth depth, bool createNewList, out ErrorResultTO errors)
 {
     return(left.Merge(right, mergeType, depth, createNewList, out errors));
 }
Example #5
0
 /// <summary>
 /// Merges the specified left ID with the right ID
 /// </summary>
 /// <param name="leftID">The left ID.</param>
 /// <param name="rightID">The right ID.</param>
 /// <param name="mergeType">Type of the merge.</param>
 /// <param name="depth"></param>
 /// <param name="createNewList"></param>
 /// <param name="errors"></param>
 /// <returns></returns>
 public Guid Merge(Guid leftID, Guid rightID, enDataListMergeTypes mergeType, enTranslationDepth depth, bool createNewList, out ErrorResultTO errors)
 {
     return(_svrCompiler.Merge(null, leftID, rightID, mergeType, depth, createNewList, out errors));
 }
Example #6
0
        public IBinaryDataListEntry Clone(enTranslationDepth depth, Guid clonedStorageId, out string error)
        {
            error = string.Empty;
            BinaryDataListEntry result;
            Guid dlKey = DataListKey;

            if (clonedStorageId != GlobalConstants.NullDataListID)
            {
                dlKey = clonedStorageId;
            }

            if (Columns != null)
            {
                // clone the columns
                IList <Dev2Column> cols = new List <Dev2Column>(Columns.Count);
                foreach (Dev2Column c in Columns)
                {
                    cols.Add(new Dev2Column(c.ColumnName, c.ColumnDescription));
                }
                result = new BinaryDataListEntry(Namespace, Description, cols, dlKey);
            }
            else
            {
                result = new BinaryDataListEntry(Namespace, Description, dlKey);
            }

            // 2013.09.09 - we're the same, just adjust the view and return
            if (clonedStorageId.Equals(DataListKey))
            {
                // manip result's _internalObj aka the view of the data ;)
                result._internalObj.CopyTo(_internalObj);
                // copy express auditing data too ;)
                result.ComplexExpressionAuditor = ComplexExpressionAuditor;
            }

            if (depth == enTranslationDepth.Data || depth == enTranslationDepth.Data_With_Blank_OverWrite)
            {
                // clone _items
                if (IsRecordset)
                {
                    IIndexIterator ii      = _internalObj.Keys;
                    bool           isEmtpy = _internalObj.IsEmtpy;
                    result._internalObj.IsEmtpy = isEmtpy;
                    while (ii.HasMore())
                    {
                        int next = ii.FetchNextIndex();
                        // clone the data
                        IList <IBinaryDataListItem> items = _internalObj[next];
                        IList <IBinaryDataListItem> clone = new List <IBinaryDataListItem>();
                        // Bug 8725
                        if (items != null)
                        {
                            foreach (IBinaryDataListItem itm in items)
                            {
                                clone.Add(itm.Clone());
                            }
                        }
                        // now push back clone
                        result._internalObj[next] = clone;
                    }

                    // ensure we reset min index if not 1 ;)
                    var keys = _internalObj.Keys;
                    var min  = keys.MinIndex();
                    var max  = keys.MaxIndex();
                    var gaps = _internalObj.FetchGaps();
                    result._internalObj.MoveIndexDataForClone(min, max, gaps, false);
                }
                else
                {
                    IList <IBinaryDataListItem> items = _internalObj[0];
                    IList <IBinaryDataListItem> clone = items.Select(itm => itm.Clone()).ToList();

                    // now push back clone
                    result._internalObj[0]      = clone;
                    result._internalObj.IsEmtpy = false;
                }
            }
            else // only wanted the shape cloned
            {
                var keys = _internalObj.Keys;
                var min  = keys.MinIndex();
                var max  = keys.MaxIndex();
                var gaps = _internalObj.FetchGaps();
                result._internalObj.MoveIndexDataForClone(min, max, gaps, false);
            }

            result.ComplexExpressionAuditor = ComplexExpressionAuditor;

            return(result);
        }
        /// <summary>
        /// Depths the merge.
        /// </summary>
        /// <param name="depth">The depth.</param>
        /// <param name="cloned">The cloned.</param>
        /// <param name="key"></param>
        /// <param name="errors">The errors.</param>
        private void DepthMerge(enTranslationDepth depth, IBinaryDataListEntry cloned, string key, out IList<string> errors)
        {
            errors = new List<string>();

            if(key != null)
            {

                if(depth == enTranslationDepth.Data || depth == enTranslationDepth.Data_With_Blank_OverWrite)
                {

                    // safe to add
                    if(cloned.IsRecordset)
                    {

                        // Inject into the intellisense options...
                        CreateIntelliseneResult(key, cloned.Columns);

                        //Massimo.Guerrera - 21-01-2013 - Added for the DeleteRecordOperation, it need to over write the data with blank values.
                        if(depth == enTranslationDepth.Data_With_Blank_OverWrite)
                        {
                            _templateDict[key] = cloned;
                        }
                        else
                        {
                            // merge all the cloned rows into this reference

#pragma warning disable 219
                            // ReSharper disable NotAccessedVariable
                            int insertIdx = 1; // always default to start of recordset
                            // ReSharper restore NotAccessedVariable
#pragma warning restore 219
                            // fetch last row id and build from there
                            IBinaryDataListEntry tmpRec;
                            bool isFound = _templateDict.TryGetValue(key, out tmpRec);
                            // verify that the key exist first ;)

                            IIndexIterator ii = cloned.FetchRecordsetIndexes();
                            while(ii.HasMore())
                            {
                                int next = ii.FetchNextIndex();
                                string error;
                                IList<IBinaryDataListItem> cols = cloned.FetchRecordAt(next, out error);
                                if(error != string.Empty)
                                {
                                    errors.Add(error);
                                }

                                if(!isFound)
                                {
                                    // we need to boot strap the recordset ;)
                                    // intellisense takecare of with template method ;)
                                    TryCreateRecordsetTemplate(cloned.Namespace, cloned.Description, cloned.Columns, true, out error);
                                    if(error != string.Empty)
                                    {
                                        errors.Add(error);
                                    }
                                    isFound = true;
                                }

                                foreach(IBinaryDataListItem itm in cols)
                                {
                                    _templateDict[key].TryPutRecordItemAtIndex(itm, next, out error);
                                    if(error != string.Empty)
                                    {
                                        errors.Add(error);
                                    }
                                }
                                insertIdx++;
                            }

                        }
                    }
                    else
                    {
                        IBinaryDataListEntry thisTmp;
                        // we have an entry, better check clone for empty
                        if(_templateDict.TryGetValue(key, out thisTmp))
                        {
                            string theValue = null;
                            try
                            {
                                theValue = cloned.FetchScalar().TheValue;
                            }
                            catch(Exception e)
                            {
                                Dev2Logger.Log.Error(e);
                            }
                            if(theValue != string.Empty && depth == enTranslationDepth.Data)
                            {
                                // The clone has data, over write it on the merge ;)
                                _templateDict[key] = cloned;
                                // Inject into the intellisense options...
                                CreateIntelliseneResult(key);
                            }
                            else if(depth == enTranslationDepth.Data_With_Blank_OverWrite)
                            {
                                // The user wants to over-write Blank data on the right with existing data on the left ;)
                                _templateDict[key] = cloned;
                                // Inject into the intellisense options...
                                CreateIntelliseneResult(key);
                            }
                        }
                        else
                        {
                            // no entry, just place it there as there is no harm ;)
                            _templateDict[key] = cloned;
                            // Inject into the intellisense options...
                            CreateIntelliseneResult(key);
                        }
                    }
                }
                else if(depth == enTranslationDepth.Shape)
                {
                    _templateDict[key] = cloned; // set blank data ;)
                    // Inject into the intellisense options...
                    CreateIntelliseneResult(key);
                }
            }
        }
        /// <summary>
        /// Merges the into instance.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="typeOf">The type of.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="errorResult">The error result.</param>
        private void MergeIntoInstance(IBinaryDataList obj, enDataListMergeTypes typeOf, enTranslationDepth depth, out ErrorResultTO errorResult)
        {

            errorResult = new ErrorResultTO();
            BinaryDataList toClone = (BinaryDataList)obj;
            if(obj.ParentUID != UID)
            {
                ParentUID = toClone.ParentUID;
            }
            IList<string> lamdaErrors = new List<string>();
            IList<string> errorList = new List<string>();
            IList<string> unionKeyHits = new List<string>();

            // clone the dictionary
            IList<string> tmp = _templateDict.Keys.ToList();  // must be this way since we modify the collection...
            foreach(string e in tmp)
            {
                string error;
                IBinaryDataListEntry cloned;

                if(typeOf == enDataListMergeTypes.Union)
                {
                    // fetch this instance via clone, fetch toClone instance and merge the data
                    IBinaryDataListEntry fetchTmp;
                    if(toClone._templateDict.TryGetValue(e, out fetchTmp))
                    {
                        unionKeyHits.Add(e);
                        cloned = fetchTmp.Clone(depth, UID, out error);
                        if(error != string.Empty)
                        {
                            lamdaErrors.Add(error);
                        }
                        else
                        {
                            DepthMerge(depth, cloned, e, out lamdaErrors);
                        }

                        // We need to ensure that the intellisense dictionary is populated with this key ;)

                    }
                }
                else if(typeOf == enDataListMergeTypes.Intersection)
                {
                    IBinaryDataListEntry toFetch;
                    if(toClone.TryGetEntry(e, out toFetch, out error))
                    {
                        cloned = toClone._templateDict[e].Clone(depth, UID, out error);
                        if(error != string.Empty)
                        {
                            lamdaErrors.Add(error);
                        }
                        else
                        {
                            DepthMerge(depth, cloned, e, out lamdaErrors);
                        }
                    }
                    else
                    {
                        lamdaErrors.Add("Missing DataList item [ " + e + " ] ");
                    }
                }

                // compile error list ?!
                foreach(string err in lamdaErrors)
                {
                    errorList.Add(err);
                }
                lamdaErrors.Clear();
            }


            // now process key misses for union
            if(typeOf == enDataListMergeTypes.Union)
            {
                //toClone._templateDict.Keys
                foreach(string k in (toClone._templateDict.Keys.ToArray().Except(unionKeyHits)))
                {
                    string error;
                    IBinaryDataListEntry cloned = toClone._templateDict[k].Clone(depth, UID, out error);
                    if(error != string.Empty)
                    {
                        lamdaErrors.Add(error);
                    }
                    else
                    {
                        DepthMerge(depth, cloned, k, out lamdaErrors);
                    }
                }
            }

            // now build the silly composite object since lamba is an daft construct
            // how about proper exception handling MS?!
            foreach(string err in errorList)
            {
                errorResult.AddError(err);
            }
        }
        /// <summary>
        /// Clones the specified type of.
        /// </summary>
        /// <param name="depth">The depth.</param>
        /// <param name="errorResult">The error result.</param>
        /// <param name="onlySystemTags">if set to <c>true</c> [only system tags].</param>
        /// <returns></returns>
        public IBinaryDataList Clone(enTranslationDepth depth, out ErrorResultTO errorResult, bool onlySystemTags)
        {
            // set parent child reference
            BinaryDataList result = new BinaryDataList { ParentUID = ParentUID };

            errorResult = new ErrorResultTO();

            // clone the dictionary
            foreach(string e in _templateDict.Keys)
            {

                if((onlySystemTags && e.IndexOf(GlobalConstants.SystemTagNamespaceSearch, StringComparison.Ordinal) >= 0) || !onlySystemTags)
                {
                    string error;
                    // fetch this instance via clone, fetch toClone instance and merge the data
                    IBinaryDataListEntry cloned = _templateDict[e].Clone(depth, UID, out error);
                    // Copy over the intellisesne parts ;)
                    result._intellisenseParts = _intellisenseParts;
                    errorResult.AddError(error);
                    if(error == string.Empty)
                    {
                        // safe to add
                        result._templateDict[e] = cloned;
                    }
                }
            }

            // if only system tags, clean the intellisense parts out ;)
            if(onlySystemTags)
            {
                var parts =
                    result._intellisenseParts.Where(
                        c => c.Name.IndexOf(GlobalConstants.SystemTagNamespaceSearch, StringComparison.Ordinal) >= 0);
                result._intellisenseParts = parts.ToList();
            }


            return result;
        }
        /*
         * Adjust Clone to simply copy the object instance
         * 
         * 
         */
        public IBinaryDataList Merge(IBinaryDataList right, enDataListMergeTypes mergeType, enTranslationDepth depth, bool newList, out ErrorResultTO errors)
        {
            IBinaryDataList mergeResult = newList ? Clone(depth, out errors, false) : this;

            // do the merge ;)
            ((BinaryDataList)mergeResult).MergeIntoInstance(right, mergeType, depth, out errors);

            return mergeResult;
        }
Example #11
0
        /// <summary>
        /// Depths the merge.
        /// </summary>
        /// <param name="depth">The depth.</param>
        /// <param name="cloned">The cloned.</param>
        /// <param name="key"></param>
        /// <param name="errors">The errors.</param>
        private void DepthMerge(enTranslationDepth depth, IBinaryDataListEntry cloned, string key, out IList <string> errors)
        {
            errors = new List <string>();

            if (key != null)
            {
                if (depth == enTranslationDepth.Data || depth == enTranslationDepth.Data_With_Blank_OverWrite)
                {
                    // safe to add
                    if (cloned.IsRecordset)
                    {
                        // Inject into the intellisense options...
                        CreateIntelliseneResult(key, cloned.Columns);

                        //Massimo.Guerrera - 21-01-2013 - Added for the DeleteRecordOperation, it need to over write the data with blank values.
                        if (depth == enTranslationDepth.Data_With_Blank_OverWrite)
                        {
                            _templateDict[key] = cloned;
                        }
                        else
                        {
                            // merge all the cloned rows into this reference

#pragma warning disable 219
                            int insertIdx = 1; // always default to start of recordset
#pragma warning restore 219
                            // fetch last row id and build from there
                            IBinaryDataListEntry tmpRec;
                            bool isFound = _templateDict.TryGetValue(key, out tmpRec);
                            // verify that the key exist first ;)

                            IIndexIterator ii = cloned.FetchRecordsetIndexes();
                            while (ii.HasMore())
                            {
                                int    next = ii.FetchNextIndex();
                                string error;
                                IList <IBinaryDataListItem> cols = cloned.FetchRecordAt(next, out error);
                                if (error != string.Empty)
                                {
                                    errors.Add(error);
                                }

                                if (!isFound)
                                {
                                    // we need to boot strap the recordset ;)
                                    // intellisense takecare of with template method ;)
                                    TryCreateRecordsetTemplate(cloned.Namespace, cloned.Description, cloned.Columns, true, out error);
                                    if (error != string.Empty)
                                    {
                                        errors.Add(error);
                                    }
                                    isFound = true;
                                }

                                foreach (IBinaryDataListItem itm in cols)
                                {
                                    _templateDict[key].TryPutRecordItemAtIndex(itm, next, out error);
                                    if (error != string.Empty)
                                    {
                                        errors.Add(error);
                                    }
                                }
                                insertIdx++;
                            }
                        }
                    }
                    else
                    {
                        IBinaryDataListEntry thisTmp;
                        // we have an entry, better check clone for empty
                        if (_templateDict.TryGetValue(key, out thisTmp))
                        {
                            string theValue = null;
                            try
                            {
                                theValue = cloned.FetchScalar().TheValue;
                            }
                            catch (Exception e)
                            {
                                Dev2Logger.Log.Error(e);
                            }
                            if (theValue != string.Empty && depth == enTranslationDepth.Data)
                            {
                                // The clone has data, over write it on the merge ;)
                                _templateDict[key] = cloned;
                                // Inject into the intellisense options...
                                CreateIntelliseneResult(key);
                            }
                            else if (depth == enTranslationDepth.Data_With_Blank_OverWrite)
                            {
                                // The user wants to over-write Blank data on the right with existing data on the left ;)
                                _templateDict[key] = cloned;
                                // Inject into the intellisense options...
                                CreateIntelliseneResult(key);
                            }
                        }
                        else
                        {
                            // no entry, just place it there as there is no harm ;)
                            _templateDict[key] = cloned;
                            // Inject into the intellisense options...
                            CreateIntelliseneResult(key);
                        }
                    }
                }
                else if (depth == enTranslationDepth.Shape)
                {
                    _templateDict[key] = cloned; // set blank data ;)
                    // Inject into the intellisense options...
                    CreateIntelliseneResult(key);
                }
            }
        }
Example #12
0
        /// <summary>
        /// Merges the into instance.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="typeOf">The type of.</param>
        /// <param name="depth">The depth.</param>
        /// <param name="errorResult">The error result.</param>
        private void MergeIntoInstance(IBinaryDataList obj, enDataListMergeTypes typeOf, enTranslationDepth depth, out ErrorResultTO errorResult)
        {
            errorResult = new ErrorResultTO();
            BinaryDataList toClone = (BinaryDataList)obj;

            if (obj.ParentUID != UID)
            {
                ParentUID = toClone.ParentUID;
            }
            IList <string> lamdaErrors  = new List <string>();
            IList <string> errorList    = new List <string>();
            IList <string> unionKeyHits = new List <string>();

            // clone the dictionary
            IList <string> tmp = _templateDict.Keys.ToList();  // must be this way since we modify the collection...

            foreach (string e in tmp)
            {
                string error;
                IBinaryDataListEntry cloned;

                if (typeOf == enDataListMergeTypes.Union)
                {
                    // fetch this instance via clone, fetch toClone instance and merge the data
                    IBinaryDataListEntry fetchTmp;
                    if (toClone._templateDict.TryGetValue(e, out fetchTmp))
                    {
                        unionKeyHits.Add(e);
                        cloned = fetchTmp.Clone(depth, UID, out error);
                        if (error != string.Empty)
                        {
                            lamdaErrors.Add(error);
                        }
                        else
                        {
                            DepthMerge(depth, cloned, e, out lamdaErrors);
                        }

                        // We need to ensure that the intellisense dictionary is populated with this key ;)
                    }
                }
                else if (typeOf == enDataListMergeTypes.Intersection)
                {
                    IBinaryDataListEntry toFetch;
                    if (toClone.TryGetEntry(e, out toFetch, out error))
                    {
                        cloned = toClone._templateDict[e].Clone(depth, UID, out error);
                        if (error != string.Empty)
                        {
                            lamdaErrors.Add(error);
                        }
                        else
                        {
                            DepthMerge(depth, cloned, e, out lamdaErrors);
                        }
                    }
                    else
                    {
                        lamdaErrors.Add("Missing DataList item [ " + e + " ] ");
                    }
                }

                // compile error list ?!
                foreach (string err in lamdaErrors)
                {
                    errorList.Add(err);
                }
                lamdaErrors.Clear();
            }


            // now process key misses for union
            if (typeOf == enDataListMergeTypes.Union)
            {
                //toClone._templateDict.Keys
                foreach (string k in (toClone._templateDict.Keys.ToArray().Except(unionKeyHits)))
                {
                    string error;
                    IBinaryDataListEntry cloned = toClone._templateDict[k].Clone(depth, UID, out error);
                    if (error != string.Empty)
                    {
                        lamdaErrors.Add(error);
                    }
                    else
                    {
                        DepthMerge(depth, cloned, k, out lamdaErrors);
                    }
                }
            }

            // now build the silly composite object since lamba is an daft construct
            // how about proper exception handling MS?!
            foreach (string err in errorList)
            {
                errorResult.AddError(err);
            }
        }
Example #13
0
        /*
         * Adjust Clone to simply copy the object instance
         *
         *
         */
        public IBinaryDataList Merge(IBinaryDataList right, enDataListMergeTypes mergeType, enTranslationDepth depth, bool newList, out ErrorResultTO errors)
        {
            IBinaryDataList mergeResult = newList ? Clone(depth, out errors, false) : this;

            // do the merge ;)
            ((BinaryDataList)mergeResult).MergeIntoInstance(right, mergeType, depth, out errors);

            return(mergeResult);
        }