/// <summary> /// <seealso cref=" ADescribeDefinition"/> /// </summary> public override IEnumerable <IVertexView> GetResult( GQLPluginManager myPluginManager, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken) { var resultingVertices = new List <IVertexView>(); //aggregate name is not empty if (!String.IsNullOrEmpty(_AggregateName)) { #region Specific aggregate //aggregate is user defined if (_AggregateName.Contains(".")) { //get plugin var aggregate = myPluginManager.GetAndInitializePlugin <IGQLAggregate>(_AggregateName); if (aggregate != null) { resultingVertices = new List <IVertexView>() { GenerateOutput(aggregate, _AggregateName) }; } else { throw new AggregateOrFunctionDoesNotExistException(typeof(IGQLAggregate), _AggregateName, ""); } } //try get aggregate else { try { //get plugin var aggregate = myPluginManager.GetAndInitializePlugin <IGQLAggregate>(_AggregateName); if (aggregate != null) { resultingVertices = new List <IVertexView>() { GenerateOutput(aggregate, _AggregateName) }; } else { throw new AggregateOrFunctionDoesNotExistException(typeof(IGQLAggregate), _AggregateName, ""); } } catch (ASonesException e) { //maybe user forgot prefix 'sones.' //get plugin var aggregate = myPluginManager.GetAndInitializePlugin <IGQLAggregate>("SONES." + _AggregateName); if (aggregate != null) { resultingVertices = new List <IVertexView>() { GenerateOutput(aggregate, "SONES." + _AggregateName) }; } else { throw new AggregateOrFunctionDoesNotExistException(typeof(IGQLAggregate), _AggregateName, ""); } } } #endregion } else { #region All aggregates myPluginManager.GetPluginNameForType <IGQLAggregate>(); foreach (var aggregateName in myPluginManager.GetPluginNameForType <IGQLAggregate>()) { var aggregate = myPluginManager.GetAndInitializePlugin <IGQLAggregate>(aggregateName); if (aggregate != null) { resultingVertices.Add(GenerateOutput(aggregate, aggregateName)); } else { throw new AggregateOrFunctionDoesNotExistException(typeof(IGQLAggregate), _AggregateName, ""); } } #endregion } return(resultingVertices); }
private void SetExtendableMember(SonesGQLGrammar myGQLGrammar) { #region aggregate List <IGQLAggregate> aggregates = new List <IGQLAggregate>(); foreach (var plugin in _GQLPluginManager.GetPluginNameForType <IGQLAggregate>()) { aggregates.Add(_GQLPluginManager.GetAndInitializePlugin <IGQLAggregate>(plugin)); } if (aggregates.Count == 0) { throw new GQLGrammarSetExtandableMemberException(typeof(IGQLAggregate), "There is no plugin found to set in GQL grammar."); } myGQLGrammar.SetAggregates(aggregates); #endregion #region functions List <IGQLFunction> functions = new List <IGQLFunction>(); foreach (var plugin in _GQLPluginManager.GetPluginNameForType <IGQLFunction>()) { functions.Add(_GQLPluginManager.GetAndInitializePlugin <IGQLFunction>(plugin) as IGQLFunction); } if (functions.Count == 0) { throw new GQLGrammarSetExtandableMemberException(typeof(IGQLFunction), "There is no plugin found to set in GQL grammar."); } myGQLGrammar.SetFunctions(functions); #endregion #region indces List <String> indices = new List <string>(); indices.AddRange(_GQLPluginManager.GetPluginNameForType <ISonesVersionedIndex>()); indices.AddRange(_GQLPluginManager.GetPluginNameForType <ISonesIndex>()); if (indices.Count < 1) { throw new GQLGrammarSetExtandableMemberException(typeof(ISonesIndex), @"There is no valid index plugin found to set in GQL grammar."); } myGQLGrammar.SetIndices(indices); #endregion #region import List <IGraphDBImport> importer = new List <IGraphDBImport>(); foreach (var plugin in _GQLPluginManager.GetPluginNameForType <IGraphDBImport>()) { importer.Add(_GQLPluginManager.GetAndInitializePlugin <IGraphDBImport>(plugin)); } if (importer.Count == 0) { throw new GQLGrammarSetExtandableMemberException(typeof(IGraphDBImport), "There is no plugin found to set in GQL grammar."); } myGQLGrammar.SetGraphDBImporter(importer); #endregion #region export List <IGraphDBExport> exporter = new List <IGraphDBExport>(); foreach (var plugin in _GQLPluginManager.GetPluginNameForType <IGraphDBExport>()) { exporter.Add(_GQLPluginManager.GetAndInitializePlugin <IGraphDBExport>(plugin)); } if (exporter.Count == 0) { throw new GQLGrammarSetExtandableMemberException(typeof(IGraphDBExport), "There is no plugin found to set in GQL grammar."); } myGQLGrammar.SetGraphDBExporter(exporter); #endregion #region additional statements List <IGQLStatementPlugin> statements = new List <IGQLStatementPlugin>(); foreach (var plugin in _GQLPluginManager.GetPluginNameForType <IGQLStatementPlugin>()) { statements.Add(_GQLPluginManager.GetAndInitializePlugin <IGQLStatementPlugin>(plugin, new Dictionary <string, object> { { "sonesGQL", myGQLGrammar }, { "graphDB", _IGraphDBInstance } })); } myGQLGrammar.SetStatements(statements); #endregion }