You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by kelvin goodson <ke...@gmail.com> on 2007/06/26 11:31:07 UTC

[SDO Java] Request for review of updates to samples

Following recent discussions on the mailing list I have been updating the
SDO Java sample code and I'd like to solicit some input.

My aims have been

-- to make it an informative exercise to run binary samples without
necessarily directly referencing the source code

-- categorize the samples into novice, intermediate and advanced

-- allow customization of output to match the skill level of the user to
novice, intermediate or advanced

-- to make the sample code clearer for inspection while executing the code

-- to make the main aspect of the sample stand out from the standard
prerequisite initialisation code

-- to bring the samples up to date with current best practice, given the
revisions between the 2.01. and .1 specifications and updates to our own
Tuscany APIs

-- to make the samples more aligned with common usage

I would welcome your comments on these updates.  To that end,  rather than
get you to build and run them I will point out the relevant new code and
paste output from running selected samples.

I have created 2 base classes for the samples,  one that provides
uninteresting infrastructure [1],  and a derived one that provides SDO
utility methods common to samples that are of interest to the SDO user [2].
For example, take a look at the createScopeForTypes() and
loadTypesFromXMLSchemaFile() methods in [2].

I have increased the level of commentary output from each sample.  This
commentary includes a verbose description of the steps being taken. It also
includes and echo of the relevant lines of SDO code,  thus making the
execution of samples which are pre-compiled binaries a useful exercise in
the absence of the original source code.

Each sample is assigned an experience level, NOVICE, INTERMEDIATE or
ADVANCED.

Each element of commentary is assigned a user level,  for example the
commentary output from all the utility methods in SampleBase is NOVICE
commentary.  If you run the sample with COMMENTARY_FOR_INTERMEDIATE, you
won't see any of the commentary for novices,  (extrapolate for ADVANCED).
(The default experience level for each comment is that of the sample
itself.)

Some elements of commentary for which the code may be executed more than
once in a sample run are given alternative briefer forms of commentary so
that the verbose form only appears once per sample run,  and the terse form
will be output each subsequent time that the code block is executed.  The
terse form usually ends with some thing like "... as we saw before"

The samples are designed to be run either on their own or from a program
which executes a sequence of samples [3] (still under development) . In this
way the above feature allowing terse forms of commentary reduces the overall
length of output significantly.  The top level program [3] may currently be
edited to run samples up to a given user experience level. This may be
better as a command line argument.

The set of sample program classes which I have moved to the new format may
be seen in the "sampleClasses" instance member of [3].  For example see the
runSample() method of [4].   Attached below is the execution of this sample
with commentary level for a novice user and then repeated for an
intermediate user.

Your comments are very welcome.

Kelvin.

[1]
https://svn.apache.org/repos/asf/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java
[2]
https://svn.apache.org/repos/asf/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java
[3]
https://svn.apache.org/repos/asf/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java
[4]
https://svn.apache.org/repos/asf/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specCodeSnippets/DynamicCustomerTypeSample.java

--------------------------------------------------------------
- Running with commentary level for a novice user            -
- Edit the sample program's constructor argument to one from -
- COMMENTARY_FOR_NOVICE                                      -
- COMMENTARY_FOR_INTERMEDIATE or                             -
- COMMENTARY_FOR_ADVANCED                                    -
- in order to alter the level of commentary you are seeing   -
--------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------
-     Tuscany SDO Java Sample
org.apache.tuscany.samples.sdo.specCodeSnippets.DynamicCustomerTypeSample
-
-     This sample is aimed at a intermediate
user                                                           -
-------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------
- Demonstrates the use of the SDO API to build types dynamically -
- by building a data graph representing the type system and      -
- submitting that graph to TypeHelper.define()                   -
------------------------------------------------------------------

