public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); _query = myQuery; //prepare var vertexType = myGraphDB.GetVertexType <IVertexType>( mySecurityToken, myTransactionToken, new RequestGetVertexType(_SourceType), (stats, vtype) => vtype); //validate _Condition.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType); //calculate var expressionGraph = _Condition.Calculon(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, new CommonUsageGraph(myGraphDB, mySecurityToken, myTransactionToken), false); //extract var myToBeUpdatedVertices = expressionGraph.Select(new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken), null, true).ToList(); if (myToBeUpdatedVertices.Count > 0) { //update ProcessUpdate(myToBeUpdatedVertices, myGraphDB, myPluginManager, mySecurityToken, myTransactionToken); } sw.Stop(); return(GenerateResult(sw.Elapsed.TotalMilliseconds)); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { Query = myQuery; var indexDef = new IndexPredefinition(_IndexName, _DBType) .SetIndexType(_IndexType) .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 <IQueryResult>(mySecurityToken, myTransactionToken, new RequestCreateIndex(indexDef), GenerateResult)); }
/// <summary> /// The returned IQueryResult contains vertices which are null if no Int64 is created, /// otherwise they contain a vertexview with a property dictionary, where in first position is the created Int64 /// </summary> public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); var myToken = myGraphDB.BeginTransaction(mySecurityToken, IsLongRunning, Isolation); VertexView view = null; var readoutVals = new Dictionary <String, Object>(); readoutVals.Add("TransactionID", myToken); readoutVals.Add("Created", TimeStamp); readoutVals.Add("Distributed", IsDistributed); readoutVals.Add("IsolationLevel", Isolation); readoutVals.Add("LongRunning", IsLongRunning); readoutVals.Add("Name", Name); view = new VertexView(readoutVals, null); sw.Stop(); return(QueryResult.Success(myQuery, SonesGQLConstants.GQL, new List <IVertexView> { view }, Convert.ToUInt64(sw.ElapsedMilliseconds))); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { _queryString = myQuery; IQueryResult result; try { result = myGraphDB.Insert <IQueryResult>( 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 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 SearchPageViewModel(INavigationService navigationService, IGraphQL graphQL) : base(navigationService) { this.navigationService = navigationService; this.graphQL = graphQL; SendRequest = new DelegateCommand <string>(async(show) => await SearchForShows(show)); ProfilePageCommand = new DelegateCommand(async() => await this.navigationService.NavigateAsync("ProfilePage")); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 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 <IQueryResult>( mySecurityToken, myTransactionToken, new RequestDelete(new RequestGetVertices(_typeName, toBeDeletedVertices.Select(_ => _.VertexID))).AddAttributes(_toBeDeletedAttributes), CreateQueryResult)); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); var _ReturnValues = new Dictionary <String, Object>(); if (Command_Type == CommandType.Commit) { myGraphDB.CommitTransaction(mySecurityToken, myTransactionToken); } else { myGraphDB.RollbackTransaction(mySecurityToken, myTransactionToken); } _ReturnValues.Add("TransactionID", myTransactionToken); _ReturnValues.Add("ExecutedCommand", Command_Type); _ReturnValues.Add("Name", Name == null ? "" : Name); _ReturnValues.Add("ASync", ASync); return(QueryResult.Success(myQuery, SonesGQLConstants.GQL, new List <IVertexView> { new VertexView(_ReturnValues, null) }, Convert.ToUInt64(sw.ElapsedMilliseconds))); }
public InfoPopupPageViewModel(INavigationService navigationService, IGraphQL graphQL) : base(navigationService) { this.navigationService = navigationService; this.graphQL = graphQL; CloseCommand = new DelegateCommand(async() => await this.navigationService.ClearPopupStackAsync()); EpisodePageCommand = new DelegateCommand(async() => await GotoEpisodePage()); }
private void Import(Stream myInputStream, IGraphDB myIGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, Int64 myTransactionToken, UInt32 myParallelTasks = 1U, IEnumerable <string> myComments = null, ulong?myOffset = null, ulong?myLimit = null, VerbosityTypes myVerbosityType = VerbosityTypes.Silent) { var lines = ReadLinesFromStream(myInputStream); #region Evaluate Limit and Offset if (myOffset != null) { if (lines != null) { lines = lines.Skip <String> (Convert.ToInt32(myOffset.Value)); } } if (myLimit != null) { if (lines != null) { lines = lines.Take <String> (Convert.ToInt32(myLimit.Value)); } } #endregion #region Import queries ExecuteAsSingleThread(lines, myGraphQL, mySecurityToken, myTransactionToken, myVerbosityType, myComments); #endregion }
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; }
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); }
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 EpisodePageViewModel(INavigationService navigationService, IToast toast, IGraphQL graphQL) : base(navigationService) { this.navigationService = navigationService; this.toast = toast; this.graphQL = graphQL; AddToListCommand = new DelegateCommand(async() => await AddtoList()); SearchPageCommand = new DelegateCommand(async() => await this.navigationService.NavigateAsync("SearchPage")); ProfilePageCommand = new DelegateCommand(async() => await this.navigationService.NavigateAsync("ProfilePage")); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { _query = myQuery; return(myGraphDB.AlterVertexType <IQueryResult>( mySecurityToken, myTransactionToken, CreateNewRequest(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken), CreateOutput)); }
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); }
public IEnumerable <IVertexView> Import(String myLocation, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, Int64 myTransactionToken, UInt32 myParallelTasks = 1U, IEnumerable <string> myComments = null, UInt64?myOffset = null, UInt64?myLimit = null, VerbosityTypes myVerbosityType = VerbosityTypes.Silent, Dictionary <string, string> myOptions = null) { Stream stream = null; #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 { throw new InvalidImportLocationException(myLocation, @"file:\\", "http://"); } #region Start import using the AGraphDBImport implementation and return the result var result = Import(stream, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, myParallelTasks, myComments, myOffset, myLimit, myVerbosityType); return(AggregateListOfListOfVertices(result)); #endregion } finally { if (stream != null) { stream.Dispose(); } } #endregion }
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 }
public HomePageViewModel(INavigationService navigationService, IToast toast, IGraphQL graphQL) : base(navigationService) { this.navigationService = navigationService; this.toast = toast; this.graphQL = graphQL; ShowInfo = new DelegateCommand(async() => await ShowPopup()); GotoSearchPageCommand = new DelegateCommand(async() => await this.navigationService.NavigateAsync("SearchPage")); GotoMyListPage = new DelegateCommand(async() => await this.navigationService.NavigateAsync("MyListPage")); GotoProfilePage = new DelegateCommand(async() => await this.navigationService.NavigateAsync("ProfilePage")); AddtoListCommand = new DelegateCommand(async() => await AddtoList()); }
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); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { try { var stat = myGraphDB.DropIndex(mySecurityToken, myTransactionToken, new RequestDropIndex(_TypeName, _IndexName, _IndexEdition), (stats) => stats); return(QueryResult.Success(myQuery, SonesGQLConstants.GQL, null, Convert.ToUInt64(stat.ExecutionTime.Milliseconds))); } catch (ASonesException ex) { return(QueryResult.Failure(myQuery, SonesGQLConstants.GQL, ex)); } }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { try { var stat = myGraphDB.Truncate(mySecurityToken, myTransactionToken, new RequestTruncate(_TypeName), (stats) => stats); return QueryResult.Success(myQuery, SonesGQLConstants.GQL, null, Convert.ToUInt64(stat.ExecutionTime.Milliseconds)); } catch(ASonesException e) { return QueryResult.Failure(myQuery, SonesGQLConstants.GQL, e); } }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { try { var request = new RequestRebuildIndices(_Types); return myGraphDB.RebuildIndices<IQueryResult>(mySecurityToken, myTransactionToken, request, _=> GenerateOutput(myQuery, _)); } catch (ASonesException ex) { return QueryResult.Failure(myQuery, SonesGQLConstants.GQL, ex); } }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { try { var request = new RequestRebuildIndices(_Types); return(myGraphDB.RebuildIndices <IQueryResult>(mySecurityToken, myTransactionToken, request, _ => GenerateOutput(myQuery, _))); } catch (ASonesException ex) { return(QueryResult.Failure(myQuery, SonesGQLConstants.GQL, ex)); } }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); IQueryResult 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)); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { _query = myQuery; return(myGraphDB.DropEdgeType(mySecurityToken, myTransactionToken, new RequestDropEdgeType(_TypeName), GenerateOutput)); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { _query = myQuery; return myGraphDB.DropEdgeType(mySecurityToken, myTransactionToken, new RequestDropEdgeType(_TypeName), GenerateOutput); }
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) }); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var selectManager = new SelectManager(myGraphDB, myPluginManager); return(selectManager.ExecuteSelect(mySecurityToken, myTransactionToken, new SelectDefinition(TypeList, SelectedElements, WhereExpressionDefinition, GroupByIDs, Having, Limit, Offset, OrderByDefinition, ResolutionDepth), myQuery)); }
public IEnumerable <IVertexView> Export(string destination, IDumpable myGrammar, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, Int64 myTransactionToken, IEnumerable <String> myVertexTypes, IEnumerable <String> myEdgeTypes, DumpTypes myDumpType) { _Destination = destination; try { #region Open destination OpenStream(destination); #endregion #region Start export using the AGraphDBExport implementation return(Export(myGrammar, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, GetVertexTypes(myGraphDB, mySecurityToken, myTransactionToken, myVertexTypes), GetEdgeTypes(myGraphDB, mySecurityToken, myTransactionToken, myEdgeTypes), myDumpType)); #endregion } finally { #region Close destination CloseStream(); #endregion } }
/// <summary> /// Executes the statement and returns a IQueryResult. /// </summary> public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { Query = myQuery; return(myGraphDB.Update(mySecurityToken, myTransactionToken, GenerateUpdateRequest(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken), GenerateOutput)); }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { QueryResult result = new QueryResult(myQuery, SonesGQLConstants.GQL, 0L, ResultType.Failed); try { var stat = myGraphDB.Truncate(mySecurityToken, myTransactionToken, new RequestTruncate(_TypeName), (stats) => stats); result = new QueryResult(myQuery, SonesGQLConstants.GQL, Convert.ToUInt64(stat.ExecutionTime.Milliseconds), ResultType.Successful); } catch(ASonesException e) { result = new QueryResult(myQuery, SonesGQLConstants.GQL, 0, ResultType.Failed, null, e); } return result; }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { QueryResult qresult = null; Query = myQuery; try { var request = new RequestRebuildIndices(_Types); qresult = myGraphDB.RebuildIndices<QueryResult>(mySecurityToken, myTransactionToken, request, GenerateOutput); } catch (ASonesException e) { qresult.Error = e; } return qresult; }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { QueryResult qresult = null; ASonesException error = null; try { var stat = myGraphDB.DropIndex(mySecurityToken, myTransactionToken, new RequestDropIndex(_TypeName, _IndexName, _IndexEdition), (stats) => stats); qresult = new QueryResult(myQuery, "sones.gql", Convert.ToUInt64(stat.ExecutionTime.Milliseconds), ResultType.Successful); } catch (ASonesException e) { error = e; } return new QueryResult(myQuery, "sones.gql", qresult.Duration, qresult.TypeOfResult, qresult.Vertices, error); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); IEnumerable <IVertexView> result = null; var plugin = myPluginManager.GetAndInitializePlugin <IGraphDBImport>(ImportFormat.ToUpper()); if (plugin != null) { try { result = plugin.Import(SourceLocation, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, ParallelTasks, Comments, Offset, Limit, VerbosityType, Options); return(QueryResult.Success(myQuery, SonesGQLConstants.GQL, result, (ulong)sw.ElapsedMilliseconds)); } catch (ASonesException ex) { return(QueryResult.Failure(myQuery, SonesGQLConstants.GQL, ex, result, (ulong)sw.ElapsedMilliseconds)); } catch (Exception ex) { return(QueryResult.Failure(myQuery, SonesGQLConstants.GQL, new UnknownException(ex), result, (ulong)sw.ElapsedMilliseconds)); } } return(QueryResult.Failure(myQuery, ImportFormat, new ImportFormatDoesNotExistsException(ImportFormat))); }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); QueryResult qresult = null; ASonesException error = null; try { qresult = _DescribeDefinition.GetResult(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken); } catch (ASonesException e) { error = e; } sw.Stop(); return new QueryResult(myQuery, "sones.gql", (ulong)sw.ElapsedMilliseconds, qresult != null ? qresult.TypeOfResult : ResultType.Failed, qresult != null ? qresult.Vertices : new IVertexView[0], error); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); try { if (_DumpFormat.ToString().ToUpper().Equals("GQL")) { var plugin = myPluginManager.GetAndInitializePlugin <IGraphDBExport>("GQLEXPORT"); if (plugin != null) { var result = plugin.Export(_DumpDestination, _DumpableGrammar, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, _TypesToDump, null, _DumpType); return(QueryResult.Success(myQuery, SonesGQLConstants.GQL, result, Convert.ToUInt64(sw.ElapsedMilliseconds))); } } return(QueryResult.Failure(myQuery, SonesGQLConstants.GQL, new InvalidDumpFormatException(_DumpFormat.ToString(), string.Empty))); } catch (ASonesException ex) { return(QueryResult.Failure(myQuery, SonesGQLConstants.GQL, ex)); } catch (Exception ex) { return(QueryResult.Failure(myQuery, SonesGQLConstants.GQL, new UnknownDBException(ex))); } }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { _query = myQuery; QueryResult result; try { result = myGraphDB.CreateVertexTypes<QueryResult>( mySecurityToken, myTransactionToken, new RequestCreateVertexTypes(GenerateVertexTypePredefinitions()), CreateQueryResult); } catch (ASonesException e) { result = new QueryResult(_query, SonesGQLConstants.GQL, 0, ResultType.Failed, null, e); } return result; }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { _query = myQuery; IQueryResult result; try { result = myGraphDB.CreateVertexTypes <IQueryResult>( mySecurityToken, myTransactionToken, new RequestCreateVertexTypes(GenerateVertexTypePredefinitions()), CreateQueryResult); } catch (ASonesException e) { result = new QueryResult(_query, SonesGQLConstants.GQL, 0, ResultType.Failed, null, e); } return(result); }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); try { var result = _DescribeDefinition.GetResult(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken); return QueryResult.Success(myQuery, SonesGQLConstants.GQL, result, Convert.ToUInt64(sw.ElapsedMilliseconds)); } catch (ASonesException ex) { return QueryResult.Failure(myQuery, SonesGQLConstants.GQL, ex); } }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); try { var result = _DescribeDefinition.GetResult(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken); return(QueryResult.Success(myQuery, SonesGQLConstants.GQL, result, Convert.ToUInt64(sw.ElapsedMilliseconds))); } catch (ASonesException ex) { return(QueryResult.Failure(myQuery, SonesGQLConstants.GQL, ex)); } }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { _query = myQuery; //prepare var vertexType = myGraphDB.GetVertexType<IVertexType>( mySecurityToken, myTransactionToken, new RequestGetVertexType(_TypeName), (stats, vtype) => vtype); //validate _whereExpression.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType); //calculate var expressionGraph = _whereExpression.Calculon(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, new CommonUsageGraph(myGraphDB, mySecurityToken, myTransactionToken), false); //extract var myToBeUpdatedVertices = expressionGraph.Select(new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken), null, true).ToList(); switch (myToBeUpdatedVertices.Count) { case 0: //insert throw new ReplaceException("There are no vertices that match the where expression, so it's not possible to execute a Replace statement. Try using InsertOrUpdate."); case 1: //delete ProcessDelete(myToBeUpdatedVertices[0], myGraphDB, myPluginManager, mySecurityToken, myTransactionToken); //insert return ProcessInsert(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken); default: //error throw new NotImplementedQLException("It's currenty not implemented to InsertOrReplace more than one vertex"); } }
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { _query = myQuery; //prepare var vertexType = myGraphDB.GetVertexType <IVertexType>( mySecurityToken, myTransactionToken, new RequestGetVertexType(_TypeName), (stats, vtype) => vtype); //validate _whereExpression.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexType); //calculate var expressionGraph = _whereExpression.Calculon(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, new CommonUsageGraph(myGraphDB, mySecurityToken, myTransactionToken), false); //extract var myToBeUpdatedVertices = expressionGraph.Select(new LevelKey(vertexType.ID, myGraphDB, mySecurityToken, myTransactionToken), null, true).ToList(); switch (myToBeUpdatedVertices.Count) { case 0: //insert throw new ReplaceException("There are no vertices that match the where expression, so it's not possible to execute a Replace statement. Try using InsertOrUpdate."); case 1: //delete ProcessDelete(myToBeUpdatedVertices[0], myGraphDB, myPluginManager, mySecurityToken, myTransactionToken); //insert return(ProcessInsert(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken)); default: //error throw new NotImplementedQLException("It's currenty not implemented to InsertOrReplace more than one vertex"); } }
private void ExecuteAsSingleThread(IEnumerable <String> myLines, IGraphQL myIGraphQL, SecurityToken mySecurityToken, Int64 myTransactionToken, VerbosityTypes myVerbosityType, IEnumerable <String> comments = null) { _logger.Log(Level.INFO, "Started GQL import."); #region data Int64 numberOfLine = 0; #endregion #region check lines and execute query Stopwatch sw = new Stopwatch(); foreach (var _Line in myLines) { numberOfLine++; if (String.IsNullOrWhiteSpace(_Line)) { continue; } #region Skip comments if (IsComment(_Line, comments)) { continue; } #endregion #region execute query _logger.Log(Level.INFO, String.Format("Executing query {0}: {1}", _numberOfStatements, _Line)); sw.Reset(); sw.Start(); var tempResult = myIGraphQL.Query(mySecurityToken, myTransactionToken, _Line); Interlocked.Increment(ref _numberOfStatements); sw.Stop(); _logger.Log(Level.INFO, String.Format("Took {0}ms.", sw.Elapsed.TotalMilliseconds)); #endregion #region Add errors and break execution if (tempResult.TypeOfResult == ResultType.Failed) { if (tempResult.Error.Message.Equals("Mal-formed string literal - cannot find termination symbol.")) { string error = "Query at line [" + numberOfLine + "] [" + _Line + "] failed with " + tempResult.Error.ToString() + " add next line..."; Debug.WriteLine(error); _logger.Log(Level.WARNING, error); } if (myVerbosityType == VerbosityTypes.Errors) { if (tempResult.Error != null) { _logger.Log(Level.SEVERE, tempResult.Error.ToString()); } else { _logger.Log(Level.SEVERE, "Import failed because of unknown exception"); } } } #endregion } #endregion _logger.Log(Level.INFO, String.Format("Finished GQL import and executed {0} statements", _numberOfStatements)); }
private IQueryResult ExecuteQuery(String myQuery, IGraphQL myGraphQL, SecurityToken mySecurityToken, Int64 myTransactionToken) { return(myGraphQL.Query(mySecurityToken, myTransactionToken, myQuery)); }
/// <summary> /// The returned QueryResult contains vertices which are null if no Int64 is created, /// otherwise they contain a vertexview with a property dictionary, where in first position is the created Int64 /// </summary> public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); var myToken = myGraphDB.BeginTransaction(mySecurityToken, IsLongRunning, Isolation); VertexView view = null; var readoutVals = new Dictionary<String, Object>(); readoutVals.Add("TransactionID", myToken); readoutVals.Add("Created", TimeStamp); readoutVals.Add("Distributed", IsDistributed); readoutVals.Add("IsolationLevel", Isolation); readoutVals.Add("LongRunning", IsLongRunning); readoutVals.Add("Name", Name); view = new VertexView(readoutVals, null); sw.Stop(); return new QueryResult(myQuery, "GQL", Convert.ToUInt64(sw.ElapsedMilliseconds), ResultType.Successful, new List<IVertexView> { view }); }
public GraphQLTestCase() { _graphQL = new GraphQL(); }
public GraphQLTestCase() { _graphQL = new GraphQL(); }
/// <summary> /// Executes the statement and returns a QueryResult. /// </summary> public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { Query = myQuery; return myGraphDB.Update(mySecurityToken, myTransactionToken, GenerateUpdateRequest(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken), GenerateOutput); }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { var sw = Stopwatch.StartNew(); _query = myQuery; //prepare var vertexTypeSource = myGraphDB.GetVertexType<IVertexType>( mySecurityToken, myTransactionToken, new RequestGetVertexType(_SourceType), (stats, vtype) => vtype); var vertexTypeTarget = myGraphDB.GetVertexType<IVertexType>( mySecurityToken, myTransactionToken, new RequestGetVertexType(_TargetType), (stats, vtype) => vtype); //validate _Condition.Validate(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, vertexTypeSource); //calculate var expressionGraph = _Condition.Calculon(myPluginManager, myGraphDB, mySecurityToken, myTransactionToken, new CommonUsageGraph(myGraphDB, mySecurityToken, myTransactionToken), false); //extract var myToBeUpdatedVertices = expressionGraph.Select(new LevelKey(vertexTypeSource.ID, myGraphDB, mySecurityToken, myTransactionToken), null, true).ToList(); if (myToBeUpdatedVertices.Count > 0) { //update ProcessUpdate(myToBeUpdatedVertices, myGraphDB, myPluginManager, mySecurityToken, myTransactionToken); } sw.Stop(); return GenerateResult(sw.Elapsed.TotalMilliseconds); }
private QueryResult Import(Stream myInputStream, IGraphDB myIGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, UInt32 myParallelTasks = 1U, IEnumerable<string> myComments = null, ulong? myOffset = null, ulong? myLimit = null, VerbosityTypes myVerbosityType = VerbosityTypes.Silent) { var lines = ReadLinesFromStream(myInputStream); #region Evaluate Limit and Offset if (myOffset != null) { if(lines != null) lines = lines.Skip<String>(Convert.ToInt32(myOffset.Value)); } if (myLimit != null) { if(lines != null) lines = lines.Take<String>(Convert.ToInt32(myLimit.Value)); } #endregion #region Import queries QueryResult queryResult; if (myParallelTasks > 1) { queryResult = ExecuteAsParallel(lines, myGraphQL, mySecurityToken, myTransactionToken, myVerbosityType, myParallelTasks, myComments); } else { queryResult = ExecuteAsSingleThread(lines, myGraphQL, mySecurityToken, myTransactionToken, myVerbosityType, myComments); } #endregion return queryResult; }
public IEnumerable<IVertexView> Import(String myLocation, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, Int64 myTransactionToken, UInt32 myParallelTasks = 1U, IEnumerable<string> myComments = null, UInt64? myOffset = null, UInt64? myLimit = null, VerbosityTypes myVerbosityType = VerbosityTypes.Silent, Dictionary<string, string> myOptions = null) { if (myGraphDB == null) throw new ArgumentNullException("myGraphDB"); if (myGraphQL == null) throw new ArgumentNullException("myGraphQL"); if (!typeof(SonesGraphDB).Equals(myGraphDB.GetType())) throw new ArgumentException("FASTIMPORT is designed for SonesGraphDB only."); lock (_lock) { //if verbositiy is silent, we do not configure the logger, so it is an empty logger. if (myVerbosityType != VerbosityTypes.Silent) { Level logLevel = (myVerbosityType == VerbosityTypes.Full) ? Level.FINE : Level.INFO; LogManager.Instance.ConfigureLogger("FastImport", new FileLogger(_logpath, logLevel)); } //store some arguments as fields, because there is at most one execution at any time. _logger = LogManager.Instance.GetLogger("FastImport"); _db = myGraphDB; _ql = myGraphQL; _security = mySecurityToken; _transaction = myTransactionToken; _offset = myOffset; _limit = myLimit; _currentImport = 0L; _closed = false; _autoCreateIncomingEdges = false; if (myOptions != null) { if (myOptions.ContainsKey("AutoCreateIncomingEdges")) bool.TryParse(myOptions["AutoCreateIncomingEdges"], out _autoCreateIncomingEdges); } if (!_autoCreateIncomingEdges) _sorter = new IncomingEdgeSorter(myOptions); try { if (myLocation.ToLower().StartsWith(@"file:\\")) { stream = GetStreamFromFile(myLocation.Substring(@"file:\\".Length)); } else { _logger.Log(Level.SEVERE, "Location does not start with file:\\\\."); throw new InvalidImportLocationException(myLocation, @"file:\\"); } #region Start import using the AGraphDBImport implementation and return the result return Import(); #endregion } catch (Exception ex) { //if something unexpected happens we log it and return a query result with failed. _logger.Log(Level.SEVERE, "Exception thrown:\n", ex); throw new ImportFailedException(ex); } finally { if (stream != null) { _logger.Log(Level.FINE, "Stream closed"); stream.Dispose(); if (_sorter != null) _sorter.Dispose(); } } } }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { Stopwatch sw = Stopwatch.StartNew(); _query = myQuery; QueryResult result = null; String myAction = ""; List<IVertex> myToBeUpdatedVertices = new List<IVertex>(); //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(); } switch (myToBeUpdatedVertices.Count) { case 0: //insert result = ProcessInsert(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken); myAction = "Inserted"; break; case 1: //delete ProcessDelete(myToBeUpdatedVertices[0], myGraphDB, myPluginManager, mySecurityToken, myTransactionToken); //insert result = ProcessInsert(myGraphDB, myPluginManager, mySecurityToken, myTransactionToken); myAction = "Replaced"; break; default: //error throw new NotImplementedQLException("It's currenty not implemented to InsertOrReplace more than one vertex"); } if (result.Error != null) throw result.Error; return GenerateResult(sw.ElapsedMilliseconds, result, myAction); }
public override QueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { throw new NotImplementedException(); }
private QueryResult ExecuteAsParallel(IEnumerable<String> myLines, IGraphQL myIGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, VerbosityTypes myVerbosityType, UInt32 myParallelTasks = 1U, IEnumerable<String> comments = null) { #region data QueryResult queryResult = new QueryResult(myLines.ToString(), ImportFormat, 0L, ResultType.Successful); Int64 numberOfLine = 0; var query = String.Empty; var aggregatedResults = new List<IEnumerable<IVertexView>>(); Stopwatch StopWatchLine = new Stopwatch(); Stopwatch StopWatchLines = new Stopwatch(); #endregion #region Create parallel options var parallelOptions = new ParallelOptions() { MaxDegreeOfParallelism = (int)myParallelTasks }; #endregion #region check lines and execute query StopWatchLines.Start(); Parallel.ForEach(myLines, parallelOptions, (line, state) => { if (!IsComment(line, comments)) { Interlocked.Add(ref numberOfLine, 1L); if (!IsComment(line, comments)) // Skip comments { var qresult = ExecuteQuery(line, myIGraphQL, mySecurityToken, myTransactionToken); #region VerbosityTypes.Full: Add result if (myVerbosityType == VerbosityTypes.Full) { lock (aggregatedResults) { aggregatedResults.Add(qresult.Vertices); } } #endregion #region !VerbosityTypes.Silent: Add errors and break execution if (qresult.TypeOfResult != ResultType.Successful && myVerbosityType != VerbosityTypes.Silent) { queryResult = new QueryResult(line, ImportFormat, Convert.ToUInt64(StopWatchLine.ElapsedMilliseconds), ResultType.Failed, qresult.Vertices, qresult.Error); state.Break(); } #endregion } } }); StopWatchLines.Stop(); #endregion //add the results of each query into the queryResult if (queryResult != null) queryResult = new QueryResult(myLines.ToString(), ImportFormat, Convert.ToUInt64(StopWatchLines.ElapsedMilliseconds), queryResult.TypeOfResult, AggregateListOfListOfVertices(aggregatedResults), queryResult.Error); else queryResult = new QueryResult(myLines.ToString(), ImportFormat, Convert.ToUInt64(StopWatchLines.ElapsedMilliseconds), ResultType.Successful, AggregateListOfListOfVertices(aggregatedResults)); return queryResult; }
private QueryResult ExecuteAsSingleThread(IEnumerable<String> myLines, IGraphQL myIGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, VerbosityTypes myVerbosityType, IEnumerable<String> comments = null) { #region data QueryResult queryResult = null; Int64 numberOfLine = 0; var aggregatedResults = new List<IEnumerable<IVertexView>>(); Stopwatch StopWatchLines = new Stopwatch(); #endregion #region check lines and execute query StopWatchLines.Reset(); StopWatchLines.Start(); foreach (var _Line in myLines) { numberOfLine++; if (String.IsNullOrWhiteSpace(_Line)) { continue; } #region Skip comments if (IsComment(_Line, comments)) continue; #endregion #region execute query var tempResult = myIGraphQL.Query(mySecurityToken, myTransactionToken, _Line); #endregion #region Add errors and break execution if (tempResult.TypeOfResult == ResultType.Failed) { if (tempResult.Error.Message.Equals("Mal-formed string literal - cannot find termination symbol.")) Debug.WriteLine("Query at line [" + numberOfLine + "] [" + _Line + "] failed with " + tempResult.Error.ToString() + " add next line..."); if (myVerbosityType == VerbosityTypes.Errors) { queryResult = new QueryResult(_Line, ImportFormat, 0L, ResultType.Failed, tempResult.Vertices, tempResult.Error); break; } } aggregatedResults.Add(tempResult.Vertices); #endregion } StopWatchLines.Stop(); #endregion //add the results of each query into the queryResult if(queryResult != null) queryResult = new QueryResult(myLines.ToString(), ImportFormat, Convert.ToUInt64(StopWatchLines.ElapsedMilliseconds), queryResult.TypeOfResult, AggregateListOfListOfVertices(aggregatedResults), queryResult.Error); else queryResult = new QueryResult(myLines.ToString(), ImportFormat, Convert.ToUInt64(StopWatchLines.ElapsedMilliseconds), ResultType.Successful, AggregateListOfListOfVertices(aggregatedResults)); return queryResult; }
public IEnumerable <IVertexView> Import(String myLocation, IGraphDB myGraphDB, IGraphQL myGraphQL, SecurityToken mySecurityToken, Int64 myTransactionToken, UInt32 myParallelTasks = 1U, IEnumerable <string> myComments = null, UInt64?myOffset = null, UInt64?myLimit = null, VerbosityTypes myVerbosityType = VerbosityTypes.Silent, Dictionary <string, string> myOptions = null) { Stream stream = null; #region Read querie lines from location try { //if verbositiy is silent, we do not configure the logger, so it is an empty logger. if (myVerbosityType != VerbosityTypes.Silent) { Level logLevel = (myVerbosityType == VerbosityTypes.Full) ? Level.FINE : Level.INFO; LogManager.Instance.ConfigureLogger("GqlImport", new FileLogger(_logpath, logLevel)); } //store some arguments as fields, because there is at most one execution at any time. _logger = LogManager.Instance.GetLogger("GqlImport"); #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 { throw new InvalidImportLocationException(myLocation, @"file:\\", "http://"); } #region Start import using the AGraphDBImport implementation and return the result Import(stream, myGraphDB, myGraphQL, mySecurityToken, myTransactionToken, myParallelTasks, myComments, myOffset, myLimit, myVerbosityType); return(new VertexView(new Dictionary <string, object> { { "Number of import statements:", _numberOfStatements } }, null).SingleEnumerable()); #endregion } finally { if (stream != null) { stream.Dispose(); } } #endregion }
public abstract IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken);
public override IQueryResult Execute(IGraphDB myGraphDB, IGraphQL myGraphQL, GQLPluginManager myPluginManager, String myQuery, SecurityToken mySecurityToken, Int64 myTransactionToken) { var sw = Stopwatch.StartNew(); var _ReturnValues = new Dictionary<String, Object>(); if (Command_Type == CommandType.Commit) { myGraphDB.CommitTransaction(mySecurityToken, myTransactionToken); } else { myGraphDB.RollbackTransaction(mySecurityToken, myTransactionToken); } _ReturnValues.Add("TransactionID", myTransactionToken); _ReturnValues.Add("ExecutedCommand", Command_Type); _ReturnValues.Add("Name", Name == null ? "" : Name); _ReturnValues.Add("ASync", ASync); return QueryResult.Success(myQuery, SonesGQLConstants.GQL, new List<IVertexView> { new VertexView(_ReturnValues, null) }, Convert.ToUInt64(sw.ElapsedMilliseconds)); }
private QueryResult ExecuteQuery(String myQuery, IGraphQL myGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken) { return myGraphQL.Query(mySecurityToken, myTransactionToken, myQuery); }