Using your the Purchase Order model and instance data from Exercise 2, you will now validate the data - and correct any errors found - using EMF's Validation Framework. Optionally, you will add a named constraint to the XML Schema from which the model code was generated, and implement the validation code required to activate the constraint in your PurchaseOrder model editor.
At the end of the lab, you should be able to:
This exercise is carried out entirely using the Eclipse Software Development Kit (SDK) version 3.2 with the Eclipse Modeling Framework (EMF) 2.2 installed into it. The exercise instructions refer to this product as either Eclipse or as "the workbench."
In your workspace, there should be a EMF_Workshop/Exercise4_Validation folder containing Exercise4.java. This is the class you will modify to perform the work noted above. There is also a new version of PurchaseOrder.xsd, which will be used for the optional part of this exercise.
You should see output similar to the following, though the path to po.xml may differ in your output. Line breaks and emphasis have been added.
ERROR Diagnosis of com.example.po.impl.PurchaseOrderImpl@78777877 {file:/c:/EMF_Workshop_Root/workspace/Exercises/data/po.xml#//@order} -> ERROR The feature 'partNum' of 'com.example.po.impl.ItemImpl@737a737a {file:/c:/EMF_Workshop_Root/workspace/Exercises/data/po.xml#//@order/@items.0}' contains a bad value -> ERROR The value 'SWH123456' must be match one of {'\d{3}-[A-Z]{2}'} -> ERROR The feature 'partNum' of 'com.example.po.impl.ItemImpl@78e278e2 {file:/c:/EMF_Workshop_Root/workspace/Exercises/data/po.xml#//@order/@items.1}' contains a bad value -> ERROR The value 'STV999876' must be match one of {'\d{3}-[A-Z]{2}'}
OK
You validated model instance data to verify if its contents matched its schema. Discovering a problem with the data, you repaired the problem, revalidated the model data, and saved your changes. If you would like to explore implementing a named constraint, please continue with the optional part of this exercise.