private static string FormatDeletePattern(ITriple p, ref int propId) { return(String.Format(" {0} {1} {2} .", FormatDeletePatternItem(p.Subject, ref propId), FormatDeletePatternItem(p.Predicate, ref propId), p.IsLiteral ? FormatDeletePatternItem(p.Object, p.DataType, p.LangCode) : FormatDeletePatternItem(p.Object, ref propId))); }
//private string FormatDeletePatterns(IEnumerable<Triple> deletePatterns) //{ // int propId = 0; // var deleteOp = new StringBuilder(); // deleteOp.AppendLine("DELETE {"); // foreach (var deleteGraphGroup in deletePatterns.GroupBy(d => d.Graph)) // { // deleteOp.AppendFormat("GRAPH <{0}> {{", deleteGraphGroup.Key); // deleteOp.AppendLine(); // foreach (var deletePattern in deleteGraphGroup) // { // if (deletePattern.Predicate.Equals(Constants.WildcardUri)) // { // deleteOp.AppendFormat(" <{0}> ?d{1} ?d{2} .", deletePattern.Subject, propId++, propId++); // } // else if (!deletePattern.IsLiteral && deletePattern.Object.Equals(Constants.WildcardUri)) // { // deleteOp.AppendFormat(" <{0}> <{1}> ?d{2} .", deletePattern.Subject, deletePattern.Predicate, // propId++); // } // else // { // AppendTriplePattern(deletePattern, deleteOp); // } // deleteOp.AppendLine(); // } // deleteOp.AppendLine("}"); // } // deleteOp.AppendLine("}"); // return deleteOp.ToString(); //} private void AppendTriplePattern(ITriple triple, StringBuilder builder) { builder.AppendFormat(" <{0}> <{1}> ", triple.Subject, triple.Predicate); if (triple.IsLiteral) { builder.AppendFormat("\"{0}\"", triple.Object); if (triple.DataType != null) { builder.Append("^^"); builder.AppendFormat("<{0}>", triple.DataType); } if (triple.LangCode != null) { builder.Append("@"); builder.Append(triple.LangCode); } } else { builder.AppendFormat("<{0}>", triple.Object); } builder.Append(" ."); }
//private string FormatDeletePatterns(IEnumerable<Triple> deletePatterns) //{ // int propId = 0; // var deleteOp = new StringBuilder(); // deleteOp.AppendLine("DELETE {"); // foreach (var deleteGraphGroup in deletePatterns.GroupBy(d => d.Graph)) // { // deleteOp.AppendFormat("GRAPH <{0}> {{", deleteGraphGroup.Key); // deleteOp.AppendLine(); // foreach (var deletePattern in deleteGraphGroup) // { // if (deletePattern.Predicate.Equals(Constants.WildcardUri)) // { // deleteOp.AppendFormat(" <{0}> ?d{1} ?d{2} .", deletePattern.Subject, propId++, propId++); // } // else if (!deletePattern.IsLiteral && deletePattern.Object.Equals(Constants.WildcardUri)) // { // deleteOp.AppendFormat(" <{0}> <{1}> ?d{2} .", deletePattern.Subject, deletePattern.Predicate, // propId++); // } // else // { // AppendTriplePattern(deletePattern, deleteOp); // } // deleteOp.AppendLine(); // } // deleteOp.AppendLine("}"); // } // deleteOp.AppendLine("}"); // return deleteOp.ToString(); //} private void AppendTriplePattern(ITriple triple, StringBuilder builder) { builder.AppendFormat(" <{0}> <{1}> ", triple.Subject, triple.Predicate); if (triple.IsLiteral) { builder.AppendFormat("\"{0}\"", triple.Object); if (triple.DataType != null) { builder.Append("^^"); builder.AppendFormat("<{0}>", triple.DataType); } if (triple.LangCode != null) { builder.Append("@"); builder.Append(triple.LangCode); } } else { builder.AppendFormat("<{0}>", triple.Object); } builder.Append(" ."); }
/// <summary> /// Determines if the specified triple consists of a grounded (non-wildcard) /// subject, predicate and object. /// </summary> /// <param name="t">The triple to check</param> /// <returns></returns> private static bool IsGrounded(ITriple t) { return (t.Predicate != Constants.WildcardUri) && (t.Object != Constants.WildcardUri); }
/// <summary> /// Determines if the specified triple is targeted at a specific graph /// </summary> /// <param name="t">The triple to check</param> /// <returns></returns> private static bool IsGraphTargeted(ITriple t) { return t.Graph != null && t.Graph != Constants.WildcardUri; }
private static string FormatDeletePattern(ITriple p, ref int propId) { return String.Format(" {0} {1} {2} .", FormatDeletePatternItem(p.Subject, ref propId), FormatDeletePatternItem(p.Predicate, ref propId), p.IsLiteral ? FormatDeletePatternItem(p.Object, p.DataType, p.LangCode) : FormatDeletePatternItem(p.Object, ref propId)); }
/// <summary> /// Determines if the specified triple consists of a grounded (non-wildcard) /// subject, predicate and object. /// </summary> /// <param name="t">The triple to check</param> /// <returns></returns> private static bool IsGrounded(ITriple t) { return((t.Predicate != Constants.WildcardUri) && (t.Object != Constants.WildcardUri)); }
/// <summary> /// Determines if the specified triple is targeted at a specific graph /// </summary> /// <param name="t">The triple to check</param> /// <returns></returns> private static bool IsGraphTargeted(ITriple t) { return(t.Graph != null && t.Graph != Constants.WildcardUri); }