tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelvingood...@apache.org
Subject svn commit: r553203 - in /incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo: ./ advanced/ basic/ intermediate/ otherSources/ specExampleSection/ tuscanyapi/
Date Wed, 04 Jul 2007 13:34:42 GMT
Author: kelvingoodson
Date: Wed Jul  4 06:34:40 2007
New Revision: 553203

URL: http://svn.apache.org/viewvc?view=rev&rev=553203
Log:
fixed up the java serialization sample.  Consolidated infrastructure. Removed 2 redundant samples. More rearrangement.

Added:
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateCompanyTuscanyAPI.java
      - copied, changed from r553191, incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompanyTuscanyAPI.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java
      - copied, changed from r553191, incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDeserializingADataObject.java
Removed:
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SdoSampleConstants.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessDataObjectsUsingXPath.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDeserializingADataObject.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompanyTuscanyAPI.java
Modified:
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/ObtainingDataGraphFromXml.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreateCompany.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreatePurchaseOrder.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessDataObjectUsingValidXPath.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderCmdLine.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java
    incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples.java Wed Jul  4 06:34:40 2007
@@ -29,9 +29,12 @@
 import org.apache.tuscany.samples.sdo.basic.ReadPurchaseOrder;
 import org.apache.tuscany.samples.sdo.intermediate.CreateDataObjectFromXmlString;
 import org.apache.tuscany.samples.sdo.intermediate.DynamicCustomerTypeSample;
