示例#1
0
        public QueryGroup Resolve(TripleStore triples)
        {
            QueryGroupAnd groupAnd = new QueryGroupAnd();

            QueryGroupPatterns groupRequired = new QueryGroupPatterns();

            foreach (Pattern pattern in itsPatterns)
            {
                groupRequired.Add(pattern.Resolve(triples));
            }
            groupAnd.Add(groupRequired);

            if (null != itsOptionalPatterns)
            {
                try {
                    QueryGroupPatterns groupOptional = new QueryGroupPatterns();
                    foreach (Pattern pattern in itsOptionalPatterns.Patterns)
                    {
                        groupOptional.Add(pattern.Resolve(triples));
                    }
                    groupAnd.Add(new QueryGroupOptional(groupOptional));
                }
                catch (UnknownGraphMemberException) {
                    // NOOP
                }
            }

            QueryGroupConstraints groupConstraints = new QueryGroupConstraints();

            foreach (Constraint constraint in itsConstraints)
            {
                groupConstraints.Add(constraint);
            }
            groupAnd.Add(groupConstraints);

            QueryGroupOr alternateGroups = new QueryGroupOr();

            alternateGroups.Add(groupAnd);


            foreach (PatternGroup group in itsAlternateGroups)
            {
                try {
                    QueryGroupPatterns groupAlternate = new QueryGroupPatterns();
                    foreach (Pattern pattern in group.Patterns)
                    {
                        groupAlternate.Add(pattern.Resolve(triples));
                    }
                    alternateGroups.Add(groupAlternate);
                }
                catch (UnknownGraphMemberException) {
                    // NOOP
                }
            }

            return(alternateGroups);
        }
        public QueryGroup Resolve(ResourceMap map)
        {
            QueryGroupConstraints newGroup = new QueryGroupConstraints();

            foreach (Constraint constraint in itsConstraints)
            {
                newGroup.Add(constraint);
            }
            return(newGroup);
        }
示例#3
0
 public PatternGroup()
 {
     itsPatterns                  = new ArrayList();
     itsAlternateGroups           = new ArrayList();
     itsConstraints               = new ArrayList();
     itsQueryPartAlternate        = new QueryGroupOr();
     itsQueryPartPatterns         = new QueryGroupPatterns();
     itsQueryPartOptionalPatterns = new QueryGroupPatterns();
     itsQueryPartOptional         = new QueryGroupOptional(itsQueryPartOptionalPatterns);
     itsQueryPartConstraints      = new QueryGroupConstraints(  );
 }