Exemple #1
0
        public static SparqlQuery CreateQuery(QueryTemplates template, string subjectIri)
        {
            SparqlParameterizedString queryParamString = GetQueryTemplateCopy(template);

            queryParamString.SetSubject(subjectIri);
            return(QueryParsing.ParseQuery(queryParamString));
        }
        /// <summary>
        /// Retrieve objects of the given predicate; number of objects is already set in the template query
        /// </summary>
        private static async Task RetrieveObjectsOfPredicate(PredicateResultWrapper predicate, SparqlParameterizedString template)
        {
            var queryText = new SparqlParameterizedString(template.ToString());

            queryText.SetPredicate(predicate.ToString());
            var query   = QueryParsing.ParseQuery(queryText);
            var results = await QueryProcessing.ProcessQuery(query, predicate.Endpoint);

            if (results is SparqlResultSet)
            {
                SparqlResultSet set = (SparqlResultSet)results;
                foreach (var obj in set)
                {
                    predicate.AddObject(new ObjectWrapper(obj[0], predicate.Endpoint));
                }
            }
            else if (results is AsyncError)
            {
                throw new BrowserException(ErrorProcessing.ProcessAsyncError((AsyncError)results));
            }
            else
            {
                throw new BrowserException("An unexpected error occured while processing the query.");
            }
            //template.UnsetPredicate(); //no more reusing
        }