-import org.apache.tuscany.samples.sdo.otherSources.*;
-import org.apache.tuscany.samples.sdo.specCodeSnippets.*;
-import org.apache.tuscany.samples.sdo.specExampleSection.*;
+import org.apache.tuscany.samples.sdo.intermediate.SerializingDeserializingADataObject;
+import org.apache.tuscany.samples.sdo.otherSources.PurchaseOrderCmdLine;
+import org.apache.tuscany.samples.sdo.specExampleSection.AccessingDataObjectsViaPropertyIndex;
+import org.apache.tuscany.samples.sdo.specExampleSection.AccessingTheContentsOfASequence;
+import org.apache.tuscany.samples.sdo.specExampleSection.CreatingDataObjectTreesFromXMLDocuments;
+import org.apache.tuscany.samples.sdo.specExampleSection.UsingTypeAndPropertyWithDataObjects;
 
 /**
  * Executes all command line samples. <br>
@@ -128,9 +131,7 @@
 
             System.out.println(">>>Press Enter to continue");
             in.readLine();
-            AccessDataObjectsUsingXPath.main(args);
-            System.out.println(">>>Press Enter for next sample");
-            in.readLine();
+
 
             AccessingDataObjectsViaPropertyIndex.main(args);
             System.out.println(">>>Press Enter for next sample");
@@ -141,10 +142,6 @@
             in.readLine();
 
             CreatingDataObjectTreesFromXMLDocuments.main(args);
-            System.out.println(">>>Press Enter for next sample");
-            in.readLine();
-
-            CreatingXmlFromDataObjects.main(args);
             System.out.println(">>>Press Enter for next sample");
             in.readLine();
 

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples2.java Wed Jul  4 06:34:40 2007
@@ -53,7 +53,7 @@
       AccessDataObjectUsingValidXPath.class,
       DynamicCustomerTypeSample.class,
       ObtainingDataGraphFromXml.class,
-      org.apache.tuscany.samples.sdo.tuscanyapi.CreateCompanyTuscanyAPI.class,
+      org.apache.tuscany.samples.sdo.intermediate.CreateCompanyTuscanyAPI.class,
       CreateDataObjectFromXmlString.class,
       PrintDataGraph.class,
       MedicalScenario.class

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleInfrastructure.java Wed Jul  4 06:34:40 2007
@@ -26,73 +26,89 @@
 import java.util.Set;
 
 /**
- * One of a pair of base classes for samples.  This one contains all the
- * infrastructure code that a person wanting to learn SDO would not want to look at.
+ * One of a pair of base classes for samples. This one contains all the
+ * infrastructure code that a person wanting to learn SDO would not want to look
+ * at.
  */
 public abstract class SampleInfrastructure {
 
-
   protected int sampleComplexityLevel = SAMPLE_LEVEL_BASIC.intValue();
   protected int commentaryLevel = COMMENTARY_FOR_NOVICE.intValue();
-  
+
+
   /*
-   * keep a record of what's been said,  so that if alternative terse text is
-   * offered,  the verbose text need not be repeated for repeat actions.
+   * keep a record of what's been said, so that if alternative terse text is
+   * offered, the verbose text need not be repeated for repeat actions.
    */
   private static Set commentaryHistory = new HashSet();
-  
-  public SampleInfrastructure (Integer commentaryLevel) {
+
+  public SampleInfrastructure(Integer commentaryLevel) {
     this.commentaryLevel = commentaryLevel.intValue();
   }
-  
+
   public SampleInfrastructure(Integer commentaryLevel, Integer sampLevel) {
     this.commentaryLevel = commentaryLevel.intValue();
     this.sampleComplexityLevel = sampLevel.intValue();
   }
 
   private static String hrule = "********************************************";
-  
+
   /*
-   * Constants which allow the sample program infrastructure to understand
-   * the complexity of a sample program.
+   * Constants which allow the sample program infrastructure to understand the
+   * complexity of a sample program.
    */
   protected static final Integer SAMPLE_LEVEL_BASIC = new Integer(0);
   protected static final Integer SAMPLE_LEVEL_INTERMEDIATE = new Integer(1);
   protected static final Integer SAMPLE_LEVEL_ADVANCED = new Integer(2);
-  
-  
+
   /*
-   * Constants which can be used to reduce the amount of information output
-   * by an executing sample program.
+   * Constants which can be used to reduce the amount of information output by
+   * an executing sample program.
    */
   protected static final Integer COMMENTARY_FOR_NOVICE = new Integer(0);
   protected static final Integer COMMENTARY_FOR_INTERMEDIATE = new Integer(1);
   protected static final Integer COMMENTARY_FOR_ADVANCED = new Integer(2);
   protected static final Integer COMMENTARY_ALWAYS = new Integer(3);
+
+  protected static final String[] userLevels = { "novice", "intermediate",
+      "advanced" };
   
-  protected static final String[] userLevels = {"novice","intermediate","advanced"};
-  
+  /*
+   * Various constants that reference resources etc shared between the samples
+   */
+  public static final String COMPANY_DATAOBJECT_XML = "companyGenerated.xml";
+  public static final String COMPANY_DATAGRAPH_XML = "companyDataGraphGenerated.xml";
+  public static final String COMPANY_XSD = "company.xsd";
+  public static final String COMPANY_NAMESPACE = "company.xsd";
+  public static final String PO_NAMESPACE = "http://www.example.com/PO";
+  public static final String PO_XML_GENERATED = "temporaryPoGenerated.xml";
+  public static final String PO_XML_RESOURCE = "po.xml";
+  public static final String PO_XSD_RESOURCE = "po.xsd";
+
+
   public void banner(char borderChar, String text) {
-    if(text == null || text.length() == 0) {
+    if (text == null || text.length() == 0) {
       System.out.println(hrule);
       return;
     }
-    String [] lines = text.split("\n");
+    String[] lines = text.split("\n");
     int maxlinelen = 0;
-    
-    for(int i=0; i<lines.length; i++) {
-      maxlinelen = lines[i].length() > maxlinelen ? lines[i].length() : maxlinelen;
+
+    for (int i = 0; i < lines.length; i++) {
+      maxlinelen = lines[i].length() > maxlinelen ? lines[i].length()
+          : maxlinelen;
     }
-    
+
     StringBuffer buf = new StringBuffer();
     for (int p = 0; p < maxlinelen + 4; p++) {
       buf.append(borderChar);
     }
     buf.append("\n");
-    for(int l=0; l<lines.length; l++) {
+    for (int l = 0; l < lines.length; l++) {
       buf.append(borderChar).append(" ");
       buf.append(lines[l]);
-      for(int rem=lines[l].length()+2; rem < maxlinelen+3; rem++) buf.append(" ");
+      for (int rem = lines[l].length() + 2; rem < maxlinelen + 3; rem++)
+        buf.append(" ");
       buf.append(borderChar).append("\n");
     }
     for (int p = 0; p < maxlinelen + 4; p++) {
@@ -101,18 +117,19 @@
     buf.append("\n");
     System.out.println(buf.toString());
   }
-  
+
   public void banner(String text) {
     banner('-', text);
   }
-  
+
   protected void commentary(Integer commentLevel, String text, String repeatText) {
 
-    if(commentLevel.intValue() < commentaryLevel) return;
-    
-    if(repeatText != null)  {
+    if (commentLevel.intValue() < commentaryLevel)
+      return;
+
+    if (repeatText != null) {
       boolean alreadySeen = commentaryHistory.contains(text);
-      if(alreadySeen) {
+      if (alreadySeen) {
         commentary(commentLevel, repeatText);
       } else {
         commentary(commentLevel, text);
@@ -121,84 +138,88 @@
     } else {
       commentary(commentLevel, text);
     }
-    
+
   }
-  
+
   protected void commentary(Integer commentLevel, String text) {
-    if(commentLevel.intValue() >= commentaryLevel) {
+    if (commentLevel.intValue() >= commentaryLevel) {
       banner(text);
     }
   }
-  
+
   /*
-   * convenience method to allow commentary level to default to that of
-   * the sample's complexity
+   * convenience method to allow commentary level to default to that of the
+   * sample's complexity
    */
   protected void commentary(String text) {
     commentary(new Integer(getSampleComplexityLevel()), text);
   }
-  
+
   public void somethingUnexpectedHasHappened(Exception e) {
-    banner('!',
-        "Something unexpected has gone wrong with the execution of this sample program\n" +
-        "Please take a look at the exception and see if its something wrong with your environment\n" +
-        "If you can't figure it out please send a note to the tuscany-user@ws.apache.org mailing list\n" +
-        "including the text of the exception and any other useful information, thanks");
-    
+    banner(
+        '!',
+        "Something unexpected has gone wrong with the execution of this sample program\n"
+            + "Please take a look at the exception and see if its something wrong with your environment\n"
+            + "If you can't figure it out please send a note to the tuscany-user@ws.apache.org mailing list\n"
+            + "including the text of the exception and any other useful information, thanks");
+
     e.printStackTrace();
   }
-  
 
   /**
-   * Utility method to obtain information from the user about whether or not they would like to use a DataGraph or simply use a DataObject
+   * Utility method to obtain information from the user about whether or not
+   * they would like to use a DataGraph or simply use a DataObject
    * 
    * @return whether or not a DataGraph should be used
    * @throws Exception
    */
   protected boolean yesOrNoFromUser(String question) throws Exception {
 
-      System.out.print(question + " {y,n} :");
-      BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-      String answer = in.readLine();
-      while ((! answer.equalsIgnoreCase("n")) && (! answer.equalsIgnoreCase("y"))) {
-          
-          System.out.println();
-          System.out.print("Sorry, please enter 'y' or 'n':");
-          answer = in.readLine();
-      }
+    System.out.print(question + " {y,n} :");
+    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+    String answer = in.readLine();
+    while ((!answer.equalsIgnoreCase("n")) && (!answer.equalsIgnoreCase("y"))) {
+
       System.out.println();
+      System.out.print("Sorry, please enter 'y' or 'n':");
+      answer = in.readLine();
+    }
+    System.out.println();
 
-      if (answer.equalsIgnoreCase("y")) {
-          return true;
-      } else {
-          return false;
-      }
+    if (answer.equalsIgnoreCase("y")) {
+      return true;
+    } else {
+      return false;
+    }
   }
-  
+
   public void run() {
- 
-    
-    commentary(COMMENTARY_FOR_INTERMEDIATE, "Running with commentary level for a " + userLevels[commentaryLevel] + " user\n"+
-        "Edit the sample program's constructor argument to one from\n"+
-        "COMMENTARY_FOR_NOVICE\nCOMMENTARY_FOR_INTERMEDIATE or\nCOMMENTARY_FOR_ADVANCED\n"+
-        "in order to alter the level of commentary you are seeing",
-        "");
-    
-    commentary(COMMENTARY_ALWAYS,"    Tuscany SDO Java Sample " + this.getClass().getName() + "    \n"+
-        "    This sample is aimed at a " + userLevels[sampleComplexityLevel] + " user");
 
-    
+    commentary(
+        COMMENTARY_FOR_INTERMEDIATE,
+        "Running with commentary level for a "
+            + userLevels[commentaryLevel]
+            + " user\n"
+            + "Edit the sample program's constructor argument to one from\n"
+            + "COMMENTARY_FOR_NOVICE\nCOMMENTARY_FOR_INTERMEDIATE or\nCOMMENTARY_FOR_ADVANCED\n"
+            + "in order to alter the level of commentary you are seeing", "");
+
+    commentary(COMMENTARY_ALWAYS, "    Tuscany SDO Java Sample "
+        + this.getClass().getName() + "    \n"
+        + "    This sample is aimed at a " + userLevels[sampleComplexityLevel]
+        + " user");
+
     try {
       runSample();
     } catch (Exception e) {
       somethingUnexpectedHasHappened(e);
-    }
-    finally {   
-      commentary(COMMENTARY_ALWAYS, "    End of sample "  + this.getClass().getName() + "    ");
+    } finally {
+      commentary(COMMENTARY_ALWAYS, "    End of sample "
+          + this.getClass().getName() + "    ");
     }
   }
-  
-  public abstract void runSample() throws Exception ;
+
+  public abstract void runSample() throws Exception;
 
   public int getSampleComplexityLevel() {
     return sampleComplexityLevel;
@@ -207,6 +228,5 @@
   public void setSampleComplexityLevel(Integer sampleComplexityLevel) {
     this.sampleComplexityLevel = sampleComplexityLevel.intValue();
   }
-  
-  
+
 }

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/ObtainingDataGraphFromXml.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/ObtainingDataGraphFromXml.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/ObtainingDataGraphFromXml.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/ObtainingDataGraphFromXml.java Wed Jul  4 06:34:40 2007
@@ -25,7 +25,6 @@
 
 import org.apache.tuscany.samples.sdo.SampleBase;
 import org.apache.tuscany.samples.sdo.SampleInfrastructure;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
 import org.apache.tuscany.sdo.api.SDOUtil;
 
 
@@ -55,9 +54,9 @@
  * <br>
  * To define the correct Types for each DataObject ( CompanyType, DepartmentType etc )
  * this sample relies upon
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#COMPANY_XSD} which is
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#COMPANY_XSD} which is
  * provided in the resources directory of these samples. The xml file
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#COMPANY_DATAGRAPH_XML} is
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#COMPANY_DATAGRAPH_XML} is
  * used to load the DataGraph and is also located in this resources directory. <br>
  * <P>
  * <b>Usage:</b> <br>
@@ -138,7 +137,7 @@
         );
         
         scope = useDefaultScopeForTypes();
-        loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.COMPANY_XSD);
+        loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.COMPANY_XSD);
         
 
 
@@ -157,7 +156,7 @@
                 "ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAGRAPH_XML));"
                 );
             
-            InputStream is = ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAGRAPH_XML);
+            InputStream is = ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAGRAPH_XML);
             int x= is.available();
             byte b[]= new byte[x];
             is.read(b);
@@ -166,7 +165,7 @@
             System.out.println(instanceDoc);
 
             XMLDocument doc = scope.getXMLHelper().load(
-                    ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAGRAPH_XML));
+                    ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAGRAPH_XML));
             
             commentary(
                 "Now we can get the wrapper for the data graph, which in this case is the DataObject\n"+
@@ -204,7 +203,7 @@
 
             );
 
-            DataGraph datagraph = SDOUtil.loadDataGraph(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAGRAPH_XML), null);
+            DataGraph datagraph = SDOUtil.loadDataGraph(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAGRAPH_XML), null);
 
             System.out.println(datagraph);
 

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java Wed Jul  4 06:34:40 2007
@@ -25,7 +25,7 @@
 import java.util.ListIterator;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 
 import commonj.sdo.DataObject;
