Exemple #1
0
        public IQueryResult Query(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken, string myQueryString, string myQueryLanguageName)
        {
            IGraphQL queryLanguage;

            if (_QueryLanguages.TryGetValue(myQueryLanguageName, out queryLanguage))
            {
                // drain every query (before the query)
                foreach (KeyValuePair <String, IDrainPipe> _drainpipe in _DrainPipes)
                {
                    _drainpipe.Value.Query(mySecurityToken, myTransactionToken, myQueryString, myQueryLanguageName);
                }

                IQueryResult result = queryLanguage.Query(mySecurityToken, myTransactionToken, myQueryString);

                // drain every query result (after the query)
                foreach (KeyValuePair <String, IDrainPipe> _drainpipe in _DrainPipes)
                {
                    _drainpipe.Value.DrainQueryResult(result);
                }

                return(result);
            }
            else
            {
                throw new QueryLanguageNotFoundException(String.Format("The GraphDS server does not support the query language {0}", myQueryLanguageName));
            }
        }
Exemple #2
0
        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            _query = myQuery;

            var vertexType = myGraphDB.GetVertexType<IVertexType>(
                mySecurityToken,
                myTransactionToken,
                new RequestGetVertexType(_typeName),
                (stats, vType) => vType);

            _WhereExpression.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType);

            var expressionGraph = _WhereExpression.Calculon(myPluginManager, myGraphDB, mySecurityToken,
                                                            myTransactionToken,
                                                            new CommonUsageGraph(myGraphDB, mySecurityToken,
                                                                                 myTransactionToken));

            var toBeDeletedVertices =
                expressionGraph.Select(
                    new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken),
                    null, true);

            //TODO: do sth that is better than that: ew RequestDelete(new RequestGetVertices(_typeName, toBeDeletedVertices.Select(_ => _.VertexID))).
            return myGraphDB.Delete<QueryResult>(
                mySecurityToken,
                myTransactionToken,
                new RequestDelete(new RequestGetVertices(_typeName, toBeDeletedVertices.Select(_ => _.VertexID))).AddAttributes(_toBeDeletedAttributes),
                CreateQueryResult);
        }
        public override QueryResult GetResult(
            GQLPluginManager myPluginManager,
            IGraphDB myGraphDB,
            SecurityToken mySecurityToken,
            TransactionToken myTransactionToken)
        {
            var resultingVertices = new List<IVertexView>();
            ASonesException error = null;

            #region Specific index

            var request = new RequestDescribeIndex(_TypeName, _IndexName, _IndexEdition);

            var indices = myGraphDB.DescribeIndex<IEnumerable<IIndexDefinition>>(mySecurityToken, myTransactionToken, request, (stats, definitions) => definitions);

            if (indices == null)
            {
                error = new IndexTypeDoesNotExistException(_TypeName, _IndexName);
            }

            if (String.IsNullOrEmpty(_IndexEdition))
            {
                //_IndexEdition = DBConstants.DEFAULTINDEX;
            }

            resultingVertices = new List<IVertexView>() { GenerateOutput(indices, _IndexName) };

            #endregion

            if(error != null)
                return new QueryResult("", SonesGQLConstants.GQL, 0L, ResultType.Failed, resultingVertices, error);
            else
                return new QueryResult("", SonesGQLConstants.GQL, 0L, ResultType.Successful, resultingVertices);
        }
Exemple #4
0
        public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, params FuncParameter[] myParams)
        {
            if (!(myCallingObject is String))
            {
                throw new FunctionParameterTypeMismatchException(typeof(String), myCallingObject.GetType());
            }

            var pos = Convert.ToInt32(myParams[0].Value);

            StringBuilder resString = new StringBuilder();
            bool dontInsert = false;

            if (pos > (myCallingObject as String).Length)
            {
                dontInsert = true;
                resString.Append((myCallingObject as String).ToString());
            }
            else
            {
                resString.Append((myCallingObject as String).ToString().Substring(0, pos));
            }

            foreach (FuncParameter fp in myParams.Skip(1))
            {
                resString.Append(fp.Value as String);
            }

            if(!dontInsert)
                resString.Append((myCallingObject as String).ToString().Substring(pos));

            return new FuncParameter(resString.ToString());
        }
Exemple #5
0
        /// <summary>
        /// Executes the function on myCallingObject
        /// </summary>
        public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, params FuncParameter[] myParams)
        {
            var currentInnerEdgeType = ((IOutgoingEdgeDefinition)myAttributeDefinition).InnerEdgeType;

            if (myCallingObject is IHyperEdge && currentInnerEdgeType.HasProperty("Weight"))
            {
                var hyperEdge = myCallingObject as IHyperEdge;

                if (currentInnerEdgeType.HasProperty("Weight"))
                {
                    var weightProperty = currentInnerEdgeType.GetPropertyDefinition("Weight");

                    var maxWeight = hyperEdge.InvokeHyperEdgeFunc<Double>(singleEdges =>
                    {
                        return Convert.ToDouble(
                            weightProperty.GetValue(
                            singleEdges
                            .OrderByDescending(edge => weightProperty.GetValue(edge))
                            .First()));
                    });

                    return new FuncParameter(maxWeight);

                }
            }

            throw new InvalidTypeException(myCallingObject.GetType().ToString(), "Weighted IHyperEdge");
        }
Exemple #6
0
 public TResult Update <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken, RequestUpdate myRequestUpdate, Converter.UpdateResultConverter <TResult> myOutputconverter)
 {
     return(_iGraphDB.Update <TResult>(mySecurityToken,
                                       myTransactionToken,
                                       myRequestUpdate,
                                       myOutputconverter));
 }
