private void AddChildGraphPattern(Action <IGraphPatternBuilder> buildGraphPattern, GraphPatternType graphPatternType, IToken graphSpecifier) { var childBuilder = new GraphPatternBuilder(graphPatternType, graphSpecifier); buildGraphPattern(childBuilder); _childGraphPatternBuilders.Add(childBuilder); }
public void CanBuildUnionWithGraphPatternBuilders() { // Define two pattern builders which will be used to generate triple patterns for a UNION expression. GraphPatternBuilder patternBuilder0 = new GraphPatternBuilder(); GraphPatternBuilder patternBuilder1 = new GraphPatternBuilder(); IQueryBuilder queryBuilder0 = QueryBuilder .Ask() .Union(patternBuilder0, patternBuilder1); // Add some triple patterns after the UNION was added to the query. patternBuilder0.Where(p => p.Subject("s0").Predicate("p0").ObjectLiteral(0)); patternBuilder1.Where(p => p.Subject("s1").Predicate("p1").ObjectLiteral(1)); SparqlQuery q0 = queryBuilder0.BuildQuery(); Assert.Single(q0.RootGraphPattern.ChildGraphPatterns); Assert.True(q0.RootGraphPattern.ChildGraphPatterns.First().IsUnion); Assert.Equal(2, q0.RootGraphPattern.ChildGraphPatterns.First().ChildGraphPatterns.Count()); // Now add other triples to the query after the query was already build. patternBuilder1.Where(p => p.Subject("s1").Predicate("p2").ObjectLiteral(2)); SparqlQuery q1 = queryBuilder0.BuildQuery(); Assert.Single(q1.RootGraphPattern.ChildGraphPatterns); Assert.True(q1.RootGraphPattern.ChildGraphPatterns.First().IsUnion); Assert.Equal(2, q1.RootGraphPattern.ChildGraphPatterns.First().ChildGraphPatterns.Count()); Assert.Contains(q1.RootGraphPattern.ChildGraphPatterns.First().ChildGraphPatterns, p => p.ToString().Contains("p2")); }
private void AddChildGraphPattern(Action <IGraphPatternBuilder> buildGraphPattern, GraphPatternType graphPatternType) { var childBuilder = new GraphPatternBuilder(graphPatternType); buildGraphPattern(childBuilder); _childGraphPatternBuilders.Add(childBuilder); }
/// <inheritdoc /> public IGraphPatternBuilder Group(Action <IGraphPatternBuilder> buildGraphPattern) { GraphPatternBuilder groupBuilder = new GraphPatternBuilder(); buildGraphPattern(groupBuilder); _childGraphPatternBuilders.Add(groupBuilder); return(this); }
/// <inheritdoc /> public IGraphPatternBuilder Group(GraphPatternBuilder groupBuilder) { if (!_childGraphPatternBuilders.Contains(groupBuilder)) { _childGraphPatternBuilders.Add(groupBuilder); } return(this); }
/// <summary> /// Creates a call of the EXISTS function /// </summary> /// <param name="eb"></param> /// <param name="buildExistsPattern">a function, which will create the graph pattern parameter</param> public static BooleanExpression Exists(this ExpressionBuilder eb, Action <IGraphPatternBuilder> buildExistsPattern) { GraphPatternBuilder builder = new GraphPatternBuilder(); buildExistsPattern(builder); var existsFunction = new ExistsFunction(builder.BuildGraphPattern(eb.Prefixes), true); return(new BooleanExpression(existsFunction)); }
/// <inheritdoc /> public IGraphPatternBuilder Child(IQueryBuilder queryBuilder) { SparqlQuery subquery = queryBuilder.BuildQuery(); GraphPatternBuilder childBuilder = new GraphPatternBuilder(); childBuilder.Where(new SubQueryPattern(subquery)); _childGraphPatternBuilders.Add(childBuilder); return(this); }
public IGraphPatternBuilder Union(Action <IGraphPatternBuilder> buildGraphPattern) { GraphPatternBuilder union; if (_graphPatternType == GraphPatternType.Union) { union = this; } else { union = new GraphPatternBuilder(GraphPatternType.Union); union._childGraphPatternBuilders.Add(this); } union.AddChildGraphPattern(buildGraphPattern, GraphPatternType.Normal); return(union); }
/// <inheritdoc /> public IGraphPatternBuilder Union(Action <IGraphPatternBuilder> firstGraphPattern, params Action <IGraphPatternBuilder>[] unionedGraphPatternBuilders) { if (unionedGraphPatternBuilders == null || unionedGraphPatternBuilders.Length == 0) { return(Child(firstGraphPattern)); } var union = new GraphPatternBuilder(GraphPatternType.Union); union.AddChildGraphPattern(firstGraphPattern, GraphPatternType.Normal); foreach (var builder in unionedGraphPatternBuilders) { union.AddChildGraphPattern(builder, GraphPatternType.Normal); } _childGraphPatternBuilders.Add(union); return(this); }
/// <inheritdoc /> public IGraphPatternBuilder Union(GraphPatternBuilder firstGraphPattern, params GraphPatternBuilder[] unionedGraphPatternBuilders) { if (unionedGraphPatternBuilders == null || unionedGraphPatternBuilders.Length == 0) { return(Child(firstGraphPattern)); } var union = new GraphPatternBuilder(GraphPatternType.Union); union.Child(firstGraphPattern); foreach (var builder in unionedGraphPatternBuilders) { union.Child(builder); } _childGraphPatternBuilders.Add(union); return(this); }
/// <inheritdoc /> public IGraphPatternBuilder Child(GraphPatternBuilder childBuilder) { _childGraphPatternBuilders.Add(childBuilder); return(this); }
internal BindAssignmentVariableNamePart(GraphPatternBuilder graphPatternBuilder, Func <ExpressionBuilder, SparqlExpression> buildAssignmentExpression) : base(buildAssignmentExpression) { _graphPatternBuilder = graphPatternBuilder; }
/// <summary> /// See <see cref="IGraphPatternBuilder.Union(GraphPatternBuilder,VDS.RDF.Query.Builder.GraphPatternBuilder[])"/>. /// </summary> public static IQueryBuilder Union(this IQueryBuilder queryBuilder, GraphPatternBuilder firstGraphPattern, params GraphPatternBuilder[] otherGraphPatterns) { queryBuilder.Root.Union(firstGraphPattern, otherGraphPatterns); return(queryBuilder); }
internal ConstructBuilder(Action <IDescribeGraphPatternBuilder> buildPattern) : base(SparqlQueryType.Construct) { _builder = new GraphPatternBuilder(); buildPattern(_builder); }
public GraphPatternBuilderTests() { _namespaceMapper = new Mock <INamespaceMapper>(MockBehavior.Strict); _builder = new GraphPatternBuilder(); }
internal DescribeGraphPatternBuilder(GraphPatternBuilder builder) { _builder = builder; }