Ejemplo n.º 1
0
        /// <summary>
        /// This will write the output lines to the destination. Only one output for each <paramref name="myDumpType"/> is allowed.
        /// </summary>
        /// <param name="myDumpType"></param>
        /// <param name="lines"></param>
        public void Write(DumpTypes myDumpType, IEnumerable <String> lines)
        {
            if (_DumpReadout.ContainsKey(myDumpType.ToString()))
            {
                throw new ArgumentException(myDumpType.ToString() + " already added");
            }

            switch (_TypeOfOutputDestination)
            {
            case TypeOfOutputDestination.QueryResult:
                _DumpReadout.Add(myDumpType.ToString(), lines);

                break;

            default:
                _DumpReadout.Add(myDumpType.ToString(), _Destination);

                foreach (var line in lines)
                {
                    if (!line.IsNullOrEmpty())
                    {
                        _Stream.WriteLine(line);
                    }
                }
                break;
            }
        }
Ejemplo n.º 2
0
        private IEnumerable <IVertexView> Export(IDumpable myGrammar,
                                                 IGraphDB myGraphDB,
                                                 IGraphQL myGraphQL,
                                                 SecurityToken mySecurityToken,
                                                 Int64 myTransactionToken,
                                                 IEnumerable <IVertexType> myVertexTypes,
                                                 IEnumerable <IEdgeType> myEdgeTypes,
                                                 DumpTypes myDumpType)
        {
            var dumpReadout = new Dictionary <String, Object>();

            #region dump gddl
            if ((myDumpType & DumpTypes.GDDL) == DumpTypes.GDDL)
            {
                var graphDDL = myGrammar.ExportGraphDDL(DumpFormats.GQL,
                                                        myVertexTypes,
                                                        myEdgeTypes);

                if (graphDDL == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");
                }

                dumpReadout.Add("GDDL", new ListCollectionWrapper(graphDDL));

                Write(DumpTypes.GDDL, graphDDL);
            }
            #endregion

            #region dump gdml
            if ((myDumpType & DumpTypes.GDML) == DumpTypes.GDML)
            {
                var graphDML = myGrammar.ExportGraphDML(DumpFormats.GQL,
                                                        myVertexTypes,
                                                        mySecurityToken,
                                                        myTransactionToken);

                if (graphDML == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");
                }

                dumpReadout.Add("GDML", new ListCollectionWrapper(graphDML));

                Write(DumpTypes.GDML, graphDML);
            }
            #endregion

            return(new IVertexView[] { new VertexView(dumpReadout, null) });
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This will write the output lines to the destination. Only one output for each <paramref name="myDumpType"/> is allowed.
        /// </summary>
        /// <param name="myDumpType"></param>
        /// <param name="lines"></param>
        protected Exceptional Write(DumpTypes myDumpType, IEnumerable<String> lines)
        {
            if (_DumpReadout.ContainsKey(myDumpType.ToString()))
            {
                return new Exceptional(new Error_ArgumentException(myDumpType.ToString() + " already added"));
            }

            switch (_TypeOfOutputDestination)
            {

                case TypeOfOutputDestination.QueryResult:
                    _DumpReadout.Add(myDumpType.ToString(), lines);

                    break;

                default:
                    _DumpReadout.Add(myDumpType.ToString(), _Destination);

                    foreach (var line in lines)
                    {
                        _Stream.WriteLine(line);
                    }
                    break;
            }

            return Exceptional.OK;
        }
Ejemplo n.º 4
0
        private IEnumerable<IVertexView> Export(IDumpable myGrammar, 
            IGraphDB myGraphDB,
            IGraphQL myGraphQL,
            SecurityToken mySecurityToken,
            Int64 myTransactionToken,
            IEnumerable<IVertexType> myVertexTypes,
            IEnumerable<IEdgeType> myEdgeTypes,
            DumpTypes myDumpType)
        {
            var dumpReadout = new Dictionary<String, Object>();

            #region dump gddl
            if ((myDumpType & DumpTypes.GDDL) == DumpTypes.GDDL)
            {

                var graphDDL = myGrammar.ExportGraphDDL(DumpFormats.GQL,
                                                        myVertexTypes,
                                                        myEdgeTypes);

                if (graphDDL == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");

                }

                dumpReadout.Add("GDDL", new ListCollectionWrapper(graphDDL));

                Write(DumpTypes.GDDL, graphDDL);

            }
            #endregion

            #region dump gdml
            if ((myDumpType & DumpTypes.GDML) == DumpTypes.GDML)
            {

                var graphDML = myGrammar.ExportGraphDML(DumpFormats.GQL,
                                                        myVertexTypes,
                                                        mySecurityToken,
                                                        myTransactionToken);

                if (graphDML == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");
                }

                dumpReadout.Add("GDML", new ListCollectionWrapper(graphDML));

                Write(DumpTypes.GDML, graphDML);

            }
            #endregion

            return new IVertexView[] { new VertexView(dumpReadout, null) };
        }
Ejemplo n.º 5
0
        /// <summary>
        /// This will write the output lines to the destination. Only one output for each <paramref name="myDumpType"/> is allowed.
        /// </summary>
        /// <param name="myDumpType"></param>
        /// <param name="lines"></param>
        public void Write(DumpTypes myDumpType, IEnumerable<String> lines)
        {
            if (_DumpReadout.ContainsKey(myDumpType.ToString()))
            {
                throw new ArgumentException(myDumpType.ToString() + " already added");
            }

            switch (_TypeOfOutputDestination)
            {
                case TypeOfOutputDestination.QueryResult:
                    _DumpReadout.Add(myDumpType.ToString(), lines);

                    break;

                default:
                    _DumpReadout.Add(myDumpType.ToString(), _Destination);

                    foreach (var line in lines)
                    {
                        if(!line.IsNullOrEmpty())
                            _Stream.WriteLine(line);
                    }
                    break;
            }
        }
Ejemplo n.º 6
0
        private QueryResult Export(IDumpable myGrammar, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, IEnumerable<IVertexType> myTypes, DumpTypes myDumpType)
        {
            var dumpReadout = new Dictionary<String, Object>();
            ASonesException error = null;

            #region dump gddl
            if ((myDumpType & DumpTypes.GDDL) == DumpTypes.GDDL)
            {

                var graphDDL = myGrammar.ExportGraphDDL(DumpFormats.GQL, myTypes);

                if (graphDDL == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");

                }

                dumpReadout.Add("GDDL", new ListCollectionWrapper(graphDDL));

                try
                {
                    Write(DumpTypes.GDDL, graphDDL);
                }
                catch (ASonesException e)
                {
                    error = e;
                }

            }
            #endregion

            #region dump gdml
            if ((myDumpType & DumpTypes.GDML) == DumpTypes.GDML)
            {

                var graphDML = myGrammar.ExportGraphDML(DumpFormats.GQL, myTypes, mySecurityToken, myTransactionToken);

                if (graphDML == null)
                {
                    throw new ExportFailedException(myDumpType.ToString(), "");
                }

                dumpReadout.Add("GDML", new ListCollectionWrapper(graphDML));

                try
                {
                    Write(DumpTypes.GDML, graphDML);
                }
                catch (ASonesException e)
                {
                    error = e;
                }

            }
            #endregion

            return new QueryResult("", ExportFormat, 0L, ResultType.Successful, new List<IVertexView> { new VertexView(dumpReadout, null) }, error);
        }