Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Obsolete COSMOS SDD Tooling BTG Rules

Revision as of 09:23, 28 January 2008 by Cmbrandt.us.ibm.com (Talk | contribs) (Resources)

This page holds ideas about how rules should be written for combining two SDDs together.

Rules

Our rules engine is Drools 4.0.4. When dealing with rules, we need to take into consideration the following:

  • We have no control over when a comparison could be made and a rule fires
  • I'm sure there's more, please fill in other bullets.

Resources

Resources can have any number of hosted resources, and those hosted resources can have any number of hosted resources, and etc. We need some rules to determine how to combine two trees from different descriptors.

Let's say we have the following two resource trees:

Tree 1:

A
  B
    C
  D
  E
H
  G

Tree 2:

F
  A
    B
      C
  G

The same letters in different trees refer to the same resource and should be merge together when merging trees.

Since we don't know the order resources are compared, we need to write the rules in a way that order doesn't matter. Our rules for merging are the following:

  1. Merge two matching resources when at least one of the resources has a parent that is not a resource.
    • If the resources are in different trees, the ancestry (parent resource and up) should be left in tact. Meaning, the resource with no parent will now have the same parent as the matching resource in the other tree. The resource with no parent will be removed from the root of the tree and merge in the tree with the resource that has a parent.
    • If the resources are in the same tree, the resource with no parent will be removed from the root of the tree and merged with the resource that has a parent.
    • If both matching resources do not have parent resources, then the resource from one of the trees will be removed and merged with the other.
    • During merging, the children of both objects will simply be copied in place to be handled by the second rule.
  2. If two matching resources have the same parent in the same tree, then merge them.
    • During merging, the children of both object will simply be copied in place to be handled by another firing of this rule.

Taking the two trees above, here is one possible case of merging: (A lowercase m is used to indicate two matching resources that have been merged. A number indicates the tree that a resource has originated from.)

Merging of resource A

Both A resources are merged into tree 2. Resource A's children are brought along and copied in place. A is then removed from tree 1.

Tree 1:

H
  G

Tree 2:

F
  Am
    B
      C
    B1
      C1
    D1
    E1
  G

Merging of resources without parents

Both H and F resources don't have parents that are resources. This means the entire resource can be copied to the root of the other tree. We will copy F to tree 1. Tree 2 is now empty.

Tree 1:

H
  G
F2
  Am
    B2
      C2
    B1
      C1
    D1
    E1
  G2

Tree 2:


Merging of resource B

The B resources have the same parent. We will merge the B resources and copy the rest of the tree in place.

Tree 1:

H
  G
F2
  Am
    Bm
      C2
      C1
    D1
    E1
  G2

Merging of resource C

The C resources have the same parent. We will merge the C resources.

Tree 1:

H
  G
F2
  Am
    Bm
      Cm
    D1
    E1
  G2

We now have the final merged tree. The G resources don't get merged since they exist under different parents.

Back to the top