/// <summary>Get verion history by URI and timestamp</summary> /// <param name="uri">object URI</param> /// <param name="kind">search kind, should be object SearchKind.LatestVersion, SearchKind.LatestBefore or /// SearchKind.OldestAfter</param> /// <param name="timestamp">timestamp used to locate version</param> /// <returns>version of the object or null if no such version is found</returns> public Thing GetVersion(string uri, SearchKind kind, DateTime timestamp) { VersionHistory vh = (VersionHistory)root.prefixUriIndex[uri]; if (vh != null) { return(vh.GetVersion(kind, timestamp)); } return(null); }
private bool FollowReference(NameVal prop, VersionHistory vh) { if (vh != null) { if (kind == SearchKind.AllVersions) { foreach (Thing v in vh.versions) { if (MatchProperty(prop, v)) { return(true); } } } else { Thing thing = vh.GetVersion(kind, timestamp); return(thing != null && MatchProperty(prop, thing)); } } return(false); }
static void DumpObject(Thing thing, TextWriter writer, int indent, SearchKind kind, DateTime timestamp, int depth) { WriteTab(writer, indent); string typeName = GetQualifiedName(thing.type.vh.uri, writer); writer.WriteLine(" rdf:about=\"" + thing.vh.uri + "\" vr:timestamp=\"" + thing.timestamp + "\">"); foreach (PropVal pv in thing.props) { object val = pv.val; if (val is VersionHistory) { VersionHistory ptr = (VersionHistory)val; if (kind != SearchKind.AllVersions) { if (depth > 0 || ptr.uri.StartsWith(thing.vh.uri)) { Thing t = ptr.GetVersion(kind, timestamp); if (t != null) { DumpObject(t, writer, indent + 1, kind, timestamp, depth - 1); continue; } } } WriteTab(writer, indent + 1); GetQualifiedName(pv.def.name, writer); writer.WriteLine(" rdf:resource=\"" + ptr.uri + "\"/>"); } else { WriteTab(writer, indent + 1); string propName = GetQualifiedName(pv.def.name, writer); writer.WriteLine(">" + val + "</" + propName + ">"); } } WriteTab(writer, indent); writer.WriteLine("</" + typeName + ">"); }
private bool FollowReference(NameVal prop, VersionHistory vh) { if (vh != null) { if (kind == SearchKind.AllVersions) { foreach (Thing v in vh.versions) { if (MatchProperty(prop, v)) { return true; } } } else { Thing thing = vh.GetVersion(kind, timestamp); return thing != null && MatchProperty(prop, thing); } } return false; }