Skip to content

Commit

Permalink
#68 FIX empty value should be considered compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesalvo committed Aug 18, 2019
1 parent 3b4e352 commit f697c45
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions RDFSharp/Query/Mirella/Algebra/Filters/RDFExistsFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ internal override Boolean ApplyFilter(DataRow row, Boolean applyNegation)
&& this.PatternResults.Columns.Contains(this.Pattern.Subject.ToString())
&& row.Table.Columns.Contains(this.Pattern.Subject.ToString()))
{

//Get subject filter's value for the given row
RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Subject.ToString()].ToString());

//Apply subject filter on the pattern resultset
patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field<String>(this.Pattern.Subject.ToString())).Equals(rowMember));
//In case of emptiness the solution is compatible, otherwise proceed with comparison
if (!row.IsNull(this.Pattern.Subject.ToString()))
{
//Get subject filter's value for the given row
RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Subject.ToString()].ToString());

//Apply subject filter on the pattern resultset
patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field<String>(this.Pattern.Subject.ToString())).Equals(rowMember));
}
subjectCompared = true;

}
#endregion

Expand All @@ -130,14 +132,16 @@ internal override Boolean ApplyFilter(DataRow row, Boolean applyNegation)
&& this.PatternResults.Columns.Contains(this.Pattern.Predicate.ToString())
&& row.Table.Columns.Contains(this.Pattern.Predicate.ToString()))
{

//Get predicate filter's value for the given row
RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Predicate.ToString()].ToString());

//Apply predicate filter on the pattern resultset
patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field<String>(this.Pattern.Predicate.ToString())).Equals(rowMember));
//In case of emptiness the solution is compatible, otherwise proceed with comparison
if (!row.IsNull(this.Pattern.Predicate.ToString()))
{
//Get predicate filter's value for the given row
RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Predicate.ToString()].ToString());

//Apply predicate filter on the pattern resultset
patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field<String>(this.Pattern.Predicate.ToString())).Equals(rowMember));
}
predicateCompared = true;

}
#endregion

Expand All @@ -147,14 +151,16 @@ internal override Boolean ApplyFilter(DataRow row, Boolean applyNegation)
&& this.PatternResults.Columns.Contains(this.Pattern.Object.ToString())
&& row.Table.Columns.Contains(this.Pattern.Object.ToString()))
{

//Get object filter's value for the given row
RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Object.ToString()].ToString());

//Apply object filter on the pattern resultset
patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field<String>(this.Pattern.Object.ToString())).Equals(rowMember));
//In case of emptiness the solution is compatible, otherwise proceed with comparison
if (!row.IsNull(this.Pattern.Object.ToString()))
{
//Get object filter's value for the given row
RDFPatternMember rowMember = RDFQueryUtilities.ParseRDFPatternMember(row[this.Pattern.Object.ToString()].ToString());

//Apply object filter on the pattern resultset
patternResultsEnumerable = patternResultsEnumerable.Where(x => RDFQueryUtilities.ParseRDFPatternMember(x.Field<String>(this.Pattern.Object.ToString())).Equals(rowMember));
}
objectCompared = true;

}
#endregion

Expand Down

0 comments on commit f697c45

Please sign in to comment.