Exemple #7
0
        /// <summary> Конструктор класса GraphDBTest
        /// Создается база данных graphDB и сервер GraphDSServer
        /// </summary>
        public GraphDBTest()
        {
            var graphDB = new SonesGraphDB();

            List<PluginDefinition> QueryLanguagePATH = new List<PluginDefinition>();
            Dictionary<string, object> GQL_Parameters = new Dictionary<string, object>();
            GQL_Parameters.Add("GraphDB", graphDB);

            QueryLanguagePATH.Add(new PluginDefinition("sones.gql", GQL_Parameters));
 
            //adding the QueryLanguage as a GraphDSPlugin
            GraphDSPlugins PluginsAndParameters = new GraphDSPlugins(QueryLanguagePATH);

            GraphDSServer = new GraphDS_Server(graphDB, PluginsAndParameters);
            
            SecToken = GraphDSServer.LogOn(new UserPasswordCredentials("User", "test"));
            TransactionID = GraphDSServer.BeginTransaction(SecToken);

            edge_list = new List<List< KeyValuePair<long, Int32> >>();

            Dictionary<string, object> RestParameter = new Dictionary<string, object>();
            RestParameter.Add("IPAddress", IPAddress.Any);
            RestParameter.Add("Port", 9975);
            RestParameter.Add("Username", "test");
            RestParameter.Add("Password", "test");
            GraphDSServer.StartService("sones.RESTService", RestParameter);
        }
Exemple #8
0
 public TResult GetAllEdgeTypes <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken, RequestGetAllEdgeTypes myRequestGetAllEdgeTypes, Converter.GetAllEdgeTypesResultConverter <TResult> myOutputconverter)
 {
     return(_iGraphDB.GetAllEdgeTypes <TResult>(mySecurityToken,
                                                myTransactionToken,
                                                myRequestGetAllEdgeTypes,
                                                myOutputconverter));
 }
Exemple #9
0
 public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, params FuncParameter[] myParams)
 {
     if (myCallingObject is IHyperEdge)
     {
         return new FuncParameter((UInt64)((IHyperEdge)myCallingObject).GetAllEdges().Count());
     }
     else if (myCallingObject is ISingleEdge)
     {
         UInt64 count = 1;
         return new FuncParameter(count);
     }
     else if (myCallingObject is IncomingEdgeCollection)
     {
         return new FuncParameter((UInt64)(myCallingObject as IncomingEdgeCollection).LongCount());
     }
     else if (myCallingObject is IEnumerable<long>)
     {
         return new FuncParameter((UInt64)(myCallingObject as IEnumerable<long>).LongCount());
     }
     else if (myCallingObject is IEnumerable<IVertex>)
     {
         return new FuncParameter((UInt64)(myCallingObject as IEnumerable<IVertex>).LongCount());
     }
     else
     {
         throw new UnknownDBException("Unexpected input for COUNT aggregate.");
     }
 }
Exemple #10
0
 public TResult RebuildIndices <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken, RequestRebuildIndices myRequestRebuildIndices, Converter.RebuildIndicesResultConverter <TResult> myOutputconverter)
 {
     return(_iGraphDB.RebuildIndices <TResult>(mySecurityToken,
                                               myTransactionToken,
                                               myRequestRebuildIndices,
                                               myOutputconverter));
 }
Exemple #11
0
        public override QueryResult Execute(IGraphDB myGraphDB, 
            IGraphQL myGraphQL,
            GQLPluginManager myPluginManager,
            String myQuery,
            SecurityToken mySecurityToken,
            Int64 myTransactionToken)
        {
            _queryString = myQuery;

            QueryResult result;

            try
            {
                result = myGraphDB.Insert<QueryResult>(
                        mySecurityToken,
                        myTransactionToken,
                        CreateRequest(myPluginManager,
                                        myGraphDB,
                                        mySecurityToken,
                                        myTransactionToken),
                        CreateQueryResult);
            }
            catch (ASonesException e)
            {
                result = new QueryResult(_queryString, SonesGQLConstants.GQL, 0, ResultType.Failed, null, e);
            }

            return result;
        }
        public override IEnumerable<IVertex> GetVertices(RequestGetVertices _request, Int64 Int64, SecurityToken SecurityToken)
        {
            #region case 1 - Expression

            if (_request.Expression != null)
            {
                if (!_queryPlanManager.IsValidExpression(_request.Expression))
                {
                    throw new InvalidExpressionException(_request.Expression);
                }
            }
            
            #endregion

            #region case 2 - No Expression

            else if (_request.VertexTypeName != null)
            {
                //2.1 typeName as string
                _vertexTypeManager.CheckManager.GetType(_request.VertexTypeName, Int64, SecurityToken);
            }
            else
            {
                //2.2 type as id
                _vertexTypeManager.CheckManager.GetType(_request.VertexTypeID, Int64, SecurityToken);
            }

            #endregion

            return null;
        }
Exemple #13
0
 public TResult DropEdgeType <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken, RequestDropEdgeType myRequestDropType, Converter.DropEdgeTypeResultConverter <TResult> myOutputconverter)
 {
     return(_iGraphDB.DropEdgeType <TResult>(mySecurityToken,
                                             myTransactionToken,
                                             myRequestDropType,
                                             myOutputconverter));
 }
