Truxton file create relation

From truxwiki.com
Revision as of 12:56, 4 December 2020 by Sam (talk | contribs)
Jump to navigation Jump to search

This creates a relation object sourced from this file that you can use in the Relation API. A relation object is how you add records to the [Relation] table. The resulting object will automatically be associated with the file it was created from and with the media the file belongs to.

Syntax

uint64_t truxton_file_create_relation( uint64_t file_handle );

Parameters

file_handle

The handle created by the truxton_file_open_id or truxton_file_open_md5 call.

Return value

A handle to relation object.

Sample

void process_file(uint64_t truxton)
{
   uint64_t file = truxton_file_open_md5(truxton, "9ec8fb6095c35eff2b236863b7caaf10");

   uint64_t artifact_1 = truxton_file_create_artifact(file);

   truxton_artifact_set_type(artifact_1, ENTITY_TYPE_EMAIL_ADDRESS);
   truxton_artifact_set_value(artifact_1, "mdyson@cyberdynesystems.com" );
   truxton_artifact_save(artifact_1);

   uint64_t artifact_2 = truxton_file_create_artifact(file);

   truxton_artifact_set_type(artifact_2, ENTITY_TYPE_PERSON);
   truxton_artifact_set_value(artifact_2, "Miles Dyson" );
   truxton_artifact_save(artifact_2);

   uint64_t relation = truxton_file_create_relation(file);

   char identifier[40];

   truxton_artifact_get_id(artifact_1, identifier, sizeof(identifier));
   truxton_relation_set_a_id(relation, identifier);
   truxton_relation_set_a_type(relation, OBJECT_TYPE_ENTITY);

   truxton_artifact_get_id(artifact_2, identifier, sizeof(identifier));
   truxton_relation_set_b_id(relation, identifier);
   truxton_relation_set_b_type(relation, OBJECT_TYPE_ENTITY);

   truxton_relation_set_relation(relation, RELATION_MESSAGE_ADDRESS);

   truxton_relation_save(relation);

   truxton_relation_destroy(relation);
   truxton_artifact_destroy(artifact_1);
   truxton_artifact_destroy(artifact_2);
   truxton_file_free(file);
}