@@ -75,10 +75,10 @@
         "First we look at a data graph of a Purchase Order which has a fairly simple XML schema\n"
             + "and the graph's containment hierarchy has a couple of levels of depth");
 
-    loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.PO_XSD_RESOURCE);
+    loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE);
 
     XMLDocument purchaseOrder = getXMLDocumentFromFile(scope,
-        SdoSampleConstants.PO_XML_RESOURCE);
+        SampleInfrastructure.PO_XML_RESOURCE);
 
     printXMLDocument(purchaseOrder);
 

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java Wed Jul  4 06:34:40 2007
@@ -23,7 +23,7 @@
 import java.util.List;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 
 import commonj.sdo.DataObject;
@@ -62,9 +62,9 @@
 
         // setting up the type system for the example,  see the utility methods for details of these operations
         HelperContext scope = createScopeForTypes();
-        loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.PO_XSD_RESOURCE);
+        loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE);
 
-        DataObject purchaseOrder = getDataObjectFromFile(scope, SdoSampleConstants.PO_XML_RESOURCE);
+        DataObject purchaseOrder = getDataObjectFromFile(scope, SampleInfrastructure.PO_XML_RESOURCE);
 
 
         System.out.println("Accessing properties by name");

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreateCompany.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreateCompany.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreateCompany.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreateCompany.java Wed Jul  4 06:34:40 2007
@@ -23,7 +23,7 @@
 import java.io.FileOutputStream;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 
 import commonj.sdo.DataObject;