Exemple #14
0
        /// <summary>
        /// Creates a query plan using a logic expression
        /// </summary>
        /// <param name="myExpression">The logic expression</param>
        /// <param name="myIsLongRunning">Determines whether it is anticipated that the request could take longer</param>
        /// <param name="myTransaction">The current transaction token</param>
        /// <param name="mySecurity">The current security token</param>
        /// <returns>A query plan</returns>
        public IQueryPlan CreateQueryPlan(IExpression myExpression, 
                                            Boolean myIsLongRunning, 
                                            Int64 myTransaction, 
                                            SecurityToken mySecurity)
        {
            IQueryPlan result;

            switch (myExpression.TypeOfExpression)
            {
                case TypeOfExpression.Binary:

                    result = GenerateFromBinaryExpression((BinaryExpression) myExpression, myIsLongRunning, myTransaction, mySecurity);

                    break;
                
                case TypeOfExpression.Unary:
                    
                    result = GenerateFromUnaryExpression((UnaryExpression)myExpression, myTransaction, mySecurity);    

                    break;
               
                case TypeOfExpression.Property:

                    result = GenerateFromPropertyExpression((PropertyExpression)myExpression, myTransaction, mySecurity);

                    break;
                
                default:
                    throw new ArgumentOutOfRangeException();
            }

            return result;
        }
Exemple #15
0
 public TResult Insert <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken, RequestInsertVertex myRequestInsert, Converter.InsertResultConverter <TResult> myOutputconverter)
 {
     return(_iGraphDB.Insert <TResult>(mySecurityToken,
                                       myTransactionToken,
                                       myRequestInsert,
                                       myOutputconverter));
 }
Exemple #16
0
        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            Query = myQuery;

            var indexDef = new IndexPredefinition(_IndexName);
            indexDef.SetIndexType(_IndexType);
            indexDef.SetVertexType(_DBType);
            indexDef.SetEdition(_IndexEdition);

            //to be indices attributes
            foreach (var aIndexedProperty in _AttributeList)
            {
                indexDef.AddProperty(aIndexedProperty.IndexAttribute.ContentString);
            }

            //options for the index
            if (_options != null)
            {
                foreach (var aKV in _options)
                {
                    indexDef.AddOption(aKV.Key, aKV.Value);
                }
            }

            return myGraphDB.CreateIndex<QueryResult>(mySecurityToken, myTransactionToken, new RequestCreateIndex(indexDef), GenerateResult);
        }
Exemple #17
0
        public IVertex AddVertex(RequestInsertVertex myInsertDefinition, TransactionToken myTransaction, SecurityToken mySecurity)
        {
            IVertexType vertexType = GetVertexType(myInsertDefinition.VertexTypeName, myTransaction, mySecurity);

            if (vertexType.IsAbstract)
                throw new AbstractConstraintViolationException(myInsertDefinition.VertexTypeName);

            ConvertUnknownProperties(myInsertDefinition, vertexType);
            ConvertDefaultValues(myInsertDefinition, vertexType);

            if (myInsertDefinition.OutgoingEdges != null)
                CheckOutgoingEdges(myInsertDefinition.OutgoingEdges, vertexType);

            if (myInsertDefinition.StructuredProperties != null)
            {
                CheckAddStructuredProperties(myInsertDefinition.StructuredProperties, vertexType);
            }

            CheckMandatoryConstraint(myInsertDefinition, vertexType);

            if (myInsertDefinition.BinaryProperties != null)
                CheckAddBinaryProperties(myInsertDefinition, vertexType);

            return null;
        }
Exemple #18
0
 public TResult CreateIndex <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken, RequestCreateIndex myRequestCreateIndex, Converter.CreateIndexResultConverter <TResult> myOutputconverter)
 {
     return(_iGraphDB.CreateIndex <TResult>(mySecurityToken,
                                            myTransactionToken,
                                            myRequestCreateIndex,
                                            myOutputconverter));
 }
Exemple #19
0
 public List<Int64> Clear(SecurityToken mySecurityToken, Int64 myTransactionToken)
 {
     var Request = ServiceRequestFactory.MakeRequestClear();
     var Response = this.GraphDS.Clear(mySecurityToken, myTransactionToken, Request,
         ServiceReturnConverter.ConvertOnlyVertexTypeIDs);
     return Response.ToList();
 }
Exemple #20
0
        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            var sw = Stopwatch.StartNew();

            QueryResult result = null;

            if (_DumpFormat.ToString().ToUpper().Equals("GQL"))
            {
                var plugin = myPluginManager.GetAndInitializePlugin<IGraphDBExport>("GQLEXPORT");

                if (plugin != null)
                {
                    result = plugin.Export(_DumpDestination, _DumpableGrammar, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, _TypesToDump, _DumpType);
                }
            }

            sw.Stop();

            if (result != null)
            {
                return new QueryResult(myQuery, _DumpFormat.ToString(), (ulong)sw.ElapsedMilliseconds, result.TypeOfResult, result.Vertices, result.Error);
            }
            else
                return null;
        }
Exemple #21
0
        public TResult Truncate <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.RequestTruncate myRequestTruncate, sones.GraphDB.Request.Converter.TruncateResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();

            _GraphDSService.TruncateVertexType(mySecurityToken, myTransactionID, myRequestTruncate.VertexTypeName);
            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks))));
        }
Exemple #22
0
 public ServiceVertexType AlterVertexType(SecurityToken mySecurityToken, Int64 myTransactionToken,
     ServiceVertexType myVertexType, ServiceAlterVertexChangeset myChangeset)
 {
     var Request = ServiceRequestFactory.MakeRequestAlterVertexType(myVertexType, myChangeset);
     var Response = this.GraphDS.AlterVertexType<IVertexType>(mySecurityToken, myTransactionToken, Request,
         ServiceReturnConverter.ConvertOnlyVertexType);
     return new ServiceVertexType(Response);
 }
