示例#1
0
		public override MetaQueryResult MetaQuery(Statement[] graph, SemWeb.Query.QueryOptions options, SelectableSource source) {
			SemWeb.Query.MetaQueryResult ret = new SemWeb.Query.MetaQueryResult();
			
			ret.QuerySupported = true;
			
			ret.NoData = new bool[graph.Length];
			for (int i = 0; i < graph.Length; i++) {
				// Take this statement and replace variables by nulls
				// to make it a statement template.
				Statement st = graph[i];
				for (int j = 0; j < 4; j++) {
					if (st.GetComponent(j) is Variable)
						st.SetComponent(j, null);
				}
				
				// See if the store contains this template.
				if (st != Statement.All && !source.Contains(st)) {
					ret.NoData[i] = true;
					continue;
				}
			
				// Process it further in case we have variables
				// with known values, in which case if none of the
				// known values is in the store, we also know this
				// statement is unanswerable.
				for (int j = 0; j < 4; j++) {
					Resource r = graph[i].GetComponent(j);
					
					// No need to check the following given the check above.
					//if (r != null && !(r is Variable) && !source.Contains(r))
					//	ret.NoData[i] = true;
					
					if (r != null && r is Variable && options.VariableKnownValues != null && 
					#if !DOTNET2
					options.VariableKnownValues.Contains((Variable)r)
					#else
					options.VariableKnownValues.ContainsKey((Variable)r)
					#endif
					) {
						bool found = false;
						#if !DOTNET2
						foreach (Resource s in (ICollection)options.VariableKnownValues[(Variable)r]) {
						#else
						foreach (Resource s in (ICollection<Resource>)options.VariableKnownValues[(Variable)r]) {
						#endif
							if (source.Contains(s)) {
								found = true;
								break;
							}
						}
						if (!found) {
							ret.NoData[i] = true;
						}
					}
				}
			}
			
			return ret;
		}
示例#2
0
        public override MetaQueryResult MetaQuery(Statement[] graph, SemWeb.Query.QueryOptions options, SelectableSource source)
        {
            SemWeb.Query.MetaQueryResult ret = new SemWeb.Query.MetaQueryResult();

            ret.QuerySupported = true;

            ret.NoData = new bool[graph.Length];
            for (int i = 0; i < graph.Length; i++)
            {
                // Take this statement and replace variables by nulls
                // to make it a statement template.
                Statement st = graph[i];
                for (int j = 0; j < 4; j++)
                {
                    if (st.GetComponent(j) is Variable)
                    {
                        st.SetComponent(j, null);
                    }
                }

                // See if the store contains this template.
                if (st != Statement.All && !source.Contains(st))
                {
                    ret.NoData[i] = true;
                    continue;
                }

                // Process it further in case we have variables
                // with known values, in which case if none of the
                // known values is in the store, we also know this
                // statement is unanswerable.
                for (int j = 0; j < 4; j++)
                {
                    Resource r = graph[i].GetComponent(j);

                    // No need to check the following given the check above.
                    //if (r != null && !(r is Variable) && !source.Contains(r))
                    //	ret.NoData[i] = true;

                    if (r != null && r is Variable && options.VariableKnownValues != null &&
                                        #if !DOTNET2
                        options.VariableKnownValues.Contains((Variable)r)
                                        #else
                        options.VariableKnownValues.ContainsKey((Variable)r)
                                        #endif
                        )
                    {
                        bool found = false;
                                                #if !DOTNET2
                        foreach (Resource s in (ICollection)options.VariableKnownValues[(Variable)r])
                        {
                                                #else
                        foreach (Resource s in (ICollection <Resource>)options.VariableKnownValues[(Variable)r])
                        {
                                                #endif
                            if (source.Contains(s))
                            {
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            ret.NoData[i] = true;
                        }
                    }
                }
            }

            return(ret);
        }