@@ -74,14 +74,14 @@
                "from an XML Schema contained in a file on the file system");
                 
         HelperContext scope = createScopeForTypes();       
-        loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.COMPANY_XSD);
+        loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.COMPANY_XSD);
         
         commentary(
             "Now that our type system has been loaded and made available through the scope\n"+
             "DataObjects can be created by a DataFactory that has access to the required types.\n\n"+
             "DataObject company = scope.getDataFactory().create(SdoSampleConstants.COMPANY_NAMESPACE, \"CompanyType\");");
         
-        DataObject company = scope.getDataFactory().create(SdoSampleConstants.COMPANY_NAMESPACE, "CompanyType");
+        DataObject company = scope.getDataFactory().create(SampleInfrastructure.COMPANY_NAMESPACE, "CompanyType");
         
         populateGraph(scope, company);
             
@@ -91,13 +91,13 @@
             "The XMLHelper can be used to write an XML serialized version of the data graph\n\n"+
             "scope.getXMLHelper().save(company, SdoSampleConstants.COMPANY_NAMESPACE, \"company\", fos);");
         
-        scope.getXMLHelper().save(company, SdoSampleConstants.COMPANY_NAMESPACE, "company", fos);
+        scope.getXMLHelper().save(company, SampleInfrastructure.COMPANY_NAMESPACE, "company", fos);
         
         commentary(
             "Similarly we can serialize the graph to an XML String using the XMLHelper\n\n"+
             "String xml = scope.getXMLHelper().save(company, SdoSampleConstants.COMPANY_NAMESPACE, \"company\");\n");
         
-        String xml = scope.getXMLHelper().save(company, SdoSampleConstants.COMPANY_NAMESPACE, "company");
+        String xml = scope.getXMLHelper().save(company, SampleInfrastructure.COMPANY_NAMESPACE, "company");
         
         System.out.println(xml);
 

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreatePurchaseOrder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreatePurchaseOrder.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreatePurchaseOrder.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreatePurchaseOrder.java Wed Jul  4 06:34:40 2007
@@ -24,7 +24,7 @@
 import java.io.OutputStream;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 
 import commonj.sdo.DataObject;
@@ -35,9 +35,9 @@
 /**
  * Demonstrates creating a purchaseOrder DataObject from an existing XSD and then
  * persisting to disk. Uses previously defined model
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XSD_RESOURCE} to
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#PO_XSD_RESOURCE} to
  * define types then generates a purchase order DataObject and persists to
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XML_GENERATED}. This
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#PO_XML_GENERATED}. This
  * sample was used to generate valid XML for Fuhwei Lwo's paper <A
  * HREF="http://www-128.ibm.com/developerworks/webservices/library/ws-sdoxmlschema/"
  * title="Me" onClick="checkLinks(this)">Create and read an XML document based on XML
@@ -102,7 +102,7 @@
 
           HelperContext scope = createScopeForTypes();
           
-          loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.PO_XSD_RESOURCE);
+          loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE);
           
           
           commentary (
@@ -112,7 +112,7 @@
               "DataObject purchaseOrder = factory.create(SdoSampleConstants.PO_NAMESPACE, \"PurchaseOrderType\");");
           
           DataFactory factory = scope.getDataFactory();           
-          DataObject purchaseOrder = factory.create(SdoSampleConstants.PO_NAMESPACE, "PurchaseOrderType");
+          DataObject purchaseOrder = factory.create(SampleInfrastructure.PO_NAMESPACE, "PurchaseOrderType");
 
 
           commentary(
@@ -163,8 +163,8 @@
               );
           
           
-          OutputStream stream = new FileOutputStream(SdoSampleConstants.PO_XML_GENERATED);
-          scope.getXMLHelper().save(purchaseOrder, SdoSampleConstants.PO_NAMESPACE, "purchaseOrder", stream);
+          OutputStream stream = new FileOutputStream(SampleInfrastructure.PO_XML_GENERATED);
+          scope.getXMLHelper().save(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, "purchaseOrder", stream);
           stream.close();
 
           commentary(
@@ -176,7 +176,7 @@
               "scope.getXMLHelper().save(doc, System.out, null);");
           
           
-          XMLDocument doc = scope.getXMLHelper().createDocument(purchaseOrder, SdoSampleConstants.PO_NAMESPACE, "purchaseOrder");
+          XMLDocument doc = scope.getXMLHelper().createDocument(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, "purchaseOrder");
           scope.getXMLHelper().save(doc, System.out, null);
           System.out.println();
       }

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java Wed Jul  4 06:34:40 2007
@@ -24,7 +24,6 @@
 
 import org.apache.tuscany.samples.sdo.SampleBase;
 import org.apache.tuscany.samples.sdo.SampleInfrastructure;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
 
 
 import commonj.sdo.DataObject;
@@ -36,7 +35,7 @@
  * HREF="http://www-128.ibm.com/developerworks/webservices/library/ws-sdoxmlschema/"
  * title="Me" onClick="checkLinks(this)">Create and read an XML document based on XML
  * Schema</A>.  Uses file
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XML_GENERATED}
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#PO_XML_GENERATED}
  * previously generated by {@link CreatePurchaseOrder} to populate purchase order
  * DataObject
  * <p>
@@ -126,7 +125,7 @@
 
         HelperContext scope = createScopeForTypes();
         
-        loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.PO_XSD_RESOURCE);
+        loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE);
 
         commentary(
             "We load the purchase order document into an instance of XMLDocument\n\n"+

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessDataObjectUsingValidXPath.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessDataObjectUsingValidXPath.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessDataObjectUsingValidXPath.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessDataObjectUsingValidXPath.java Wed Jul  4 06:34:40 2007
@@ -24,7 +24,6 @@
 
 import org.apache.tuscany.samples.sdo.SampleBase;
 import org.apache.tuscany.samples.sdo.SampleInfrastructure;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
 
 import commonj.sdo.DataObject;
 import commonj.sdo.helper.HelperContext;
@@ -80,9 +79,9 @@
     /**
      * Accesses and modifies properties of a purchase order DataObject using xPath(
      * properties are defined in the xsd
-     * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XSD_RESOURCE} and
+     * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#PO_XSD_RESOURCE} and
      * populated by xml
-     * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XML_RESOURCE} )
+     * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#PO_XML_RESOURCE} )
      * 
      * @param args.
      *            No parameters required.
@@ -105,8 +104,8 @@
             "First we create the type system using an XML Schema file and then create\n"+
             "A DataObject using an XML document for convenience");
         
-        loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.PO_XSD_RESOURCE);
-        DataObject purchaseOrder = getDataObjectFromFile(scope, SdoSampleConstants.PO_XML_RESOURCE);
+        loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE);
+        DataObject purchaseOrder = getDataObjectFromFile(scope, SampleInfrastructure.PO_XML_RESOURCE);
 
 
 

Copied: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateCompanyTuscanyAPI.java (from r553191, incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompanyTuscanyAPI.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateCompanyTuscanyAPI.java?view=diff&rev=553203&p1=incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompanyTuscanyAPI.java&r1=553191&p2=incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateCompanyTuscanyAPI.java&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/tuscanyapi/CreateCompanyTuscanyAPI.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateCompanyTuscanyAPI.java Wed Jul  4 06:34:40 2007
@@ -18,11 +18,11 @@
  *  under the License.
  */
 