Exemple #23
0
        public TResult DropIndex <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestDropIndex myRequestDropIndex, sones.GraphDB.Request.Converter.DropIndexResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();

            _GraphDSService.DropIndex(mySecurityToken, myTransactionID, new ServiceVertexType(myRequestDropIndex.TypeName), myRequestDropIndex.IndexName, myRequestDropIndex.Edition);
            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks))));
        }
Exemple #24
0
 /// <summary>
 /// Constructor
 /// </summary>
 public CommonUsageGraph(IGraphDB myIGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
     : this()
 {
     _iGraphDB = myIGraphDB;
     _securityToken = mySecurityToken;
     _transactionToken = myTransactionToken;
     _Levels = new Dictionary<int, IExpressionLevel>();
 }
Exemple #25
0
        public TResult DropEdgeType <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestDropEdgeType myRequestDropType, sones.GraphDB.Request.Converter.DropEdgeTypeResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       result      = _GraphDSService.DropEdgeType(mySecurityToken, myTransactionID, new ServiceEdgeType(myRequestDropType.TypeName));

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), result));
        }
 public override IEnumerable<IVertex> GetVertices(IVertexType myVertexType, Int64 myTransaction, SecurityToken mySecurity, Boolean myIncludeSubtypes)
 {
     if (myVertexType == null)
     {
         throw new ArgumentNullException("myVertexType");
     }
     return null;
 }
Exemple #27
0
        public TResult Clear <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestClear myRequestClear, sones.GraphDB.Request.Converter.ClearResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       result      = _GraphDSService.Clear(mySecurityToken, myTransactionID);

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), result));
        }
Exemple #28
0
        public TResult RebuildIndices <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestRebuildIndices myRequestRebuildIndices, sones.GraphDB.Request.Converter.RebuildIndicesResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();

            _GraphDSService.RebuildIndices(mySecurityToken, myTransactionID, myRequestRebuildIndices.Types.ToList());
            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks))));
        }
Exemple #29
0
        public TResult GetVertexCount <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestGetVertexCount myRequestGetVertexCount, sones.GraphDB.Request.Converter.GetVertexCountResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       vertexCount = _GraphDSService.GetVertexCount(mySecurityToken, myTransactionID, new ServiceVertexType(myRequestGetVertexCount.VertexTypeName));

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), vertexCount));
        }
