Getting Started with generating code for TPTP EMF models
Author: Alex Nan (apnan@ca.ibm.com)
Last Updated: February 6th, 2008

Getting Started with generating code for TPTP EMF models

The following document provides the necessary information for getting started with generating TPTP EMF model code.

Table of Contents:
1.0 Introduction
2.0 Installation of the EMF Generator
3.0 Generating the model code
4.0 Maintaining the model code
5.0 Additional documentation

1.0 Introduction

The TPTP models are EMF based models which are generated from ECore model files. The main model plugin org.eclipse.tptp.platform.models hosts the following models:


The Log and Trace Anayzer models are located in the org.eclipse.tptp.platform.models.lta plugin:

Note that the two model plugins depend on a common plugin org.eclipse.tptp.platform.models.hierarchy which defines the hierarchical structure that is used to organize and interact with the various agent content.
Also note that the Trace, Statistical and CBE models depend on the Hierarchy model.

The Producer CommonBaseEvent model is located in the plugin org.eclipse.tptp.platform.logging.events, the EMF implementation under the src.cbe101 subfolder and the Java implementation under src.events.

Locations of the various sources for the TPTP models are listed in the following:


2.0 Installation of the EMF Generator

3.0 Generating the model code
Once the workbench is up, check out the model plugins that you need to generate, switch to the Java perspective and follow the steps:
  1. Select the model plugin and subfolder for the corresponding model for which you want to perform code generation.
  2. Select the EMF generator model, i.e. the <model>.genmodel file, right click and choose "Open with"->"EMF Generator", the EMF Generator editor opens.
  3. Select the root node in the main view (the whole model), right click and choose "Show Properties View", the properties view is shown displaying various properties used for code generation.
  4. Verify that the following properties are pointing to the right locations:
    1. Model->Model Directory: the directory where the model will be generated
    2. Templates & Merge->Template Directory: the directory where the templates used to generate the model reside, if any customized templates are used or blank, in this case the default EMF templates are used.
    3. if customized templates are used make sure to set the property Templates & Merge->Dynamic Templates to true and otherwise to false
  5. Right click on the root element in the main view and choose Generate Model Code, the model files will be generated in the directory specified at bullet 4.1.
  6. Make sure no compilation errors are displayed, if any, try to fix them manually or revisit the code generation procedure for what could have gone wrong.
  7. Synchronize the generated code with CVS and do a difference on each generated class. Be aware that existing methods tagged with @generated NOT in the method's Java doc comment, are not overwritten.
  8. Once you've decided that the generated code looks good, check the code into CVS.
Note that the following features were changed to be non-unique in either the ecore or package implementation:
  1. hierarchy.ecore
    • TRCAnnotation_values unique=false
  2. trace.ecore
    • TRCThread_initialInvocations unique=false
  3. cbe.ecore
    • CBEDefaultElement_values unique=false
  4. SymptomPackageImpl
    • getSymptomCatalog_SymptomDefinition() unique=false
    • getSymptomCatalog_SymptomRule() unique=false
    • getSymptomCatalog_SymptomEffect() unique=false
    Keep in mind that when you regenerate the symptom model these changes will be overwritten, make sure you merge them with the newly generated code! The best would be to update the symptom.ecore file with these changes before regenerating the model!

4.0 Maintaining the model code

5.0 Additional documentation