User's Manual

130 Chapter 11. Services Tutorials
Category b = new Category(new OID(124));
Category c = new Category(new OID(125));
if ( a != null && b != null && c != null ) {
// Makes Category B the parent of Category A
b.addChild(a);
// Makes Category C the parent of Category A
c.addChild(a);
// Sets Category B as the default parent of Category A
a.setDefaultParentCategory(b);
}
Example 11-3. Adding more parent categories
Figure 11-6. Category hierarchy before and after adding parent categories.
11.2.4. Removing Parent Categories
// Fetch category A from the database.
Category a = new Category(new OID(123));
// Fetch the parent category
Category b = a.getDefaultParentCategory();
b.removeChild(a);
a.setDefaultParentCategory(b.getDefaultParentCategory());
Example 11-4. Removing Parent Categories