Exemple #30
0
        public LevelKey(IEnumerable<EdgeKey> myEdgeKey, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken)
        {
            Edges = new List<EdgeKey>();

            foreach (var aEdgeKey in myEdgeKey)
            {
                if (aEdgeKey.IsAttributeSet)
                {
                    var vertexType = myGraphDB.GetVertexType<IVertexType>
                        (mySecurityToken,
                        myTransactionToken,
                        new RequestGetVertexType(aEdgeKey.VertexTypeID),
                        (stats, type) => type);

                    var attribute = vertexType.GetAttributeDefinition(aEdgeKey.AttributeID);

                    if (attribute != null && attribute.Kind != AttributeType.Property)
                    {
                        //so there is an edge
                        Edges.Add(aEdgeKey);
                        Level++;

                        AddHashCodeFromSingleEdge(ref _hashcode, aEdgeKey);
                    }
                    else
                    {
                        if (Level == 0)
                        {
                            var newEdgeKey = new EdgeKey(aEdgeKey.VertexTypeID);
                            Edges.Add(newEdgeKey);

                            AddHashCodeFromSingleEdge(ref _hashcode, newEdgeKey);

                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    if (Level == 0)
                    {
                        Edges.Add(aEdgeKey);

                        AddHashCodeFromSingleEdge(ref _hashcode, aEdgeKey);

                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
Exemple #31
0
        public override QueryResult GetResult(  GQLPluginManager myPluginManager,
            IGraphDB myGraphDB,
            SecurityToken mySecurityToken,
            Int64 myTransactionToken)
        {
            var resultingVertices = new List<IVertexView>();
            ASonesException error = null;

            if (!String.IsNullOrEmpty(_EdgeName))
            {

                #region Specific edge

                var request = new RequestGetEdgeType(_EdgeName);
                var edge = myGraphDB.GetEdgeType<IEdgeType>(mySecurityToken,
                                                            myTransactionToken,
                                                            request,
                                                            (stats, edgeType) => edgeType);

                if (edge != null)
                {
                    resultingVertices = new List<IVertexView>() { GenerateOutput(edge, _EdgeName) };
                }
                else
                {
                    error = new EdgeTypeDoesNotExistException(_EdgeName);
                }

                #endregion

            }
            else
            {

                #region All edges

                var resultingReadouts = new List<IVertexView>();

                var request = new RequestGetAllEdgeTypes();

                foreach (var edge in myGraphDB.GetAllEdgeTypes<IEnumerable<IEdgeType>>(mySecurityToken,
                                                                                        myTransactionToken,
                                                                                        request,
                                                                                        (stats, edgeTypes) => edgeTypes))
                {
                    resultingReadouts.Add(GenerateOutput(edge, edge.Name));
                }

                #endregion

            }

            if(error != null)
                return new QueryResult("", SonesGQLConstants.GQL, 0L, ResultType.Failed, resultingVertices, error);
            else
                return new QueryResult("", SonesGQLConstants.GQL, 0L, ResultType.Successful, resultingVertices);
        }
Exemple #32
0
        /// <summary>
        /// This will receive a query and store it to the log
        /// </summary>
        public IQueryResult Query(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionID, string myQueryString, string myQueryLanguageName)
        {
            byte[] Part1, Part2, Part3, Part4 = null;
            System.IO.MemoryStream stream     = new System.IO.MemoryStream();

            System.Runtime.Serialization.Formatters.Binary.BinaryFormatter Formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();

            #region Generate byte represenation of query
            if (mySecurityToken != null)
            {
                Formatter.Serialize(stream, mySecurityToken);
            }
            else
            {
                Formatter.Serialize(stream, new SecurityToken());
            }

            Part1 = stream.ToArray();
            if (myTransactionID != null)
            {
                Formatter.Serialize(stream, myTransactionID);
            }
            else
            {
                Formatter.Serialize(stream, long.MaxValue);
            }

            Part2 = stream.ToArray();
            if (myQueryString != null)
            {
                Formatter.Serialize(stream, myQueryString);
            }
            else
            {
                Formatter.Serialize(stream, "");
            }
            Part3 = stream.ToArray();
            if (myQueryLanguageName != null)
            {
                Formatter.Serialize(stream, myQueryLanguageName);
            }
            else
            {
                Formatter.Serialize(stream, "");
            }
            Part4 = stream.ToArray();
            #endregion

            byte[] Data = new byte[Part1.Length + Part2.Length + Part3.Length + Part4.Length];
            System.Buffer.BlockCopy(Part1, 0, Data, 0, Part1.Length);
            System.Buffer.BlockCopy(Part2, 0, Data, Part1.Length, Part2.Length);
            System.Buffer.BlockCopy(Part3, 0, Data, Part1.Length + Part2.Length, Part3.Length);
            System.Buffer.BlockCopy(Part4, 0, Data, Part1.Length + Part2.Length + Part3.Length, Part4.Length);

            Write(Data);
            return(null);
        }
Exemple #33
0
 public SecurityToken LogOn(IUserCredentials myUserCredentials)
 {
     if (myUserCredentials is RemoteUserPasswordCredentials)
     {
         _SecurityToken = _GraphDSService.LogOn(((RemoteUserPasswordCredentials)myUserCredentials).ServiceObject);
         return(_SecurityToken);
     }
     return(null);
 }
 /// <summary>
 /// Creates a new comparative operator
 /// </summary>
 /// <param name="myProperty">The interesting property</param>
 /// <param name="myConstant">The constant value</param>
 /// <param name="myIsLongrunning">Determines whether it is anticipated that the request could take longer</param>
 /// <param name="mySecurityToken">The current security token</param>
 /// <param name="myTransactionToken">The current transaction token</param>
 /// <param name="myVertexStore">The vertex store that is needed to load the vertices</param>
 protected AComparativeOperator(QueryPlanProperty myProperty, ILiteralExpression myConstant, Boolean myIsLongrunning, SecurityToken mySecurityToken, Int64 myTransactionToken, IVertexStore myVertexStore)
 {
     _property = myProperty;
     _constant = myConstant;
     _isLongrunning = myIsLongrunning;
     _vertexStore = myVertexStore;
     _securityToken = mySecurityToken;
     _transactionToken = myTransactionToken;
 }
Exemple #35
0
        public TResult DescribeIndices <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestDescribeIndex myRequestDescribeIndex, sones.GraphDB.Request.Converter.DescribeIndicesResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       svcIndices  = _GraphDSService.DescribeIndices(mySecurityToken, myTransactionID, myRequestDescribeIndex.TypeName);
            var       indices     = svcIndices.Select(x => new RemoteIndexDefinition(x, this));

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), indices));
        }
Exemple #36
0
        public TResult GetAllEdgeTypes <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestGetAllEdgeTypes myRequestGetAllEdgeTypes, sones.GraphDB.Request.Converter.GetAllEdgeTypesResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime  = Stopwatch.StartNew();
            var       svcEdgeTypes = _GraphDSService.GetAllEdgeTypes(mySecurityToken, myTransactionID, myRequestGetAllEdgeTypes.Edition);
            var       edgeTypes    = svcEdgeTypes.Select(x => new RemoteEdgeType(x, this));

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), edgeTypes));
        }
Exemple #37
0
        public TResult CreateVertexType <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestCreateVertexType myRequestCreateVertexType, sones.GraphDB.Request.Converter.CreateVertexTypeResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime   = Stopwatch.StartNew();
            var       svcVertexType = _GraphDSService.CreateVertexType(mySecurityToken, myTransactionID, new ServiceVertexTypePredefinition(myRequestCreateVertexType.VertexTypeDefinition));
            var       vertexType    = new RemoteVertexType(svcVertexType, this);

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), vertexType));
        }
Exemple #38
0
        public TResult CreateIndex <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestCreateIndex myRequestCreateIndex, sones.GraphDB.Request.Converter.CreateIndexResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       svcIndexDef = _GraphDSService.CreateIndex(mySecurityToken, myTransactionID, new ServiceIndexPredefinition(myRequestCreateIndex.IndexDefinition));
            var       indexDef    = new RemoteIndexDefinition(svcIndexDef, this);

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), indexDef));
        }
        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            _query = myQuery;

            return myGraphDB.AlterVertexType<QueryResult>(
                mySecurityToken,
                myTransactionToken,
                CreateNewRequest(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken),
                CreateOutput);
        }