-----------------------------------------------------------------------------------------------
- All MetaData for SDO types can be viewed as being held in an instance of
HelperContext      -
- The Helper Context instance provides access to a collection of other
helpers                -
- that you will see exercised in the SDO
samples                                              -
- All the Helpers related to a given helper context instance know about the
same set of types -
-
-
- The SDO specification doesn't state how an SDO implementation should
create a HelperContext -
- So we use a Tuscany specific API to do this
...                                             -
-
-
- HelperContext scope = SDOUtil.createHelperContext();
-
-----------------------------------------------------------------------------------------------

----------------------------------------------------------------------------
- A TypeHelper is used for both looking up types,  and later creating them -
-                                                                          -
- TypeHelper typeHelper = scope.getTypeHelper();                           -
----------------------------------------------------------------------------

----------------------------------------------------------------------
- We can look up existing types to use in the creation of Properties -
-                                                                    -
- Type intType = types.getType("commonj.sdo", "Int");                -
- Type stringType = types.getType("commonj.sdo", "String");          -
----------------------------------------------------------------------

-----------------------------------------------------------------------------------
- To begin modelling the type system we create a DataObject
with                  -
- Type "commonj.sdo#Type" and set the URI and name for that
type                  -
-
-
- DataObject customerType = scope.getDataFactory().create("commonj.sdo",
"Type"); -
- customerType.set("uri", "http://example.com/customer");
-
- customerType.set("name",
"Customer");                                           -
-----------------------------------------------------------------------------------

---------------------------------------------------------------------------
- Now we can create a model for the Properties for the Type               -
- and set the name and Types of those Properties                          -
-                                                                         -
- DataObject custNumProperty = customerType.createDataObject("property"); -
- custNumProperty.set("name", "custNum");                                 -
- custNumProperty.set("type", intType);                                   -
---------------------------------------------------------------------------

------------------------------------------------------------------------------------
- We continue in this manner until all the Types and their Properties are
modelled -
------------------------------------------------------------------------------------

------------------------------------------------------------------------------------
- Now that our type is fully modelled we submit the model to the
TypeHelper        -
- The new Type instance is retuend to us,  but is also available for lookup
within -
- the scope associated with the
TypeHelper                                         -
-
-
- Type t = typeHelper.define(customerType);
-
------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
- Here we see the newly created Type being accessed via the
TypeHelper                      -
- along with a printout of the Type's
Properties                                            -
-
-
- Type testType = scope.getTypeHelper().getType("http://example.com/customer",
"Customer"); -
---------------------------------------------------------------------------------------------

org.apache.tuscany.sdo.impl.AttributeImpl@1833955 (name: custNum) (ordered:
true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true,
volatile: false, transient: false, defaultValueLiteral: null, unsettable:
false, derived: false) (iD: false)
org.apache.tuscany.sdo.impl.AttributeImpl@291aff (name: lastName) (ordered:
true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true,
volatile: false, transient: false, defaultValueLiteral: null, unsettable:
false, derived: false) (iD: false)
org.apache.tuscany.sdo.impl.AttributeImpl@ab95e6 (name: firstName) (ordered:
true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true,
volatile: false, transient: false, defaultValueLiteral: null, unsettable:
false, derived: false) (iD: false)
--------------------------------------------------------------------------------------------------
- Now we can create an instance of the type using the DataFactory associated
with the type scope -
-
-
- DataFactory factory = scope.getDataFactory();
-
- DataObject customer1 = factory.create("http://example.com/customer",
"Customer");              -
--------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------
- Here's an XML String representing a DataObject we have created with the
new type -
------------------------------------------------------------------------------------

<?xml version="1.0" encoding="ASCII"?>
<customer:customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:customer="http://www.example.com/customer"
    xmlns:customer_1="http://example.com/customer"
xsi:type="customer_1:Customer"
    custNum="1" lastName="Adams" firstName="John"/>