-package org.apache.tuscany.samples.sdo.tuscanyapi;
+package org.apache.tuscany.samples.sdo.intermediate;
 
 import java.io.FileOutputStream;
 
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 import org.apache.tuscany.sdo.api.SDOUtil;
 
 import commonj.sdo.DataGraph;
@@ -108,7 +108,7 @@
             "other than the default scope. So here is an occasion where we must use"+
             "the default singleton scope");
         HelperContext scope = useDefaultScopeForTypes();
-        loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.COMPANY_XSD);
+        loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.COMPANY_XSD);
        
         commentary (COMMENTARY_FOR_INTERMEDIATE,
             "Here is the use of the Tuscany API for creating a DataGraph instance\n\n"+
@@ -121,7 +121,7 @@
             "This is an example of a DataGraph interface that currently forces us to use the default scope.\n\n"+
             "company = dataGraph.createRootObject(SdoSampleConstants.COMPANY_NAMESPACE, \"CompanyType\");");
         
-        DataObject company = dataGraph.createRootObject(SdoSampleConstants.COMPANY_NAMESPACE, "CompanyType");
+        DataObject company = dataGraph.createRootObject(SampleInfrastructure.COMPANY_NAMESPACE, "CompanyType");
         
         populateGraph(scope, company);
         

