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 for building tools and other applications that are based on a structured data model. For more information, see Eclipse Modeling Framework.

In this tutorial, you use the Eclipse Modeling framework to generate the Java classes for your service module from the provided Project and ProjectCollection nouns. 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 HCL 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, which you downloaded from the tutorial introduction.
      To open the Project.xsd files, right-click each file and select to open the file with an XML editor.
Use the Project.genmodel to help you automatically generate code that you need for completing the projects in this tutorial.
  1. Expand Project-DataObjects > ecore.
  2. Right-click Project.genmodel. Select Reload.
  3. Select XML Schema, click Next > Next.
  4. 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
  5. Click Finish.
    The Project.genmodel editor opens.
  6. Set the genmodel to generate objects that are compatible with EMF 2.2
  7. Open Project.genmodel.
  8. Right-click the Project element under the Project root and select Generate Model Code. This option generates the Project-DataObjects code.
  9. Right-click the Project-DataObjects project. Select Build Path > Configure Build Path.
  10. Click the Libraries tab. Then, click Add JARs.
  11. In the list of JAR files, expand WC. Select Foundation-DataObjects.jar and click OK > OK.
  12. 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.
Import the logic for the Project noun delete action from the sample code that is provided for this tutorial.
  1. Expand Project-Server > ejbModule.
  2. Right-click com.mycompany.commerce.project.facade.server.commands. Click Import.
  3. Expand General. Select File System then click Next.
  4. Click Browse to the right of the From directory field, and browse to the temporary location where you extracted the RecipeServices.zip file that you downloaded from the tutorial introduction.
  5. 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.
  6. 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.