Assertion histAddParent (RDF_Resource child, RDF_Resource parent) { Assertion nextAs, prevAs, newAs; RDF_Resource s = gCoreVocab->RDF_parent; RDF_ValueType type = RDF_RESOURCE_TYPE; nextAs = prevAs = child->rarg1; while (nextAs != null) { if (asEqual(nextAs, child, s, parent, type)) return null; prevAs = nextAs; nextAs = nextAs->next; } newAs = makeNewAssertion(child, s, parent, type, 1); if (prevAs == null) { child->rarg1 = newAs; } else { prevAs->next = newAs; } nextAs = prevAs = parent->rarg2; if (nextAs == NULL) { parent->rarg2 = newAs; } else { PRBool added = 0; while (nextAs != null) { char* nid = resourceID(nextAs->u); if (strcmp( resourceID(child), resourceID(nextAs->u)) > 0) { if (prevAs == nextAs) { newAs->invNext = prevAs; parent->rarg2 = newAs; added = 1; break; } else { newAs->invNext = nextAs; prevAs->invNext = newAs; added = 1; break; } } prevAs = nextAs; nextAs = nextAs->invNext; } if (!added) prevAs->invNext = newAs; } sendNotifications2(gHistoryStore, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); /* XXX have to mark the entire subtree XXX */ /* sendNotifications(gRemoteStore->rdf, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); */ }
Assertion remoteStoreAdd (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, int tv) { Assertion newAs = makeNewAssertion(mcf, u, s, v, type, tv); newAs->next = u->rarg1; u->rarg1 = newAs; if (type == RDF_RESOURCE_TYPE) { RDF_Resource iu = (RDF_Resource)v; newAs->invNext = iu->rarg2; iu->rarg2 = newAs; } /* if (type == RDF_STRING_TYPE) RDFGS_AddSearchIndex(mcf, (char*) v, s, u); */ return newAs; }
PRBool ESDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type) { Assertion nextAs, prevAs, newAs; if ((s == gCoreVocab->RDF_instanceOf) && (v == gWebData->RDF_Container)) { setContainerp(u, true); return 1; } nextAs = prevAs = u->rarg1; while (nextAs != null) { if (asEqual(nextAs, u, s, v, type)) return 1; prevAs = nextAs; nextAs = nextAs->next; } newAs = makeNewAssertion(u, s, v, type, 1); if (prevAs == null) { u->rarg1 = newAs; } else { prevAs->next = newAs; } if (type == RDF_RESOURCE_TYPE) { nextAs = prevAs = ((RDF_Resource)v)->rarg2; while (nextAs != null) { prevAs = nextAs; nextAs = nextAs->invNext; } if (prevAs == null) { ((RDF_Resource)v)->rarg2 = newAs; } else { prevAs->invNext = newAs; } } sendNotifications2(rdf, RDF_ASSERT_NOTIFY, u, s, v, type, 1); return true; }