Exemple #40
0
        public List<TypeWithProperty> StringParser(String current_string, IGraphDB myDB, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            current_string = current_string.Replace(" ","");

            List<TypeWithProperty> list = new List<TypeWithProperty>();
            bool endFlag = false;
            int EndPos = 0;

                do
                {

                    EndPos = current_string.IndexOf(',');
                    if (EndPos == -1)
                    {
                        EndPos = current_string.Length;
                        endFlag = true;
                    }

                    var typeVertexString = current_string.Substring(0, current_string.IndexOf('.'));


                    IVertexType typeVertex = null;

                    try
                    {

                        typeVertex = myDB.GetVertexType<IVertexType>(
                                                         mySecurityToken,
                                                         myTransactionToken,
                                                         new sones.GraphDB.Request.RequestGetVertexType(typeVertexString),
                                                         (statistics, type) => type);
                    }
                    catch
                    {
                        throw new InvalidFunctionParameterException("edgeType", "Object reference not set to an instance of an object.", "null");
                    }
                    var propertyIDString = current_string.Substring(current_string.IndexOf('.') + 1, EndPos - current_string.IndexOf('.') - 1);
                    var property = typeVertex.GetPropertyDefinition(propertyIDString);
                     if (property==null)
                         throw new InvalidFunctionParameterException("Property", "Property: " + propertyIDString + " not exist in VertexType:" + typeVertexString, "null");
                    TypeWithProperty value = new TypeWithProperty();
                    value.propertyDifinition = property;
                    value.type = typeVertex;

                    if (!list.Contains(value))
                        list.Add(value);

                    if (!endFlag)
                        current_string = current_string.Substring(EndPos + 1);

                }
                while (endFlag != true);
 
            return list;
        }
        public override IEnumerable<IVertexView> GetResult(
                                                GQLPluginManager myPluginManager,
                                                IGraphDB myGraphDB,
                                                SecurityToken mySecurityToken,
                                                Int64 myTransactionToken)
        {
            var resultingVertices = new List<IVertexView>();

            if (!String.IsNullOrEmpty(_EdgeName))
            {

                #region Specific edge

                var request = new RequestGetEdgeType(_EdgeName);
                var edge = myGraphDB.GetEdgeType<IEdgeType>(mySecurityToken, 
                                                            myTransactionToken, 
                                                            request, 
                                                            (stats, edgeType) => edgeType);

                if (edge != null)
                {
                    resultingVertices = new List<IVertexView>() { GenerateOutput(edge, _EdgeName) };
                }
                else
                {
                    throw new EdgeTypeDoesNotExistException(_EdgeName);
                }

                #endregion

            }
            else
            {

                #region All edges

                var resultingReadouts = new List<IVertexView>();

                var request = new RequestGetAllEdgeTypes();

                foreach (var edge in myGraphDB.GetAllEdgeTypes<IEnumerable<IEdgeType>>(mySecurityToken,     
                                                                                        myTransactionToken, 
                                                                                        request, 
                                                                                        (stats, edgeTypes) => edgeTypes))
                {
                    resultingReadouts.Add(GenerateOutput(edge, edge.Name));
                }


                #endregion

            }

            return resultingVertices;
        }
Exemple #42
0
 public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, TransactionToken myTransactionToken, params FuncParameter[] myParams)
 {
     if (myCallingObject != null)
     {
         return new FuncParameter(true);
     }
     else
     {
         return new FuncParameter(false);
     }
 }
Exemple #43
0
        public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken, params FuncParameter[] myParams)
        {
            if (!(myCallingObject is String))
            {
                throw new FunctionParameterTypeMismatchException(typeof(String), myCallingObject.GetType());
            }

            var substring = myCallingObject.ToString().Substring(Convert.ToInt32(myParams[0].Value), Convert.ToInt32(myParams[1].Value));

            return new FuncParameter(substring);
        }
Exemple #44
0
        public override IEnumerable<IVertexType> AddVertexTypes(IEnumerable<VertexTypePredefinition> myVertexTypeDefinitions, TransactionToken myTransaction, SecurityToken mySecurity)
        {
            #region check arguments

            myVertexTypeDefinitions.CheckNull("myVertexTypeDefinitions");

            #endregion

            CheckAdd(myVertexTypeDefinitions);
            return null;
        }
Exemple #45
0
        public TResult AlterEdgeType <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestAlterEdgeType myRequestAlterEdgeType, sones.GraphDB.Request.Converter.AlterEdgeTypeResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       svcEdgeType = _GraphDSService.AlterEdgeType(mySecurityToken, myTransactionID,
                                                                  new ServiceEdgeType(myRequestAlterEdgeType.TypeName),
                                                                  new ServiceAlterEdgeChangeset(myRequestAlterEdgeType));
            var edgeType = new RemoteEdgeType(svcEdgeType, this);

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), edgeType));
        }
Exemple #46
0
        public TResult Delete <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestDelete myRequestDelete, sones.GraphDB.Request.Converter.DeleteResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       result      = _GraphDSService.Delete(mySecurityToken, myTransactionID,
                                                           new ServiceVertexType(myRequestDelete.ToBeDeletedVertices.VertexTypeName),
                                                           myRequestDelete.ToBeDeletedVertices.VertexIDs.ToList(),
                                                           new ServiceDeletePayload(myRequestDelete));

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), result.Item1.Select(x => (IComparable)x), result.Item2.Select(x => (IComparable)x)));
        }