Copied: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java (from r553191, incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDeserializingADataObject.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java?view=diff&rev=553203&p1=incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDeserializingADataObject.java&r1=553191&p2=incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDeserializingADataObject.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java Wed Jul  4 06:34:40 2007
@@ -18,190 +18,105 @@
  *  under the License.
  */
 
-package org.apache.tuscany.samples.sdo.specExampleSection;
+package org.apache.tuscany.samples.sdo.intermediate;
 
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-import commonj.sdo.helper.EqualityHelper;
-import commonj.sdo.DataObject;
-
-import java.io.BufferedReader;
 import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.ObjectInputStream;
 import java.io.FileOutputStream;
-import java.io.ObjectOutputStream;
 import java.io.IOException;
-
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
-import org.apache.tuscany.samples.sdo.basic.AccessDataObjectPropertiesByName;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
 
 /**
- * Demonstrates serializing and deserializing a DataObject to disk.
- * 
- * The following sample is from the <a href="http://incubator.apache.org/tuscany"
- * target="_blank"> Apache Tuscany</a> project. It was written to help users
- * understand and experiement with SDO. It is based upon example code contained
- * within, and is meant for use with, and reference to the <a
- * href="http://www.osoa.org/download/attachments/791/SDO_Specification_Java_V2.01.pdf?version=1"
- * target="_bank">SDO Specification</a>. In general this sample attempts to use the
- * code and comments contained within the specification, exceptions to this are noted
- * in comments.<br>
- * <br>
- * The following sample is based upon the 'Serializing/Deserializing a DataGraph or DataObject' example from the Examples section of the SDO
- * specification. <br>
- * <br>
- * The DataObject and DataGraph interfaces extend java.io.Serializable, so any DataObject
- * or DataGraph be serialized.  The following code serializes the company dataObject to a file
- * of the user's choosing.  The file is not deleted after execution.<br> 
- * <br><br>
- * <b>Usage:</b> <br>
- * This sample can easily be run from within Eclipse as a Java Application if tuscany or 
- * the sample-sdo project is imported into Eclipse as an existing project.
- * <br><br>
- * If executing as a standalone application please do the following: 
- * <br>
- * <UL>
- * <LI>Include the following jar files on your classpath :
- * <UL>
- * <LI>SDO API and Tuscany Implementation
- * <UL>
- * <LI>sdo-api-{version}.jar - SDO API
- * <LI>tuscany-sdo-impl-{version}.jar - Tuscany SDO implementation
- * </UL>
- * </LI>
- * <LI>EMF dependencies. 
- * <UL>
- * <LI>emf-common-{version}.jar - some common framework utility and base classes
- * <LI>emf-ecore-{version}.jar - the EMF core runtime implementation classes (the Ecore metamodel)
- * <LI>emf-ecore-change-{version}.jar - the EMF change recorder and framework
- * <LI>emf-ecore-xmi-{version}.jar - EMF's default XML (and XMI) serializer and loader
- * <LI>xsd-{version}.jar - the XML Schema model
- * </UL>
- * </LI>
- * </UL>
- * 
- * These jar files can be obtained by downloading and unpacking a <a href="http://cwiki.apache.org/TUSCANY/sdo-downloads.html" target="_blank">Tuscany binary distribution </a> </LI>
- * <LI>Execute: <br>
- * java org.apache.tuscany.samples.sdo.specExampleSection.SerializingDeserializingADataObject</LI>
- * </UL>
- * 
- * @author Robbie Minshall
+ * Demonstrates serializing and deserializing a DataObject to disk
+ * using java serialization.
  */
-
 public class SerializingDeserializingADataObject  extends SampleBase {
-
-
+// TODO reference central build instructions
     HelperContext scope;
 
     public SerializingDeserializingADataObject(Integer userLevel) {
-      super(userLevel);
+      super(userLevel, SAMPLE_LEVEL_INTERMEDIATE);
     }
 
 
-    /**
-     * Default fileName to serialize DataObject to
-     */
-    public static final String DEFAULT_FILE_NAME = "temporarySerializedDataObject.xml";
-    
-    public static void serializeDO(DataObject DataObject, String fileName) throws IOException {
-        // serialize data object
-        FileOutputStream fos = new FileOutputStream(fileName);
-        ObjectOutputStream out = new ObjectOutputStream(fos);
-        out.writeObject(DataObject);
-        out.close();
-    }
-
-    /**
-     * Execute this method in order to run the sample.
-     * 
-     * @param args
-     */
     public static void main(String[] args) {
-      // TODO make the default level COMMENTARY_FOR_NOVICE, once the rest of the sample has been
-      // converted to using commentary()
-      SerializingDeserializingADataObject sample = new SerializingDeserializingADataObject(COMMENTARY_FOR_INTERMEDIATE);
-
-      try {
-        sample.run();
-      }
-      catch (Exception e) {
-        sample.somethingUnexpectedHasHappened(e);
-      }
+
+      SerializingDeserializingADataObject sample =
+    	  new SerializingDeserializingADataObject(COMMENTARY_FOR_INTERMEDIATE);
+      sample.run();
+
     }
 
     public void runSample () throws Exception {
-        System.out.println("***************************************");
-        System.out.println("SDO Sample AccessingTheContentsOfASequence");
-        System.out.println("***************************************");
-        System.out.println("Demonstrates serializing and deserializing a DataObject to disk.");
-        System.out.println("***************************************");
-        
-
-        try {
-            scope = createScopeForTypes();
-
-            // define Types using XSDHelper and predefined xsd file
-            System.out.println("Defining Types using XSD");
-            scope.getXSDHelper().define(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_XSD), null);
-            System.out.println("Type definition completed");
-
-            // create company DataObject using XMLHelper which is an example of a XML DAS
-            System.out.println("Creating company DataObject");
-            DataObject company = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAOBJECT_XML))
-                    .getRootObject();
-
-            // prompt user for a fileName
-            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-            System.out.print("Please enter file name, enter for default :");
-            String fileName = in.readLine();
-            if ( (fileName == null) || (fileName.equals(""))){
-                fileName = DEFAULT_FILE_NAME;
-            }
-                     
-            // serialize dataObject out
-            System.out.println("Serializing DataObject to " + fileName);
-            FileOutputStream fos = new FileOutputStream(fileName);
-            ObjectOutputStream out = new ObjectOutputStream(fos);
-            out.writeObject(company);
-            out.close();            
-            
-            // read in DataObject
-            System.out.println("Deserialize DataObject from file");
-            FileInputStream fis = new FileInputStream(fileName);
-            ObjectInputStream input = new ObjectInputStream(fis);
-            DataObject newDataObject = (DataObject) input.readObject();
-            input.close();
-            
-            /**
-             * Compare DataObjects
-             */
-            
-            System.out.println("Comparing original and deserialized DataObject");                       
-            //determine if two graphs of DataObjects are equal 
-            System.out.println("DataObjects are equal: " + scope.getEqualityHelper().equal(company, newDataObject));
-            
-            //determine if two DataObjects have the same values for their datatype properties          
-            System.out.println("DataObjects have same values for their datatype properties : " + scope.getEqualityHelper().equalShallow(company, newDataObject));
-                                 
-            //print out xml representation
-            System.out.println();
-            System.out.println("Original company DataObject:");
-            System.out.println(scope.getXMLHelper().save(company, SdoSampleConstants.COMPANY_NAMESPACE, "company"));
-            
-            System.out.println();
-            System.out.println("Deserialized company DataObject:");
-            System.out.println(scope.getXMLHelper().save(newDataObject, SdoSampleConstants.COMPANY_NAMESPACE, "company"));                       
-            
-        } catch (Exception e) {
-            System.out.println("Sorry there was an error encountered " + e.toString());
-            e.printStackTrace();
-        }
+
+        commentary(
+        		"Demonstrates serializing and deserializing a DataObject\n" +
+        		"to disk using Java serialization.");
+
+        scope = useDefaultScopeForTypes();
+        loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.COMPANY_XSD);
+        DataObject company = getDataObjectFromFile(scope, SampleInfrastructure.COMPANY_DATAOBJECT_XML);
+
+
+        commentary("We've loaded a data graph 'company' from a file\n" +
+        		"using XML schema for the model and XML for the graph in the usual manner\n");
+        String fileName = "temporarySerializedDataObject.xml";
+        commentary("We've loaded a data graph 'company' from a file\n" +
+        "using XML schema for the model and XML for the graph in the usual manner\n" +
+        "Now we are going to serialize it to, and read it from a temporary file: "+fileName);
+        
+        commentary(
+        		"The following code,  which doesn't use any SDO APIs, demonstrates the\n" +
+        		"underlying SDO function of performing Java serialization on SDO objects\n\n" +
+        		"FileOutputStream fos = new FileOutputStream(fileName);\n" +
+        		"ObjectOutputStream out = new ObjectOutputStream(fos);\n" +
+        		"out.writeObject(company);\n" +
+        		"out.close();");
+
+        FileOutputStream fos = new FileOutputStream(fileName);
+        ObjectOutputStream out = new ObjectOutputStream(fos);
+        out.writeObject(company);
+        out.close();            
+        
+        // read in DataObject
+        commentary("Having written the data graph to the temporary file we\n" +
+        		"can read it back\n\n" +
+        		"FileInputStream fis = new FileInputStream(fileName);\n" +
+        		"ObjectInputStream input = new ObjectInputStream(fis);\n" +
+        		"DataObject newDataObject = (DataObject) input.readObject();\n" +
+        		"input.close();");
+        
+        FileInputStream fis = new FileInputStream(fileName);
+        ObjectInputStream input = new ObjectInputStream(fis);
+        DataObject newDataObject = (DataObject) input.readObject();
+        input.close();
         
