« Back to CIDOC-CRM Project

Calculate Class Hierarchy

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Calculate Class Hierarchy
community class documentation
Answer
27/03/14 11:12
Is it possible to calculate the underlying class hierarchy in ADOxx from an instance modelled?

RE: Calculate Class Hierarchy
Answer
26/07/13 10:39 as a reply to Anonymous.
The underlying class hierarchy can be calculated from any instance created by following the steps below and using the resources attached to this message:

Library Prerequesites:
- Class Hierarchy Calculation Module is available in the library and loaded
- Instance Attributes have been defined to hold the results of the calculation
- Trigger is defined according to the needs

For the following example snipplet the following is assumed:
- The trigger for the calculation is the user, clicking on a button in the notebook of the instance
- The attributes "Class hierarchy (ID)" and "Class hierarchy (Name)" are available in the instance to store the return values of the procedure
- The PROCEDURE of the Calculation module is loaded during application startup

Steps:
1. Add 3 attributes to the root object of the library "__D-contruct__" (this makes sure that it is available for all classes)
a. Attribute name: "Class hierarchy (ID)" TYPE: STRING; this attribute is set after calculation with class ID tree of parent classes
b. Attribute name: "Class hierarchy (Name)" TYPE: STRING; this attribute is set after calculation with class name tree of parent classes
c. Attribute name: "Calculate class hierarchy" TYPE: PROGRAMCALL; this attribute shows the button in the notebook to trigger the calculation of the class hierarchy

2. Define the AdoScript to be run on PROGRAMMCALL: see attached file triggerClassHierarchyCalculation.asc: add the content of the file to the facets of the attribute

3. Add attributes to the AttrRep of classes
1CHAPTER "ClassHierarchy"
2ATTR "Class hierarchy (ID)"
3ATTR "Class hierarchy (Name)"
4ATTR "Calculate class hierarchy" no-param push-button


4. Add file using library file management function "class_hierarchy.bin"

5. Load file "class_hierarchy.bin" ON_EVENT "AppInitialized"

1ON_EVENT "AppInitialized" {
2...
3EXECUTE file: ("db:\\class_hierarchy.bin")
4...
5}

6. Test for the class, using the notebook button for calculation. Remove the INFOBOX commands to remove the UI interaction.

.
Attachments: 20130717 - ADOxxORG - ClassHierarchy Calculation_PUBLIC.zip (2.8k)

RE: Calculate Class Hierarchy
Answer
26/07/13 10:40 as a reply to Anonymous.
The solution below is slightly easier to implement, but it is limited to returning only a list of concrete classes (without abstract classes) that are superclasses of a selected instance, without any hierarchy.

1. Add a context menu item named "Get all parent classes..." for the context "drawingarea.mobject" that triggers the script in the file "getAllParentClasses_Lib.asc" . (see attached file ExtCoupl_ClassHierarcyCalc.asc)

1ON_EVENT "AppInitialized" {
2...
3CC "Application" INSERT_CONTEXT_MENU_ITEM context: "drawingarea.mobject" item: "Get all parent classes..."
4CC "Application" SET_CMI_SELECT_HDL context: "drawingarea.mobject" item: "Get all parent classes..." {
5EXECUTE file: ("db:\\getAllParentClasses_Lib.asc")
6}
7...
8}


2. Import the file "getAllParentClasses_Lib.asc" into the application library.

3. Right-click on any object and click the context menu item "Get all parent classes..." to trigger the script and get a list of all concrete superclasses of the selected object.

4. The file "getAllParentClasses_MT.asc" only returns the concrete superclasses of the current object that are included in the current model type.
Attachments: ADOxxORG-ConcreteClassHierarchy_Calculation.zip (3.0k)