You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ro...@apache.org on 2006/08/16 15:56:32 UTC
svn commit: r431902 [3/3] - in /incubator/tuscany/java/samples/sdo: ./ src/
src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/samples/
src/main/java/org/apache/tusca...
Added: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java (added)
+++ incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java Wed Aug 16 06:56:30 2006
@@ -0,0 +1,224 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tuscany.samples.sdo.specExampleSection;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import commonj.sdo.DataObject;
+
+/**
+ * Demonstrates accessing the properties of a DataObject using property indices.
+ *
+ * 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 'Accessing DataObjects via Property Index'
+ * example from the Examples section of the SDO specification. It shows the use of
+ * DataObjects and the XMLHelper amd demonstrates accessing the properties of a
+ * DataObject using property indices. <br>
+ * <br>
+ * The following example has the same effect as
+ * {@link org.apache.tuscany.samples.sdo.specExampleSection.AccessDataObjectsUsingXPath}.
+ * The indexes for the properties are defined as constants in this class. <br>
+ * <br>
+ * This sample reads an xml file representing a DataObject of a company. In order to
+ * create a DataObject or DataGraph this sample relies upon XMLHelper class which is
+ * essentially example of a XML DAS implementation. The code shown here would work
+ * just as well against an equivalent DataObject that was provided by any DAS. <br>
+ * <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
+ * provided in the resources directory of these samples <br>
+ * The xml file
+ * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#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.otherSources.CreateCompany} which is a good
+ * resource for populating DataObjects, or creating DataGraphs dynamically.
+ * <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 from directly from Tuscany and EMF projects or from <a
+ * href="http://wiki.apache.org/ws-data/attachments/Tuscany(2f)TuscanyJava(2f)SDO_Java_Overview/attachments/SDO%20Execution%20Dependencies"
+ * target="_bank">SDO Execution Dependancies </a> </LI>
+ * <LI>Execute: <br>
+ * java org.apache.tuscany.samples.sdo.specExampleSection.AccessingDataObjectsViaPropertyIndex </LI>
+ * </UL>
+ *
+ * @author Robbie Minshall
+ */
+
+public class AccessingDataObjectsViaPropertyIndex {
+
+ /**
+ * Predefine the property indexes.
+ *
+ * Please note that these indices differ from those in the Examples section of
+ * the SDO 2.0 specification.
+ *
+ * Properties from Type.getDeclaredProperties() and therefore the properties
+ * obtained from a data object are in alphanumerical ordering of the xml schema
+ * complex type.
+ *
+ */
+
+ private static final int COMPANY_DEPARTMENT = 0;
+
+ private static final int COMPANY_EMPLOYEE_OF_MONTH = 1;
+
+ private static final int COMPANY_NAME = 2;
+
+ private static final int DEPARTMENT_EMPLOYEES = 0;
+
+ private static final int EMPLOYEE_MANAGER = 0;
+
+ private static final int EMPLOYEE_NAME = 1;
+
+ private static final int EMPLOYEE_SN = 2;
+
+ /**
+ * Execute this method in order to run the sample.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ System.out.println("***************************************");
+ System.out.println("SDO Sample AccessingDataObjectsViaPropertyIndex");
+ System.out.println("***************************************");
+ System.out.println("Demonstrates accessing the properties of a DataObject using property indices.");
+ System.out.println("***************************************");
+
+ // TODO: what happens if not type is defined
+ try {
+ System.out.println("Defining Types using XSD");
+ InputStream is = null;
+ is = ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_XSD);
+ XSDHelper.INSTANCE.define(is, null);
+ is.close();
+ System.out.println("Type definition completed");
+ } catch (Exception e) {
+ System.out.println("Exception caught defining types " + e.toString());
+ e.printStackTrace();
+ }
+
+ try {
+
+ /**
+ * In this example simply use a company DataObject read in from xml
+ */
+
+ // For DataObjects
+ // 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 = XMLHelper.INSTANCE.load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.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 = XMLHelper.INSTANCE.save(company, SdoSampleConstants.COMPANY_NAMESPACE, "company");
+ System.out.println("Company data object xml representation: ");
+ System.out.println(generatedXml);
+
+ System.out.println("Setting name of company to MegaCorp");
+ // Set the "name" property for the company
+ company.setString(COMPANY_NAME, "MegaCorp");
+ // Get the list of departments
+ List departments = company.getList(COMPANY_DEPARTMENT);
+ // Get the department at index 0 on the list
+ DataObject department = (DataObject) departments.get(0);
+ // Get the list of employees for the department
+ List employees = department.getList(DEPARTMENT_EMPLOYEES);
+ // Get the employee at index 1 on the list
+ DataObject employeeFromList = (DataObject) employees.get(2);
+
+ // remove the employee from the graph
+ System.out.println("Removing employee " + employeeFromList.getString("name") + " from list of employees");
+ employeeFromList.detach();
+
+ // create a new employee
+ System.out.println("Creating new employee (manager) Al Smith and adding to list");
+ DataObject newEmployee = department.createDataObject(DEPARTMENT_EMPLOYEES);
+
+ /**
+ * Properties from Type.getDeclaredProperties, or Type.getProperties
+ * should be in lexical (alphanumerical) ordering of the xml schema
+ * complex type.
+ */
+
+ newEmployee.set(EMPLOYEE_NAME, "Al Smith");
+ newEmployee.set(EMPLOYEE_SN, "E0005");
+ newEmployee.setBoolean(EMPLOYEE_MANAGER, true);
+
+ System.out.println("setting employee of the month to new employee");
+ company.set(COMPANY_EMPLOYEE_OF_MONTH, newEmployee.get(EMPLOYEE_SN));
+
+ // print out some information to show the user what the objects look like
+ System.out.println("The modified company DataObject :");
+ System.out.println(company);
+
+ generatedXml = XMLHelper.INSTANCE.save(company, SdoSampleConstants.COMPANY_NAMESPACE, "company");
+ System.out.println("Company data object xml representation: ");
+ System.out.println(generatedXml);
+
+ } catch (Exception e) {
+ System.out.println("Sorry there was an error encountered " + e.toString());
+ e.printStackTrace();
+ }
+ System.out.println("GoodBye");
+
+ }
+}
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingDataObjectsViaPropertyIndex.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java (added)
+++ incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java Wed Aug 16 06:56:30 2006
@@ -0,0 +1,191 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tuscany.samples.sdo.specExampleSection;
+
+
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import commonj.sdo.DataObject;
+import commonj.sdo.Sequence;
+import commonj.sdo.Property;
+
+/**
+ * Demonstrates accessing the sequence from a DataObject containing mixed content.
+ *
+ * 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>
+ *
+ * Specifically the following sample is based upon the 'Accessing the contents of a Sequence' example from the Examples section of the SDO specification. <br>
+ * <br>
+ * The following code uses the Sequence interface to analyze the contents of a DataObject that conforms to teh Letter model defined in
+ * {@link #LETTER_XSD}. This code first goes through the Sequence looking for unformatted text entrires and prints them out. Then the code checks to
+ * verify that the contents of teh "lastName" property of the DataObject matches the contents of the same property of the Sequence. <br>
+ * <br>
+ * This sample reads an xml file (@link #LETTER_XML} representing a DataObject of a letter. In order to create a DataObject or DataGraph this sample
+ * relies upon XMLHelper class which is an example of a XML DAS. The code shown here would work just as well against an equivalent DataObject that was
+ * provided by any DAS. <br>
+ *
+ * The XSD for {@link #LETTER_XSD} defines the FormLetter complex type as mixed. Mixed content and sequences are often used for semi structured business data.
+ * <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 from directly from Tuscany and EMF projects or from <a
+ * href="http://wiki.apache.org/ws-data/attachments/Tuscany(2f)TuscanyJava(2f)SDO_Java_Overview/attachments/SDO%20Execution%20Dependencies"
+ * target="_bank">SDO Execution Dependancies </a> </LI>
+ * <LI>Execute: <br>
+ * java org.apache.tuscany.samples.sdo.specExampleSection.AccessingTheContentsOfASequence</LI>
+ * </UL>
+ *
+ * @author Robbie Minshall
+ */
+
+public class AccessingTheContentsOfASequence {
+
+ /**
+ * previously created XSD file used
+ */
+ public static final String LETTER_XSD = "letter.xsd";
+
+ /**
+ * previously created XML file used
+ */
+ public static final String LETTER_XML = "letter.xml";
+
+ /**
+ * Execute this method in order to run the sample.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ System.out.println("***************************************");
+ System.out.println("SDO Sample AccessingTheContentsOfASequence");
+ System.out.println("***************************************");
+ System.out.println("Demonstrates accessing the sequence from a DataObject containing mixed content.");
+ System.out.println("***************************************");
+
+ try {
+ // define model
+ System.out.println("Defining Types using XSD");
+ XSDHelper.INSTANCE.define(ClassLoader.getSystemResourceAsStream(LETTER_XSD), null);
+
+ // define letter data object
+ System.out.println("Loading Letter DataObject from XML");
+ DataObject letter = XMLHelper.INSTANCE.load(ClassLoader.getSystemResourceAsStream(LETTER_XML)).getRootObject();
+
+ // print letter sequence
+ System.out.println("Printing sequence for " + letter);
+ System.out.println(XMLHelper.INSTANCE.save(letter, "letter.xsd", "letter"));
+ printSequence(letter);
+
+ } catch (Exception e) {
+ System.out.println("Sorry there was an error encountered " + e.toString());
+ e.printStackTrace();
+ }
+ System.out.println("GoodBye");
+
+ }
+
+ /**
+ * Uses the Sequence interface to analyze the contents of a DataObject that conforms to teh Letter model defined in
+ * {@link #LETTER_XSD}. This code first goes through the Sequence looking for unformatted text entrires and prints them out. Then the code checks
+ * to verify that the contents of the "lastName" property of the DataObject matches the contents of the same property of the Sequence. <br>
+ *
+ * @param letter. Letter DataObject conforming to {@link #LETTER_XSD}
+ */
+ public static void printSequence(DataObject letter) {
+ // Access the Sequence of the FormLetter
+ System.out.println("The type is for letter dataObject is mixed " + XSDHelper.INSTANCE.isMixed(letter.getType()));
+
+ Sequence letterSequence = letter.getSequence();
+ // Print out all the settings that contain unstructured text
+ System.out.println("Unstructured text:");
+ for (int i = 0; i < letterSequence.size(); i++) {
+
+ /*
+ * Please note that the following line is a correction to the 2.0 specification which incorrectly calls:
+ *
+ * String propertyName = ((Property) letterSequence.getProperty(i)).getName();
+ *
+ * According to the SDO API sequence.getProperty will return null if the content is mixed, in this case
+ * we want to print it out as unstructured text
+ */
+ Property prop = letterSequence.getProperty(i);
+ if (prop == null) {
+ String text = (String) letterSequence.getValue(i);
+ System.out.println("\t(" + text + ")");
+ }
+
+ }
+
+ /*
+ * Please note that the following line is a correction to the 2.0 Specification which incorrectly uses letterDataObject variable rather than
+ * simply letter
+ */
+ // Verify that the lastName property of the DataObject has the same
+ // value as the lastName property for the Sequence.
+ String dataObjectLastName = letter.getString("lastName");
+ for (int i = 0; i < letterSequence.size(); i++) {
+
+ /*
+ * The following line has been corrected from the 2.0 specification
+ * According to the SDO API sequence.getProperty will return null if the content is mixed.
+ * We want to check that the content is not mixed, and then check that it it is the property which
+ * we are looking for
+ */
+ Property property = letterSequence.getProperty(i);
+
+ if ( (property != null) && ("lastName".equals(property.getName()))) {
+ String sequenceLastName = (String) letterSequence.getValue(i);
+ if (dataObjectLastName == sequenceLastName)
+ System.out.println("Last Name property matches");
+ break;
+ }
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/AccessingTheContentsOfASequence.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java (added)
+++ incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java Wed Aug 16 06:56:30 2006
@@ -0,0 +1,133 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tuscany.samples.sdo.specExampleSection;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+
+/**
+ * Demonstrates creating a DataObject from an XML String.
+ * <br>
+ * 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>
+ * Specifically this sample is based upon the 'Creating DataObject Trees from XML
+ * documents' example from the Examples section of the SDO Specification. It is
+ * possible to convert to and from XML documents to build DataObject trees, which is
+ * useful when assembling DataObjects from serval data sources. This sample uses the
+ * XMLHelper to convert xml Strings to DataObjects. <br>
+ * <br>
+ * Uses previously defined model
+ * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#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}
+ * <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 from directly from Tuscany and EMF projects or from <a
+ * href="http://wiki.apache.org/ws-data/attachments/Tuscany(2f)TuscanyJava(2f)SDO_Java_Overview/attachments/SDO%20Execution%20Dependencies"
+ * target="_bank">SDO Execution Dependancies </a> </LI>
+ * <LI>Execute: <br>
+ * java org.apache.tuscany.samples.sdo.specExampleSection.CreatingDataObjectTreesFromXMLDocuments</LI>
+ * </UL>
+ *
+ * @author Robbie Minshall
+ * @see {@link org.apache.tuscany.samples.sdo.otherSources.CreatePurchaseOrder}
+ */
+
+public class CreatingDataObjectTreesFromXMLDocuments {
+
+ /**
+ * Drives sample
+ *
+ * @param args.
+ * none required.
+ */
+ public static void main(String[] args) {
+ try {
+
+ System.out.println("***************************************");
+ System.out.println("SDO Sample CreatingDataObjectTreesFromXMLDocuments");
+ System.out.println("***************************************");
+
+ // use xsd to define purchase order types
+ System.out.println("Definging purchase order types using " + SdoSampleConstants.PO_XSD_RESOURCE);
+ XSDHelper.INSTANCE.define(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.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 = XMLHelper.INSTANCE.load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XML_RESOURCE))
+ .getRootObject();
+
+ // To create the shipTo DataObject from XML:
+ String shipToXML = "<shipTo country='US'>" + " <name>Alice Smith</name>" + " <street>123 Maple Street</street>"
+ + " <city>Mill Valley</city>" + " <state>PA</state>" + " <zip>90952</zip>" + "</shipTo>";
+ DataObject shipTo = XMLHelper.INSTANCE.load(shipToXML).getRootObject();
+
+ // Modify shipTo DataObject on purchaseOrder to value created from a
+ // String
+ System.out.println("Modifying shipTo DataObject on purchaseOrder to value created from a String");
+ purchaseOrder.set("shipTo", shipTo);
+
+ // Obtain and convert the billTo DataObject to XML
+ System.out.println("Obtaining billTo dataObject from purchase order and converting to XML");
+ DataObject billTo = purchaseOrder.getDataObject("billTo");
+ String billToXML = XMLHelper.INSTANCE.save(billTo, null, "billTo");
+ System.out.println("billTo DataObject:");
+ System.out.println(billToXML);
+
+ } catch (Exception e) {
+ System.out.println("Sorry an error occured " + e.toString());
+ e.printStackTrace();
+ }
+ System.out.println("GoodBye");
+ }
+}
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingDataObjectTreesFromXMLDocuments.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java (added)
+++ incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java Wed Aug 16 06:56:30 2006
@@ -0,0 +1,157 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tuscany.samples.sdo.specExampleSection;
+
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+
+import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+
+/**
+ * Demonstrates programmatically creating a DataObject and generating an XML String.
+ * <br>
+ * 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>
+ * Specifically this sample is based upon the 'Creating XML from DataObjects' example
+ * from the SDO specification's Examples section. <br>
+ * <br>
+ * Uses previously defined model
+ * {@link org.apache.tuscany.samples.sdo.SdoSampleConstants#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}
+ * <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 from directly from Tuscany and EMF projects or from <a
+ * href="http://wiki.apache.org/ws-data/attachments/Tuscany(2f)TuscanyJava(2f)SDO_Java_Overview/attachments/SDO%20Execution%20Dependencies"
+ * target="_bank">SDO Execution Dependancies </a> </LI>
+ * <LI>Execute: <br>
+ * java org.apache.tuscany.samples.sdo.specExampleSection.CreatingXmlFromDataObjects</LI>
+ * </UL>
+ *
+ * @author Robbie Minshall
+ * @see {@link org.apache.tuscany.samples.sdo.otherSources.CreatePurchaseOrder}
+ */
+
+public class CreatingXmlFromDataObjects {
+
+ /**
+ * Drives sample
+ *
+ * @param args.
+ * none required.
+ */
+ public static void main(String[] args) {
+ try {
+
+ System.out.println("***************************************");
+ System.out.println("SDO Sample CreatingXmlFromDataObjects");
+ System.out.println("***************************************");
+ System.out.println("Demonstrates programmatically creating a DataObject and generating an XML String");
+ System.out.println("***************************************");
+
+ XSDHelper.INSTANCE.define(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XSD_RESOURCE), null);
+ System.out.println("Defined Types using xsd");
+ DataObject purchaseOrder = DataFactory.INSTANCE.create(SdoSampleConstants.PO_NAMESPACE, "PurchaseOrderType");
+ System.out.println("Created DataObject using DataFactory");
+
+ System.out.println("Populating purchase order data object");
+
+ purchaseOrder.setString("orderDate", "1999-10-20");
+
+ DataObject shipTo = purchaseOrder.createDataObject("shipTo");
+ shipTo.set("country", "US");
+ shipTo.set("name", "Alice Smith");
+ shipTo.set("street", "123 Maple Street");
+ shipTo.set("city", "Mill Valley");
+ shipTo.set("state", "CA");
+ shipTo.setString("zip", "90952");
+ DataObject billTo = purchaseOrder.createDataObject("billTo");
+ billTo.set("country", "US");
+ billTo.set("name", "Robert Smith");
+ billTo.set("street", "8 Oak Avenue");
+ billTo.set("city", "Mill Valley");
+ billTo.set("state", "PA");
+ billTo.setString("zip", "95819");
+ purchaseOrder.set("comment", "Hurry, my lawn is going wild!");
+
+ DataObject items = purchaseOrder.createDataObject("items");
+
+ DataObject item1 = items.createDataObject("item");
+ item1.set("partNum", "872-AA");
+ item1.set("productName", "Lawnmower");
+ item1.setInt("quantity", 1);
+ item1.setString("price", "148.95");
+
+ item1.set("comment", "Confirm this is electric");
+
+ DataObject item2 = items.createDataObject("item");
+ item2.set("partNum", "926-AA");
+ item2.set("productName", "Baby Monitor");
+ item2.setInt("quantity", 1);
+ item2.setString("price", "39.98");
+ item2.setString("shipDate", "1999-05-21");
+
+ OutputStream stream = new FileOutputStream(SdoSampleConstants.PO_XML_GENERATED);
+ XMLHelper.INSTANCE.save(purchaseOrder, SdoSampleConstants.PO_NAMESPACE, "purchaseOrder", stream);
+ System.out.println("Created file " + SdoSampleConstants.PO_XML_GENERATED);
+ System.out.println("Populated with :");
+ System.out.println(XMLHelper.INSTANCE.save(purchaseOrder, SdoSampleConstants.PO_NAMESPACE, "purchaseOrder"));
+ } catch (Exception e) {
+ System.out.println("Sorry an error occured " + e.toString());
+ e.printStackTrace();
+ }
+ System.out.println("GoodBye");
+ }
+}
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/CreatingXmlFromDataObjects.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java (added)
+++ incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java Wed Aug 16 06:56:30 2006
@@ -0,0 +1,180 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tuscany.samples.sdo.specExampleSection;
+
+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 org.apache.tuscany.samples.sdo.SdoSampleConstants;
+
+/**
+ * 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 from directly from Tuscany and EMF projects or from <a
+ * href="http://wiki.apache.org/ws-data/attachments/Tuscany(2f)TuscanyJava(2f)SDO_Java_Overview/attachments/SDO%20Execution%20Dependencies"
+ * target="_bank">SDO Execution Dependancies </a> </LI>
+ * <LI>Execute: <br>
+ * java org.apache.tuscany.samples.sdo.specExampleSection.SerializingDesearializingADataObject</LI>
+ * </UL>
+ *
+ * @author Robbie Minshall
+ */
+
+public class SerializingDesearializingADataObject {
+
+ /**
+ * 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) {
+ 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 {
+ // define Types using XSDHelper and predefined xsd file
+ System.out.println("Defining Types using XSD");
+ XSDHelper.INSTANCE.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 = XMLHelper.INSTANCE.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: " + EqualityHelper.INSTANCE.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 : " + EqualityHelper.INSTANCE.equalShallow(company, newDataObject));
+
+ //print out xml representation
+ System.out.println();
+ System.out.println("Original company DataObject:");
+ System.out.println(XMLHelper.INSTANCE.save(company, SdoSampleConstants.COMPANY_NAMESPACE, "company"));
+
+ System.out.println();
+ System.out.println("Deserialized company DataObject:");
+ System.out.println(XMLHelper.INSTANCE.save(newDataObject, SdoSampleConstants.COMPANY_NAMESPACE, "company"));
+
+ } catch (Exception e) {
+ System.out.println("Sorry there was an error encountered " + e.toString());
+ e.printStackTrace();
+ }
+
+ System.out.println("GoodBye");
+
+ }
+}
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/SerializingDesearializingADataObject.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java (added)
+++ incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java Wed Aug 16 06:56:30 2006
@@ -0,0 +1,187 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tuscany.samples.sdo.specExampleSection;
+
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.Property;
+
+import java.util.List;
+
+import org.apache.tuscany.samples.sdo.SdoSampleConstants;
+
+/**
+ * Demonstrates the use of Type and Property to display and the META-DATA for and access Properties of a DataObject.
+ * <br>
+ * 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 'Using Type and Property with DataObjects' example from the Examples section of the SDO specification. <br>
+ * <br>
+ * The Type interface provides access to the metadata for DataObjects. The methods on Type and Property provide information that describes the
+ * properties of a DataObject. To obtain the Type for a DataObject use the getType() method. This example prints out the contents of a DataObject,
+ * each property has it's meta-data displayed, accessed dynamically using Type and Property.<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 from directly from Tuscany and EMF projects or from <a
+ * href="http://wiki.apache.org/ws-data/attachments/Tuscany(2f)TuscanyJava(2f)SDO_Java_Overview/attachments/SDO%20Execution%20Dependencies"
+ * target="_bank">SDO Execution Dependancies </a> </LI>
+ * <LI>Execute: <br>
+ * java org.apache.tuscany.samples.sdo.specExampleSection.UsingTypeAndPropertyWithDataObjects</LI>
+ * </UL>
+ *
+ * @author Robbie Minshall
+ * @see org.apache.tuscany.samples.sdo.specCodeSnippets.PrintPropertiesOfDataObject
+ */
+
+public class UsingTypeAndPropertyWithDataObjects {
+
+ /**
+ * Execute this method in order to run the sample.
+ *
+ * @param args
+ */
+ public static void main(String[] args) {
+ System.out.println("***************************************");
+ System.out.println("SDO Sample UsingTypeAndPropertyWithDataObjects");
+ System.out.println("***************************************");
+ System.out.println("Demonstrates the use of Type and Property to display and the META-DATA for and access Properties of a DataObject.");
+ System.out.println("***************************************");
+
+ try {
+ // define Types using XSDHelper and predefined xsd file
+ System.out.println("Defining company Types using XSD");
+ XSDHelper.INSTANCE.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 = XMLHelper.INSTANCE.load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.COMPANY_DATAOBJECT_XML))
+ .getRootObject();
+
+ printDataObject(company, 0);
+
+ System.out.println("Defining purchase order types");
+ XSDHelper.INSTANCE.define(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.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 = XMLHelper.INSTANCE.load(ClassLoader.getSystemResourceAsStream(SdoSampleConstants.PO_XML_RESOURCE))
+ .getRootObject();
+
+ printDataObject(po, 0);
+
+
+
+
+
+
+
+ } catch (Exception e) {
+ System.out.println("Sorry there was an error encountered " + e.toString());
+ e.printStackTrace();
+ }
+ System.out.println("GoodBye");
+ }
+
+ /**
+ * Prints out the contents of a DataObject, each property has it's meta-data displayed, accessed dynamically using Type and Property.
+ * @param dataObject. DataObject to be printed.
+ * @param indent. For formatting
+ */
+ public static void printDataObject(DataObject dataObject, int indent) {
+ // For each Property
+ List properties = dataObject.getInstanceProperties();
+ for (int p = 0, size = properties.size(); p < size; p++) {
+ if (dataObject.isSet(p)) {
+ Property property = (Property) properties.get(p);
+ if (property.isMany()) {
+ // For many-valued properties, process a list of values
+ List values = dataObject.getList(p);
+ for (int v = 0, count = values.size(); v < count; v++) {
+ printValue(values.get(v), property, indent);
+ }
+ } else {
+ // For single-valued properties, print out the value
+ printValue(dataObject.get(p), property, indent);
+ }
+ }
+ }
+ }
+
+ /**
+ * Prints the value of a property
+ * @param value. Value of Property to be printed
+ * @param property. Property to be printed
+ * @param indent. For formatting
+ */
+ public static void printValue(Object value, Property property, int indent) {
+ // Get the name of the property
+ String propertyName = property.getName();
+ // Construct a string for the proper indentation
+ String margin = "";
+ for (int i = 0; i < indent; i++)
+ margin += "\t";
+ if (value != null && property.isContainment()) {
+ // For containment properties, display the value
+ // with printDataObject
+ Type type = property.getType();
+ String typeName = type.getName();
+ System.out.println(margin + propertyName + " (" + typeName + "):");
+ printDataObject((DataObject) value, indent + 1);
+ } else {
+ // For non-containment properties, just print the value
+ System.out.println(margin + propertyName + ": " + value);
+ }
+ }
+
+}
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/UsingTypeAndPropertyWithDataObjects.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/package.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/package.html?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/package.html (added)
+++ incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/package.html Wed Aug 16 06:56:30 2006
@@ -0,0 +1,24 @@
+<html>
+<head>
+ <title>package information</title>
+</head>
+<body>
+
+Provides samples from the Examples section of the SDO Specification. In general these samples attempt to use the
+code and comments contained within the specification, exceptions to this are noted in comments.
+ The user is encouraged to modify and execute these code examples.
+
+
+
+<h2>Related Documentation</h2>
+
+For overviews, tutorials, examples, guides, and tool documentation, please see:
+<ul>
+ <li>
+ <a href="http://download.boulder.ibm.com/ibmdl/pub/software/dw/specs/ws-sdo/SDO_Specification_Java_V2.01.pdf">SDO Specification</a>
+ </li>
+</ul>
+
+
+</body>
+</html>
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/org/apache/tuscany/samples/sdo/specExampleSection/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/tuscany/java/samples/sdo/src/main/java/overview.html
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/java/overview.html?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/java/overview.html (added)
+++ incubator/tuscany/java/samples/sdo/src/main/java/overview.html Wed Aug 16 06:56:30 2006
@@ -0,0 +1,70 @@
+<html>
+<head>
+ <title>SDO Sample Overview</title>
+</head>
+<body>
+<h2>Overview</h2>
+Tuscany, Service DataObject samples.
+The following packages are from the <a href="http://incubator.apache.org/tuscany"
+ target="_blank"> Apache Tuscany</a> project. They were written to help users
+understand and experiement with SDO. Some are based upon example code contained
+within, and is meant for use with, and reference to the <a
+ href="http://download.boulder.ibm.com/ibmdl/pub/software/dw/specs/ws-sdo/SDO_Specification_Java_V2.01.pdf"
+ target="_bank">SDO Specification</a>, others are based upon papers, and some were simply written
+ specifically for these samples.
+
+<H3>Experimentation</H3>
+The SDO samples are written to be used in conjunction with the specification and other documents. However,
+the most important function that these samples provide is a place to begin experimenting with the SDO API
+and programming model. Developers are encouraged to extend and experiment with the current set of samples.
+If a sample is unclear, is missing documentation or a tutorial, or does not cover a desired area people
+are encouraged to join the Tuscany team and contribute back to the project.
+
+
+<h3>Where to start</h3>
+In order to get an overview of the samples the user may wish to run {@link org.apache.tuscany.samples.sdo.ExecuteSamples} which will
+ execute all the command line examples. Another suggestion is to read the SDO specifciaton in conjunction with the examples in
+ {@link org.apache.tuscany.samples.sdo.specExampleSection}
+
+<h3>Usage</h3>
+
+These samples can be 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. For more information
+on setting up a Tuscany environment please refer to the following Guide :
+<a href="http://wiki.apache.org/ws/Tuscany/TuscanyJava/GetTuscany" target="_bank">Check out and build Tuscany</a>
+
+
+<br><br>
+Most of the samples can also be executed as a standalone application. In general you simply need to :
+
+ <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 from directly from Tuscany and EMF projects or from <a
+ href="http://wiki.apache.org/ws-data/attachments/Tuscany(2f)TuscanyJava(2f)SDO_Java_Overview/attachments/SDO%20Execution%20Dependencies"
+ target="_bank">SDO Execution Dependancies </a> </LI>
+ <LI>Include sample, and sample resources (i.e required xml files) on the classpath. You can simply place the SDO sample jar (i.e sample-sdo.jar),
+ or place any SDO sample/test code on your classpath </LI>
+ <LI>Execute: java desiredSample
+ <br><i>i.e java org.apache.tuscany.samples.sdo.ExecuteSamples</i>
+ </UL>
+
+</body>
+</html>
Propchange: incubator/tuscany/java/samples/sdo/src/main/java/overview.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/tuscany/java/samples/sdo/src/main/resources/company.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/company.xsd?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/company.xsd (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/company.xsd Wed Aug 16 06:56:30 2006
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <xsd:schema xmlns:company="company.xsd"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="company.xsd">
+ <xsd:element name="company" type="company:CompanyType"/>
+ <xsd:complexType name="CompanyType">
+ <xsd:sequence>
+ <xsd:element name="departments" type="company:DepartmentType" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="employeeOfTheMonth" type="xsd:string"/>
+ </xsd:complexType>
+ <xsd:complexType name="DepartmentType">
+ <xsd:sequence>
+ <xsd:element name="employees" type="company:EmployeeType" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="location" type="xsd:string"/>
+ <xsd:attribute name="number" type="xsd:int"/>
+ </xsd:complexType>
+ <xsd:complexType name="EmployeeType">
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="SN" type="xsd:ID"/>
+ <xsd:attribute name="manager" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:schema>
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/company.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/company.xsd
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/resources/companyCompleteDataGraph.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/companyCompleteDataGraph.xml?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/companyCompleteDataGraph.xml (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/companyCompleteDataGraph.xml Wed Aug 16 06:56:30 2006
@@ -0,0 +1,50 @@
+<sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+xmlns:company="company.xsd"
+xmlns:sdo="commonj.sdo">
+
+ <xsd>
+ <xsd:schema targetNamespace="company.xsd">
+ <xsd:element name="company" type="company:CompanyType" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:complexType name="CompanyType">
+ <xsd:sequence>
+ <xsd:element name="departments" type="company:DepartmentType" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="employeeOfTheMonth" type="xsd:string"/>
+ </xsd:complexType>
+ <xsd:complexType name="DepartmentType">
+ <xsd:sequence>
+ <xsd:element name="employees" type="company:EmployeeType" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="location" type="xsd:string"/>
+ <xsd:attribute name="number" type="xsd:int"/>
+ </xsd:complexType>
+ <xsd:complexType name="EmployeeType">
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="SN" type="xsd:ID"/>
+ <xsd:attribute name="manager" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:schema>
+ </xsd>
+
+ <changeSummary create="E0004" delete="E0002">
+ <company sdo:ref="#/company" name="ACME"
+ employeeOfTheMonth="E0002"/>
+ <departments sdo:ref="#/company/departments[1]">
+ <employees sdo:ref="E0001"/>
+ <employees name="Mary Smith" SN="E0002" manager="true"/>
+ <employees sdo:ref="E0003"/>
+ </departments>
+ </changeSummary>
+
+ <company:company name="MegaCorp" employeeOfTheMonth="E0004">
+ <departments name="Advanced Technologies" location="NY" number="123">
+ <employees name="John Jones" SN="E0001"/>
+ <employees name="Jane Doe" SN="E0003"/>
+ <employees name="Al Smith" SN="E0004" manager="true"/>
+ </departments>
+ </company:company>
+
+</sdo:datagraph>
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/companyCompleteDataGraph.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/companyCompleteDataGraph.xml
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraph.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraph.xml?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraph.xml (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraph.xml Wed Aug 16 06:56:30 2006
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="ASCII"?>
+<sdo:datagraph xmlns:company="company.xsd"
+ xmlns:sdo="commonj.sdo">
+ <company:company name="ACME" employeeOfTheMonth="E0002">
+ <departments name="Advanced Technologies" location="NY" number="123">
+ <employees name="John Jones" SN="E0001"/>
+ <employees name="Mary Smith" SN="E0002" manager="true"/>
+ <employees name="Jane Doe" SN="E0003"/>
+ </departments>
+ </company:company>
+</sdo:datagraph>
+
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraph.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraph.xml
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraphGenerated.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraphGenerated.xml?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraphGenerated.xml (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraphGenerated.xml Wed Aug 16 06:56:30 2006
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<sdo:datagraph xmlns:company="company.xsd" xmlns:sdo="commonj.sdo">
+ <company:CompanyType employeeOfTheMonth="E0002"
+ name="ACME">
+ <departments location="NY" name="Advanced Technologies" number="123">
+ <employees name="John Jones" SN="E0001"/>
+ <employees name="Jane Doe" SN="E0003"/>
+ <employees manager="true" name="Al Smith" SN="E0004"/>
+ </departments>
+ </company:CompanyType>
+</sdo:datagraph>
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraphGenerated.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/companyDataGraphGenerated.xml
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/resources/companyGenerated.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/companyGenerated.xml?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/companyGenerated.xml (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/companyGenerated.xml Wed Aug 16 06:56:30 2006
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="ASCII"?>
+<company:company xmlns:company="company.xsd" employeeOfTheMonth="E0001"
+ name="ACME">
+ <departments location="NY" name="Advanced Technologies" number="123">
+ <employees name="John Jones" SN="E0001"/>
+ <employees name="Jane Doe" SN="E0003"/>
+ <employees manager="true" name="A Varone" SN="E0004"/>
+ </departments>
+</company:company>
\ No newline at end of file
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/companyGenerated.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/companyGenerated.xml
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/resources/doc-files/cmdPrompt.GIF
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/doc-files/cmdPrompt.GIF?rev=431902&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/doc-files/cmdPrompt.GIF
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/tuscany/java/samples/sdo/src/main/resources/letter.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/letter.xml?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/letter.xml (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/letter.xml Wed Aug 16 06:56:30 2006
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="ASCII"?>
+<letter:letters xmlns:letter="letter.xsd"><date>August 1, 2003</date>Mutual of Omaha Wild Kingdom, USA Dear<firstName>Casy</firstName><lastName>Crocodile</lastName>Please buy more shark repellent. Your premium is past due.</letter:letters>
\ No newline at end of file
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/letter.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/letter.xml
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/resources/letter.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/letter.xsd?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/letter.xsd (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/letter.xsd Wed Aug 16 06:56:30 2006
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:letter="letter.xsd" targetNamespace="letter.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:element name="letters" type="letter:FormLetter"/>
+ <xsd:complexType name="FormLetter" mixed="true">
+ <xsd:sequence>
+ <xsd:element name="date" minOccurs="0" type="xsd:string"/>
+ <xsd:element name="firstName" minOccurs="0" type="xsd:string"/>
+ <xsd:element name="lastName" minOccurs="0" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+</xsd:schema>
+
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/letter.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/letter.xsd
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/resources/po.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/po.xml?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/po.xml (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/po.xml Wed Aug 16 06:56:30 2006
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ASCII"?>
+<PO:purchaseOrder xmlns:PO="http://www.example.com/PO" orderDate="1999-10-20">
+ <shipTo country="US">
+ <name>Robbie Minshall</name>
+ <street>123 Maple Street</street>
+ <city>Mill Valley</city>
+ <state>CA</state>
+ <zip>90952</zip>
+ </shipTo>
+ <billTo country="US">
+ <name>Robert Smith</name>
+ <street>8 Oak Avenue</street>
+ <city>Mill Valley</city>
+ <state>PA</state>
+ <zip>95819</zip>
+ </billTo>
+ <PO:comment>Hurry, my lawn is going wild!</PO:comment>
+ <items>
+ <item partNum="872-AA">
+ <productName>Lawnmower</productName>
+ <price>148.95</price>
+ <quantity>1</quantity>
+ <PO:comment>Confirm this is electric</PO:comment>
+ </item>
+ <item partNum="926-AA">
+ <productName>Baby Monitor</productName>
+ <price>39.98</price>
+ <quantity>1</quantity>
+ <shipDate>1999-05-21</shipDate>
+ </item>
+ <item partNum="876">
+ <productName>GrassSeed</productName>
+ <price>50</price>
+ <quantity>100</quantity>
+ <PO:comment>For Shade</PO:comment>
+ </item>
+ </items>
+</PO:purchaseOrder>
\ No newline at end of file
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/po.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/po.xml
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/java/samples/sdo/src/main/resources/po.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/samples/sdo/src/main/resources/po.xsd?rev=431902&view=auto
==============================================================================
--- incubator/tuscany/java/samples/sdo/src/main/resources/po.xsd (added)
+++ incubator/tuscany/java/samples/sdo/src/main/resources/po.xsd Wed Aug 16 06:56:30 2006
@@ -0,0 +1,62 @@
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="http://www.example.com/PO" targetNamespace="http://www.example.com/PO">
+
+ <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
+ <xsd:element name="comment" type="xsd:string"/>
+
+ <xsd:complexType name="PurchaseOrderType">
+ <xsd:sequence>
+ <xsd:element name="shipTo" type="USAddress"/>
+ <xsd:element name="billTo" type="USAddress"/>
+ <xsd:element ref="comment" minOccurs="0"/>
+ <xsd:element name="items" type="Items"/>
+
+ </xsd:sequence>
+ <xsd:attribute name="orderDate" type="xsd:date"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="USAddress">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+
+ <xsd:element name="street" type="xsd:string"/>
+ <xsd:element name="city" type="xsd:string"/>
+ <xsd:element name="state" type="xsd:string"/>
+ <xsd:element name="zip" type="xsd:decimal"/>
+ </xsd:sequence>
+ <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>
+
+ </xsd:complexType>
+
+ <xsd:complexType name="Items">
+ <xsd:sequence>
+ <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+
+ <xsd:element name="productName" type="xsd:string"/>
+ <xsd:element name="price" type="xsd:decimal"/>
+ <xsd:element name="quantity">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:positiveInteger">
+ <xsd:maxExclusive value="100"/>
+ </xsd:restriction>
+
+ </xsd:simpleType>
+ </xsd:element>
+ <xsd:element ref="comment" minOccurs="0"/>
+ <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
+ </xsd:sequence>
+
+ <xsd:attribute name="partNum" type="SKU" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:simpleType name="SKU">
+
+ <xsd:restriction base="xsd:string">
+ <xsd:pattern value="\d{3}-[A-Z]{2}"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:schema>
\ No newline at end of file
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/po.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/samples/sdo/src/main/resources/po.xsd
------------------------------------------------------------------------------
svn:keywords = Rev,Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org