|
@@ -15,7 +15,7 @@ LSR_desc_new_multi (LSUP_Graph *const *data, LSR_Desc **rsrc_p)
|
|
|
LSUP_Term *main_data_urn = LSR_id_to_urn (rsrc->id, "__main");
|
|
|
rsrc->main_data = LSUP_graph_new (NULL, main_data_urn, LSUP_default_nsm);
|
|
|
LSUP_term_free (main_data_urn);
|
|
|
- log_debug (
|
|
|
+ LOG_DEBUG (
|
|
|
"Main data graph: %s",
|
|
|
LSUP_graph_uri(rsrc->main_data)->data);
|
|
|
|
|
@@ -28,7 +28,7 @@ LSR_desc_new_multi (LSUP_Graph *const *data, LSR_Desc **rsrc_p)
|
|
|
LSUP_Term *admin_uri = LSR_id_to_urn (rsrc->id, "__admin");
|
|
|
rsrc->admin_data = LSUP_graph_new (NULL, admin_uri, NULL);
|
|
|
|
|
|
- log_debug (
|
|
|
+ LOG_DEBUG (
|
|
|
"Admin data graph (@%p): %s",
|
|
|
LSUP_graph_uri (rsrc->admin_data),
|
|
|
LSUP_graph_uri (rsrc->admin_data)->data);
|
|
@@ -141,14 +141,14 @@ LSR_desc_store (const LSR_Desc *rsrc)
|
|
|
if (get_rc == LSUP_OK) {
|
|
|
for (size_t i = 0; old_rsrc->user_data[i] != NULL; i++) {
|
|
|
|
|
|
- LSUP_Term *gr_uri = LSUP_graph_uri (old_rsrc->user_data[i]);
|
|
|
+ const LSUP_Term *gr_uri = LSUP_graph_uri (old_rsrc->user_data[i]);
|
|
|
|
|
|
size_t ct;
|
|
|
// Remove triples from user graph.
|
|
|
PCHECK (LSUP_graph_remove_txn (
|
|
|
txn, old_rsrc->user_data[i],
|
|
|
NULL, NULL, NULL, &ct), fail);
|
|
|
- log_debug ("Removed %lu triples from graph %s", ct, gr_uri->data);
|
|
|
+ LOG_DEBUG ("Removed %lu triples from graph %s", ct, gr_uri->data);
|
|
|
|
|
|
// Remove user graph metadata.
|
|
|
PCHECK (LSUP_graph_remove_txn (
|
|
@@ -157,8 +157,6 @@ LSR_desc_store (const LSR_Desc *rsrc)
|
|
|
PCHECK (LSUP_graph_remove_txn (
|
|
|
txn, old_rsrc->main_data,
|
|
|
NULL, NULL, gr_uri, NULL), fail);
|
|
|
-
|
|
|
- LSUP_term_free (gr_uri);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -173,7 +171,7 @@ LSR_desc_store (const LSR_Desc *rsrc)
|
|
|
goto fail;
|
|
|
}
|
|
|
PCHECK (LSUP_graph_copy_contents_txn (
|
|
|
- txn, rsrc->user_data[i], tmp_gr), fail);
|
|
|
+ txn, rsrc->user_data[i], tmp_gr, NULL, NULL, NULL), fail);
|
|
|
LSUP_graph_free (tmp_gr);
|
|
|
}
|
|
|
|
|
@@ -185,7 +183,7 @@ LSR_desc_store (const LSR_Desc *rsrc)
|
|
|
goto fail;
|
|
|
}
|
|
|
PCHECK (LSUP_graph_copy_contents_txn (
|
|
|
- txn, rsrc->admin_data, tmp_gr), fail);
|
|
|
+ txn, rsrc->admin_data, tmp_gr, NULL, NULL, NULL), fail);
|
|
|
LSUP_graph_free (tmp_gr);
|
|
|
|
|
|
// Update graph metadata.
|
|
@@ -196,7 +194,7 @@ LSR_desc_store (const LSR_Desc *rsrc)
|
|
|
goto fail;
|
|
|
}
|
|
|
PCHECK (LSUP_graph_copy_contents_txn (
|
|
|
- txn, rsrc->main_data, tmp_gr), fail);
|
|
|
+ txn, rsrc->main_data, tmp_gr, NULL, NULL, NULL), fail);
|
|
|
LSUP_graph_free (tmp_gr);
|
|
|
|
|
|
PCHECK (LSUP_store_commit (LSR_store, txn), fail);
|
|
@@ -213,6 +211,14 @@ fail:
|
|
|
}
|
|
|
|
|
|
|
|
|
+LSUP_rc
|
|
|
+LSR_desc_delete (LSR_id id)
|
|
|
+{
|
|
|
+ // TODO
|
|
|
+ return LSUP_NOT_IMPL_ERR;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
LSUP_rc
|
|
|
LSR_desc_get (const uuid_t id, LSR_Desc **rsrc_p)
|
|
|
{
|
|
@@ -273,7 +279,7 @@ LSR_desc_metadata (const LSR_Desc *rsrc)
|
|
|
{
|
|
|
LSUP_Graph *res = LSUP_graph_new (
|
|
|
LSR_store, LSUP_graph_uri (rsrc->admin_data), NULL);
|
|
|
- LSUP_graph_copy_contents (rsrc->admin_data, res);
|
|
|
+ LSUP_graph_copy (rsrc->admin_data, res);
|
|
|
|
|
|
return res;
|
|
|
}
|
|
@@ -283,19 +289,43 @@ LSUP_Graph **
|
|
|
LSR_desc_user_data (const LSR_Desc *rsrc)
|
|
|
{
|
|
|
size_t ct = 0;
|
|
|
- while (rsrc->user_data[ct++]);
|
|
|
+ while (rsrc->user_data[ct]) ct++;
|
|
|
LSUP_Graph **res = malloc (sizeof (*res) * (ct + 1));
|
|
|
if (UNLIKELY (!res)) return NULL;
|
|
|
|
|
|
for (size_t i = 0; i < ct; i++) {
|
|
|
res[i] = LSUP_graph_new (
|
|
|
LSR_store, LSUP_graph_uri (rsrc->user_data[i]), NULL);
|
|
|
- LSUP_graph_copy_contents (rsrc->user_data[i], res[i]);
|
|
|
+ PCHECK (LSUP_graph_copy (rsrc->user_data[i], res[i]), fail);
|
|
|
}
|
|
|
-
|
|
|
res[ct] = NULL;
|
|
|
|
|
|
return res;
|
|
|
+
|
|
|
+fail:
|
|
|
+ for (size_t i = 0; i < ct; i++)
|
|
|
+ LSUP_graph_free (res[i]);
|
|
|
+ return NULL;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+LSUP_Graph *
|
|
|
+LSR_desc_triples (const LSR_Desc *rsrc)
|
|
|
+{
|
|
|
+ LSUP_Graph *res = LSR_desc_metadata (rsrc);
|
|
|
+ if (UNLIKELY (!res)) return NULL;
|
|
|
+ LSUP_graph_set_uri (res, LSR_desc_urn (rsrc));
|
|
|
+
|
|
|
+ size_t ct = 0;
|
|
|
+ while (rsrc->user_data[ct]) ct++;
|
|
|
+ for (size_t i = 0; i < ct; i++)
|
|
|
+ PCHECK (LSUP_graph_copy (rsrc->user_data[i], res), fail);
|
|
|
+
|
|
|
+ return res;
|
|
|
+
|
|
|
+fail:
|
|
|
+ LSUP_graph_free (res);
|
|
|
+ return NULL;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -331,7 +361,7 @@ LSR_desc_update (
|
|
|
for (j = 0; j < 4; j++)
|
|
|
LSUP_buffer_free (sspoc[j]);
|
|
|
|
|
|
- log_debug (
|
|
|
+ LOG_DEBUG (
|
|
|
"Removed %lu triples for %s",
|
|
|
ct_loop, rm_data[i][0]->data);
|
|
|
|
|
@@ -365,9 +395,9 @@ LSR_desc_update (
|
|
|
|
|
|
// Loop over input graphs.
|
|
|
for (size_t i = 0; i < ct; i++) {
|
|
|
- LSUP_Term *gr_uri = LSUP_graph_uri (add_data[i]);
|
|
|
+ const LSUP_Term *gr_uri = LSUP_graph_uri (add_data[i]);
|
|
|
|
|
|
- log_debug ("Adding user data #%lu with uri: %s", i, gr_uri->data);
|
|
|
+ LOG_DEBUG ("Adding user data #%lu with uri: %s", i, gr_uri->data);
|
|
|
|
|
|
LSUP_Term *rel_uri = LSUP_iriref_relative (rsrc_uri, gr_uri);
|
|
|
if (strstr (rel_uri->data, "#__") == rel_uri->data) {
|
|
@@ -378,7 +408,7 @@ LSR_desc_update (
|
|
|
if (rc < 0) goto finally;
|
|
|
|
|
|
rsrc->user_data[i] = LSUP_graph_new (NULL, gr_uri, NULL);
|
|
|
- log_debug (
|
|
|
+ LOG_DEBUG (
|
|
|
"User data graph (@%p): %s",
|
|
|
LSUP_graph_uri(rsrc->user_data[i]),
|
|
|
LSUP_graph_uri(rsrc->user_data[i])->data);
|
|
@@ -449,7 +479,7 @@ LSR_desc_update (
|
|
|
strcmp (spo->o->data, "lsup:ListItem") == 0 ||
|
|
|
strcmp (spo->o->data, "lsup:Set") == 0 ||
|
|
|
strcmp (spo->o->data, "lsup:Proxy") == 0) {
|
|
|
- // TODO
|
|
|
+ // TODO handle system-managed types.
|
|
|
} else {
|
|
|
log_error (
|
|
|
"%s is a managed predicate and cannot "
|
|
@@ -474,7 +504,7 @@ loop_end:
|
|
|
// Add user graph metadata to default graph.
|
|
|
LSUP_GraphIterator *admin_add_it = LSUP_graph_add_init (
|
|
|
rsrc->main_data);
|
|
|
- dest_s = gr_uri;
|
|
|
+ dest_s = LSUP_iriref_new (gr_uri->data, NULL);
|
|
|
dest_p = LSUP_iriref_new ("rdf:type", LSUP_default_nsm);
|
|
|
|
|
|
dest_o = LSUP_iriref_new ("lsup:Metadata", LSUP_default_nsm);
|
|
@@ -495,6 +525,8 @@ loop_end:
|
|
|
LSUP_graph_add_iter (admin_add_it, spo);
|
|
|
LSUP_term_free (dest_p);
|
|
|
|
|
|
+ LSUP_term_free (dest_s);
|
|
|
+
|
|
|
LSUP_graph_iter_free (lu_it);
|
|
|
LSUP_graph_add_done (add_it);
|
|
|
LSUP_graph_add_done (admin_add_it);
|
|
@@ -510,3 +542,9 @@ finally:
|
|
|
}
|
|
|
|
|
|
|
|
|
+/*
|
|
|
+ * Inline function declarations.
|
|
|
+ */
|
|
|
+
|
|
|
+LSUP_Term *LSR_desc_urn (const LSR_Desc *rsrc);
|
|
|
+
|