Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel3
minLevel3
styleborder:1
locationtop
typeflat
separatorpipe

Relationships in WSO2 Governance Registry defines a uni-directional association between two resources or collections, which is classified by a label. A dependency is a special type of association with a label "depends". Relationships defined in WSO2 Governance Registry have semantics similar to that of RDF Triples. By default, there are no rules on what types of associations are created and what resources can be associated with each other. However, if required you can setup validations to ensure that associations are meaningful. This can be achieved by introducing Handlers and Lifecycle Validators.

Creating a Relationship Between Two Resources

...

Creating a relationship between two resources

A relationship (for example, dependency) can be created between two resources using the following line of code:

Code Block
registry.addAssociation("c1/c2/r3", "c1/c2/r4", "depends on"); // in this case r3 depends on r4

...

Removing a

...

relationship between two resources

A relationship can be removed between two resources using the following line of code:

Code Block
registry.removeAssociation("c1/c2/r3", "c1/c2/r4", "depends on"); // in this case r3 depends on r4

...

Retrieving

...

relationships from a

...

resource

Relationships of a resource between two resources can be retrieved using the following line of code:

Code Block
registry.addAssociation("c1/c2/r3", "c1/c2/r4", "depends on"); // in this case r3 depends on r4
 
Association all[] = registry.getAllAssociations("c1/c2/r3"); // all associations of r3
String sourcePath1 = all[0].getSourcePath(); // equals to "c1/c2/r3"

Association dependsAll[] = registry.getAssociations("c1/c2/r3", "depends on"); // "depends on" associations of r3
String sourcePath2 = dependsAll[0].getSourcePath(); // equals to "c1/c2/r3"
 
Association r4Assoc[] = registry.getAssociations("c1/c2/r4", "depends on"); // "depends on" associations of r3
boolean hasAssociations = (r4Assoc.length == 0); // this returns true 

 

See also Managing Dependencies and Associations to learn how to manage relationships of a resource in the Governance Registry Management Console.

Excerpt
hiddentrue

Instructions on how to manage relationships of a resource in Governance Registry.

...