---------------------------------------------------------------------------------------------------
-     End of sample
org.apache.tuscany.samples.sdo.specCodeSnippets.DynamicCustomerTypeSample
-
---------------------------------------------------------------------------------------------------










--------------------------------------------------------------
- Running with commentary level for a intermediate user      -
- Edit the sample program's constructor argument to one from -
- COMMENTARY_FOR_NOVICE                                      -
- COMMENTARY_FOR_INTERMEDIATE or                             -
- COMMENTARY_FOR_ADVANCED                                    -
- in order to alter the level of commentary you are seeing   -
--------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------
-     Tuscany SDO Java Sample
org.apache.tuscany.samples.sdo.specCodeSnippets.DynamicCustomerTypeSample
-
-     This sample is aimed at a intermediate
user                                                           -
-------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------
- Demonstrates the use of the SDO API to build types dynamically -
- by building a data graph representing the type system and      -
- submitting that graph to TypeHelper.define()                   -
------------------------------------------------------------------

----------------------------------------------------------------------------
- A TypeHelper is used for both looking up types,  and later creating them -
-                                                                          -
- TypeHelper typeHelper = scope.getTypeHelper();                           -
----------------------------------------------------------------------------

----------------------------------------------------------------------
- We can look up existing types to use in the creation of Properties -
-                                                                    -
- Type intType = types.getType("commonj.sdo", "Int");                -
- Type stringType = types.getType("commonj.sdo", "String");          -
----------------------------------------------------------------------

-----------------------------------------------------------------------------------
- To begin modelling the type system we create a DataObject
with                  -
- Type "commonj.sdo#Type" and set the URI and name for that
type                  -
-
-
- DataObject customerType = scope.getDataFactory().create("commonj.sdo",
"Type"); -
- customerType.set("uri", "http://example.com/customer");
-
- customerType.set("name",
"Customer");                                           -
-----------------------------------------------------------------------------------

---------------------------------------------------------------------------
- Now we can create a model for the Properties for the Type               -
- and set the name and Types of those Properties                          -
-                                                                         -
- DataObject custNumProperty = customerType.createDataObject("property"); -
- custNumProperty.set("name", "custNum");                                 -
- custNumProperty.set("type", intType);                                   -
---------------------------------------------------------------------------

------------------------------------------------------------------------------------
- We continue in this manner until all the Types and their Properties are
modelled -
------------------------------------------------------------------------------------

------------------------------------------------------------------------------------
- Now that our type is fully modelled we submit the model to the
TypeHelper        -
- The new Type instance is retuend to us,  but is also available for lookup
within -
- the scope associated with the
TypeHelper                                         -
-
-
- Type t = typeHelper.define(customerType);
-
------------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
- Here we see the newly created Type being accessed via the
TypeHelper                      -
- along with a printout of the Type's
Properties                                            -
-
-
- Type testType = scope.getTypeHelper().getType("http://example.com/customer",
"Customer"); -
---------------------------------------------------------------------------------------------

org.apache.tuscany.sdo.impl.AttributeImpl@1833955 (name: custNum) (ordered:
true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true,
volatile: false, transient: false, defaultValueLiteral: null, unsettable:
false, derived: false) (iD: false)
org.apache.tuscany.sdo.impl.AttributeImpl@291aff (name: lastName) (ordered:
true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true,
volatile: false, transient: false, defaultValueLiteral: null, unsettable:
false, derived: false) (iD: false)
org.apache.tuscany.sdo.impl.AttributeImpl@ab95e6 (name: firstName) (ordered:
true, unique: true, lowerBound: 0, upperBound: 1) (changeable: true,
volatile: false, transient: false, defaultValueLiteral: null, unsettable:
false, derived: false) (iD: false)
--------------------------------------------------------------------------------------------------
- Now we can create an instance of the type using the DataFactory associated
with the type scope -
-
-
- DataFactory factory = scope.getDataFactory();
-
- DataObject customer1 = factory.create("http://example.com/customer",
"Customer");              -
--------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------
- Here's an XML String representing a DataObject we have created with the
new type -
------------------------------------------------------------------------------------