Exemple #47
0
        public QueryResult Import(String myLocation, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, UInt32 myParallelTasks = 1U, IEnumerable<string> myComments = null, UInt64? myOffset = null, UInt64? myLimit = null, VerbosityTypes myVerbosityType = VerbosityTypes.Silent)
        {
            ASonesException error;
            Stream stream = null;
            QueryResult result;

            #region Read querie lines from location

            try
            {
                #region file
                if (myLocation.ToLower().StartsWith(@"file:\\"))
                {
                    //lines = ReadFile(location.Substring(@"file:\\".Length));
                    stream = GetStreamFromFile(myLocation.Substring(@"file:\\".Length));
                }
                #endregion
                #region http
                else if (myLocation.ToLower().StartsWith("http://"))
                {
                    stream = GetStreamFromHttp(myLocation);
                }
                #endregion
                else
                {
                    error = new InvalidImportLocationException(myLocation, @"file:\\", "http://");
                    result = new QueryResult("", ImportFormat, 0L, ResultType.Failed, null, error);
                    return result;
                }

                #region Start import using the AGraphDBImport implementation and return the result

                return Import(stream, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, myParallelTasks, myComments, myOffset, myLimit, myVerbosityType);

                #endregion
            }
            catch (Exception ex)
            {
                #region throw new exception
                error = new ImportFailedException(ex);
                result = new QueryResult("", ImportFormat, 0L, ResultType.Failed, null, error);
                return result;
                #endregion
            }
            finally
            {
                if (stream != null)
                {
                    stream.Dispose();
                }
            }

            #endregion
        }
Exemple #48
0
 public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition, Object myCallingObject, IVertex myDBObject, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken, params FuncParameter[] myParams)
 {
     if (myCallingObject is String)
     {
         return new FuncParameter(((String)myCallingObject).ToLower());
     }
     else
     {
         throw new FunctionParameterTypeMismatchException(typeof(String), myCallingObject.GetType());
     }
 }
Exemple #49
0
        public TResult Update <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestUpdate myRequestUpdate, sones.GraphDB.Request.Converter.UpdateResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       svcVertices = _GraphDSService.Update(
                mySecurityToken,
                myTransactionID,
                new ServiceUpdateChangeset(myRequestUpdate));
            var vertices = svcVertices.Select(x => new RemoteVertex(x, this));

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), vertices));
        }
Exemple #50
0
 public List<ServiceEdgeInstance> GetAllOutgoingEdges(SecurityToken mySecurityToken, Int64 myTransToken, ServiceVertexInstance myVertex)
 {
     var Request = ServiceRequestFactory.MakeRequestGetVertex(myVertex.TypeID, myVertex.VertexID);
     var Response = this.GraphDS.GetVertex<IVertex>(mySecurityToken, myTransToken, Request, ServiceReturnConverter.ConvertOnlyVertexInstance);
     return Response.GetAllOutgoingEdges().Select<Tuple<long, IEdge>, ServiceEdgeInstance>(x =>
     {
         if (x.Item2 is ISingleEdge)
             return new ServiceSingleEdgeInstance(x.Item2 as ISingleEdge, x.Item1);
         else
             return new ServiceHyperEdgeInstance(x.Item2 as IHyperEdge, x.Item1);
     }).ToList();
 }
Exemple #51
0
 public List<ServiceIncomingVerticesContainer> GetAllIncomingVertices(SecurityToken mySecurityToken, Int64 myTransToken, ServiceVertexInstance myVertex)
 {
     var Request = ServiceRequestFactory.MakeRequestGetVertex(myVertex.TypeID, myVertex.VertexID);
     var Response = this.GraphDS.GetVertex<IVertex>(mySecurityToken, myTransToken, Request, ServiceReturnConverter.ConvertOnlyVertexInstance);
     return Response.GetAllIncomingVertices().Select(
         x => new ServiceIncomingVerticesContainer
             {
                 VertexTypeID = x.VertexTypeID,
                 EdgePropertyID = x.EdgePropertyID,
                 IncomingVertices = x.IncomingVertices.Select(y => new ServiceVertexInstance(y)).ToList()
             } ).ToList();
 }
Exemple #52
0
        public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken)
        {
            var sw = Stopwatch.StartNew();

            QueryResult result = null;
            _query = myQuery;
            String myAction = "";
            IEnumerable<IVertex> myToBeUpdatedVertices = null;

            //prepare
            var vertexType = myGraphDB.GetVertexType<IVertexType>(
                mySecurityToken,
                myTransactionToken,
                new RequestGetVertexType(_Type),
                (stats, vtype) => vtype);

            if (_WhereExpression != null)
            {
                //validate
                _WhereExpression.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType);

                //calculate
                var expressionGraph = _WhereExpression.Calculon(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, new CommonUsageGraph(myGraphDB, mySecurityToken, myTransactionToken), false);

                //extract
                myToBeUpdatedVertices = expressionGraph.Select(new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken), null, true).ToList();
            }

            if (myToBeUpdatedVertices != null && myToBeUpdatedVertices.Count() > 0)
            {

                //update
                result = ProcessUpdate(myToBeUpdatedVertices, myGraphDB, myPluginManager, mySecurityToken, myTransactionToken);
                myAction = "Updated";

            }
            else
            {

                //insert
                result = ProcessInsert(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken);
                myAction = "Inserted";

            }

            if (result.Error != null)
                throw result.Error;

            sw.Stop();

            return GenerateResult(sw.Elapsed.TotalMilliseconds, result, myAction);
        }
Exemple #53
0
        /// <summary>
        /// Shutdown of this plugin / GraphDS interface handling
        /// </summary>
        /// <param name="mySecurityToken"></param>
        public void Shutdown(sones.Library.Commons.Security.SecurityToken mySecurityToken)
        {
            WriteThreadInstance.Shutdown();

            if (AsynchronousMode)
            {
                while (!WriteThreadInstance.ShutdownComplete)
                {
                    Thread.Sleep(1);
                }
            }
            // flush and close up
            if (_AppendLog != null)
            {
                _AppendLog.Shutdown();
            }
        }
