コード例 #1
0
ファイル: StoreProcessor.cs プロジェクト: angshuman/hexadb
        public JObject Query(string storeId, JObject query, string[] expand, int level)
        {
            try {
                var (data, _, _) = GetSetGraphs(storeId);
                ObjectQueryModel queryModel;
                try {
                    queryModel = query.ToObject<ObjectQueryModel>();
                } catch (Exception e) {
                    throw new StoreException(e.Message, _storeErrors.UnableToParseQuery);
                }

                var result = new ObjectQueryExecutor().Query(queryModel, data);
                dynamic response = new {
                    values = result.Values?.Select(x => {
                        var expanded = GraphOperator.Expand(data, x.Subject, level, expand);
                        var rspGraph = new SPOIndex();
                        rspGraph.Assert(expanded);
                        return rspGraph.ToJson(x.Subject);
                    }),
                    continuation = result.Continuation,
                    aggregates = result.Aggregates
                };
                return JObject.FromObject(response);
            } catch (Exception e) {
                _logger.LogError("Query failed. {Message}\n {StackTrace}", e.Message, e.StackTrace);
                throw e;
            }
        }
コード例 #2
0
ファイル: StoreProcessor.cs プロジェクト: angshuman/hexadb
 public JObject GetSubject(string storeId, string subject, string[] expand, int level)
 {
     var (data, _, _) = GetSetGraphs(storeId);
     var triples = GraphOperator.Expand(data, subject, level, expand).ToList();
     if (triples.Count() == 0) {
         return null;
     }
     var rspGraph = new SPOIndex();
     rspGraph.Assert(triples);
     return rspGraph.ToJson(subject);
 }
コード例 #3
0
ファイル: StoreProcessor.cs プロジェクト: emgarten/hexadb
 public JObject GetSubject(string storeId, string subject, string[] expand, int level)
 {
     using (var op = _storeOperationFactory.Read(storeId)) {
         var(data, _, _) = GetSetGraphs(storeId);
         var triples = GraphOperator.Expand(data, subject, level, expand).ToList();
         if (triples.Count() == 0)
         {
             return(null);
         }
         var rspGraph = new SPOIndex();
         rspGraph.Assert(triples);
         return(rspGraph.ToJson(subject));
     }
 }