-        System.out.println("GoodBye");
+        /**
+         * Compare data graphs
+         */
+        
+        commentary("We can use the SDO EqualityHelper to check that we have got\n" +
+        		"back an equivalent graph to the one we had originally\n\n" +
+        		"boolean equal = scope.getEqualityHelper().equal(company, newDataObject);");                       
+
+        boolean equal = scope.getEqualityHelper().equal(company, newDataObject);
+        System.out.println("DataObjects are equal: " + equal);
+        
+       //print out xml representation
+        System.out.println();
+        System.out.println("Original company DataObject:");
+        System.out.println(scope.getXMLHelper().save(company, SampleInfrastructure.COMPANY_NAMESPACE, "company"));
+        
+        System.out.println();
+        System.out.println("Deserialized company DataObject:");
+        System.out.println(scope.getXMLHelper().save(newDataObject, SampleInfrastructure.COMPANY_NAMESPACE, "company"));                       
+            
 
     }
 }

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderCmdLine.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderCmdLine.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderCmdLine.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderCmdLine.java Wed Jul  4 06:34:40 2007
@@ -21,7 +21,8 @@
 package org.apache.tuscany.samples.sdo.otherSources;
 
 import java.io.*;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 /**
  * Provides interactive menu based command line interface to modify, save, view purchase order DataObject.
@@ -366,8 +367,8 @@
     private static void printUsage() {
         System.out.println("***************************************");
         System.out.println("java org.apache.tuscany.samples.sdo.otherSources.PurchaseOrderCmdLine <xsdFileName> <xmlFileName>");
-        System.out.println("If xsdFileName and xmlFileName are not specified " + SdoSampleConstants.PO_XSD_RESOURCE + " and "
-                + SdoSampleConstants.PO_XML_RESOURCE + " will be used as resources");
+        System.out.println("If xsdFileName and xmlFileName are not specified " + SampleInfrastructure.PO_XSD_RESOURCE + " and "
+                + SampleInfrastructure.PO_XML_RESOURCE + " will be used as resources");
         System.out.println("Specify null if you wish to use the appropiate resource from the jar rather specifying a fileName");
         System.out.println("***************************************");
     }

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/otherSources/PurchaseOrderControl.java Wed Jul  4 06:34:40 2007
@@ -34,7 +34,7 @@
 import commonj.sdo.helper.CopyHelper;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 import org.apache.tuscany.samples.sdo.specCodeSnippets.*;
 
@@ -115,7 +115,7 @@
         if ((xsdFileName == null) || (xsdFileName.equals("")) || (xsdFileName.equalsIgnoreCase("null"))) {
 
             // use simple example to define type from resource
-            loadTypesFromXMLSchemaFile(scope, SdoSampleConstants.PO_XSD_RESOURCE);
+            loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE);
 
         } else {
             System.out.println("Using file to access xsd in order to define types");
@@ -144,7 +144,7 @@
 
         if ((xmlFileName == null) || (xmlFileName.equals("")) || (xmlFileName.equalsIgnoreCase("null"))) {
 
-            purchaseOrder = getDataObjectFromFile(scope, SdoSampleConstants.PO_XML_RESOURCE);
+            purchaseOrder = getDataObjectFromFile(scope, SampleInfrastructure.PO_XML_RESOURCE);
         } else {
             try {
 
@@ -297,9 +297,9 @@
         if (this.xmlFileName != null) {
             saveAs(xmlFileName);            
         } else {
-            System.out.println("Sorry, can not save to resource within jar, will create file called " + SdoSampleConstants.PO_XML_RESOURCE
+            System.out.println("Sorry, can not save to resource within jar, will create file called " + SampleInfrastructure.PO_XML_RESOURCE
                     + " and save");
-            saveAs(SdoSampleConstants.PO_XML_RESOURCE);
+            saveAs(SampleInfrastructure.PO_XML_RESOURCE);
         }
     }
 
@@ -312,7 +312,7 @@
      */
     public void saveAs(String fileName) throws IOException {
         OutputStream stream = new FileOutputStream(fileName);
-        scope.getXMLHelper().save(purchaseOrder, SdoSampleConstants.PO_NAMESPACE, "purchaseOrder", stream);
+        scope.getXMLHelper().save(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, "purchaseOrder", stream);
         System.out.println("Saved to " + fileName);
     }
 