Exemple #54
0
        public TResult GetEdgeType <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestGetEdgeType myRequestGetEdgeType, sones.GraphDB.Request.Converter.GetEdgeTypeResultConverter <TResult> myOutputconverter)
        {
            Stopwatch       RunningTime = Stopwatch.StartNew();
            ServiceEdgeType svcEdgeType;

            if (myRequestGetEdgeType.EdgeTypeName != null)
            {
                svcEdgeType = _GraphDSService.GetEdgeTypeByName(mySecurityToken, myTransactionID, myRequestGetEdgeType.EdgeTypeName, myRequestGetEdgeType.Edition);
            }
            else
            {
                svcEdgeType = _GraphDSService.GetEdgeTypeByID(mySecurityToken, myTransactionID, myRequestGetEdgeType.EdgeTypeID, myRequestGetEdgeType.Edition);
            }
            var edgeType = new RemoteEdgeType(svcEdgeType, this);

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), edgeType));
        }
Exemple #55
0
        public TResult Insert <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestInsertVertex myRequestInsert, sones.GraphDB.Request.Converter.InsertResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            var       svcVertex   = _GraphDSService.Insert(mySecurityToken, myTransactionID, myRequestInsert.VertexTypeName, new ServiceInsertPayload(myRequestInsert));

            if (myRequestInsert.BinaryProperties != null)
            {
                foreach (var item in myRequestInsert.BinaryProperties)
                {
                    _StreamedService.SetBinaryProperty(new SetBinaryPropertyMessage(item.Key, _SecurityToken, _TransactionToken, svcVertex.VertexID, svcVertex.TypeID, item.Value));
                }
            }


            var vertex = new RemoteVertex(svcVertex, this);

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), vertex));
        }
Exemple #56
0
        public void Shutdown(sones.Library.Commons.Security.SecurityToken mySecurityToken)
        {
            _iGraphDB.Shutdown(mySecurityToken);

            foreach (var aDrainPipe in _DrainPipes)
            {
                aDrainPipe.Value.Shutdown(mySecurityToken);
            }

            foreach (var aUsageDataCollector in _usagedatacollectors)
            {
                aUsageDataCollector.Value.Shutdown();
            }

            foreach (var aService in _graphDSServices)
            {
                aService.Value.Stop();
            }
        }
Exemple #57
0
        public TResult GetVertices <TResult>(sones.Library.Commons.Security.SecurityToken mySecurityToken, long myTransactionID, sones.GraphDB.Request.RequestGetVertices myRequestGetVertices, sones.GraphDB.Request.Converter.GetVerticesResultConverter <TResult> myOutputconverter)
        {
            Stopwatch RunningTime = Stopwatch.StartNew();
            List <ServiceVertexInstance> svcVertices;

            if (myRequestGetVertices.VertexTypeName != null)
            {
                svcVertices = _GraphDSService.GetVerticesByType(mySecurityToken, myTransactionID, new ServiceVertexType(myRequestGetVertices.VertexTypeName));
            }
            else if (myRequestGetVertices.VertexTypeID != null)
            {
                svcVertices = _GraphDSService.GetVerticesByType(mySecurityToken, myTransactionID, new ServiceVertexType(myRequestGetVertices.VertexTypeID));
            }
            else
            {
                svcVertices = _GraphDSService.GetVerticesByExpression(mySecurityToken, myTransactionID, ConvertHelper.ToServiceExpression(myRequestGetVertices.Expression));
            }
            var vertices = svcVertices.Select(x => new RemoteVertex(x, this));

            RunningTime.Stop();
            return(myOutputconverter(new RequestStatistics(new TimeSpan(RunningTime.ElapsedTicks)), vertices));
        }
Exemple #58
0
        }//method

        #endregion

        #region the actual example

        public void Run()
        {
            GraphDSClient = new GraphDS_RemoteClient(new Uri("http://localhost:9970/rpc"));
            SecToken      = GraphDSClient.LogOn(new RemoteUserPasswordCredentials("test", "test"));
            TransToken    = GraphDSClient.BeginTransaction(SecToken);

            GraphDSClient.Clear <IRequestStatistics>(SecToken, TransToken, new RequestClear(), (Statistics, DeletedTypes) => Statistics);

            #region create types, create instances and additional work using the GraphDB API

            GraphDSClient.Clear <IRequestStatistics>(SecToken, TransToken, new RequestClear(), (Statistics, DeletedTypes) => Statistics);

            Console.WriteLine("Press enter to start example");
            Console.ReadLine();

            GraphDBRequests();

            #endregion

            //clear the DB (delete all created types) to create them again using the QueryLanguage
            GraphDSClient.Clear <IRequestStatistics>(SecToken, TransToken, new RequestClear(), (Statistics, DeletedTypes) => Statistics);

            #region create some types and insert values using the SonesQueryLanguage

            GraphQLQueries();

            #endregion

            #region make some SELECTS

            SELECTS();

            #endregion

            Console.WriteLine();
            Console.WriteLine("Finished Example. Type a key to finish!");
            Console.ReadKey();
        }
Exemple #59
0
 public void RollbackTransaction(sones.Library.Commons.Security.SecurityToken mySecurityToken, Int64 myTransactionToken)
 {
     _iGraphDB.RollbackTransaction(mySecurityToken, myTransactionToken);
 }
Exemple #60
0
 public void LogOff(sones.Library.Commons.Security.SecurityToken toBeLoggedOfToken)
 {
     _iGraphDB.LogOff(toBeLoggedOfToken);
 }