<?xml version="1.0" encoding="ASCII"?>
<customer:customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:customer="http://www.example.com/customer"
    xmlns:customer_1="http://example.com/customer"
xsi:type="customer_1:Customer"
    custNum="1" lastName="Adams" firstName="John"/>
---------------------------------------------------------------------------------------------------
-     End of sample
org.apache.tuscany.samples.sdo.specCodeSnippets.DynamicCustomerTypeSample
-
---------------------------------------------------------------------------------------------------

Re: [SDO Java] Request for review of updates to samples

Posted by kelvin goodson <ke...@gmail.com>.
I'm still looking for input to understand if I'm doing the right kind of
thing for our users with these samples.  It's work in progress,  but the
time I have available for taking on board your suggestions is decreasing.  I
have just substituted the PrintPropertiesOfDataObject  sample with something
a bit more generic, in the new PrintDataGraph sample [1].  Again I attach
the output of this sample to save you the trouble of building from the svn
trunk.

Regards, Kelvin.

[1]
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/PrintDataGraph.java?view=markup


--------------------------------------------------------------
- Running with commentary level for a novice user            -
- Edit the sample program's constructor argument to one from -
- COMMENTARY_FOR_NOVICE                                      -
- COMMENTARY_FOR_INTERMEDIATE or                             -
- COMMENTARY_FOR_ADVANCED                                    -
- in order to alter the level of commentary you are seeing   -
--------------------------------------------------------------

---------------------------------------------------------------------------------
-     Tuscany SDO Java Sample org.apache.tuscany.samples.sdo.PrintDataGraph
-
-     This sample is aimed at a intermediate
user                               -
---------------------------------------------------------------------------------

-----------------------------------------------------------------------------------
- This sample demonstrates a common pattern of traversing a data
graph            -
- and printing the values of its Properties.  As the sample traverses a
couple of -
- graphs it provides commentary about what it has found and what actions
it       -
- is taking, whilst building up a text representation of the graph. It
then       -
- shows you the results of its
labours.                                           -
-----------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------
- All MetaData for SDO types can be viewed as being held in an instance of
HelperContext      -
- The Helper Context instance provides access to a collection of other
helpers                -
- that you will see exercised in the SDO
samples                                              -
- All the Helpers related to a given helper context instance know about the
same set of types -
-
-
- The SDO specification doesn't state how an SDO implementation should
create a HelperContext -
- So we use a Tuscany specific API to do this
...                                             -
-
-
- HelperContext scope = SDOUtil.createHelperContext();
-
-----------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------
- First we look at a data graph of a Purchase Order which has a fairly
simple XML schema -
- and the graph's containment hierarchy has a couple of levels of
depth                  -
------------------------------------------------------------------------------------------

------------------------------------------------------------------------------
- If you want to create types dynamically by loading an XML schema you
-
- use an instance of XSDHelper. You get that helper from a HelperContext.
-
- After successful loading of a schema, the new types are available to every
-
- other helper belonging to the HelperContext instance
-
-
-
- XSDHelper xsdHelper = scope.getXSDHelper();
-
- xsdHelper.define(inputStream, null);
-
------------------------------------------------------------------------------

