Manual Java Generation Process

These steps will walk you through the process to manual generate the java source code.

The Java project must not have the CDABuilder active. Check the builders by Right Clickin on Java Project and select properties > Builders. If the CDA Project Builder is listed with a check mark hit Cancel then Right Click on Java Project and select Add/Remove CDA Builder if the builder is active.

MDHT provides an automated build but you can always manually build parts of the project

  1. Run Model Transformation
    • First Time Running
    1. Right Click on the transform.xml file in the Java project
    2. Select Run as Ant Task...
    3. Select the JRE Tab
    4. Set Runtime JRE option to Run in the same JRE as the workspace
    • All Other Times
    1. Right Click on the transform.xml file in the Java project
    2. Select Run as Ant Task
    The transform takes the structural constraints defined in the source UML model and generates a series of OCL constraints in the target model. The new UML model will be in the model folder in the java project.
  2. Generate Model Classes (Java APIs) from the EMF model
    1. Right-click on the mytestmodel.genmodel file in the model folder and select "Reload" from the context menu.
    2. Select "UML model" and then select "Next".
    3. Select "next" again. (This tells it to pull the information from the mytestmodel_Ecore.uml file that was just created from the transform.
    4. Select "Finish"
    When this is finished, it will open the mytestmodel.genModel in the eclipse editor. It will have regenerated mytestmodel.ecore and mytestmodel.genmodel files.
  3. In the eclipse editor, right-click on the mytestmodel node (in the editor window and not the project window) and select "Generate Model Code" from the context menu.
  4. Note: If you encouter errors in the compiled Java source code, here are some steps to fix the issue
    How to Fix Source Code
    1. Expand the "src" folder in the project.
    2. Delete the org.openhealthtools.mdht.uml.cda.consol.mytestmodel package and sub-packages
    3. Re-Generate the model code
The Java source code has been generated and compiled without any errors. You are ready to use the Java source to create, consume, and validate CDA documents.