Difference between revisions of "Truxton file create relation"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "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 <code>...")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This creates a relation object sourced from this file that you can use in the [[Truxton C API#Relation | Relation API.]]
 
This creates a relation object sourced from this file that you can use in the [[Truxton C API#Relation | Relation API.]]
A relation object is how you add records to the <code>[[Relation Table | Relation]]</code> table.
+
A relation object is how you add records to the <code><nowiki>[</nowiki>[[Relation Table|Relation]]<nowiki>]</nowiki></code> table.
 
The resulting object will automatically be associated with the file it was created from and with the media the file belongs to.
 
The resulting object will automatically be associated with the file it was created from and with the media the file belongs to.
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
uint64_t truxton_file_create_relation( uint64_t file_handle );
 
uint64_t truxton_file_create_relation( uint64_t file_handle );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
 
==<code>file_handle</code>==
 
==<code>file_handle</code>==
 
+
The handle created by the [[truxton_file_open_id]] or [[truxton_file_open_md5]] call.
The handle created by the [[truxton_child_file_create]] or [[truxton_file_create_child]] call.
 
  
 
=Return value=
 
=Return value=
Line 17: Line 16:
  
 
=Sample=
 
=Sample=
 
+
<source lang="C" highlight="17">
<syntaxhighlight lang="C" highlight="17">
+
void process_file( uint64_t truxton )
void process_file(uint64_t truxton)
 
 
{
 
{
   uint64_t file = truxton_file_open_md5(truxton, "9ec8fb6095c35eff2b236863b7caaf10");
+
   uint64_t file = truxton_file_open_md5( truxton, "9ec8fb6095c35eff2b236863b7caaf10" );
  
   uint64_t artifact_1 = truxton_file_create_artifact(file);
+
   uint64_t artifact_1 = truxton_file_create_artifact( file );
  
   truxton_artifact_set_type(artifact_1, ENTITY_TYPE_EMAIL_ADDRESS);
+
   truxton_artifact_set_type( artifact_1, ENTITY_TYPE_EMAIL_ADDRESS );
   truxton_artifact_set_value(artifact_1, "mdyson@cyberdynesystems.com" );
+
   truxton_artifact_set_value( artifact_1, "mdyson@cyberdynesystems.com" );
   truxton_artifact_save(artifact_1);
+
   truxton_artifact_save( artifact_1 );
  
   uint64_t artifact_2 = truxton_file_create_artifact(file);
+
   uint64_t artifact_2 = truxton_file_create_artifact( file );
  
   truxton_artifact_set_type(artifact_2, ENTITY_TYPE_PERSON);
+
   truxton_artifact_set_type( artifact_2, ENTITY_TYPE_PERSON );
   truxton_artifact_set_value(artifact_2, "Miles Dyson" );
+
   truxton_artifact_set_value( artifact_2, "Miles Dyson" );
   truxton_artifact_save(artifact_2);
+
   truxton_artifact_save( artifact_2 );
  
   uint64_t relation = truxton_file_create_relation(file);
+
   uint64_t relation = truxton_file_create_relation( file );
  
 
   char identifier[40];
 
   char identifier[40];
  
   truxton_artifact_get_id(artifact_1, identifier, sizeof(identifier));
+
   truxton_artifact_get_id( artifact_1, identifier, sizeof(identifier) );
   truxton_relation_set_a_id(relation, identifier);
+
   truxton_relation_set_a_id( relation, identifier );
   truxton_relation_set_a_type(relation, OBJECT_TYPE_ENTITY);
+
   truxton_relation_set_a_type( relation, OBJECT_TYPE_ENTITY );
  
   truxton_artifact_get_id(artifact_2, identifier, sizeof(identifier));
+
   truxton_artifact_get_id( artifact_2, identifier, sizeof(identifier) );
   truxton_relation_set_b_id(relation, identifier);
+
   truxton_relation_set_b_id( relation, identifier );
   truxton_relation_set_b_type(relation, OBJECT_TYPE_ENTITY);
+
   truxton_relation_set_b_type( relation, OBJECT_TYPE_ENTITY );
  
   truxton_relation_set_relation(relation, RELATION_MESSAGE_ADDRESS);
+
   truxton_relation_set_relation( relation, RELATION_MESSAGE_ADDRESS );
  
   truxton_relation_save(relation);
+
   truxton_relation_save( relation );
  
   truxton_relation_destroy(relation);
+
   truxton_relation_destroy( relation );
   truxton_artifact_destroy(artifact_1);
+
   truxton_artifact_destroy( artifact_1 );
   truxton_artifact_destroy(artifact_2);
+
   truxton_artifact_destroy( artifact_2 );
   truxton_file_destroy(child);
+
   truxton_file_free( file );
 
}
 
}
</syntaxhighlight>
+
</source>

Latest revision as of 04:58, 13 February 2021

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 );
}