-------------------------------------------------------------------------------
- The XMLHelper can be used to create an SDO XMLDocument instance from a
file -
-
-
- inputStream = ClassLoader.getSystemResourceAsStream(filename);
-
- result = scope.getXMLHelper().load(is);
-
-------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------
- We are going to traverse a data graph that has been wrapped in an instance
of XMLDocument -
- Amongst other things, the XMLDocument instance provides access to the root
element name   -
- and the root DataObject of the data
graph.                                                -
-
-
- xmlDocument.getRootElementName();
-
- xmlDocument.getRootObject();
-
---------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------
- We begin traversing the data graph by examining the root object of the
graph's containment hierarchy       -
- making a record of the values of its Properties. As we inspect the values
of the Properties of this object -
- if we encounter contained DataObjects, then we will recurse through the
containment hierarchy of the       -
- data graph in a depth first fashion, and create a text representaation of
the graph that we'll print       -
- out after the graph traversal has been
completed.                                                          -
--------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------
- We access the Property values of this DataObject by first getting the list
of 'Instance Properties'        -
- from the DataObject.  For many DataObjects, this will be the same set of
Properties that are defined       -
- by the DataObject's Type.  However, if the DataObject's type is 'Open'
then an instance of that Type       -
- may contain more Properties that the type itself.  The list of Instance
Properties will always include     -
- the Properties defined in the Type,  but will also include any Properties
that the instance has values for -
- by virtue of it's type being
'Open'
-
-
-
- for (int i = 0; i < dataObject.getInstanceProperties().size(); i++)
{                                      -
-   Property p = (Property) dataObject.getInstanceProperties().get(i);
-
--------------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------
- We are about to inspect the value of a Property,  but we
must                            -
- consider the nature of that Property in order to deal with it
appropriately.             -
- Firstly we see if the Property value has been set
(dataObject.isSet(property))
-
- Then we see if the Property is simple valued (property.isDataType() ==
true)             -
- --if not then we know it's a DataObject and we must recurse deepen into
the graph's      -
- containment
hierarchy
-
- Whether or not the property value is a DataObject,  is may be single or
multi-valued     -
- so we must either use one of the DataObject's get*(Property) accessors for
single        -
- valued Properties or the getList() method for multi-valued
properties.                   -
- Another thing we must deal with when the Property is a DataObject, is
whether or not the -
- Property is a 'containment' Property.  If it isn't then we simple record
the fact that   -
- we have encountered this non-containment relationship,  and move on to the
next Property -
--------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------
- We have arrived at a contained dataObject in the graph, and will inspect
its Property values, -
-  recursing deeper if
necessary                                                                -
-------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------
- Traversing the instance Properties of this DataObject                 -
- for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) { -
-   Property p = (Property) dataObject.getInstanceProperties().get(i);  -
-------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

-------------------------------------------
- Inspecting another contained dataObject -
-------------------------------------------

-------------------------------------------------------------------------
- Traversing the instance Properties of this DataObject                 -
- for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) { -
-   Property p = (Property) dataObject.getInstanceProperties().get(i);  -
-------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

-------------------------------------------
- Inspecting another contained dataObject -
-------------------------------------------

-------------------------------------------------------------------------
- Traversing the instance Properties of this DataObject                 -
- for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) { -
-   Property p = (Property) dataObject.getInstanceProperties().get(i);  -
-------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------
- Traversing a list of DataObjects which represent the values of a
multi-valued containment Property -
------------------------------------------------------------------------------------------------------

-------------------------------------------
- Inspecting another contained dataObject -
-------------------------------------------

-------------------------------------------------------------------------
- Traversing the instance Properties of this DataObject                 -
- for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) { -
-   Property p = (Property) dataObject.getInstanceProperties().get(i);  -
-------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

-------------------------------------------
- Inspecting another contained dataObject -
-------------------------------------------

-------------------------------------------------------------------------
- Traversing the instance Properties of this DataObject                 -
- for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) { -
-   Property p = (Property) dataObject.getInstanceProperties().get(i);  -
-------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

-------------------------------------------
- Inspecting another contained dataObject -
-------------------------------------------

-------------------------------------------------------------------------
- Traversing the instance Properties of this DataObject                 -
- for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) { -
-   Property p = (Property) dataObject.getInstanceProperties().get(i);  -
-------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------
- Inspecting another property to determine how to access it's value,  as we
saw before -
----------------------------------------------------------------------------------------

----------------------------------------------------
- And here is the resultant view of the data graph -
----------------------------------------------------

XMLDocument: purchaseOrder

  DataObject: Type: http://www.example.com/PO#PurchaseOrderType
    Property shipTo:  -
      DataObject: Type: http://www.example.com/PO#USAddress
        Property name:  - Robbie Minshall
        Property street:  - 123 Maple Street
        Property city:  - Mill Valley
        Property state:  - CA
        Property zip:  - 90952
        Property country:  - US

    Property billTo:  -
      DataObject: Type: http://www.example.com/PO#USAddress
        Property name:  - Robert Smith
        Property street:  - 8 Oak Avenue
        Property city:  - Mill Valley
        Property state:  - PA
        Property zip:  - 95819
        Property country:  - US

    Property comment:  - Hurry, my lawn is going wild!
    Property items:  -
      DataObject: Type: http://www.example.com/PO#Items
        Property item:  -
          [

            DataObject: Type: http://www.example.com/PO#item
              Property productName:  - Lawnmower
              Property price:  - 148.95
              Property quantity:  - 1
              Property comment:  - Confirm this is electric
              Property shipDate:  -  is not set
              Property partNum:  - 872-AA

            DataObject: Type: http://www.example.com/PO#item
              Property productName:  - Baby Monitor
              Property price:  - 39.98
              Property quantity:  - 1
              Property comment:  -  is not set
              Property shipDate:  - 1999-05-21
              Property partNum:  - 926-AA

            DataObject: Type: http://www.example.com/PO#item
              Property productName:  - GrassSeed
              Property price:  - 50
              Property quantity:  - 100
              Property comment:  - For Shade
              Property shipDate:  -  is not set
              Property partNum:  - 876
          ]

    Property orderDate:  - 1999-10-20

------------------------------------------------------------------------------
- Next we look at a graph represneting a form letter,  where the Type of the
-
- root data object is 'Sequenced'
-
------------------------------------------------------------------------------

---------------------------------------------------------------------------------------------------
- Using an XSDHelper again to create types from an XML schema file as we saw
in a previous sample -
---------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------
- Getting an XMLDocument instance from an XML file as seen in previous
samples -
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------------
- An XMLDocument instance provides a wrapper for the root DataObject of a
data graph -
- along with other aspects of the XML nature of the
document                         -
-
-
- DataObject result = xmlDoc.getRootObject();
-
--------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------------------------
- We are beginning to start to traverse another data graph from its root
object, as we have seen previously -
-------------------------------------------------------------------------------------------------------------

-------------------------------------------------------------------------------------------
- We've encountered a DataObject in the graph for which the Type is
'Sequenced'           -
- That is to say that the order of addition of property values to the
DataObject instance -
- is important,  and is preserved by the
DataObject                                       -
-
-
- dataObject.getType().isSequenced();
-
-------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------------
- The Property/Value pairs of a Sequence can be accessed via the
getProperty(int) and getValue(int)          -
- accessor methods of the Sequence interface.  The size() method of the
Sequence tells us how many there are -
- If the getProperty(int) method retunes null,  then the value is text.
These values may be encountered     -
- when the DataObject's type is 'mixed' (dataObject.getType().isMixed() ==
true). A typical example of this  -
- is when the data graph represents a form
letter.                                                           -
--------------------------------------------------------------------------------------------------------------

----------------------------------------------------
- And here is the resultant view of the data graph -
----------------------------------------------------


DataObject: Type: letter.xsd#FormLetter
  Sequence: {
    Property: date: August 1, 2003
    text: Mutual of Omaha Wild Kingdom, USA Dear
    Property: firstName: Casy
    Property: lastName: Crocodile
    text: Please buy more shark repellent.  Your premium is past due.
  }
-----------------------------------------------------------------------
-     End of sample org.apache.tuscany.samples.sdo.PrintDataGraph     -
-----------------------------------------------------------------------