Tsparql.Resource
Description: Reference for Tsparql.Resource

### Class

# TsparqlResource

#### Description [src]

    final class Tsparql.Resource : GObject.Object
    {
      /* No available fields */
    }

`TrackerResource` is an in-memory representation of RDF data about a given resource.

This object keeps track of a set of properties for a given resource, and can also link to other `TrackerResource` objects to form trees or graphs of RDF data. See `tracker_resource_set_relation()` and `tracker_resource_set_uri()` on how to link a `TrackerResource` to other RDF data.

`TrackerResource` may also hold data about literal values, added through the specialized `tracker_resource_set_int64()`, `tracker_resource_set_string()`, etc family of functions, or the generic `tracker_resource_set_gvalue()` method.

Since RDF properties may be multi-valued, for every `set` call there exists another `add` call (e.g. `tracker_resource_add_int64()`, `tracker_resource_add_string()` and so on). The `set` methods do also reset any previously value the property might hold for the given resource.

Resources may have an IRI set at creation through `tracker_resource_new()`, or set afterwards through `tracker_resource_set_identifier()`. Resources without a name will represent a blank node, and will be dealt with as such during database insertions.

`TrackerResource` performs no validation on the data being coherent as per any ontology. Errors will be found out at the time of using the TrackerResource for e.g. database updates.

Once the RDF data is built in memory, the (tree of) `TrackerResource` may be converted to a RDF format through `tracker_resource_print_rdf()`, or directly inserted into a database through `tracker_batch_add_resource()` or `tracker_sparql_connection_update_resource()`.

#### Ancestors

- GObject

#### Constructors

###### tracker_resource_new

Creates a TrackerResource instance.

#### Functions

###### tracker_resource_deserialize

Deserializes a `TrackerResource` previously serialized with `tracker_resource_serialize()`. It is implied that both ends use a common `TrackerNamespaceManager`.

#### Instance methods

###### tracker_resource_add_boolean

Adds a boolean property. Previous values for the same property are kept.

###### tracker_resource_add_datetime

Adds a date property as a `GDateTime`. Previous values for the same property are kept.

since: 3.2

###### tracker_resource_add_double

Adds a numeric property with double precision. Previous values for the same property are kept.

###### tracker_resource_add_gvalue

Add `value` to the list of values for given property.

###### tracker_resource_add_int

Adds a numeric property with integer precision. Previous values for the same property are kept.

###### tracker_resource_add_int64

Adds a numeric property with 64-bit integer precision. Previous values for the same property are kept.

###### tracker_resource_add_relation

Adds a resource property as a `TrackerResource`. Previous values for the same property are kept.

###### tracker_resource_add_string

Adds a string property. Previous values for the same property are kept.

###### tracker_resource_add_take_relation

Adds a resource property as a `TrackerResource`. Previous values for the same property are kept. Takes ownership on the given `resource`.

###### tracker_resource_add_uri

Adds a resource property as an URI string. Previous values for the same property are kept.

###### tracker_resource_get_first_boolean

Returns the first boolean object previously assigned to a property.

###### tracker_resource_get_first_datetime

Returns the first `GDateTime` previously assigned to a property.

since: 3.2

###### tracker_resource_get_first_double

Returns the first double object previously assigned to a property.

###### tracker_resource_get_first_int

Returns the first integer object previously assigned to a property.

###### tracker_resource_get_first_int64

Returns the first integer object previously assigned to a property.

###### tracker_resource_get_first_relation

Returns the first resource object previously assigned to a property.

###### tracker_resource_get_first_string

Returns the first string object previously assigned to a property.

###### tracker_resource_get_first_uri

Returns the first resource object previously assigned to a property.

###### tracker_resource_get_identifier

Returns the identifier of a resource.

###### tracker_resource_get_properties

Gets the list of properties defined in `resource`.

###### tracker_resource_get_property_overwrite

Returns whether the prior values for this property would be deleted in the SPARQL issued by `resource`.

since: 3.1

###### tracker_resource_get_values

Returns the list of all known values of the given property.

###### tracker_resource_identifier_compare_func

A helper function that compares a `TrackerResource` by its identifier string.

###### tracker_resource_print_jsonld

Serialize all the information in `resource` as a JSON-LD document.

deprecated: 3.5

###### tracker_resource_print_rdf

Serialize all the information in `resource` into the selected RDF format.

since: 3.4

###### tracker_resource_print_sparql_update

Generates a SPARQL command to update a database with the information stored in `resource`.

###### tracker_resource_print_turtle

Serialize all the information in `resource` as a Turtle document.

deprecated: 3.4

###### tracker_resource_serialize

Serializes a `TrackerResource` to a `GVariant` in a lossless way. All child resources are subsequently serialized. It is implied that both ends use a common `TrackerNamespaceManager`.

###### tracker_resource_set_boolean

Sets a boolean property. Replaces any previous value.

###### tracker_resource_set_datetime

Sets a date property as a `GDateTime`. Replaces any previous value.

since: 3.2

###### tracker_resource_set_double

Sets a numeric property with double precision. Replaces any previous value.

###### tracker_resource_set_gvalue

Replace any previously existing value for `property_uri` with `value`.

###### tracker_resource_set_identifier

Changes the identifier of a `TrackerResource`. The identifier should be a URI or compact URI, but this is not necessarily enforced. Invalid identifiers may cause errors when serializing the resource or trying to insert the results in a database.

###### tracker_resource_set_int

Sets a numeric property with integer precision. Replaces any previous value.

###### tracker_resource_set_int64

Sets a numeric property with 64-bit integer precision. Replaces any previous value.

###### tracker_resource_set_relation

Sets a resource property as a `TrackerResource`. Replaces any previous value.

###### tracker_resource_set_string

Sets a string property. Replaces any previous value.

###### tracker_resource_set_take_relation

Sets a resource property as a `TrackerResource`. Replaces any previous value. Takes ownership on the given `resource`.

###### tracker_resource_set_uri

Sets a resource property as an URI string. Replaces any previous value.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Tsparql.Resource:identifier

The URI identifier for this class, or `NULL` for a blank node.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct TsparqlResourceClass {
      /* no available fields */
    }

No description available.