The Web Graph Database

Changes between Initial Version and Version 1 of Docs/BlessingUnblessingRelationship


Ignore:
Timestamp:
07/24/09 16:23:31 (8 years ago)
Author:
http://mylid.net/jernst
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/BlessingUnblessingRelationship

    v1 v1  
     1= Blessing and Unblessing a Relationship between two !MeshObjects = 
     2 
     3== Blessing a Relationship == 
     4 
     5Assume an existing [wiki:Relationship] between the following two [wiki:MeshObject MeshObjects] needs to be [wiki:Blessing blessed] with RelationshipType `org.infogrid.model.Test.AR1A`: 
     6{{{ 
     7MeshObject obj1 = ...; 
     8MeshObject obj2 = ...; 
     9}}} 
     10 
     11A [wiki:Transaction] is necessary to create, delete or update any MeshObject. Note that if the RelationshipType requires the source and/or destination MeshObject to be blessed with a certain EntityType, blessing of the [wiki:Relationship] will fail unless the the [wiki:MeshObject MeshObjects] are indeed blessed with the correct EntityType. 
     12 
     13To bless the [wiki:Relationship]: 
     14{{{ 
     15MeshBase    mb = obj1.getMeshObject(); 
     16Transaction tx = null; 
     17try { 
     18    tx = mb.createTransactionAsap(); 
     19 
     20    obj1.blessRelationship( TestSubjectArea.AR1A.getSource(), obj2 ); // blessing 
     21 
     22} finally { 
     23    if( tx != null ) { 
     24        tx.commitTransaction(); 
     25    } 
     26} 
     27}}} 
     28 
     29Note that this RelationshipType is directed. The line: 
     30{{{ 
     31    obj1.blessRelationship( TestSubjectArea.AR1A.getSource(), obj2 ); // blessing 
     32}}} 
     33accomplishes the same effect as the line: 
     34{{{ 
     35    obj2.blessRelationship( TestSubjectArea.AR1A.getDestination(), obj1 ); // blessing 
     36}}} 
     37 
     38 
     39== Unblessing a Relationship == 
     40 
     41Assume the following two [wiki:MeshObject MeshObjects] are currently related, the [wiki:Relationship] is blessed with RelationshipType `org.infogrid.model.Test.AR1A` and needs to be [wiki:Blessing unblessed]: 
     42{{{ 
     43MeshObject obj1 = ...; 
     44MeshObject obj2 = ...; 
     45}}} 
     46 
     47A [wiki:Transaction] is necessary to create, delete or update any MeshObject. 
     48 
     49To unbless the [wiki:Relationship]: 
     50{{{ 
     51MeshBase    mb = obj.getMeshObject(); 
     52Transaction tx = null; 
     53try { 
     54    tx = mb.createTransactionAsap(); 
     55 
     56    obj1.unblessRelationship( TestSubjectArea.AR1A.getSource(), obj2 ); // unblessing 
     57 
     58} finally { 
     59    if( tx != null ) { 
     60        tx.commitTransaction(); 
     61    } 
     62} 
     63}}} 
     64 
     65Note that this RelationshipType is directed. The line: 
     66{{{ 
     67    obj1.unblessRelationship( TestSubjectArea.AR1A.getSource(), obj2 ); // unblessing 
     68}}} 
     69accomplishes the same effect as the line: 
     70{{{ 
     71    obj2.unblessRelationship( TestSubjectArea.AR1A.getDestination(), obj1 ); // unblessing 
     72}}} 
     73 
     74See also: 
     75 * [wiki:Docs/BlessingUnblessingMeshObject Blessing and unblessing a MeshObject].