@@ -468,7 +468,7 @@
      * @return XMLDocument that represents current purchase order DataObject
      */
     public XMLDocument getXMLDocuement() {
-        return scope.getXMLHelper().createDocument(purchaseOrder, SdoSampleConstants.PO_NAMESPACE, "purchaseOrder");
+        return scope.getXMLHelper().createDocument(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, "purchaseOrder");
     }
 
     /**
@@ -479,7 +479,7 @@
         // alternativly could use the following
         // return scope.getXMLHelper().createDocument(purchaseOrder, PO_NAMESPACE,
         // "purchaseOrder").toString();
-        return scope.getXMLHelper().save(purchaseOrder, SdoSampleConstants.PO_NAMESPACE, "purchaseOrder");
+        return scope.getXMLHelper().save(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, "purchaseOrder");
     }
 
     // PRIVATE HELPER METHODS
@@ -520,8 +520,7 @@
     }
 
     public void runSample() throws Exception {
-      // TODO Auto-generated method stub
-      // FIXME make this sample fit the pattern
+      // FIXME make this sample fit the pattern or delete it
       
     }
 }

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java Wed Jul  4 06:34:40 2007
@@ -24,7 +24,7 @@
 import java.util.List;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 import commonj.sdo.DataObject;
 import commonj.sdo.helper.HelperContext;
@@ -57,10 +57,10 @@
  * <br>
  * To define the correct Types for each DataObject ( CompanyType, DepartmentType etc )
  * this sample relies upon
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#COMPANY_XSD} which is
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#COMPANY_XSD} which is
  * provided in the resources directory of these samples <br>
  * The xml file
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#COMPANY_DATAOBJECT_XML}
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#COMPANY_DATAOBJECT_XML}
  * used to load the DataObject is also located in this resources directory. To help
  * ensure consistancy with the xsd the xml was generated by
  * {@link org.apache.tuscany.samples.sdo.basic.CreateCompany} which is a good
@@ -171,7 +171,7 @@
         try {
             System.out.println("Defining Types using XSD");
             InputStream is = null;
-            is = ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_XSD);
+            is = ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_XSD);
             scope.getXSDHelper().define(is, null);
             is.close();
             System.out.println("Type definition completed");
@@ -190,14 +190,14 @@
             // Obtain the RootObject from the XMLDocument obtained from the XMLHelper
             // instance.
             // In this case the root object is a DataObject representing a company
-            DataObject company = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAOBJECT_XML))
+            DataObject company = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAOBJECT_XML))
                     .getRootObject();
 
             // print out some information to show the user what the objects look like
             System.out.println("Company DataObject:");
             System.out.println(company);
 
-            String generatedXml = scope.getXMLHelper().save(company, SdoSampleConstants.COMPANY_NAMESPACE, "company");
+            String generatedXml = scope.getXMLHelper().save(company, SampleInfrastructure.COMPANY_NAMESPACE, "company");
             System.out.println("Company data object xml representation: ");
             System.out.println(generatedXml);
 
@@ -238,7 +238,7 @@
             System.out.println("The modified company DataObject :");
             System.out.println(company);
 
-            generatedXml = scope.getXMLHelper().save(company, SdoSampleConstants.COMPANY_NAMESPACE, "company");
+            generatedXml = scope.getXMLHelper().save(company, SampleInfrastructure.COMPANY_NAMESPACE, "company");
             System.out.println("Company data object xml representation: ");
             System.out.println(generatedXml);
 

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java Wed Jul  4 06:34:40 2007
@@ -126,6 +126,8 @@
         System.out.println("***************************************");
         System.out.println("Demonstrates accessing the sequence from a DataObject containing mixed content.");
         System.out.println("***************************************");
+        
+        // FIXME update sample, and see if it deals with xml attribute sequencing
 
         scope = createScopeForTypes();
         

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java Wed Jul  4 06:34:40 2007
@@ -21,7 +21,7 @@
 package org.apache.tuscany.samples.sdo.specExampleSection;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 import commonj.sdo.DataObject;
 import commonj.sdo.helper.HelperContext;
@@ -45,9 +45,9 @@
  * XMLHelper to convert xml Strings to DataObjects. <br>
  * <br>
  * Uses previously defined model
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XSD_RESOURCE} to
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#PO_XSD_RESOURCE} to
  * define types then generates a purchase order DataObject and persists to
- * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#PO_XML_GENERATED}
+ * {@link org.apache.tuscany.samples.sdo.SampleInfrastructure#PO_XML_GENERATED}
  * <br><br> 
  * <b>Usage:</b> <br>
  * This sample can easily be run from within Eclipse as a Java Application if tuscany or 
@@ -122,12 +122,12 @@
             scope = createScopeForTypes();
 
             // use xsd to define purchase order types
-            System.out.println("Definging purchase order types using " + SdoSampleConstants.PO_XSD_RESOURCE);
-            scope.getXSDHelper().define(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XSD_RESOURCE), null);
+            System.out.println("Defining purchase order types using " + SampleInfrastructure.PO_XSD_RESOURCE);
+            scope.getXSDHelper().define(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.PO_XSD_RESOURCE), null);
             System.out.println("Defined Types using xsd");
 
-            System.out.println("Creating purchase order DataObject using previously created " + SdoSampleConstants.PO_XML_RESOURCE);
-            DataObject purchaseOrder = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XML_RESOURCE))
+            System.out.println("Creating purchase order DataObject using previously created " + SampleInfrastructure.PO_XML_RESOURCE);
+            DataObject purchaseOrder = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.PO_XML_RESOURCE))
                     .getRootObject();
 
             // To create the shipTo DataObject from XML:

Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java?view=diff&rev=553203&r1=553202&r2=553203
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java Wed Jul  4 06:34:40 2007
@@ -23,7 +23,7 @@
 import java.util.List;
 
 import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+import org.apache.tuscany.samples.sdo.SampleInfrastructure;
 
 import commonj.sdo.DataObject;
 import commonj.sdo.Property;
@@ -125,23 +125,23 @@
           
             // define Types using XSDHelper and predefined xsd file
             System.out.println("Defining company Types using XSD");
-            scope.getXSDHelper().define(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_XSD), null);
+            scope.getXSDHelper().define(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_XSD), null);
             System.out.println("Type definition completed");
 
             // create company DataObject using XMLHelper which is an example of a XML DAS
             System.out.println("Creating company DataObject");
-            DataObject company = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAOBJECT_XML))
+            DataObject company = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAOBJECT_XML))
                     .getRootObject();
 
             printDataObject(company, 0);
             
             System.out.println("Defining purchase order types");
-            scope.getXSDHelper().define(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XSD_RESOURCE), null);
+            scope.getXSDHelper().define(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.PO_XSD_RESOURCE), null);
             System.out.println("Type definition completed");
 
             // create company DataObject using XMLHelper which is an example of a XML DAS
             System.out.println("Creating purchase order DataObject");
-            DataObject po = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XML_RESOURCE))
+            DataObject po = scope.getXMLHelper().load(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.PO_XML_RESOURCE))
                     .getRootObject();
 
             printDataObject(po, 0);



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message