Generating the SDOs for the Project noun

In this lesson, you generate the Service Data Objects (SDOs) that implement the logical data model of your Project and ProjectCollection nouns. SDOs are Java objects that represent the nouns in your logical model. Use the Eclipse Modeling Framework (EMF) to generate these SDOs from your noun definitions.

About this task

EMF is a modeling framework and code generation facility for building tools and other applications that are based on a structured data model. From a model specification that is described in XMI, EMF provides tools and runtime support. The framework is used to produce a set of Java classes for the model, a set of adapter classes for viewing and command-based editing of the model, and a basic editor. Models can be specified by annotated Java, XML documents, or modeling tools, then imported into EMF. Most important of all, EMF provides the foundation for interoperability with other EMF-based tools and applications. For more information, see http://www.eclipse.org/modeling/emf/.

Remember: A noun is defined as an XML schema. A noun can include primitive XML schema types, new complex types, or reuse WebSphere Commerce and Oagis 9 predefined type constructs. The Project and ProjectCollection nouns represent the logical data model of the new service module that you are building in this tutorial.

Before you generate data objects, set up the predefined WebSphere Commerce type constructs, and update the JET generated Project.xsd and ProjectCollection.xsd template with your own noun definition. For more information, see Java Emitter Template (JET) Component Projects pattern.

Procedure

  1. Update the generated Project noun:
    1. In the Enterprise Explorer view, expand Project-DataObjects/xsd/OAGIS/9.0/Overlays/MyCompany/Commerce/Resources/Nouns
    2. Open the Project.xsd file for editing.
    3. Replace the content of the file with the contents of the Project.xsd file in the RecipeServices.zip file. The RecipeServices.zip file was downloaded as part of the system requirements for this tutorial.
    4. Go to Project-DataObjects/xsd/OAGIS/9.0/Overlays/MyCompany/Commerce/Resources/Nouns
    5. Open the ProjectCollection.xsd file for editing.
    6. Replace the content of the file with the contents of the ProjectCollection.xsd file in the RecipeServices.zip file.
  2. Expand Project-DataObjects\ecore.
  3. Right-click Project.genmodel; select Reload.
  4. Select XML Schema, click Next > Next.
  5. In Root packages, select com.mycompany.commerce.project.facade.datatypes. Under file name, ensure that com.mycompany.commerce.project.facade.datatypes.ecore displays. In Referenced generator models, ensure that the following options are selected:
    Foundation model: Oagis9 model:
    • com.ibm.commerce.foundation.common.datatypes
    • com.ibm.commerce.oagis9.datatypes.codelists
    • com.ibm.commerce.oagis9.datatypes.unqualifieddatatypes
    • com.ibm.commerce.oagis9.datatypes

    Package data type selection

  6. Click Finish.
  7. Open Project.genmodel. Set the genmodel to generate objects that are compatible with EMF 2.2.
  8. Right-click the Project element under the Project root and select Generate Model Code. This option generates the Project-DataObjects code.

    Selecting Generate Model Code

  9. Verify that the Project-DataObjects project has no compilation errors. If there are errors, check that you did not miss any steps or prerequisites.
    Note: If you continue to experience compilation errors, clean the project:
    1. Click Project > Clean.
    2. Select the Clean projects selected below radio button; then select Project-DataObjects.
    3. Click Ok.
  10. Expand Project-Server/ejbModule.
  11. Right-click com.mycompany.commerce.project.facade.server.commands; click Import.
  12. Expand General; select File System then click Next.
  13. Click Browse to the right of the From directory field, and browse to the temporary location where you extracted the RecipeServices.zip file.
  14. Click Browse to the right of the Into folder field, and browse to the com.mycompany.commerce.project.facade.server.commands folder; select the folder then click Ok.
  15. Select the com.mycompany.commerce.project.facade.server.commands file. The contents of the file display in the right pane. Select the ProcessProjectCollectionDeleteActionCmdImpl.java and ProcessProjectDeleteActionCmdImpl.java files in the right pane; click Finish.
  16. Click Yes to All to overwrite any existing file.

Results

In this step, you used the Eclipse Modeling Framework (EMF) to generate Service Data Objects (SDO) from the Project noun. This noun is defined in the Project and ProjectCollection XSD files.