Example

  1. Creating Express Project
  2. Creating Express File
  3. Writing Express-schema
  4. Compiling and generating JAR
  5. Setting up Java Project
  6. Running
  7. Validate p21

Creating Express Project

Follow the routine to create an Express Project:

Figure 1. Create new Express Project wizard dialog window


Figure 2. Created Express project ('Family')
To top

Creating Express File

Follow the routine to create an express file:

Figure 3. New Express file wizard dialog window


Figure 4. Created Express file
To top

Writing Express-schema

After a new Express file (.exg) is created and opened, enter the following Express-schema into the Express Editor panel:

SCHEMA Family;

ENTITY Person
    ABSTRACT SUPERTYPE OF (ONEOF (Male, Female));
      name: STRING;
      mother: OPTIONAL Female;
      father: OPTIONAL Male;
     WHERE
          WR1: exists(mother) OR exists(father);
END_ENTITY;
 
ENTITY Female
    SUBTYPE OF (Person);
END_ENTITY;
 
ENTITY Male
    SUBTYPE OF (Person);
END_ENTITY;

END_SCHEMA;

Save file after you finish.

To top

Compiling and generating JAR

Now you have to compile the Family.exp file:

Figure 1. Highlighted errors in Express editor panel and descriptions in Console panel.


Figure 6. Generated files
To top

Setting up Java Project

Create a java project FamilyJava: File -> New -> JSDAI Java Project.   The New Java Project wizard dialog window appears (see Figure 7):

Figure 7. New Java Project wizard dialog window

Figure 8. New Java Project wizard dialog window, Libraries panel


Figure 9. JAR Selection dialog window
  • Click Finish button to create the JSDAI Java project.
             import jsdai.lang.*;
      import jsdai.SFamily.*;

      public class FamilyJava {
                 public static void main(String[] args) throws SdaiException {
                 // TODO Auto-generated method stub
                   SdaiSession session = SdaiSession.openSession();
                   SdaiTransaction trans = session.startTransactionReadWriteAccess();
                   SdaiRepository repo = session.createRepository("", null);
                   repo.openRepository();
     
                   SdaiModel mod_world = repo.createSdaiModel("mod_world", SFamily.class);
     
                   mod_world.startReadWriteAccess();
     
                   EPerson p1 = (EPerson)mod_world.createEntityInstance(CMale.definition);
                   p1.setName(null, "Jack");
                   String s = p1.getName(null);
                   System.out.println("Hi  " + s);
                   repo.exportClearTextEncoding("family1.p21");
                   trans.endTransactionAccessAbort();
                   System.out.println("Good bye");
                   session.closeSession();
                   }
      }


Figure 10. Editor panel with java file


Running Java

Now you may run the java application: Run -> Run As -> Java Application.
It should print in the Console panel (see Figure 11):
Hi Jack
Good bye

Figure 11. Console panel view



Figure 12. Navigator panel, FamilyJava project files.

  • Double click on the family1.p21 node to open file in the Editor panel (see Figure 13).


Figure 13. Editor panel, family1.p21 file


To top

Validate p21

Run validation of the created family1.p21 file:

Figure 14. Select the part21 file to validate dialog window

Figure 15. Problems panel with provided validation errors


Figure 16. Console panel with validation results

To top


Copyright © 2005-2008 LKSoftWare GmbH. All Rights Reserved.
JSDAI is a registered trade mark of LKSoftWare GmbH.