diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 19:20:03 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 19:20:03 +0000 |
commit | 836328ea2ca7c6780307abf258503201c91e5a96 (patch) | |
tree | 1bb1b4a3af18e95389780d65ece875ba5ae93aff /branches/sdo-1.1.1-incubating/sample/src | |
parent | 2a444004802173fa97afbc389fc4a6600b6d3f88 (diff) |
moving SDO branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834615 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sdo-1.1.1-incubating/sample/src')
41 files changed, 0 insertions, 5263 deletions
diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples.java deleted file mode 100644 index 02bce0efe6..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/ExecuteSamples.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - - -/** - * A program to execute a sequence of SDO sample programs. The program executes - * the sample programs listed in the {@link SampleInfrastructure#sampleClasses sample classes} - * static constant. These samples are executed in roughly increasing order of complexity. - * You can edit the {@link #pauseBetweenSamples}, {@link #runSamplesUpToLevel} and - * {@link #constructorArgs} variables to change the way this program executes the samples. - * - * <P> - * Each of the samples creates text output to the console. If the commentary - * level in {@link #constructorArgs the sample program constructor arguments} - * used to construct each sample is set to - * {@link SampleInfrastructure#COMMENTARY_FOR_NOVICE COMMENTARY_FOR_NOVICE} then there - * will be much more output than if set to one of the other values. - * - */ -public class ExecuteSamples extends SampleBase { - - /** - * Edit this value to cause the program to pause between each sample program - * and wait for the user to hit the enter key. - */ - private static final boolean pauseBetweenSamples = true; - - /** - * By default run all samples from novice level right up to advanced level. - * Edit this to run fewer samples. - */ - private static final int runSamplesUpToLevel = SampleInfrastructure.SAMPLE_LEVEL_ADVANCED.intValue(); - - /** - * Edit the value of this argument to one of COMMENTARY_FOR_NOVICE, COMMENTARY_FOR_INTERMEDIATE or COMMENTARY_FOR_ADVANCED to see - * more or less commentary. Note, this value only controls the level of commentary, - * not which samples are executed. Use it to filter out the noise if you have already - * understood the more basic commentary. - */ - private static final Object[] constructorArgs = { SampleInfrastructure.COMMENTARY_FOR_NOVICE }; - - - public static void main(String [] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException, IOException { - ExecuteSamples sample = new ExecuteSamples(COMMENTARY_FOR_NOVICE); - sample.run(); - } - - public ExecuteSamples(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_BASIC); - } - - public void runSample() throws Exception { - Class[] constructorArgTypes = { Integer.class }; - - - BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); - - int sampleCount = 0; - for (int i=0; i < SampleInfrastructure.sampleClasses.length; i++) { - Constructor c = SampleInfrastructure.sampleClasses[i].getConstructor(constructorArgTypes); - SampleBase sample = (SampleBase)c.newInstance(constructorArgs); - if(sample.getSampleComplexityLevel() <= runSamplesUpToLevel) { - sample.run(); - sampleCount++; - if(pauseBetweenSamples) { - System.out.println(">>>Press Enter to continue"); - in.readLine(); - } - } - } - System.out.println("Ran " + sampleCount + " samples"); - } -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java deleted file mode 100644 index 3b4aba2b42..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; - -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; -import org.apache.tuscany.sdo.api.SDOUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.XMLDocument; -import commonj.sdo.helper.XSDHelper; -import commonj.sdo.impl.HelperProvider; - -/** - * the base function for samples is split into two classes. This one is intended - * to house all the interesting SDO utility methods, and the superclass houses - * all the infrastructure that the SDO user isn't interested in inspecting. - */ -public abstract class SampleBase extends SampleInfrastructure { - - - public SampleBase() - { - super(COMMENTARY_FOR_NOVICE); - } - - - public SampleBase(Integer commentaryLevel, Integer sampLevel) { - super(commentaryLevel, sampLevel); - } - - protected HelperContext createScopeForTypes() { - commentary( - COMMENTARY_FOR_NOVICE, - "All MetaData for SDO types can be viewed as being scoped within an instance of HelperContext\n" + - "The Helper Context instance provides access to a collection of other helpers\n" + - "that you will see exercised in the SDO samples\n" + - "All the Helpers related to a given helper context instance know about the same set of types\n\n" + - "The SDO specification doesn't state how an SDO implementation should create a HelperContext\n" + - "So we use a Tuscany specific API to do this ...\n\n" + - "HelperContext scope = SDOUtil.createHelperContext();", - - "Creating a new HelperContext scope for types for the next sample run as we did in previous samples" - ); - - HelperContext scope = SDOUtil.createHelperContext(); - return scope; - } - - protected HelperContext useDefaultScopeForTypes() { - commentary( - COMMENTARY_FOR_NOVICE, - "All MetaData for SDO types can be viewed as being held in an instance of HelperContext\n" + - "The Helper Context instance provides access to a collection of other helpers\n" + - "that you will see exercised in the SDO samples\n" + - "All the Helpers related to a given helper context instance know about the same set of types\n\n" + - "For most cases it's best to take control of the type scope by creating a new HelperContext,\n" + - "but a default helper context is provided and can be accessed using ...\n\n" + - "HelperContext scope = HelperProvider.getDefaultContext();\n\n" + - "A case in point where the default scope must be used is when using some of the DataGraph APIs\n" + - "which don't all support the type scoping extensions which were introduced in the SDO 2.1 specification", - - "Retrieving the default HelperContext scope for types for the next sample run as we saw in a previous sample" - ); - - HelperContext scope = HelperProvider.getDefaultContext(); - return scope; - } - - - protected void loadTypesFromXMLSchemaFile(HelperContext scope, String fileName) { - commentary(COMMENTARY_FOR_NOVICE, - "If you want to create types dynamically by loading an XML schema you\n" + - "use an instance of XSDHelper. You get that helper from a HelperContext.\n" + - "After successful loading of a schema, the new types are available to every\n" + - "other helper belonging to the HelperContext instance\n\n" + - "XSDHelper xsdHelper = scope.getXSDHelper();\n"+ - "xsdHelper.define(inputStream, null);", - - "Using an XSDHelper again to create types from an XML schema file as we saw in a previous sample" - ); - - XSDHelper xsdHelper = scope.getXSDHelper(); - - InputStream is = null; - try { - - URL url = getClass().getResource("/"+fileName); - is = url.openStream(); - xsdHelper.define(is, url.toString()); - - } catch (Exception e) { - somethingUnexpectedHasHappened(e); - } finally { - try { - is.close(); - } catch (Exception e) { - somethingUnexpectedHasHappened(e); - } - } - } - - public DataObject getDataObjectFromFile(HelperContext scope, String filename) - throws Exception { - - - XMLDocument xmlDoc = getXMLDocumentFromFile(scope, filename); - commentary(COMMENTARY_FOR_NOVICE, - "An XMLDocument instance provides a wrapper for the root DataObject of a data graph\n" + - "along with other aspects of the XML nature of the document\n\n"+ - "DataObject result = xmlDoc.getRootObject();", - - "Getting the root object from an XMLDocument as seen in previous samples" - ); - DataObject result = xmlDoc.getRootObject(); - - return result; - } - - public XMLDocument getXMLDocumentFromFile(HelperContext scope, - String filename) throws Exception { - - XMLDocument result = null; - InputStream is = null; - - try { - commentary(COMMENTARY_FOR_NOVICE, - "The XMLHelper can be used to create an SDO XMLDocument instance from a file\n\n"+ - "inputStream = ClassLoader.getSystemResourceAsStream(filename);\n"+ - "result = scope.getXMLHelper().load(is);", - - "Getting an XMLDocument instance from an XML file as seen in previous samples" - ); - is = ClassLoader.getSystemResourceAsStream(filename); - result = scope.getXMLHelper().load(is); - - } catch (Exception e) { - somethingUnexpectedHasHappened(e); - } finally { - try { - is.close(); - } catch (Exception e) { - somethingUnexpectedHasHappened(e); - } - } - - return result; - } - - protected XMLDocument getXMLDocumentFromString(HelperContext scope, String xmlDoc) throws IOException { - XMLDocument result = null; - InputStream is = null; - - - commentary(COMMENTARY_FOR_NOVICE, - "The XMLHelper can be used to create an SDO XMLDocument instance from an\n\n"+ - "inputStream = new ByteArrayInputStream(xmlDoc.getBytes());\n"+ - "result = scope.getXMLHelper().load(is);", - - "Getting an XMLDocument instance from an XML file as seen in previous samples" - ); - - is = new ByteArrayInputStream(xmlDoc.getBytes()); - result = scope.getXMLHelper().load(is); - - return result; - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenario.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenario.java deleted file mode 100644 index 916fe9405c..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenario.java +++ /dev/null @@ -1,424 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.advanced; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.sdo.api.SDOUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Type; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.TypeHelper; - -/** - * This sample is based on a 2 part article by Kelvin Goodson and Geoffrey Winn. - * See <A href="http://soa.sys-con.com/read/313547.htm">Part1</A> and <A - * href="http://soa.sys-con.com/read/358059.htm">Part 2</A> of the article. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class MedicalScenario extends SampleBase { - - private static final String sdoApiUri = "commonj.sdo"; - - private static final String peopleURI = "www.example.org/people"; - - private static final String medicalURI = "www.example.org/MedicalTest"; - - boolean typesViaAPI = false; - - private static final String usage = " [-api |-xsd]\n" - + " -api : define the types using the SDO API\n" - + " -xsd : define the types using an XML schema file"; - - public MedicalScenario(String[] args, Integer userLevel) { - - super(userLevel, SAMPLE_LEVEL_ADVANCED); - - if (args.length > 1) { - printUsage(args); - System.exit(-1); - } - if (args.length == 1) { - if (args[0].equals("-xsd")) { - typesViaAPI = false; - } else if (args[0].equals("-api")) { - typesViaAPI = true; - } else { - printUsage(args); - System.exit(-1); - } - } - } - - public MedicalScenario(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_ADVANCED); - } - - - private void printUsage(String[] args) { - System.out.println("Usage: " + this.getClass().getName() + usage); - } - - /** - * @param args - * @throws Exception - */ - public static void main(String[] args) throws Exception { - - MedicalScenario s = new MedicalScenario(args, COMMENTARY_FOR_NOVICE); - s.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.CONTAINMENT, - SDOFacets.CREATE_TYPES_USING_THE_SDO_API, - SDOFacets.CREATE_TYPES_USING_XML_SCHEMA, - SDOFacets.OPEN_CONTENT, - SDOFacets.NON_CONTAINMENT - }; - - public static int [] SIGNIFICANT_FUNCTION = { - SDOFacets.CREATE_DATAOBJECTS_BY_NAME, - SDOFacets.ISMANY_PROPERTIES, - SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL, - SDOFacets.SAVING_DATA_TO_XML - }; - - public void runSample() throws Exception { - - HelperContext scope = SDOUtil.createHelperContext(); - - if (typesViaAPI) { - - commentary("In this execution of the sample we use Types created\n" - + "using the SDO API"); - - createTypesViaAPI(scope); - - } else { - - commentary("In this execution of the sample we use Types created\n" - + "by loading an XMLSchema"); - - loadTypesFromXMLSchemaFile(scope, "MedicalTest.xsd"); - - } - - commentary( - COMMENTARY_FOR_NOVICE, - "The DataFactory associated with the scope that the types were created within\n" - + "can be used to create an instance of the Person Type\n\n" - + "DataFactory dataFactory = scope.getDataFactory();\n" - + "DataObject person1 = dataFactory.create(\"www.example.org/people\", \"Person\");"); - - DataFactory dataFactory = scope.getDataFactory(); - DataObject person1 = dataFactory.create("www.example.org/people", "Person"); - - commentary("The setString() of dataObject method is used to set the properties of the\n" - + "new Person DataObject, including a unique identifier reference value\n" - + "for the Person instance.\n\n" - + "person1.setString(\"id\", \"1\");\n" - + "person1.setString(\"name\", \"Joe Johnson Snr.\");\n" - + "person1.setString(\"gender\", \"male\"););"); - - person1.setString("id", "1"); - person1.setString("name", "Joe Johnson Snr."); - person1.setString("gender", "male"); - - commentary("An alternative approach to using the DataFactory directly to create\n" - + "all DataObjects is to use a top-down approach, where we create the\n" - + "root object for a data graph, and then use the createDataObject(String propertyName)\n" - + "method to create the contained DataObjects. Here we create the overall\n" - + "medical test DataObject, and then create the contained \"referrals\" DataObject\n\n" - + "DataObject test = dataFactory.create(\"www.example.org/MedicalTest\", \"Test\");\n" - + "DataObject referrals = test.createDataObject(\"referrals\");"); - - DataObject test = dataFactory.create("www.example.org/MedicalTest", "Test"); - DataObject referrals = test.createDataObject("referrals"); - - commentary("Now we can add the person we created earlier into the set of people who have\n" - + "been referred for this medical test.\n\n" - + "test.set(\"referrals\", referrals);\n" - + "referrals.getList(\"person\").add(person1);"); - - test.set("referrals", referrals); - referrals.getList("person").add(person1); - - commentary("Let's take a look at how the current state of the data" - + "graph is rendered in XML ..."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("The scenario unfolds and the Joe Johnson Snr. becomes a patient\n\n" - + "DataObject patients = test.createDataObject(\"patients\");\n" - + "patients.getList(\"person\").add(person1);"); - - DataObject patients = test.createDataObject("patients"); - - patients.getList("person").add(person1); - - commentary("Having added Joe Johnson Snr. to the set of patients we can see\n" - + "the way that SDO preserves a single containment hierarchy within a\n" - + "datagraph. If we look at the XML rendering of the graph again, we will\n" - + "see that by adding him to the set of patients he has been removed from the\n" - + "containment property associated with the referrals set ..."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("The 'Person' Type we are making use of here has been designed to be\n" - + "multi-purpose, in that the type has been declared to be 'Open'.\n" - + "That means that we can make use of 'Open Content' Properties\n" - + "(If the type system has been defined using an XML schema\n" - + "then these properties will derive from global elements)\n" - + "We can look up open content Properties using the TypeHelper\n\n" - + "Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(\n" - + " \"www.example.org/MedicalTest\", \"condition\");"); - - Property conditionProperty = scope.getTypeHelper().getOpenContentProperty( - "www.example.org/MedicalTest", "condition"); - - commentary("We can create a value of the appropriate Type for this open\n" - + "content Property\n\n" - + "DataObject condition = dataFactory.create(conditionProperty.getType());\n" - + "condition.setString(\"name\", \"Panar Syndrome\");"); - - DataObject condition = dataFactory.create(conditionProperty.getType()); - condition.setString("name", "Panar Syndrome"); - - commentary("If you ask a DataObject that has an 'Open' Type for its list of\n" - + "values associated with an open content Property, and the DataObject\n" - + "doesn't currently have any values for the Property, it will return\n" - + "an empty list. We can use the list to add values for the Property\n\n" - + "List conditions = person1.getList(conditionProperty);\n" - + "conditions.add(condition);"); - - List conditions = person1.getList(conditionProperty); - conditions.add(condition); - - commentary("A further look at the data graph in XML form shows\n" - + "the presence of the new condition Property's value ..."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("Having looked at the way SDO handles Open content\n" - + "We now turn our attention to 'non-containment' relationships.\n" - + "To do this we first create the set of people in the test that\n" - + "constitute the blood relatives of patients -- 'relatives'\n" - + "and define a new person to be Joe Johnson Snr's child.\n\n" - + "DataObject relatives = test.createDataObject(\"relatives\");\n" - + "DataObject person2 = relatives.createDataObject(\"person\");\n" - + "person2.setString(\"id\", \"2\");\n" - + "person2.setString(\"name\", \"Joe Johnson Jnr.\");\n" - + "person2.setString(\"gender\", \"male\");"); - - DataObject relatives = test.createDataObject("relatives"); - DataObject person2 = relatives.createDataObject("person"); - - person2.setString("id", "2"); - person2.setString("name", "Joe Johnson Jnr."); - person2.setString("gender", "male"); - - commentary("Another quick look at the XML rendering of the graph confirms that\n" - + "the set of relatives now includes Joe Johnson Jnr, but we haven't yet\n" - + "defined who he is related to, or how."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("The Person type has a Property 'relative'\n" - + "so we create a relative for Joe Johnson Snr.\n\n" - + "DataObject relation = person1.createDataObject(\"relative\");\n" - + "relation.set(\"target\", person2);\n" - + "relation.set(\"relationship\", \"child\");"); - - DataObject relation = person1.createDataObject("relative"); - relation.set("target", person2); - relation.set("relationship", "child"); - - commentary("Now when we look at the XML rendering of the data graph\n" - + "we can see that the action of setting the 'target' of the\n" - + "relationship to Joe Johnson Jnr didn't displace him from the\n" - + "set of 'relatives', because the 'target' Property is a\n" - + "non-containment Property. This non-containment relationship\n" - + "is reflected in the XML by a reference to the Person DataObject\n" - + "describing Joe Johnson Jnr, \"2\" ...\n" - + "If the Type system has been created from an XML schema then the\n" - + "unique ID of the target can be used in the serialization.\n" - + "If however the type system was defined dynamically, then the reference\n" - + "will be represented as an XPath from the root of the data graph."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("Now that the graph is complete we can use the PrintDataGraph sample utility\n" + - "to reveal the full SDO nature of the final data graph\n\n" + - ""); - - PrintDataGraph printer = new PrintDataGraph(COMMENTARY_FOR_ADVANCED); - printer.printDataObject(test); - System.out.println(printer.getBuf()); - } - - /** - * @throws Exception - * @throws FileNotFoundException - */ - private void createTypesViaAPI(HelperContext scope) throws Exception { - - List typeDeclarations = new ArrayList(); - - TypeHelper typeHelper = scope.getTypeHelper(); - - Type stringType = typeHelper.getType(sdoApiUri, "String"); - Type dateType = typeHelper.getType(sdoApiUri, "Date"); - Type booleanType = typeHelper.getType(sdoApiUri, "Boolean"); - - // <complexType name="Person"> - // <sequence> - // <element name="dob" type="date"/> - // <element name="relative" maxOccurs="unbounded" type="tns:Relative"/> - // <any namespace="##other" processContents="lax" maxOccurs="unbounded"/> - // </sequence> - // <attribute name="id" type="ID"/> - // <attribute name="name" type="string"/> - // <attribute name="gender" type = "tns:Gender"/> - // </complexType> - - DataObject personTypeDesc = createTypeDescription(scope, peopleURI, - "Person"); - typeDeclarations.add(personTypeDesc); - - addPropertyDescription(personTypeDesc, stringType, "name"); - addPropertyDescription(personTypeDesc, dateType, "dob"); - addPropertyDescription(personTypeDesc, stringType, "id"); // set to unique - // identifier? - addPropertyDescription(personTypeDesc, stringType, "gender"); // restrict? - - DataObject relativeType = createTypeDescription(scope, peopleURI, - "Relative"); // forward declare the Relative type - typeDeclarations.add(relativeType); - - DataObject rp = addPropertyDescription(personTypeDesc, relativeType, - "relative"); - rp.setBoolean("many", true); - personTypeDesc.set("open", Boolean.TRUE); - - // <complexType name="Relative"> - // <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person" - // use="required"/> - // <attribute name="relationship" type="string" /> - // <attribute name="genetic" use="optional" type="boolean"/> - // </complexType> - - addPropertyDescription(relativeType, stringType, "relationship"); - addPropertyDescription(relativeType, booleanType, "genetic"); - DataObject targetPersonProp = addPropertyDescription(relativeType, - personTypeDesc, "target"); - targetPersonProp.setBoolean("containment", false); - - // <complexType name="PersonSet"> - // <sequence> - // <element name="person" type="tns:Person" maxOccurs="unbounded"/> - // </sequence> - // </complexType> - - DataObject pSet = createTypeDescription(scope, peopleURI, "PersonSet"); - typeDeclarations.add(pSet); - DataObject pSetProperty = addPropertyDescription(pSet, personTypeDesc, - "person"); - pSetProperty.setBoolean("many", true); - - // <complexType name="Condition"> - // <sequence> - // <element name="diagnosed" type="date" /> - // </sequence> - // <attribute name="name" type="tns:ConditionName" /> - // </complexType> - - DataObject condition = createTypeDescription(scope, medicalURI, "Condition"); - typeDeclarations.add(condition); - addPropertyDescription(condition, booleanType, "diagnosed"); - addPropertyDescription(condition, stringType, "name"); // constrain? - - // <complexType name="Test"> - // <sequence> - // <element name="referrals" type="people:PersonSet" /> - // <element name="patients" type="people:PersonSet" /> - // <element name="relatives" type="people:PersonSet" /> - // </sequence> - // </complexType> - - DataObject testType = createTypeDescription(scope, medicalURI, "Test"); - typeDeclarations.add(testType); - addPropertyDescription(testType, pSet, "referrals"); - addPropertyDescription(testType, pSet, "patients"); - addPropertyDescription(testType, pSet, "relatives"); - - List types = typeHelper.define(typeDeclarations); - - DataObject p = scope.getDataFactory().create("commonj.sdo", "Property"); - p.set("type", typeHelper.getType(medicalURI, "Condition")); - p.set("name", "condition"); - p.setBoolean("many", true); - p.setBoolean("containment", true); // why is this not the default? - - typeHelper.defineOpenContentProperty(medicalURI, p); - - } - - /** - * @param uri - * @param name - * @return - */ - private DataObject createTypeDescription(HelperContext scope, String uri, - String name) { - DataObject typeDesc = scope.getDataFactory().create(sdoApiUri, "Type"); - typeDesc.set("name", name); - typeDesc.set("uri", uri); - return typeDesc; - } - - private DataObject addPropertyDescription( - DataObject containerTypeDescription, Object propertyType, - String propertyName) { - DataObject property = containerTypeDescription.createDataObject("property"); - property.set("type", propertyType); - property.setString("name", propertyName); - property.setBoolean("containment", true); - return property; - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenarioWithChangeMonitoring.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenarioWithChangeMonitoring.java deleted file mode 100644 index 32d63f4335..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenarioWithChangeMonitoring.java +++ /dev/null @@ -1,449 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.advanced; - -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.sdo.api.SDOUtil; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Type; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.TypeHelper; - -/** - * This sample is based on a 2 part article by Kelvin Goodson and Geoffrey Winn. - * In this variant of the sample the model for the test includes change monitoring. - * The facility for undoing changes on the basis of the change monitoring is - * demonstrated. - * See <A href="http://soa.sys-con.com/read/313547.htm">Part1</A> and <A - * href="http://soa.sys-con.com/read/358059.htm">Part 2</A> of the article. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class MedicalScenarioWithChangeMonitoring extends SampleBase { - - private static final String sdoApiUri = "commonj.sdo"; - - private static final String peopleURI = "www.example.org/people"; - - private static final String medicalURI = "www.example.org/MedicalTest"; - - boolean typesViaAPI = false; - - private static final String usage = " [-api |-xsd]\n" - + " -api : define the types using the SDO API\n" - + " -xsd : define the types using an XML schema file"; - - public MedicalScenarioWithChangeMonitoring(String[] args, Integer userLevel) { - - super(userLevel, SAMPLE_LEVEL_ADVANCED); - - if (args.length > 1) { - printUsage(args); - System.exit(-1); - } - if (args.length == 1) { - if (args[0].equals("-xsd")) { - typesViaAPI = false; - } else if (args[0].equals("-api")) { - typesViaAPI = true; - } else { - printUsage(args); - System.exit(-1); - } - } - } - - public MedicalScenarioWithChangeMonitoring(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_ADVANCED); - } - - - private void printUsage(String[] args) { - System.out.println("Usage: " + this.getClass().getName() + usage); - } - - /** - * @param args - * @throws Exception - */ - public static void main(String[] args) throws Exception { - - MedicalScenarioWithChangeMonitoring s = new MedicalScenarioWithChangeMonitoring(args, COMMENTARY_FOR_NOVICE); - s.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.CONTAINMENT, - SDOFacets.CREATE_TYPES_USING_THE_SDO_API, - SDOFacets.CREATE_TYPES_USING_XML_SCHEMA, - SDOFacets.OPEN_CONTENT, - SDOFacets.NON_CONTAINMENT, - SDOFacets.CHANGE_MONITORING_USING_A_CHANGESUMMARY_PROPERTY_ON_A_DATAOBJECT - }; - - public static int [] SIGNIFICANT_FUNCTION = { - SDOFacets.CREATE_DATAOBJECTS_BY_NAME, - SDOFacets.ISMANY_PROPERTIES, - SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL, - SDOFacets.SAVING_DATA_TO_XML - }; - - public void runSample() throws Exception { - - HelperContext scope = SDOUtil.createHelperContext(); - - if (typesViaAPI) { - - commentary("In this execution of the sample we use Types created\n" - + "using the SDO API"); - - createTypesViaAPI(scope); - - } else { - - commentary("In this execution of the sample we use Types created\n" - + "by loading a variant of the XMLSchema that includes a change summary Property"); - - loadTypesFromXMLSchemaFile(scope, "MedicalTest_CS.xsd"); - - } - - commentary( - COMMENTARY_FOR_NOVICE, - "The DataFactory associated with the scope that the types were created within\n" - + "can be used to create an instance of the Person Type\n\n" - + "DataFactory dataFactory = scope.getDataFactory();\n" - + "DataObject person1 = dataFactory.create(\"www.example.org/people\", \"Person\");"); - - DataFactory dataFactory = scope.getDataFactory(); - DataObject person1 = dataFactory.create("www.example.org/people", "Person"); - - commentary("The setString() of dataObject method is used to set the properties of the\n" - + "new Person DataObject, including a unique identifier reference value\n" - + "for the Person instance.\n\n" - + "person1.setString(\"id\", \"1\");\n" - + "person1.setString(\"name\", \"Joe Johnson Snr.\");\n" - + "person1.setString(\"gender\", \"male\"););"); - - person1.setString("id", "1"); - person1.setString("name", "Joe Johnson Snr."); - person1.setString("gender", "male"); - - commentary("An alternative approach to using the DataFactory directly to create\n" - + "all DataObjects is to use a top-down approach, where we create the\n" - + "root object for a data graph, and then use the createDataObject(String propertyName)\n" - + "method to create the contained DataObjects. Here we create the overall\n" - + "medical test DataObject, and then create the contained \"referrals\" DataObject\n\n" - + "DataObject test = dataFactory.create(\"www.example.org/MedicalTest\", \"Test\");\n" - + "DataObject referrals = test.createDataObject(\"referrals\");"); - - DataObject test = dataFactory.create("www.example.org/MedicalTest", "Test"); - - DataObject referrals = test.createDataObject("referrals"); - - commentary("The default state for monitoring changes for the DataObject when created in this\n" + - "way is the monitoring is switched off, so we switch it on. (Note that if you\n" + - "get your data graphs from a data Access Service then this service may turn on\n" + - "change monitoring be default\n\n" + - "test.getChangeSummary().beginLogging();"); - test.getChangeSummary().beginLogging(); - - commentary("We'll repeat the whole of the MedicalScenario sample, but then at the \n" + - "last minute we'll decide it was all wrong and roll back the changes......"); - - commentary("Now we can add the person we created earlier into the set of people who have\n" - + "been referred for this medical test.\n\n" - + "test.set(\"referrals\", referrals);\n" - + "referrals.getList(\"person\").add(person1);"); - - test.set("referrals", referrals); - referrals.getList("person").add(person1); - - commentary("Let's take a look at how the current state of the data" - + "graph is rendered in XML ..."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("The scenario unfolds and the Joe Johnson Snr. becomes a patient\n\n" - + "DataObject patients = test.createDataObject(\"patients\");\n" - + "patients.getList(\"person\").add(person1);"); - - DataObject patients = test.createDataObject("patients"); - - patients.getList("person").add(person1); - - commentary("Having added Joe Johnson Snr. to the set of patients we can see\n" - + "the way that SDO preserves a single containment hierarchy within a\n" - + "datagraph. If we look at the XML rendering of the graph again, we will\n" - + "see that by adding him to the set of patients he has been removed from the\n" - + "containment property associated with the referrals set ..."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("The 'Person' Type we are making use of here has been designed to be\n" - + "multi-purpose, in that the type has been declared to be 'Open'.\n" - + "That means that we can make use of 'Open Content' Properties\n" - + "(If the type system has been defined using an XML schema\n" - + "then these properties will derive from global elements)\n" - + "We can look up open content Properties using the TypeHelper\n\n" - + "Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(\n" - + " \"www.example.org/MedicalTest\", \"condition\");"); - - Property conditionProperty = scope.getTypeHelper().getOpenContentProperty( - "www.example.org/MedicalTest", "condition"); - - commentary("We can create a value of the appropriate Type for this open\n" - + "content Property\n\n" - + "DataObject condition = dataFactory.create(conditionProperty.getType());\n" - + "condition.setString(\"name\", \"Panar Syndrome\");"); - - DataObject condition = dataFactory.create(conditionProperty.getType()); - condition.setString("name", "Panar Syndrome"); - - commentary("If you ask a DataObject that has an 'Open' Type for its list of\n" - + "values associated with an open content Property, and the DataObject\n" - + "doesn't currently have any values for the Property, it will return\n" - + "an empty list. We can use the list to add values for the Property\n\n" - + "List conditions = person1.getList(conditionProperty);\n" - + "conditions.add(condition);"); - - List conditions = person1.getList(conditionProperty); - conditions.add(condition); - - commentary("A further look at the data graph in XML form shows\n" - + "the presence of the new condition Property's value ..."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("Having looked at the way SDO handles Open content\n" - + "We now turn our attention to 'non-containment' relationships.\n" - + "To do this we first create the set of people in the test that\n" - + "constitute the blood relatives of patients -- 'relatives'\n" - + "and define a new person to be Joe Johnson Snr's child.\n\n" - + "DataObject relatives = test.createDataObject(\"relatives\");\n" - + "DataObject person2 = relatives.createDataObject(\"person\");\n" - + "person2.setString(\"id\", \"2\");\n" - + "person2.setString(\"name\", \"Joe Johnson Jnr.\");\n" - + "person2.setString(\"gender\", \"male\");"); - - DataObject relatives = test.createDataObject("relatives"); - DataObject person2 = relatives.createDataObject("person"); - - person2.setString("id", "2"); - person2.setString("name", "Joe Johnson Jnr."); - person2.setString("gender", "male"); - - commentary("Another quick look at the XML rendering of the graph confirms that\n" - + "the set of relatives now includes Joe Johnson Jnr, but we haven't yet\n" - + "defined who he is related to, or how."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("The Person type has a Property 'relative'\n" - + "so we create a relative for Joe Johnson Snr.\n\n" - + "DataObject relation = person1.createDataObject(\"relative\");\n" - + "relation.set(\"target\", person2);\n" - + "relation.set(\"relationship\", \"child\");"); - - DataObject relation = person1.createDataObject("relative"); - relation.set("target", person2); - relation.set("relationship", "child"); - - commentary("Now when we look at the XML rendering of the data graph\n" - + "we can see that the action of setting the 'target' of the\n" - + "relationship to Joe Johnson Jnr didn't displace him from the\n" - + "set of 'relatives', because the 'target' Property is a\n" - + "non-containment Property. This non-containment relationship\n" - + "is reflected in the XML by a reference to the Person DataObject\n" - + "describing Joe Johnson Jnr, \"2\" ...\n" - + "If the Type system has been created from an XML schema then the\n" - + "unique ID of the target can be used in the serialization.\n" - + "If however the type system was defined dynamically, then the reference\n" - + "will be represented as an XPath from the root of the data graph."); - - System.out.println(scope.getXMLHelper().save(test, - "www.example.org/MedicalTest", "test")); - - commentary("Now that the graph is complete we can use the PrintDataGraph sample utility\n" + - "to reveal the full SDO nature of the final data graph\n\n" + - ""); - - PrintDataGraph printer = new PrintDataGraph(COMMENTARY_FOR_ADVANCED); - printer.printDataObject(test); - System.out.println(printer.getBuf()); - - commentary("But Wait! it's all wrong. Let's go back to our checkpoint where we started monitoring changes\n\n" + - "test.getChangeSummary().undoChanges();"); - - test.getChangeSummary().undoChanges(); - - printer.reset(); - printer.printDataObject(test); - System.out.println(printer.getBuf()); - - } - - /** - * @throws Exception - * @throws FileNotFoundException - */ - private void createTypesViaAPI(HelperContext scope) throws Exception { - - List typeDeclarations = new ArrayList(); - - TypeHelper typeHelper = scope.getTypeHelper(); - - Type stringType = typeHelper.getType(sdoApiUri, "String"); - Type dateType = typeHelper.getType(sdoApiUri, "Date"); - Type booleanType = typeHelper.getType(sdoApiUri, "Boolean"); - - // <complexType name="Person"> - // <sequence> - // <element name="dob" type="date"/> - // <element name="relative" maxOccurs="unbounded" type="tns:Relative"/> - // <any namespace="##other" processContents="lax" maxOccurs="unbounded"/> - // </sequence> - // <attribute name="id" type="ID"/> - // <attribute name="name" type="string"/> - // <attribute name="gender" type = "tns:Gender"/> - // </complexType> - - DataObject personTypeDesc = createTypeDescription(scope, peopleURI, - "Person"); - typeDeclarations.add(personTypeDesc); - - addPropertyDescription(personTypeDesc, stringType, "name"); - addPropertyDescription(personTypeDesc, dateType, "dob"); - addPropertyDescription(personTypeDesc, stringType, "id"); // set to unique - // identifier? - addPropertyDescription(personTypeDesc, stringType, "gender"); // restrict? - - DataObject relativeType = createTypeDescription(scope, peopleURI, - "Relative"); // forward declare the Relative type - typeDeclarations.add(relativeType); - - DataObject rp = addPropertyDescription(personTypeDesc, relativeType, - "relative"); - rp.setBoolean("many", true); - personTypeDesc.set("open", Boolean.TRUE); - - // <complexType name="Relative"> - // <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person" - // use="required"/> - // <attribute name="relationship" type="string" /> - // <attribute name="genetic" use="optional" type="boolean"/> - // </complexType> - - addPropertyDescription(relativeType, stringType, "relationship"); - addPropertyDescription(relativeType, booleanType, "genetic"); - DataObject targetPersonProp = addPropertyDescription(relativeType, - personTypeDesc, "target"); - targetPersonProp.setBoolean("containment", false); - - // <complexType name="PersonSet"> - // <sequence> - // <element name="person" type="tns:Person" maxOccurs="unbounded"/> - // </sequence> - // </complexType> - - DataObject pSet = createTypeDescription(scope, peopleURI, "PersonSet"); - typeDeclarations.add(pSet); - DataObject pSetProperty = addPropertyDescription(pSet, personTypeDesc, - "person"); - pSetProperty.setBoolean("many", true); - - // <complexType name="Condition"> - // <sequence> - // <element name="diagnosed" type="date" /> - // </sequence> - // <attribute name="name" type="tns:ConditionName" /> - // </complexType> - - DataObject condition = createTypeDescription(scope, medicalURI, "Condition"); - typeDeclarations.add(condition); - addPropertyDescription(condition, booleanType, "diagnosed"); - addPropertyDescription(condition, stringType, "name"); // constrain? - - // <complexType name="Test"> - // <sequence> - // <element name="referrals" type="people:PersonSet" /> - // <element name="patients" type="people:PersonSet" /> - // <element name="relatives" type="people:PersonSet" /> - // </sequence> - // </complexType> - - DataObject testType = createTypeDescription(scope, medicalURI, "Test"); - typeDeclarations.add(testType); - addPropertyDescription(testType, pSet, "referrals"); - addPropertyDescription(testType, pSet, "patients"); - addPropertyDescription(testType, pSet, "relatives"); - - List types = typeHelper.define(typeDeclarations); - - DataObject p = scope.getDataFactory().create("commonj.sdo", "Property"); - p.set("type", typeHelper.getType(medicalURI, "Condition")); - p.set("name", "condition"); - p.setBoolean("many", true); - p.setBoolean("containment", true); // why is this not the default? - - typeHelper.defineOpenContentProperty(medicalURI, p); - - } - - /** - * @param uri - * @param name - * @return - */ - private DataObject createTypeDescription(HelperContext scope, String uri, - String name) { - DataObject typeDesc = scope.getDataFactory().create(sdoApiUri, "Type"); - typeDesc.set("name", name); - typeDesc.set("uri", uri); - return typeDesc; - } - - private DataObject addPropertyDescription( - DataObject containerTypeDescription, Object propertyType, - String propertyName) { - DataObject property = containerTypeDescription.createDataObject("property"); - property.set("type", propertyType); - property.setString("name", propertyName); - property.setBoolean("containment", true); - return property; - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/ObtainingDataGraphFromXml.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/ObtainingDataGraphFromXml.java deleted file mode 100644 index 6d8ac0ab31..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/ObtainingDataGraphFromXml.java +++ /dev/null @@ -1,201 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.advanced; - -import java.io.InputStream; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; -import org.apache.tuscany.sdo.api.SDOUtil; - -import commonj.sdo.DataGraph; -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.XMLDocument; - -/** - * This sample program demonstrates a variety of methods available to obtain the root DataObject - * contained within an xml representation of a DataGraph. This is currently a grey - * area of the specification and this sample demonstrates spec compliant methods, as - * well as utility methods that have been added to Tuscany to address issues within - * the specification. - * - * 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 experiment with SDO. It is based upon example code contained - * within, and is meant for use with, and reference to the <a - * href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1" - * target="_bank">SDO Specification</a>. This sample attempts to clarify aspects of - * the the AccessDataObjectsUsingXPath example from the Examples section of the SDO - * specification.<br> - * <br> - * To define the correct Types for each DataObject ( CompanyType, DepartmentType etc ) - * this sample relies upon - * {@link org.apache.tuscany.samples.sdo.internal.SampleInfrastructure#COMPANY_XSD} which is - * provided in the resources directory of these samples. The xml file - * {@link org.apache.tuscany.samples.sdo.internal.SampleInfrastructure#COMPANY_DATAGRAPH_XML} is - * used to load the DataGraph and is also located in this resources directory. <br> - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ - -public class ObtainingDataGraphFromXml extends SampleBase { - - HelperContext scope; - - - - public ObtainingDataGraphFromXml(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_ADVANCED); - } - - public static void main(String[] args) { - - /* - * Create an instance of the sample program. Edit the "commentaryLevel" argument to suit - * your experience, COMMENTARY_FOR_NOVICE, COMMENTARY_FOR_INTERMEDIATE or COMMENTARY_FOR_ADVANCED - */ - ObtainingDataGraphFromXml sample = - new ObtainingDataGraphFromXml(COMMENTARY_FOR_ADVANCED); - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.WRAPPING_DATA_GRAPH_IN_A_DATAGRAPH_INSTANCE - }; - - public static int [] SIGNIFICANT_FUNCTION = { - SDOFacets.USING_BUILT_IN_TYPES - }; - - - public void runSample () { - banner('*', - "SDO Sample " + this.getClass().getName() + "\n\n" + - - "This sample touches an area of the SDO API where the emphasis has changed over the various\n"+ - "version of the specification, and so it's important to be clear what's going on\n"+ - "First off lets be sure of our terminology ...\n"+ - "1) A \"data graph\" is a just collection of DataObjects, all contained within a single\n"+ - "containment hierarchy, with a single root object, and possibly having some non-containment\n"+ - "references\n"+ - "2) A \"DataGraph\" is an instance of the SDO DataGraph class, used as a container for the root\n"+ - "DataObject of a data graph, and providing a means to access a change summary for the data graph.\n\n"+ - "More recent versions of the SDO specification have provided alternative means of containment\n"+ - "of a data graph ...\n"+ - "3) The graph can be contained in a DataObject of a built-in SDO Type with namespace URI \"commonj.sdo\"\n" + - "and name \"DataGraph\": so this is a modeled version of the special DataGraph class.\n"+ - "4) The Graph can be contained in an XMLDocument instance, which provides for things such as\n"+ - "naming the root element of an XML instance document" - ); - - scope = useDefaultScopeForTypes(); - loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.COMPANY_XSD); - - - - try { - - - - - DataObject company = null; - - commentary( - "Here we see the specification's example for obtaining dealing with\n"+ - "loading a data graph which uses a method, XMLHelper.load(). This loads an XML instance document\n"+ - "into an instance of XMLDocument ...\n\n"+ - "XMLDocument doc = scope.getXMLHelper().load(\n"+ - "ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAGRAPH_XML));" - ); - - InputStream is = ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAGRAPH_XML); - int x= is.available(); - byte b[]= new byte[x]; - is.read(b); - String instanceDoc = new String(b); - - System.out.println(instanceDoc); - - XMLDocument doc = scope.getXMLHelper().load( - 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"+ - "of type commonj.sdo#DataGraph. Note how there's no magic here; no special class for\n"+ - "DataGraph, no special handling, this is just a standard pattern of using a built in SDO Type.\n"+ - "The wrapper is there purely because it was serialized\n"+ - "into the XML document, using the standard serialization technique.\n\n" + - "DataObject dataObjectRepresentingDataGraph = doc.getRootObject();"); - - DataObject dataObjectRepresentingDataGraph = doc.getRootObject(); - - System.out.println(dataObjectRepresentingDataGraph); - - commentary( - "If you are confused by the fact that what we really get is an instance of DataGraphTypeImpl\n"+ - "This really is a DataObject, but it is a generated class extending DataObjectImpl\n+"+ - "representing the DataGraph model."); - - company = dataObjectRepresentingDataGraph.getDataObject("company"); - - commentary( - "We've obtained a DataObject representing the data graph, and from that we have obtained\n"+ - "the true root object of the business data"); - - System.out.println(company); - System.out.println(); - - commentary( - "Using an instance of DataGraph can perhaps be seen as an older style pattern of wrapping a data graph\n"+ - "and the first approach is likely to get more emphasis and attention in future revisions of the spec.\n"+ - "The SDO API has some limitations in the area of saving and loading instances of the\n"+ - "Java DataGraph type, so Tuscany has an API for doing this ...\n\n"+ - "DataGraph datagraph = SDOUtil.loadDataGraph(\n"+ - " ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAGRAPH_XML), null);" - - ); - - DataGraph datagraph = SDOUtil.loadDataGraph(ClassLoader.getSystemResourceAsStream(SampleInfrastructure.COMPANY_DATAGRAPH_XML), null); - - System.out.println(datagraph); - - commentary( - "In this case we directly receive an instance of DataGraph and can retrieve the root\n"+ - "business object from the DataGraph\n\n"+ - "DataObject company = datagraph.getRootObject();"); - - company = datagraph.getRootObject(); - System.out.println(company); - System.out.println(); - - } catch (Exception e) { - somethingUnexpectedHasHappened(e); - } - - } -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java deleted file mode 100644 index 7458eef76c..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java +++ /dev/null @@ -1,498 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.advanced; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Sequence; -import commonj.sdo.Type; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.XMLDocument; -import commonj.sdo.helper.XSDHelper; -import commonj.sdo.impl.HelperProvider; - -/** - * - * This sample program traverses data graphs and builds up a text representation of the - * data graph. As it traverses a graph it outputs commentary to the console - * about what it has encountered and how it intends to process what it finds. At - * the end of each traversal the text representation of the graph is printed to - * the console. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class PrintDataGraph extends SampleBase { - - StringBuffer buf = null; - HelperContext scope = HelperProvider.getDefaultContext(); - - private int indent; - - private int indentIncrement = 2; - - public PrintDataGraph(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_ADVANCED); - buf = new StringBuffer(); - } - - public static void main(String[] args) { - PrintDataGraph sample = new PrintDataGraph(COMMENTARY_FOR_NOVICE); - sample.run(); - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL - }; - - public static int [] SIGNIFICANT_FUNCTION = { - SDOFacets.GET_SET_PROPERTIES_BY_INSTANCE_PROPERTIES, - SDOFacets.ISMANY_PROPERTIES, - SDOFacets.CREATE_TYPES_USING_THE_SDO_API, - SDOFacets.ACCESSING_VALUES_IN_A_SEQUENCE, - SDOFacets.NON_CONTAINMENT - }; - - public void runSample() throws Exception { - commentary("This sample demonstrates a common pattern of traversing a data graph\n" - + "and printing the values of its Properties. As the sample traverses a couple of\n" - + "graphs it provides commentary about what it has found and what actions it\n" - + "is taking, whilst building up a text representation of the graph. It then\n" - + "shows you the results of its labours."); - - HelperContext scope = createScopeForTypes(); - - commentary( - COMMENTARY_ALWAYS, - "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, SampleInfrastructure.PO_XSD_RESOURCE); - - XMLDocument purchaseOrder = getXMLDocumentFromFile(scope, - SampleInfrastructure.PO_XML_RESOURCE); - - printXMLDocument(purchaseOrder); - - commentary(COMMENTARY_ALWAYS, - "And here is the resultant view of the data graph\n\n"); - System.out.println(getBuf().toString()); - - commentary(COMMENTARY_ALWAYS, - "Next we look at a graph representing a form letter, where the Type of the\n" - + "root data object is 'Sequenced'"); - - loadTypesFromXMLSchemaFile(scope, "letter.xsd"); - DataObject letter = getDataObjectFromFile(scope, "letter.xml"); - - reset(); - print(letter); - - commentary(COMMENTARY_ALWAYS, - "And here is the resultant view of the data graph\n\n"); - - System.out.println(getBuf().toString()); - - } - - public void reset() { - indent = 0; - buf = new StringBuffer(); - } - - /* - * a convenience method allowing untyped access to the print function for - * selected SDO artifacts - */ - public void print(Object sdoObject) throws Exception { - - if (sdoObject instanceof XMLDocument) { - printXMLDocument((XMLDocument) sdoObject); - } else if (sdoObject instanceof DataObject) { - printDataObject((DataObject) sdoObject); - } - - } - - public void printXMLDocument(XMLDocument xmlDocument) { - - commentary( - COMMENTARY_FOR_NOVICE, - "We are going to traverse a data graph that has been wrapped in an instance of XMLDocument\n" - + "Amongst other things, the XMLDocument instance provides access to the root element name\n" - + "and the root DataObject of the data graph.\n\n" - + "xmlDocument.getRootElementName();\n" - + "xmlDocument.getRootObject();", - - "Accessing another graph via an XMLDocument instance as we saw previously ...\n" - + "xmlDocument.getRootElementName();\n" - + "xmlDocument.getRootObject();"); - - buf.append("XMLDocument: ").append(xmlDocument.getRootElementName()); - lineBreak(); - incrementIndent(); - printDataObject(xmlDocument.getRootObject()); - decrementIndent(); - } - - public void printDataObject(DataObject dataObject) { - - if (dataObject.getContainer() == null) { - commentary( - COMMENTARY_FOR_NOVICE, - "We begin traversing the data graph by examining the root object of the graph's containment hierarchy,\n" - + "making a record of the values of its Properties. As we inspect the values of the Properties of this object\n" - + "if we encounter contained DataObjects, then we will recurs through the containment hierarchy of the\n" - + "data graph in a depth first fashion, and create a text representation of the graph that we'll print\n" - + "out after the graph traversal has been completed.", - - "We are beginning to traverse another data graph from its root object, in the same way that we saw previously"); - } else { - commentary( - COMMENTARY_FOR_NOVICE, - "We have arrived at a contained dataObject in the graph, and will inspect its Property values,\n" - + "recursing deeper if necessary", - - "Inspecting another contained dataObject"); - } - - lineBreak(); - indent(); - buf.append("DataObject: "); - Type type = dataObject.getType(); - buf.append("Type: ").append(type.getURI()).append('#').append( - type.getName()); - lineBreak(); - - if (dataObject.getType().isSequenced()) { - - commentary( - COMMENTARY_FOR_INTERMEDIATE, - "We've encountered a DataObject in the graph for which the Type is 'Sequenced'\n" - + "That is to say that the order of addition of Property values to the DataObject instance\n" - + "is important, and is preserved by the DataObject\n\n" - + "dataObject.getType().isSequenced();", - - "We've encountered another sequenced DataObject instance, and so will traverse the Property\n" - + "values in the order preerved by the instance, as we saw before\n\n" - + "dataObject.getType().isSequenced();"); - - commentary( - "There's a subtlety here which we must deal with if this sample code is to\n" + - "handle both Type systems that derive from XML schema, and those that come from elsewhere,\n" + - "e.g. using the SDO API. If a Sequenced DataObject has a Type that comes from XML schema\n" + - "then its Properties that derive from XML attributes are not ordered, whereas those that\n" + - "derive from XML elements are ordered. The SDO specification doesn't say whether\n" + - "the attribute related Properties should appear at the start of a Sequence or not.\n" + - "Currently in Tuscany we leave them out of the Sequence; other SDO implementations may\n" + - "include the XML attributes in the Sequence. This sample code is written to deal with\n" + - "either approach\n." + - "We use the XSDHelper.isAttribute(Property) and isElement(Property) methods to distinguish\n" + - "between the two kinds of Property", - - "Examining the xml attributes and elements of a Sequenced DataObject again." - ); - - XSDHelper xsdHelper = getScope().getXSDHelper(); - incrementIndent(); - for(Iterator it=dataObject.getInstanceProperties().iterator(); it.hasNext();) { - Property property = (Property)it.next(); - if (xsdHelper.isAttribute(property)) { - indent(); - buf.append("Property (XML Attribute): ").append(property.getName()).append(" - ").append(dataObject.get(property)); - lineBreak(); - } - - } - decrementIndent(); - Sequence seq = dataObject.getSequence(); - - commentary( - "The Property/Value pairs of a Sequence can be accessed via the getProperty(int) and getValue(int)\n" - + "accessor methods of the Sequence interface. The size() method of the Sequence tells us how many there are.\n" - + "If the getProperty(int) method returns null, then the value is text. These text values may be encountered\n" - + "when the DataObject's type is 'mixed' (dataObject.getType().isMixed() == true). A typical example of this\n" - + "is when the data graph represents a form letter.", - - "Inspecting the Property/Value pairs of another Sequence"); - - incrementIndent(); - indent(); - buf.append("Sequence: {\n"); - - incrementIndent(); - for (int i = 0; i < seq.size(); i++) { - Property p = seq.getProperty(i); - if (p == null) { - indent(); - buf.append("text: ").append(seq.getValue(i)); - lineBreak(); - } else if(!xsdHelper.isAttribute(p)){ - printPropertyValuePair(p, seq.getValue(i)); - } - } - decrementIndent(); - - indent(); - buf.append("}\n"); - decrementIndent(); - - } else { - incrementIndent(); - - commentary( - COMMENTARY_FOR_INTERMEDIATE, - "We access the Property values of this DataObject by first getting the list of 'Instance Properties'\n" - + "from the DataObject. For many DataObjects, this will be the same set of Properties that are defined\n" - + "by the DataObject's Type. However, if the DataObject's type is 'Open' then an instance of that Type\n" - + "may contain more Properties than the type itself. The list of Instance Properties will always include\n" - + "the Properties defined in the Type, but will also include any Properties that the instance has values for\n" - + "by virtue of it's type being 'Open'\n\n" - + "for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) {\n" - + " Property p = (Property) dataObject.getInstanceProperties().get(i);", - - "Traversing the instance Properties of this DataObject\n" - + "for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) {\n" - + " Property p = (Property) dataObject.getInstanceProperties().get(i);" - - ); - - for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) { - Property p = (Property) dataObject.getInstanceProperties().get(i); - indent(); - printValueOfProperty(dataObject, p); - } - - decrementIndent(); - } - - } - - - - - - private void printPropertyValuePair(Property p, Object value) { - - indent(); - buf.append("Property: ").append(p.getName()).append(": "); - if(p.getType().isDataType()) { - printSimpleValue(value); - lineBreak(); - } else { - if(p.isContainment()) { - incrementIndent(); - printDataObject((DataObject)value); - decrementIndent(); - } else { - printReferencedDataObject((DataObject)value); - } - } - - - } - - private void printValueOfProperty(DataObject dataObject, Property p) { - - commentary( - COMMENTARY_FOR_INTERMEDIATE, - "We are about to inspect the value of a Property, but we must\n" - + "consider the nature of that Property in order to deal with it appropriately.\n" - + "Firstly we see if the Property value has been set (dataObject.isSet(property))\n" - + "Then we see if the Property is simple valued (property.isDataType() == true)\n" - + "--if not then we know it's a DataObject and we must recurs deeper into the graph's\n" - + "containment hierarchy\n" - + "Whether or not the property value is a DataObject, is may be single or multi-valued\n" - + "so we must either use one of the DataObject's get*(Property) accessors for single\n" - + "valued Properties or the getList() method for multi-valued properties.\n" - + "Another thing we must deal with when the Property is a DataObject, is whether or not the\n" - + "Property is a 'containment' Property. If it isn't, then here we simply record the fact that\n" - + "we have encountered this non-containment relationship, and move on to the next Property", - - "Inspecting another property to determine how to access its value, as we saw before"); - - // TODO deal with nullable - - buf.append("Property ").append(p.getName()).append(": ").append(" - "); - - if (dataObject.isSet(p)) { - if (p.getType().isDataType()) { - if (p.isMany()) { - printSimpleValues(dataObject.getList(p)); - } else { - printSimpleValue(dataObject.get(p)); - } - } else { - if (p.isContainment()) { - incrementIndent(); - if (p.isMany()) { - printDataObjects(dataObject.getList(p)); - } else { - printDataObject(dataObject.getDataObject(p)); - } - decrementIndent(); - } else { - if (p.isMany()) { - printReferencedDataObjects(dataObject.getList(p)); - } else { - printReferencedDataObject(dataObject.getDataObject(p)); - } - } - } - } else { - buf.append(" is not set"); - } - - lineBreak(); - - } - - private void printReferencedDataObject(DataObject dataObject) { - - commentary( - COMMENTARY_FOR_INTERMEDIATE, - "We have encounted a non-containment reference to a DataObject, and so\n" - + "we know that this DataObject will be fully inspected when encountered by the\n" - + "traversal of the data graph's containment hierarchy.\n" - + "We therefore record the fact that this association has been encountered by\n" - + "establishing the path from the root object of the data graph to the referenced\n" - + "DataObject", - - "Recording the fact that we have encountered another non-containment reference"); - - List path = new ArrayList(); - DataObject current = dataObject; - while (current != null) { - Property containmentProperty = current.getContainmentProperty(); - if(containmentProperty != null) { - if(containmentProperty.isMany()) { - List pValues = current.getContainer().getList(containmentProperty); - int index = pValues.indexOf(current)+1; - path.add("["+index+"]"); - } - path.add("/"+current.getContainmentProperty().getName()); - } - current = current.getContainer(); - } - buf.append("reference to: "); - for (ListIterator i = path.listIterator(path.size()); i.hasPrevious();) { - buf.append(i.previous()); - } - } - - private void printReferencedDataObjects(List list) { - - commentary( - COMMENTARY_FOR_NOVICE, - "Traversing a list of DataObjects which represent the values of a multi-valued non-containment Property"); - - indent(); - buf.append('['); - for (Iterator i = list.iterator(); i.hasNext();) { - printReferencedDataObject((DataObject) i.next()); - } - indent(); - buf.append(']'); - } - - private void printDataObjects(List list) { - - commentary( - COMMENTARY_FOR_NOVICE, - "Traversing a list of DataObjects which represent the values of a multi-valued containment Property"); - - - lineBreak(); - indent(); - buf.append("["); - incrementIndent(); - for (Iterator i = list.iterator(); i.hasNext();) { - printDataObject((DataObject) i.next()); - } - decrementIndent(); - indent(); - buf.append(']'); - } - - private void printSimpleValue(Object object) { - buf.append(object); - } - - private void printSimpleValues(List values) { - buf.append('['); - for (Iterator i = values.iterator(); i.hasNext();) { - printSimpleValue(i.next()); - if (i.hasNext()) { - buf.append(','); - } - } - buf.append(']'); - - } - - private void decrementIndent() { - indent -= indentIncrement; - - } - - private void incrementIndent() { - indent += indentIncrement; - - } - - private void indent() { - for (int i = 0; i < indent; i++) { - buf.append(' '); - } - } - - private void lineBreak() { - buf.append('\n'); - } - - public StringBuffer getBuf() { - return buf; - } - - public void setBuf(StringBuffer b) { - buf = b; - } - - public HelperContext getScope() { - return scope; - } - - public void setScope(HelperContext scope) { - this.scope = scope; - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/package.html b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/package.html deleted file mode 100644 index 4a375228f8..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/package.html +++ /dev/null @@ -1,31 +0,0 @@ -<html>
-<!--
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * -->
-<head>
- <title>Advanced SDO Samples</title>
-</head>
-<BODY>
-<h1>Advanced Service Data Object (SDO) Sample Programs</h1>
-
-<h3>Running the Samples</h3> See <A HREF="../../../../../../index.html"
-target="_top">the main overview</A> for instructions on how to run these
-samples.
-</BODY>
-</HTML>
diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java deleted file mode 100644 index 2030f35017..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.basic; - -import java.util.List; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; - -/** - * Demonstrates accessing a DataObject's Property values by name. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class AccessDataObjectPropertiesByName extends SampleBase { - - public AccessDataObjectPropertiesByName(Integer commentaryLevel) { - super(commentaryLevel, SAMPLE_LEVEL_BASIC); - } - - - public static void main(String[] args) { - AccessDataObjectPropertiesByName sample = new AccessDataObjectPropertiesByName(COMMENTARY_FOR_NOVICE); - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.GET_PROPERTIES_OF_DATAOBJECT_BY_NAME - }; - - public void runSample () throws Exception { - - banner("This sample will access a DataObject's properties by name\n"+ - "Take a look at the sample code to see all the uses of dataObject.get(String)\n"+ - "dataObject.getList(String) and dataObject.getDataObject(String)"); - - // setting up the type system for the example, see the utility methods for details of these operations - HelperContext scope = createScopeForTypes(); - loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE); - - DataObject purchaseOrder = getDataObjectFromFile(scope, SampleInfrastructure.PO_XML_RESOURCE); - - System.out.println("Accessing properties of purchaseOrder by name"); - System.out.println("Purchase Order: "); - System.out.println(" purchaseOrder.get(\"orderDate\"): " + purchaseOrder.get("orderDate")); - System.out.println(" purchaseOrder.get(\"comment\"): " + purchaseOrder.get("comment")); - - System.out.println(" DataObject shipTo = purchaseOrder.getDataObject(\"shipTo\");"); - DataObject shipTo = purchaseOrder.getDataObject("shipTo"); - System.out.println(" shipTo.get(\"name\"): " + shipTo.get("name")); - - System.out.println(" DataObject billTo = purchaseOrder.getDataObject(\"billTo\");"); - DataObject billTo = purchaseOrder.getDataObject("billTo"); - System.out.println(" billTo.get(\"name\"): " + billTo.get("name")); - - System.out.println(" DataObject items = purchaseOrder.getDataObject(\"items\");\n" + - " List itemList = items.getList(\"item\");\n" + - " DataObject item = (DataObject) itemList.get(i);"); - DataObject items = purchaseOrder.getDataObject("items"); - List itemList = items.getList("item"); - - System.out.println(" Items:"); - for (int i = 0; i < itemList.size(); i++) { - DataObject item = (DataObject) itemList.get(i); - System.out.println(" item[" + i + "]"); - System.out.println(" item.get(\"partNum\"): " + item.get("partNum")); - System.out.println(" item.get(\"productName\"): " + item.get("productName")); - } - - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessingTheContentsOfASequence.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessingTheContentsOfASequence.java deleted file mode 100644 index e24a837ccc..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessingTheContentsOfASequence.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.basic; - - -import org.apache.tuscany.samples.sdo.SampleBase; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Sequence; -import commonj.sdo.helper.HelperContext; - -/** - * Demonstrates accessing the sequence from a DataObject containing mixed content. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ - -public class AccessingTheContentsOfASequence extends SampleBase { - - HelperContext scope; - - public AccessingTheContentsOfASequence(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_BASIC); - } - - - /** - * 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) { - - AccessingTheContentsOfASequence sample = - new AccessingTheContentsOfASequence(COMMENTARY_FOR_NOVICE); - - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.ACCESSING_VALUES_IN_A_SEQUENCE - }; - - public void runSample () throws Exception { - - commentary("Demonstrates accessing the sequence from a DataObject containing mixed content."); - - scope = createScopeForTypes(); - loadTypesFromXMLSchemaFile(scope, LETTER_XSD); - DataObject letter = getDataObjectFromFile(scope, LETTER_XML); - - // print letter sequence - commentary("We've loaded a document from an XML file that contains mixed content.\n" + - "Here's how the XML looks ...\n"); - System.out.println(scope.getXMLHelper().save(letter, "letter.xsd", "letter")); - - commentary("We can iterate over the sequence, getting the Property / Value pairs\n" + - "using the Sequence.getProperty(int) and Sequence.getValue(int) methods.\n" + - "The model for this document is \"mixed\", i.e.\n" + - "letter.getType().isMixed() returns \"true\".\n" + - "Let's take a look at the Properties in this sequence."); - - Sequence letterSequence = letter.getSequence(); - - for (int i = 0; i < letterSequence.size(); i++) { - Property prop = letterSequence.getProperty(i); - if (prop == null) { - String text = (String) letterSequence.getValue(i); - System.out.println("Unstructured text (" + text + ")"); - } else { - System.out.println("Property: " + prop.getName() + " Value : " + letterSequence.getValue(i)); - } - } - - commentary("The values of the modeled Properties are still accessible through the DataObject\n" + - "getter and setter methods, but only through the Sequence API can we get to the unstructured\n" + - "text and see the ordering of the instance document"); - - } -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreateCompany.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreateCompany.java deleted file mode 100644 index 38bafca539..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreateCompany.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.basic; - -import java.io.FileOutputStream; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; - -/** - * This sample uses the scenario of building a description of a company to demonstrate - * primarily the setting of data using strings to name Properties. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class CreateCompany extends SampleBase { - - public CreateCompany(Integer commentaryLevel) { - this(commentaryLevel, SAMPLE_LEVEL_BASIC); - } - - public CreateCompany(Integer commentaryLevel, Integer sampleLevel) { - super(commentaryLevel, sampleLevel); - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.SET_PROPERTIES_OF_DATAOBJECT_BY_NAME - }; - - /** - * XML file generated for the company DataObject - */ - private static final String COMPANY_GENERATED_XML = "companyGenerated.xml"; - - /** - * Main method. Execute this method in order to run sample - * @param args - * @throws Exception - */ - public static void main(String[] args) { - /* - * this sample is suitable for a novice to SDO. - * Change the experience level constructor argument to one of - * COMMENTARY_FOR_NOVICE, COMMENTARY_FOR_INTERMEDIATE, COMMENTARY_FOR_ADVANCED, change - * the level of commentary output. - */ - CreateCompany sample = new CreateCompany(COMMENTARY_FOR_NOVICE); - - sample.run(); - - } - - public void runSample () throws Exception { - - banner('*', - "Demonstrates how to create a data graph using a model loaded\n"+ - "from an XML Schema contained in a file on the file system"); - - HelperContext scope = createScopeForTypes(); - 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(SampleInfrastructure.COMPANY_NAMESPACE, \"CompanyType\");"); - - DataObject company = scope.getDataFactory().create(SampleInfrastructure.COMPANY_NAMESPACE, "CompanyType"); - - populateGraph(scope, company); - - FileOutputStream fos = new FileOutputStream(COMPANY_GENERATED_XML); - - commentary( - "The XMLHelper can be used to write an XML serialized version of the data graph\n\n"+ - "scope.getXMLHelper().save(company, SampleInfrastructure.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, SampleInfrastructure.COMPANY_NAMESPACE, \"company\");\n"); - - String xml = scope.getXMLHelper().save(company, SampleInfrastructure.COMPANY_NAMESPACE, "company"); - - System.out.println(xml); - - } - - public void populateGraph(HelperContext scope, DataObject company) - { - - System.out.println("Populating the company DataObject"); - company.setString("name", "ACME"); - company.setString("employeeOfTheMonth", "E0001"); - - System.out.println("Creating a Department"); - - DataObject depts = company.createDataObject("departments"); - - depts.setString("name", "Advanced Technologies"); - depts.setString("location", "NY"); - depts.setString("number", "123"); - - System.out.println("Creating an employee: John Jones"); - DataObject johnJones = depts.createDataObject("employees"); - johnJones.setString("name", "John Jones"); - - johnJones.setString("SN", "E0001"); - - System.out.println("Creating an employee: Jane Doe"); - DataObject janeDoe = depts.createDataObject("employees"); - janeDoe.setString("name", "Jane Doe"); - janeDoe.setString("SN", "E0003"); - - System.out.println("Creating a manager: Fred Bloggs"); - DataObject fVarone = depts.createDataObject("employees"); - fVarone.setString("name", "Fred Bloggs"); - fVarone.setString("SN", "E0004"); - fVarone.setString("manager", "true"); - System.out.println("DataObject creation completed"); - System.out.println(); - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreatePurchaseOrder.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreatePurchaseOrder.java deleted file mode 100644 index c41aa37397..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/CreatePurchaseOrder.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.basic; - -import java.io.FileOutputStream; -import java.io.OutputStream; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.XMLDocument; - -/** - * Demonstrates creating a purchaseOrder DataObject from an existing XSD and then - * persisting to disk. 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/"> - * Create and read an XML document based on XML Schema</A> - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ - -public class CreatePurchaseOrder extends SampleBase { - - public CreatePurchaseOrder(Integer commentaryLevel) { - super(commentaryLevel, SAMPLE_LEVEL_BASIC); - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.LOADING_DATA_FROM_XML, - SDOFacets.SAVING_DATA_TO_XML - }; - - - - public static void main(String[] args) { - - CreatePurchaseOrder sample = new CreatePurchaseOrder(COMMENTARY_FOR_NOVICE); - - sample.run(); - - } - - public void runSample() throws Exception { - - commentary(COMMENTARY_ALWAYS, - "This sample is based upon Fuhwei Lwo's paper\n" - + "http://www-128.ibm.com/developerworks/webservices/library/ws-sdoxmlschema/\n" - + "and demonstrates creating a purchaseOrder DataObject from an\n" - + "existing XSD and then persisting to disk."); - - HelperContext scope = createScopeForTypes(); - - loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE); - - - commentary ( - "We are creating a DataObject using a DataFactory by specifying the URI and name of\n"+ - "the Type that we want to use for the DataObject.\n\n"+ - "DataFactory factory = scope.getDataFactory();\n"+ - "DataObject purchaseOrder = factory.create(SampleInfrastructure.PO_NAMESPACE, \"PurchaseOrderType\");"); - - DataFactory factory = scope.getDataFactory(); - DataObject purchaseOrder = factory.create(SampleInfrastructure.PO_NAMESPACE, "PurchaseOrderType"); - - - commentary( - "Now we build on the graph using the DataObject's set() and createDataObject() methods.\n"+ - "Take a look inside the program code for the full detail of these steps"); - - 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"); - System.out.println("Created 2 items"); - - commentary( - "Now we use the XMLHelper to write an XML document representing the data graph\n"+ - "to a file. We must supply a namespace and a name for the root element of the graph, since it is\n"+ - "not contained in the DataObject\n\n"+ - "OutputStream stream = new FileOutputStream(SampleInfrastructure.PO_XML_GENERATED);\n"+ - "scope.getXMLHelper().save(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, \"purchaseOrder\", stream);" - ); - - - OutputStream stream = new FileOutputStream(SampleInfrastructure.PO_XML_GENERATED); - scope.getXMLHelper().save(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, "purchaseOrder", stream); - stream.close(); - - commentary( - "We could instead have created an XMLDocument instance to wrap the DataObject\n"+ - "This has the advantage that the namespace URI and root element name are preserved in the Object\n"+ - "This interface was introduced after Fuhwei's paper, and has particular advantage\n"+ - "when loading an XML document from a file\n\n"+ - "scope.getXMLHelper().createDocument(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, \"purchaseOrder\");\n"+ - "scope.getXMLHelper().save(doc, System.out, null);"); - - - XMLDocument doc = scope.getXMLHelper().createDocument(purchaseOrder, SampleInfrastructure.PO_NAMESPACE, "purchaseOrder"); - scope.getXMLHelper().save(doc, System.out, null); - System.out.println(); - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java deleted file mode 100644 index e1b0dce3e6..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.basic; - -import java.util.List; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.XMLDocument; - -/** - * Reads purchase order DataObject from XML, based upon Fuhwei Lwo's paper <A - * HREF="http://www-128.ibm.com/developerworks/webservices/library/ws-sdoxmlschema/"> - * Create and read an XML document based on XML Schema</A>. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - * - */ -public class ReadPurchaseOrder extends SampleBase { - - - public static String purchaseOrderDoc = - "<?xml version=\"1.0\" encoding=\"ASCII\"?>\n"+ - " <po:purchaseOrder xmlns:po=\"http://www.example.com/PO\" orderDate=\"1999-10-20\">\n"+ - " <shipTo country=\"US\">\n"+ - " <name>Alice Smith</name>\n"+ - " <street>123 Maple Street</street>\n"+ - " <city>Mill Valley</city>\n"+ - " <state>CA</state>\n"+ - " <zip>90952</zip>\n"+ - " </shipTo>\n"+ - " <billTo country=\"US\">\n"+ - " <name>Robert Smith</name>\n"+ - " <street>8 Oak Avenue</street>\n"+ - " <city>Mill Valley</city>\n"+ - " <state>PA</state>\n"+ - " <zip>95819</zip>\n"+ - " </billTo>\n"+ - " <po:comment>Hurry, my lawn is going wild!</po:comment>\n"+ - " <items>\n"+ - " <item partNum=\"872-AA\">\n"+ - " <productName>Lawnmower</productName>\n"+ - " <price>148.95</price>\n"+ - " <quantity>1</quantity>\n"+ - " <po:comment>Confirm this is electric</po:comment>\n"+ - " </item>\n"+ - " <item partNum=\"926-AA\">\n"+ - " <productName>Baby Monitor</productName>\n"+ - " <price>39.98</price>\n"+ - " <quantity>1</quantity>\n"+ - " <shipDate>1999-05-21</shipDate>\n"+ - " </item>\n"+ - " </items>\n"+ - " </po:purchaseOrder>\n"; - - public ReadPurchaseOrder(Integer commentaryLevel) { - super(commentaryLevel, SampleInfrastructure.SAMPLE_LEVEL_BASIC); - } - - public static void main(String[] args) { - ReadPurchaseOrder sample = new ReadPurchaseOrder(COMMENTARY_FOR_NOVICE); - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.LOADING_DATA_FROM_XML, - SDOFacets.SAVING_DATA_TO_XML - }; - public static int [] SIGNIFICANT_FUNCTION = { - SDOFacets.GET_PROPERTIES_OF_DATAOBJECT_BY_NAME - }; - - - - public void runSample () throws Exception { - commentary(COMMENTARY_ALWAYS, - "This sample is based upon Fuhwei Lwo's paper \n"+ - "http://www-128.ibm.com/developerworks/webservices/library/ws-sdoxmlschema/\n"); - - HelperContext scope = createScopeForTypes(); - - loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE); - - commentary( - "We load the purchase order document into an instance of XMLDocument\n\n"+ - "XMLDocument xmlDoc = getXMLDocumentFromString(scope, purchaseOrderDoc);\n"); - - XMLDocument xmlDoc = getXMLDocumentFromString(scope, purchaseOrderDoc); - - commentary( - "We then retrieve the root DataObject from the XMLDocument\n"+ - "then print out some of the details\n\n"+ - "DataObject purchaseOrder = xmlDoc.getRootObject();"); - - DataObject purchaseOrder = xmlDoc.getRootObject(); - - System.out.println("Order date: " + purchaseOrder.get("orderDate")); - System.out.println("Comment: " + purchaseOrder.get("comment")); - - DataObject shipTo = purchaseOrder.getDataObject("shipTo"); - System.out.println("Ship to name: " + shipTo.get("name")); - - DataObject billTo = purchaseOrder.getDataObject("billTo"); - System.out.println("Bill to name: " + billTo.get("name")); - System.out.println(); - - DataObject items = purchaseOrder.getDataObject("items"); - List itemList = items.getList("item"); - for (int i = 0; i < itemList.size(); i++) { - - DataObject item = (DataObject) itemList.get(i); - - System.out.println("Part num: " + item.get("partNum")); - System.out.println("Product name: " + item.get("productName")); - } - - } - - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/package.html b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/package.html deleted file mode 100644 index d926bdbf5c..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/package.html +++ /dev/null @@ -1,31 +0,0 @@ -<html>
-<!--
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * -->
-<head>
- <title>Basic SDO Samples</title>
-</head>
-<BODY>
-<h1>Simple Service Data Object (SDO) Sample Programs</h1>
-
-<h3>Running the Samples</h3> See <A HREF="../../../../../../index.html"
-target="_top">the main overview</A> for instructions on how to run these
-samples.
-</BODY>
-</HTML>
diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessDataObjectUsingValidXPath.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessDataObjectUsingValidXPath.java deleted file mode 100644 index 56bc68340f..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessDataObjectUsingValidXPath.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.intermediate; - -import java.util.List; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; - -/** - * Demonstrates accessing a created DataObject's properties using the SDO XPath like syntax. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class AccessDataObjectUsingValidXPath extends SampleBase { - HelperContext scope; - - public AccessDataObjectUsingValidXPath(Integer userLevel) { - super(userLevel, SampleInfrastructure.SAMPLE_LEVEL_INTERMEDIATE); - } - - - /** - * Accesses and modifies properties of a purchase order DataObject using xPath( - * properties are defined in the xsd - * {@link org.apache.tuscany.samples.sdo.internal.SampleInfrastructure#PO_XSD_RESOURCE} and - * populated by xml - * {@link org.apache.tuscany.samples.sdo.internal.SampleInfrastructure#PO_XML_RESOURCE} ) - * - * @param args. - * No parameters required. - */ - public static void main(String[] args) { - AccessDataObjectUsingValidXPath sample = new AccessDataObjectUsingValidXPath(COMMENTARY_FOR_NOVICE); - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.GET_SET_PROPERTIES_OF_DATAOBJECT_BY_XPATH - }; - - - public void runSample () throws Exception { - - commentary("Demonstrates accessing a DataObject's properties using the XPath style getter/setter methods"); - - - HelperContext scope = createScopeForTypes(); - - - commentary( - "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, SampleInfrastructure.PO_XSD_RESOURCE); - DataObject purchaseOrder = getDataObjectFromFile(scope, SampleInfrastructure.PO_XML_RESOURCE); - - - - commentary( - "Accessing data from the purchase order using the DataObjects XPath style methods\n"); - - - System.out.println("First we use the simplest kind of path\n" + - "purchaseOrder.getString(\"billTo/name\")\n" + - "The purchase is to be paid for by .... " + - purchaseOrder.getString("billTo/name")); - - - System.out.println("\nThen we use indexing by integer starting from 1\n" + - "purchaseOrder.getString(\"items/item[1]/productName\")\n" + - "The first item in the order is a ... " + - purchaseOrder.getString("items/item[1]/productName")); - - - System.out.println("\nThe alternative style of indexing uses a . notation and starts from 0\n"+ - "purchaseOrder.getFloat(\"items/item.0/price\")\n" + - "The price of this item is ... " + - purchaseOrder.getFloat("items/item.0/price")); - - - System.out.println("\nDataObjects can be looked up by supplying the value of one of the contained simple valued Properties\n"+ - "DataObject babyMonitorItem = purchaseOrder.getDataObject(\"items/item[productName=\\\"Baby Monitor\\\"]"); - - DataObject babyMonitorItem = purchaseOrder.getDataObject("items/item[productName=\"Baby Monitor\"]"); - System.out.println("The price of the Baby Monitor is .... " + - babyMonitorItem.getFloat("price")); - - - System.out.println("\nA parent DataObject can be accessed with the .. notation\n"+ - "List onlyIfBuyingGrassSeed = purchaseOrder.getList(\"items/item[productName=GrassSeed]/../item\");"); - List onlyIfBuyingGrassSeed = purchaseOrder.getList("items/item[productName=GrassSeed]/../item"); - if(onlyIfBuyingGrassSeed != null) { - System.out.println("The purchase order included grass seed and " + new Integer(onlyIfBuyingGrassSeed.size()-1) + " other items"); - } else { - System.out.println("The purchase order did not include GrassSeed"); - } - - - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessingDataObjectsViaPropertyIndex.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessingDataObjectsViaPropertyIndex.java deleted file mode 100644 index 98a63b5654..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/AccessingDataObjectsViaPropertyIndex.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.intermediate; - -import java.util.List; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.advanced.PrintDataGraph; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; - -/** - * Demonstrates accessing the properties of a DataObject using integer property indices. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ - -public class AccessingDataObjectsViaPropertyIndex extends SampleBase { - - HelperContext scope; - PrintDataGraph printer; - - public AccessingDataObjectsViaPropertyIndex(Integer userLevel) { - /* - * Classifying this sample as intermediate, not because it is complex - * but because it's a scenario not to be encouraged for use by - * people new to SDO. - */ - super(userLevel, SAMPLE_LEVEL_INTERMEDIATE); - printer = new PrintDataGraph(SAMPLE_LEVEL_ADVANCED); - } - - - /** - * Predefine the property indexes. - */ - - private static final int COMPANY_DEPARTMENT = 0; - private static final int COMPANY_NAME = 1; - private static final int COMPANY_EMPLOYEE_OF_MONTH = 2; - - private static final int DEPARTMENT_EMPLOYEES = 0; - - private static final int EMPLOYEE_NAME = 0; - private static final int EMPLOYEE_SN = 1; - private static final int EMPLOYEE_MANAGER = 2; - - - /** - * Execute this method in order to run the sample. - * - * @param args - */ - public static void main(String[] args) { - AccessingDataObjectsViaPropertyIndex sample = - new AccessingDataObjectsViaPropertyIndex(COMMENTARY_FOR_NOVICE); - - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.GET_SET_PROPERTIES_OF_DATAOBJECT_BY_INDEX - }; - - - public void runSample () throws Exception { - - - commentary( - "This sample demonstrates the use of integer index to get and set\n" + - "Property values of a DataObject. This approach is optimized for\n" + - "performance, but is fragile to changes to the Type system. It will be\n" + - "broken if someone alters the XML schema that is used to load the type system." + - "This kind of approach is well suited to a situation where the SDO code is being\n" + - "generated."); - - scope = createScopeForTypes(); - - loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.COMPANY_XSD); - - DataObject company = getDataObjectFromFile(scope, SampleInfrastructure.COMPANY_DATAOBJECT_XML); - - commentary("We've loaded a data graph that looks like this ..."); - - printer.print(company); - System.out.println(printer.getBuf()); - printer.reset(); - - commentary("Here's how the data graph looks rendered in XML ..."); - System.out.println( - scope.getXMLHelper().save(company, SampleInfrastructure.COMPANY_NAMESPACE, "company")); - - commentary( - "This sample class has primitive int static constants defined for the Properties\n" + - "of the Types that the program is designed to work with, e.g.\n\n" + - "private static final int COMPANY_NAME = 2;\n\n" + - "The value of the integers is defined by the sequence the Properties\n" + - "appear in the List returned by dataObject.getType().getDeclaredProperties()\n" + - "For a type derived from an XML schema this will be the sequence they appeared in the\n" + - "schema document.\n" + - "We can use these integer values to get and set Properties on the company DataObject\n\n" + - "company.setString(COMPANY_NAME, \"MegaCorp\");\n" + - "List departments = company.getList(COMPANY_DEPARTMENT);\n" + - "List employees = department.getList(DEPARTMENT_EMPLOYEES);\n"); - - company.setString(COMPANY_NAME, "MegaCorp"); - - - - commentary("The sample continues, altering the data graph by using the getter\n" + - "and setter methods that take int arguments"); - - List departments = company.getList(COMPANY_DEPARTMENT); - DataObject department = (DataObject) departments.get(0); - List employees = department.getList(DEPARTMENT_EMPLOYEES); - DataObject employeeFromList = (DataObject) employees.get(2); - employeeFromList.detach(); - - DataObject newEmployee = department.createDataObject(DEPARTMENT_EMPLOYEES); - - newEmployee.set(EMPLOYEE_NAME, "Al Smith"); - newEmployee.set(EMPLOYEE_SN, "E0005"); - newEmployee.setBoolean(EMPLOYEE_MANAGER, true); - - company.set(COMPANY_EMPLOYEE_OF_MONTH, newEmployee.get(EMPLOYEE_SN)); - - commentary("After some more manipulation (take a look at the sample code to see the detail)\n" + - "we can examine the state of the modified graph"); - - printer.print(company); - System.out.println(printer.getBuf()); - printer.reset(); - - commentary("Or rendered in XML it now looks like this ..."); - System.out.println(scope.getXMLHelper().save(company, SampleInfrastructure.COMPANY_NAMESPACE, "company")); - - } -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateCompanyTuscanyAPI.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateCompanyTuscanyAPI.java deleted file mode 100644 index 097814d35f..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateCompanyTuscanyAPI.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.intermediate; - -import java.io.FileOutputStream; - -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; -import org.apache.tuscany.sdo.api.SDOUtil; - -import commonj.sdo.DataGraph; -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; - -/** - * This sample is a variant of the CreateCompany sample where the graph of DataObjects - * is contained in an instance of DataGraph. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class CreateCompanyTuscanyAPI extends org.apache.tuscany.samples.sdo.basic.CreateCompany { - - public CreateCompanyTuscanyAPI(Integer commentaryLevel) { - super(commentaryLevel, SAMPLE_LEVEL_INTERMEDIATE); - } - - /** - * XML file generated for the company DataGraph - */ - private String COMPANY_DATAGRAPH_GENERATED_XML = "companyDataGraphGenerated.xml"; - - - /** - * Main method. Execute this method in order to run sample - * @param args - * @throws Exception - */ - public static void main(String[] args) { - /* - * this sample is best suited so someone with an intermediate level - * of understanding of SDO. Change the experience level argument to get more - * or less commentary. - */ - CreateCompanyTuscanyAPI sample = new CreateCompanyTuscanyAPI(COMMENTARY_FOR_INTERMEDIATE); - sample.run(); - - } - - public void runSample () throws Exception { - - banner('*', - " SDO Sample Create Company in a DataGraph \n\n"+ - "This is a variant of the simple CreateCompany sample, but\n"+ - "demonstrates how to create a DataGraph in the absence of a Data Access Service (DAS)\n"+ - "This is not typical of how an SDO user would code, because a DAS is usually\n"+ - "responsible for creating a DataGraph instance. This is why we must use a Tuscany API\n"+ - "to create the dataGraph in the first place\n"+ - "If you don't have a need to use a DataGraph instance then you may want to skip this\n"+ - "sample, or leave it until you have explored the DataObject interface fully\n"); - - commentary(COMMENTARY_FOR_INTERMEDIATE, - "As we are dealing with a DataGraph, the SDO API has some gray areas at the moment\n"+ - "in that the DataGraph API hasn't yet been developed to deal with scopes\n"+ - "other than the default scope. So here is an occasion where we must use "+ - "the default singleton scope"); - HelperContext scope = useDefaultScopeForTypes(); - loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.COMPANY_XSD); - - commentary (COMMENTARY_FOR_INTERMEDIATE, - "Here is the use of the Tuscany API for creating a DataGraph instance\n\n"+ - "DataGraph dataGraph = SDOUtil.createDataGraph();"); - - DataGraph dataGraph = SDOUtil.createDataGraph(); - - commentary(COMMENTARY_FOR_INTERMEDIATE, - "Now we create a root object of a selected type for the DataGraph wrapper to contain.\n"+ - "This is an example of a DataGraph interface that currently forces us to use the default scope.\n\n"+ - "company = dataGraph.createRootObject(SampleInfrastructure.COMPANY_NAMESPACE, \"CompanyType\");"); - - DataObject company = dataGraph.createRootObject(SampleInfrastructure.COMPANY_NAMESPACE, "CompanyType"); - - populateGraph(scope, company); - - commentary(COMMENTARY_FOR_INTERMEDIATE, - "Since the SDO API doesn't currently have a method for serializing the DataGraph instance\n"+ - "we again use a Tuscany specific API\n\n"+ - "SDOUtil.saveDataGraph(dataGraph, fos, null);"); - - FileOutputStream fos = new FileOutputStream(COMPANY_DATAGRAPH_GENERATED_XML); - SDOUtil.saveDataGraph(dataGraph, fos, null); - - SDOUtil.saveDataGraph(dataGraph, System.out, null); - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateDataObjectFromXmlString.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateDataObjectFromXmlString.java deleted file mode 100644 index 1ec920146d..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateDataObjectFromXmlString.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.intermediate; - -import java.util.List; - -import org.apache.tuscany.samples.sdo.SampleBase; - -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Sequence; -import commonj.sdo.helper.HelperContext; - -/** - * Demonstrates creating a DataObject from a String of XML without an explicit model. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class CreateDataObjectFromXmlString extends SampleBase { - HelperContext scope; - - - public CreateDataObjectFromXmlString(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_INTERMEDIATE); - } - - - /** - * String representing a PurchaseOrder in XML format - */ - public static final String XML_STRING = "<purchaseOrder orderDate='1999-10-20'>" + " <shipTo country='US'>" + " <name>Alice Smith</name>" - + " <street>123 Maple Street</street>" + " <city>Mill Valley</city>" + " <state>PA</state>" + " <zip>90952</zip>" + "</shipTo>" - + "</purchaseOrder>"; - - - public static void main(String[] args) { - - CreateDataObjectFromXmlString sample = new CreateDataObjectFromXmlString(COMMENTARY_FOR_NOVICE); - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.USING_BUILT_IN_TYPES, - SDOFacets.LOADING_DATA_FROM_XML - }; - - public void runSample () throws Exception { - - - commentary("Demonstrates creating a DataObject from a String of XML,\n" + - "based upon section titled 'Creating DataObjects from XML documents'\n"+ - "This quite unassuming sample demonstrates the maxim of 'less is more'\n"+ - "in that it might look like other samples where the XML document was loaded\n"+ - "from a file or string, but note that we don't define any Types before loading\n"+ - "the document. Built in generic types are used to model the data graph"); - - - scope = createScopeForTypes(); - - commentary("don't define any types! Just go ahead and load from the String\n\n"+ - "DataObject purchaseOrder = scope.getXMLHelper().load(XML_STRING).getRootObject();"); - - DataObject purchaseOrder = scope.getXMLHelper().load(XML_STRING).getRootObject(); - - commentary("Note that the Type of the newly created DataObject has no Properties defined for it\n"+ - "but the type is said to be \"Open\", which means that an instance of the Type may make use of other Properties\n"+ - "defined elsewhere. The XMLHelper's load operation creates Properties on demand for the DataObject instance to use as it loads\n"+ - "the document\n\n" + - "purchaseOrder.getType().isOpen returns true\n" + - "purchaseOrder.getType().getProperty(\"shipTo\") returns null and\n" + - "purchaseOrder.getInstanceProperty(\"shipTo\") returns a Property"); - - System.out.println("DataObject's type is open?: " + purchaseOrder.getType().isOpen()); - System.out.println("Data Object's type has a property shipTo?: " + (purchaseOrder.getType().getProperty("shipTo") != null)); - System.out.println("Data Object instance has a property shipTo?: " + (purchaseOrder.getInstanceProperty("shipTo") != null)); - - commentary( - "Without a Type definition accessing a DataObject is slightly\n"+ - "different, since without a Type definition SDO does not know\n"+ - "the intended multiplicity of properties. So every Property is assumed to\n"+ - "be multi-valued, and must be accessed via a list\n\n"+ - "List shipToList = purchaseOrder.getList(\"shipTo\");\n"+ - "DataObject shipTo = (DataObject) shipToList.get(0);"); - - List shipToList = purchaseOrder.getList("shipTo"); - DataObject shipTo = (DataObject) shipToList.get(0); - - - - /* - * With no model around, this next operation is currently quite cumbersome. - * In future specifications accessing - * the name element will be simplier and the user could simply execute: - * List nameList = shipTo.getList("name"); String actualName = (String) - * nameList.get(0); - * - * Or if name is an attribute ("<shipTo country='US' name='Alice - * Smith'>") simply: String actualName = shipTo.getString("name"); - * - * There are currently more elegant means to perform this task using the xPath support - */ - List nameList = shipTo.getList("name"); - DataObject name = (DataObject) nameList.get(0); - // access the contents of the name DataObject - Sequence s = name.getSequence(); - String actualName = (String) s.getValue(0); - System.out.println("Name being shipped to: " + actualName); - - } -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/DynamicCustomerTypeSample.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/DynamicCustomerTypeSample.java deleted file mode 100644 index abe3434fab..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/DynamicCustomerTypeSample.java +++ /dev/null @@ -1,193 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.intermediate; - -import java.util.List; - -import org.apache.tuscany.samples.sdo.SampleBase; - -import commonj.sdo.DataObject; -import commonj.sdo.Type; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.HelperContext; -import commonj.sdo.helper.TypeHelper; - -/** - * Demonstrates creating and using Types dynamically. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class DynamicCustomerTypeSample extends SampleBase { - HelperContext scope; - - public DynamicCustomerTypeSample(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_INTERMEDIATE); - } - - - /** - * XSD file used to define the model and Types for Customer Dataobject - */ - public static final String CUSTOMER_MODEL = "customer.xsd"; - - /** - * Default file name to use when generated customer XSD files. - * - * @see org.apache.tuscany.samples.sdo.specCodeSnippets.CreateXmlAndXsdFromDataObject - */ - public static final String CUSTOMER_MODEL_GENERATED = "generatedCustomer.xsd"; - - /** - * Fake namespace used for Customer - */ - public static final String CUSTOMER_NAMESPACE = "http://www.example.com/customer"; - - /** - * XML file used to populate Customer DataObjects - */ - public static final String CUSTOMER_XML = "customer.xml"; - - /** - * Default file name to use when generated customer XML files. - * - * @see org.apache.tuscany.samples.sdo.specCodeSnippets.CreateXmlAndXsdFromDataObject - */ - public static final String CUSTOMER_XML_GENERATED = "generatedCustomer.xml"; - - /** - * Drives sample methods - * - * @param args - * no arguments required - */ - public static void main(String[] args) { - - DynamicCustomerTypeSample sample = - new DynamicCustomerTypeSample(COMMENTARY_FOR_INTERMEDIATE); - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.CREATE_TYPES_USING_THE_SDO_API - }; - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] SIGNIFICANT_FUNCTION = { - SDOFacets.SET_PROPERTIES_OF_DATAOBJECT_BY_NAME, - SDOFacets.USING_BUILT_IN_TYPES, - SDOFacets.SAVING_DATA_TO_XML - }; - - public void runSample () throws Exception { - - commentary(COMMENTARY_ALWAYS, - "Demonstrates the use of the SDO API to build types dynamically\n"+ - "by building a data graph representing the type system and\n"+ - "submitting that graph to TypeHelper.define()"); - - - scope = createScopeForTypes(); - - - commentary("A TypeHelper is used for both looking up types, and later creating them\n\n"+ - "TypeHelper typeHelper = scope.getTypeHelper();"); - - TypeHelper typeHelper = scope.getTypeHelper(); - - commentary("We can look up existing types to use in the creation of Properties\n\n"+ - "Type intType = types.getType(\"commonj.sdo\", \"Int\");\n"+ - "Type stringType = types.getType(\"commonj.sdo\", \"String\");"); - - Type intType = typeHelper.getType("commonj.sdo", "Int"); - Type stringType = typeHelper.getType("commonj.sdo", "String"); - - commentary("To begin modeling the type system we create a DataObject with\n"+ - "Type \"commonj.sdo#Type\" and set the URI and name for that type\n\n"+ - - "DataObject customerType = scope.getDataFactory().create(\"commonj.sdo\", \"Type\");\n"+ - "customerType.set(\"uri\", \"http://example.com/customer\");\n"+ - "customerType.set(\"name\", \"Customer\");"); - - DataObject customerType = scope.getDataFactory().create("commonj.sdo", "Type"); - customerType.set("uri", "http://example.com/customer"); - customerType.set("name", "Customer"); - - commentary("Now we can create a model for the Properties for the Type\n"+ - "and set the name and Types of those Properties\n\n"+ - "DataObject custNumProperty = customerType.createDataObject(\"property\");\n"+ - "custNumProperty.set(\"name\", \"custNum\");\n"+ - "custNumProperty.set(\"type\", intType);" - ); - - DataObject custNumProperty = customerType.createDataObject("property"); - custNumProperty.set("name", "custNum"); - custNumProperty.set("type", intType); - - commentary("We continue in this manner until all the Types and their Properties are modeled"); - DataObject lastNameProperty = customerType.createDataObject("property"); - lastNameProperty.set("name", "lastName"); - lastNameProperty.set("type", stringType); - - DataObject firstNameProperty = customerType.createDataObject("property"); - firstNameProperty.set("name", "firstName"); - firstNameProperty.set("type", stringType); - - commentary("Now that our type is fully modeled we submit the model to the TypeHelper\n"+ - "The new Type instance is returned to us, but is also available for lookup within\n"+ - "the scope associated with the TypeHelper\n\n"+ - "Type t = typeHelper.define(customerType);"); - Type t = typeHelper.define(customerType); - - commentary("Here we see the newly created Type being accessed via the TypeHelper\n"+ - "along with a printout of the Type's Properties\n\n"+ - "Type testType = scope.getTypeHelper().getType(\"http://example.com/customer\", \"Customer\");"); - - Type testType = scope.getTypeHelper().getType("http://example.com/customer", "Customer"); - List props = testType.getProperties(); - for (int i = 0; i < props.size(); i++) { - System.out.println(props.get(i)); - } - - commentary("Now we can create an instance of the type using the DataFactory associated with the type scope\n\n"+ - "DataFactory factory = scope.getDataFactory();\n"+ - "DataObject customer1 = factory.create(\"http://example.com/customer\", \"Customer\");"); - - DataFactory factory = scope.getDataFactory(); - DataObject customer1 = factory.create("http://example.com/customer", "Customer"); - customer1.setInt("custNum", 1); - customer1.set("firstName", "John"); - customer1.set("lastName", "Adams"); - - commentary("Here's an XML String representing a DataObject we have created with the new type"); - String xmlDocString = scope.getXMLHelper().save(customer1, CUSTOMER_NAMESPACE, "customer"); - System.out.println(xmlDocString); - - - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java deleted file mode 100644 index eaecf436bf..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.intermediate; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; - -import org.apache.tuscany.samples.sdo.SampleBase; -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure; - -import commonj.sdo.DataObject; -import commonj.sdo.helper.HelperContext; - -/** - * Demonstrates serializing and deserializing a DataObject to disk - * using java serialization. - * <p> - * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html" - * target="_top">the main overview</A> for instructions on how to run this - * sample. - */ -public class SerializingDeserializingADataObject extends SampleBase { - HelperContext scope; - - public SerializingDeserializingADataObject(Integer userLevel) { - super(userLevel, SAMPLE_LEVEL_INTERMEDIATE); - } - - - public static void main(String[] args) { - - SerializingDeserializingADataObject sample = - new SerializingDeserializingADataObject(COMMENTARY_FOR_INTERMEDIATE); - sample.run(); - - } - - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] CORE_FUNCTION = { - SDOFacets.JAVA_SERIALIZATION_OF_DATA_GRAPH - }; - /* - * metadata for the sample documenting the areas of SDO that are explored - */ - public static int [] SIGNIFICANT_FUNCTION = { - SDOFacets.TESTING_FOR_GRAPH_EQUALITY - }; - - public void runSample () throws Exception { - - 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(); - - /** - * 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")); - - - } -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/package.html b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/package.html deleted file mode 100644 index 59ea1c39e6..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/package.html +++ /dev/null @@ -1,30 +0,0 @@ -<html>
-<!--
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * -->
-<head>
- <title>Intermediate SDO Samples</title>
-</head>
-<BODY>
-<h1>Intermediate Service Data Object (SDO) Sample Programs</h1>
-<h3>Running the Samples</h3> See <A HREF="../../../../../../index.html"
-target="_top">the main overview</A> for instructions on how to run these
-samples.
-</BODY>
-</HTML>
diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/DocumentSamples.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/DocumentSamples.java deleted file mode 100644 index af20cb663a..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/DocumentSamples.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.internal; - -import java.io.IOException; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure.SDOFacets; - - -/** - * Class to generate html documentation for the SDO Samples. - * The program introspects the sample programs listed in the - * {@link SampleInfrastructure#sampleClasses sample classes} - * static constant, for the values of the static CORE_FUNCTION - * and SIGNIFICANT_FUNCTION variables. - * <P> - * It builds indexes from - * sample to function and from function to sample and creates - * html output that displays these indexes. - */ -public class DocumentSamples { - - private Map classToCoreFunction = new HashMap(); - private Map coreFunctionToClass = new HashMap(); - private Map classToSignificantFunction = new HashMap(); - private Map significantFunctionToClass = new HashMap(); - - public static void main(String[] args) throws SecurityException, - NoSuchMethodException, IllegalArgumentException, InstantiationException, - IllegalAccessException, InvocationTargetException, IOException { - - DocumentSamples ds = new DocumentSamples(); - ds.run(); - - } - - private static String HTML_HEADER = - "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" + - "<html>\n" + - "<!-- Note: This file is GENERATED from the samples using the\n" + - "Document Samples utility. Hand edits will be lost when regenerated! --> \n"+ - "<!-- \n"+ - "* \n"+ - "* Licensed to the Apache Software Foundation (ASF) under one \n"+ - "* or more contributor license agreements. See the NOTICE file\n"+ - "* distributed with this work for additional information \n"+ - "* regarding copyright ownership. The ASF licenses this file \n"+ - "* to you under the Apache License, Version 2.0 (the \n"+ - "* \"License\"); you may not use this file except in compliance \n"+ - "* with the License. You may obtain a copy of the License at \n"+ - "* \n"+ - "* http://www.apache.org/licenses/LICENSE-2.0 \n"+ - "* \n"+ - "* Unless required by applicable law or agreed to in writing, \n"+ - "* software distributed under the License is distributed on an \n"+ - "* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY \n"+ - "* KIND, either express or implied. See the License for the \n"+ - "* specific language governing permissions and limitations \n"+ - "* under the License. \n"+ - "--> \n"+ - "<head><title>SDO Samples</title></head><body>\n" + - " <h1>SDO Samples</h1>\n" + - "<P>\n" + - "The samples provided in the Tuscany SDO distribution cover many areas of\n" + - "the SDO API. Here we provide two indexes into the samples. The first lists\n" + - "each sample in sequence and details the central theme(s) of the sample.\n" + - "It also mentions if the sample significantly demonstrates other areas in passing.\n" + - "The second index lists all the themes that are covered by these samples, and\n" + - "indicates which of the samples has that subject area as a central theme or as\n" + - "demonstrates the subject area significant as an incidental part of the sample."; - - private static String CLASSES_HEADING = - "<H2>Index by Sample Program Name</H2>\n"; - - private static String FUNCTION_HEADING = - "<H2>Index by function</H2>\n"; - - private static String HTML_FOOTER = - "</body>\n</html>"; - - - private void run() throws IllegalAccessException { - /* - * gather the data - */ - for (int i = 0; i < SampleInfrastructure.sampleClasses.length; i++) { - Class c = SampleInfrastructure.sampleClasses[i]; - classToCoreFunction.put(c, new HashSet()); - try { - Field coreFunction = c.getField("CORE_FUNCTION"); - recordFunction(c, coreFunction, coreFunctionToClass, classToCoreFunction); - } catch (NoSuchFieldException e) { - // no problem - } - try { - Field sigFunction = c.getField("SIGNIFICANT_FUNCTION"); - recordFunction(c, sigFunction, significantFunctionToClass, classToSignificantFunction); - } catch (NoSuchFieldException e) { - // no problem - } - } - - /* - * create the documentation - */ - StringBuffer doc = new StringBuffer(); - doc.append(HTML_HEADER); - - doc.append(CLASSES_HEADING); - Class [] classes = SampleInfrastructure.sampleClasses; - for(int i=0; i < classes.length;i++) { - doc.append("<h3>Sample Program " + getSimpleName(classes[i]) + "</h3>\n"); - doc.append("<b>Core function:</b><br/>\n"); - int [] functions = (int[])classToCoreFunction.get(classes[i]); - for(int j=0;j<functions.length;j++) { - doc.append("<a href=\"#facet") - .append(functions[j]) - .append("\">") - .append(SDOFacets.subject_areas[functions[j]]) - .append("</a><br/>\n"); } - doc.append("<br/>"); - if(classToSignificantFunction.get(classes[i])!= null) { - doc.append("<b>Also demonstrates:</b><br/>\n"); - functions = (int[])classToSignificantFunction.get(classes[i]); - for(int j=0;j<functions.length;j++) { - doc.append("<a href=\"#facet") - .append(functions[j]) - .append("\">") - .append(SDOFacets.subject_areas[functions[j]]) - .append("</a><br/>\n"); - } - } - } - - doc.append(FUNCTION_HEADING); - - String [] facets = SDOFacets.subject_areas; - for(int f = 0; f<facets.length; f++) { - Integer fobj = new Integer(f); - doc.append("<a name=\"facet") - .append(f) - .append("\"/>\n<h3>") - .append(SDOFacets.subject_areas[f]) - .append("</h3>\n"); - if(coreFunctionToClass.keySet().contains(fobj)) { - doc.append("<b>Samples which demonstrate this as their core function</b><br/>\n"); - Set classesWithFunction = (Set)coreFunctionToClass.get(fobj); - for(Iterator cwf = classesWithFunction.iterator(); cwf.hasNext();) { - Class c = (Class)cwf.next(); - doc.append(getSimpleName(c)).append("<br/>\n"); - } - } - if(significantFunctionToClass.keySet().contains(fobj)) { - doc.append("<b>Samples which demonstrate this in addition to their core function</b><br/>\n"); - Set classesWithFunction = (Set)significantFunctionToClass.get(fobj); - for(Iterator cwf = classesWithFunction.iterator(); cwf.hasNext();) { - Class c = (Class)cwf.next(); - doc.append(getSimpleName(c)).append("<br/>\n"); - } - } - - } - - doc.append(HTML_FOOTER); - System.out.println(doc); - } - - private int[] recordFunction(Class c, Field functionIndices, Map ftoc, Map ctof) - throws IllegalAccessException { - int[] functions = (int[]) functionIndices.get(c); - for (int j = 0; j < functions.length; j++) { - addClassesToFunction(ftoc, functions[j], c); - } - ctof.put(c, functions); - return functions; - } - - private void addClassesToFunction(Map functionToClass, int i, Class c) { - Integer iobj = new Integer(i); - if (!functionToClass.containsKey(iobj)) { - functionToClass.put(iobj, new HashSet()); - } - ((Set) (functionToClass.get(iobj))).add(c); - } - - private String getSimpleName(Class c) { - String result = c.getName(); - int lastDot = result.lastIndexOf('.'); - if(lastDot != -1) { - result = result.substring(lastDot+1); - } - return result; - } -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/SampleInfrastructure.java b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/SampleInfrastructure.java deleted file mode 100644 index aa65cbad6d..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/SampleInfrastructure.java +++ /dev/null @@ -1,330 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.internal; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.HashSet; -import java.util.Set; - -import org.apache.tuscany.samples.sdo.advanced.MedicalScenario; -import org.apache.tuscany.samples.sdo.advanced.MedicalScenarioWithChangeMonitoring; -import org.apache.tuscany.samples.sdo.advanced.ObtainingDataGraphFromXml; -import org.apache.tuscany.samples.sdo.advanced.PrintDataGraph; -import org.apache.tuscany.samples.sdo.basic.AccessDataObjectPropertiesByName; -import org.apache.tuscany.samples.sdo.basic.AccessingTheContentsOfASequence; -import org.apache.tuscany.samples.sdo.basic.CreateCompany; -import org.apache.tuscany.samples.sdo.basic.CreatePurchaseOrder; -import org.apache.tuscany.samples.sdo.basic.ReadPurchaseOrder; -import org.apache.tuscany.samples.sdo.intermediate.AccessDataObjectUsingValidXPath; -import org.apache.tuscany.samples.sdo.intermediate.AccessingDataObjectsViaPropertyIndex; -import org.apache.tuscany.samples.sdo.intermediate.CreateCompanyTuscanyAPI; -import org.apache.tuscany.samples.sdo.intermediate.CreateDataObjectFromXmlString; -import org.apache.tuscany.samples.sdo.intermediate.DynamicCustomerTypeSample; -import org.apache.tuscany.samples.sdo.intermediate.SerializingDeserializingADataObject; - -/** - * 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(); - - /** - * Here's the list of sample programs - */ - public static final Class[] sampleClasses = { - CreateCompany.class, - ReadPurchaseOrder.class, - CreatePurchaseOrder.class, - AccessDataObjectPropertiesByName.class, - AccessingTheContentsOfASequence.class, - - AccessDataObjectUsingValidXPath.class, - DynamicCustomerTypeSample.class, - CreateCompanyTuscanyAPI.class, - CreateDataObjectFromXmlString.class, - SerializingDeserializingADataObject.class, - AccessingDataObjectsViaPropertyIndex.class, - - ObtainingDataGraphFromXml.class, - PrintDataGraph.class, - MedicalScenario.class, - MedicalScenarioWithChangeMonitoring.class - - }; - - public static class SDOFacets { - public static final int GET_PROPERTIES_OF_DATAOBJECT_BY_NAME = 1; - public static final int SET_PROPERTIES_OF_DATAOBJECT_BY_NAME = 2; - public static final int CREATE_DATAOBJECTS_BY_NAME = 3; - public static final int GET_SET_PROPERTIES_OF_DATAOBJECT_BY_INDEX = 4; - public static final int GET_SET_PROPERTIES_BY_INSTANCE_PROPERTIES = 5; - public static final int GET_SET_PROPERTIES_OF_DATAOBJECT_BY_XPATH = 6; - public static final int ISMANY_PROPERTIES = 7; - public static final int CONTAINMENT = 8; - public static final int CREATE_TYPES_USING_THE_SDO_API = 9; - public static final int CREATE_TYPES_USING_XML_SCHEMA = 10; - public static final int CREATE_TYPES_USING_THE_TUSCANY_API = 11; - public static final int USING_BUILT_IN_TYPES = 12; - public static final int ACCESSING_VALUES_IN_A_SEQUENCE = 13; - public static final int GENERIC_DATA_GRAPH_TRAVERSAL = 14; - public static final int LOADING_DATA_FROM_XML = 15; - public static final int SAVING_DATA_TO_XML = 16; - public static final int CHANGE_MONITORING_USING_A_DATAGRAPH = 17; - public static final int CHANGE_MONITORING_USING_A_CHANGESUMMARY_PROPERTY_ON_A_DATAOBJECT = 18; - public static final int WRAPPING_DATA_GRAPH_IN_A_DATAGRAPH_INSTANCE = 19; - public static final int OPEN_CONTENT = 20; - public static final int NON_CONTAINMENT = 21; - public static final int CREATE_XML_SCHEMA_FROM_TYPES = 22; - public static final int JAVA_SERIALIZATION_OF_DATA_GRAPH = 23; - public static final int TESTING_FOR_GRAPH_EQUALITY = 24; - - public static final String [] subject_areas = { - "", - "Get Properties of DataObject by name", - "Set Properties of DataObject by name", - "Create DataObjects by name", - "Get/Set Properties of DataObject by index", - "Get/Set Properties by Instance Properties", - "Get/Set Properties of DataObject by Xpath", - "isMany Properties","Containment", - "Create Types using the SDO API", - "Create Types using XML Schema", - "Create Types using the Tuscany API", - "Using Built-in Types", - "Accessing values in a Sequence", - "Generic data graph traversal", - "Loading data from XML", - "Saving data to XML", - "Change Monitoring using a DataGraph", - "Change Monitoring using a ChangeSummary Property on a DataObject", - "Wrapping data graph in a DataGraph instance", - "Open Content","Non-Containment", - "Create XML Schema from Types", - "Java Serialization of data graph", - "Testing for Graph Equality" - }; - } - - - /* - * 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) { - 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. - */ - 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. - */ - 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" }; - - /* - * 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) { - System.out.println(hrule); - return; - } - 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; - } - - 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++) { - buf.append(borderChar).append(" "); - buf.append(lines[l]); - 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++) { - buf.append(borderChar); - } - buf.append("\n"); - System.out.println(buf.toString()); - } - - public void banner(String text) { - banner('-', text); - } - - protected void commentary(String text, String repeatText) { - commentary(new Integer(sampleComplexityLevel), text, repeatText); - - } - - protected void commentary(Integer commentLevel, String text, String repeatText) { - - if (commentLevel.intValue() < commentaryLevel) - return; - - if (repeatText != null) { - boolean alreadySeen = commentaryHistory.contains(text); - if (alreadySeen) { - commentary(commentLevel, repeatText); - } else { - commentary(commentLevel, text); - commentaryHistory.add(text); - } - } else { - commentary(commentLevel, text); - } - - } - - protected void commentary(Integer commentLevel, String text) { - if (commentLevel.intValue() >= commentaryLevel) { - banner(text); - } - } - - /* - * 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"); - - 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 - * - * @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.println(); - - 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"); - - try { - runSample(); - } catch (Exception e) { - somethingUnexpectedHasHappened(e); - } finally { - commentary(COMMENTARY_ALWAYS, " End of sample " - + this.getClass().getName() + " "); - } - } - - public abstract void runSample() throws Exception; - - public int getSampleComplexityLevel() { - return sampleComplexityLevel; - } - - public void setSampleComplexityLevel(Integer sampleComplexityLevel) { - this.sampleComplexityLevel = sampleComplexityLevel.intValue(); - } - -} diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/overview.html b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/overview.html deleted file mode 100644 index b4fc183800..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/overview.html +++ /dev/null @@ -1,127 +0,0 @@ -<html>
-<!--
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
- * -->
-<head>
- <title>SDO Sample Overview</title>
-</head>
-<BODY>
-<h1>Tuscany Service Data Object (SDO) Sample Programs</h1> <h2>Overview</h2>
-<a href="http://incubator.apache.org/tuscany">Apache Tuscany</a> SDO samples
-are provided here to help users learn SDO.
-The <a href="sampleProgramContents.html">index by SDO
-subject areas</a> lists the different samples available
-to you. These samples provide a starting point for learning SDO and can be
-extended and enhanced to experiment with other available SDO features.
-Please help us enhance these samples by sending your feedback to Tuscany
-mailing list or join us and <a href="http://incubator.apache.org/tuscany/getting-involved.html">contribute to this
-project</a>.
-</P>
-<P>
-These samples are coded to the SDO 2.1 API defined <a href="http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf">
-here</a>
-</P>
-<P>
-These samples provide a place to begin learning and 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 does not cover a desired area, please send feedback to the
-Tuscany mailing lists, or better still send us a patch or join the Tuscany team
-and contribute back to the <A
-href="http://incubator.apache.org/tuscany">project</A>.
-</P>
-<h3>Running the Samples from a Binary Distribution of Apache Tuscany</h3>
-<P>The
-SDO samples have been written to be useful in learning SDO, even without
-reference to the sample source code. The samples output commentary as they
-execute and key lines of source code are output too. One of the sample programs
-(ExecuteSamples) executes all the other samples in sequence. The binary
-distribution includes the sample source code too, so that you can investigate
-further if you wish.
-</P>
-<P>
-The binary distribution of Tuscany contains a pair of scripts to execute the
-ExecuteSamples program (runsamples.bat and runsamples.sh). To execute the
-samples first locate the appropriate script for your environment in the samples
-directory of the binary distribution and set the value of the BINARY_BASE
-variable to be the directory in your file system that contains the lib and
-samples directories. Then run the script and take a look at the output. After
-that, copy and modify the script to suit your own purposes in running the other
-samples.
-</P>
-<h3>Running the Samples from a Source Distribution of Apache Tuscany</h3>
-<P>
-The
-samples depend on the following libraries
-</P>
-<UL>
- <LI>
- The samples themselves, the SDO 2.1 API and the Tuscany SDO
- Implementation
- <UL>
- <LI>
- sample-sdo-{tuscany-version}.jar - SDO API
- </LI>
- <LI>
- sdo-api-r2.1-{tuscany-version}.jar - SDO API
- </LI>
- <LI>
- tuscany-sdo-lib-{tuscany-version}.jar - Tuscany APIs and support
- function
- </LI>
- <LI>
- tuscany-sdo-impl-{tuscany-version}.jar - Tuscany SDO
- implementation
- </LI>
- </UL>
- </LI>
- <LI>
- EMF dependencies.
- <UL>
- <LI>
- common-{version}.jar - some common framework utility and base classes
- </LI>
- <LI>
- ecore-{version}.jar - the EMF core runtime implementation classes (the Ecore
- metamodel)
- </LI>
- <LI>
- ecore-change-{version}.jar - the EMF change recorder and framework
- </LI>
- <LI>
- ecore-xmi-{version}.jar - EMF's default XML (and XMI) serializer and loader
- </LI>
- <LI>
- xsd-{version}.jar - the XML Schema model
- </LI>
- </UL>
- </LI>
- <LI>And the StAX API</LI>
- <UL>
- <LI>stax-api-1.0.1.jar</LI>
- </UL>
-</UL>
-<P>
-If you are running these samples as a result of building Tuscany SDO for Java
-from a Tuscany source distribution using maven then these dependencies will be
-resolved by having followed the instructions in the BUILDING file at the root of
-the source distribution.
-</P>
-</BODY>
-</html>
diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/package.html b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/package.html deleted file mode 100644 index c1335e6e5b..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/package.html +++ /dev/null @@ -1,33 +0,0 @@ -<html> -<!-- - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - * --> -<head> - <title>package information</title> -</head> -<body> -Provides common constants and a command line java interface for executing samples. -<h2>Related Documentation</h2> -For overviews, tutorials, examples, guides, and tool documentation, please see the -<a href="http://cwiki.apache.org/TUSCANY/sdo-overview.html"> SDO Java Overview -</a> -section of the Tuscany website. - -</body> -</html>
\ No newline at end of file diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/sampleProgramContents.html b/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/sampleProgramContents.html deleted file mode 100644 index cc646ed3a9..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/java/org/apache/tuscany/samples/sdo/sampleProgramContents.html +++ /dev/null @@ -1,243 +0,0 @@ -<html>
-<!-- Note -- this file is GENERATED from the samples using the
-Document Samples utility. Hand edits will be lost when regenerated!-->
-<!--
-*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you 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.
--->
-<head><title>SDO Samples</title></head><body>
- <h1>SDO Samples</h1>
-<P>
-The samples provided in the Tuscany SDO distribution cover many areas of
-the SDO API. Here we provide two indexes into the samples. The first lists
-each sample in sequence and details the central theme(s) of the sample.
-It also mentions if the sample significantly demonstrates other areas in passing.
-The second index lists all the themes that are covered by these samples, and
-indicates which of the samples has that subject area as a central theme or as
-demonstrates the subject area significant as an incidental part of the sample.<H2>Index by Sample Program Name</H2>
-<h3>Sample Program CreateCompany</h3>
-<b>Core function:</b><br/>
-<a href="#facet2">Set Properties of DataObject by name</a><br/>
-<br/><h3>Sample Program ReadPurchaseOrder</h3>
-<b>Core function:</b><br/>
-<a href="#facet15">Loading data from XML</a><br/>
-<a href="#facet16">Saving data to XML</a><br/>
-<br/><b>Also demonstrates:</b><br/>
-<a href="#facet1">Get Properties of DataObject by name</a><br/>
-<h3>Sample Program CreatePurchaseOrder</h3>
-<b>Core function:</b><br/>
-<a href="#facet15">Loading data from XML</a><br/>
-<a href="#facet16">Saving data to XML</a><br/>
-<br/><h3>Sample Program AccessDataObjectPropertiesByName</h3>
-<b>Core function:</b><br/>
-<a href="#facet1">Get Properties of DataObject by name</a><br/>
-<br/><h3>Sample Program AccessingTheContentsOfASequence</h3>
-<b>Core function:</b><br/>
-<a href="#facet13">Accessing values in a Sequence</a><br/>
-<br/><h3>Sample Program AccessDataObjectUsingValidXPath</h3>
-<b>Core function:</b><br/>
-<a href="#facet6">Get/Set Properties of DataObject by Xpath</a><br/>
-<br/><h3>Sample Program DynamicCustomerTypeSample</h3>
-<b>Core function:</b><br/>
-<a href="#facet9">Create Types using the SDO API</a><br/>
-<br/><b>Also demonstrates:</b><br/>
-<a href="#facet2">Set Properties of DataObject by name</a><br/>
-<a href="#facet12">Using Built-in Types</a><br/>
-<a href="#facet16">Saving data to XML</a><br/>
-<h3>Sample Program CreateCompanyTuscanyAPI</h3>
-<b>Core function:</b><br/>
-<a href="#facet2">Set Properties of DataObject by name</a><br/>
-<br/><h3>Sample Program CreateDataObjectFromXmlString</h3>
-<b>Core function:</b><br/>
-<a href="#facet12">Using Built-in Types</a><br/>
-<a href="#facet15">Loading data from XML</a><br/>
-<br/><h3>Sample Program SerializingDeserializingADataObject</h3>
-<b>Core function:</b><br/>
-<a href="#facet23">Java Serialization of data graph</a><br/>
-<br/><b>Also demonstrates:</b><br/>
-<a href="#facet24">Testing for Graph Equality</a><br/>
-<h3>Sample Program AccessingDataObjectsViaPropertyIndex</h3>
-<b>Core function:</b><br/>
-<a href="#facet4">Get/Set Properties of DataObject by index</a><br/>
-<br/><h3>Sample Program ObtainingDataGraphFromXml</h3>
-<b>Core function:</b><br/>
-<a href="#facet19">Wrapping data graph in a DataGraph instance</a><br/>
-<br/><b>Also demonstrates:</b><br/>
-<a href="#facet12">Using Built-in Types</a><br/>
-<h3>Sample Program PrintDataGraph</h3>
-<b>Core function:</b><br/>
-<a href="#facet14">Generic data graph traversal</a><br/>
-<br/><b>Also demonstrates:</b><br/>
-<a href="#facet5">Get/Set Properties by Instance Properties</a><br/>
-<a href="#facet7">isMany Properties</a><br/>
-<a href="#facet9">Create Types using the SDO API</a><br/>
-<a href="#facet13">Accessing values in a Sequence</a><br/>
-<a href="#facet21">Non-Containment</a><br/>
-<h3>Sample Program MedicalScenario</h3>
-<b>Core function:</b><br/>
-<a href="#facet8">Containment</a><br/>
-<a href="#facet9">Create Types using the SDO API</a><br/>
-<a href="#facet10">Create Types using XML Schema</a><br/>
-<a href="#facet20">Open Content</a><br/>
-<a href="#facet21">Non-Containment</a><br/>
-<br/><b>Also demonstrates:</b><br/>
-<a href="#facet3">Create DataObjects by name</a><br/>
-<a href="#facet7">isMany Properties</a><br/>
-<a href="#facet14">Generic data graph traversal</a><br/>
-<a href="#facet16">Saving data to XML</a><br/>
-<h3>Sample Program MedicalScenarioWithChangeMonitoring</h3>
-<b>Core function:</b><br/>
-<a href="#facet8">Containment</a><br/>
-<a href="#facet9">Create Types using the SDO API</a><br/>
-<a href="#facet10">Create Types using XML Schema</a><br/>
-<a href="#facet20">Open Content</a><br/>
-<a href="#facet21">Non-Containment</a><br/>
-<a href="#facet18">Change Monitoring using a ChangeSummary Property on a DataObject</a><br/>
-<br/><b>Also demonstrates:</b><br/>
-<a href="#facet3">Create DataObjects by name</a><br/>
-<a href="#facet7">isMany Properties</a><br/>
-<a href="#facet14">Generic data graph traversal</a><br/>
-<a href="#facet16">Saving data to XML</a><br/>
-<H2>Index by function</H2>
-<a name="facet0"/>
-<h3></h3>
-<a name="facet1"/>
-<h3>Get Properties of DataObject by name</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-AccessDataObjectPropertiesByName<br/>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-ReadPurchaseOrder<br/>
-<a name="facet2"/>
-<h3>Set Properties of DataObject by name</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-CreateCompany<br/>
-CreateCompanyTuscanyAPI<br/>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-DynamicCustomerTypeSample<br/>
-<a name="facet3"/>
-<h3>Create DataObjects by name</h3>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-MedicalScenario<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<a name="facet4"/>
-<h3>Get/Set Properties of DataObject by index</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-AccessingDataObjectsViaPropertyIndex<br/>
-<a name="facet5"/>
-<h3>Get/Set Properties by Instance Properties</h3>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-PrintDataGraph<br/>
-<a name="facet6"/>
-<h3>Get/Set Properties of DataObject by Xpath</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-AccessDataObjectUsingValidXPath<br/>
-<a name="facet7"/>
-<h3>isMany Properties</h3>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-PrintDataGraph<br/>
-MedicalScenario<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<a name="facet8"/>
-<h3>Containment</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-MedicalScenario<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<a name="facet9"/>
-<h3>Create Types using the SDO API</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-MedicalScenario<br/>
-DynamicCustomerTypeSample<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-PrintDataGraph<br/>
-<a name="facet10"/>
-<h3>Create Types using XML Schema</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-MedicalScenario<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<a name="facet11"/>
-<h3>Create Types using the Tuscany API</h3>
-<a name="facet12"/>
-<h3>Using Built-in Types</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-CreateDataObjectFromXmlString<br/>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-ObtainingDataGraphFromXml<br/>
-DynamicCustomerTypeSample<br/>
-<a name="facet13"/>
-<h3>Accessing values in a Sequence</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-AccessingTheContentsOfASequence<br/>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-PrintDataGraph<br/>
-<a name="facet14"/>
-<h3>Generic data graph traversal</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-PrintDataGraph<br/>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-MedicalScenario<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<a name="facet15"/>
-<h3>Loading data from XML</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-CreateDataObjectFromXmlString<br/>
-CreatePurchaseOrder<br/>
-ReadPurchaseOrder<br/>
-<a name="facet16"/>
-<h3>Saving data to XML</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-CreatePurchaseOrder<br/>
-ReadPurchaseOrder<br/>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-MedicalScenario<br/>
-DynamicCustomerTypeSample<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<a name="facet17"/>
-<h3>Change Monitoring using a DataGraph</h3>
-<a name="facet18"/>
-<h3>Change Monitoring using a ChangeSummary Property on a DataObject</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<a name="facet19"/>
-<h3>Wrapping data graph in a DataGraph instance</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-ObtainingDataGraphFromXml<br/>
-<a name="facet20"/>
-<h3>Open Content</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-MedicalScenario<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<a name="facet21"/>
-<h3>Non-Containment</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-MedicalScenario<br/>
-MedicalScenarioWithChangeMonitoring<br/>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-PrintDataGraph<br/>
-<a name="facet22"/>
-<h3>Create XML Schema from Types</h3>
-<a name="facet23"/>
-<h3>Java Serialization of data graph</h3>
-<b>Samples which demonstrate this as their core function</b><br/>
-SerializingDeserializingADataObject<br/>
-<a name="facet24"/>
-<h3>Testing for Graph Equality</h3>
-<b>Samples which demonstrate this in addition to their core function</b><br/>
-SerializingDeserializingADataObject<br/>
-</body>
-</html>
diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/LICENSE.txt b/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 9a90d375bc..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,207 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. - - - - - diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/NOTICE b/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/NOTICE deleted file mode 100644 index 9f9572a167..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/NOTICE +++ /dev/null @@ -1,7 +0,0 @@ -Apache Tuscany -Copyright (c) 2005 - 2008 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - - diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/README.txt b/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/README.txt deleted file mode 100644 index 3394b161cf..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/META-INF/README.txt +++ /dev/null @@ -1,23 +0,0 @@ -Apache Tuscany 1.1.1-incubating-SNAPSHOT build (May 2008) -========================================================= - -http://incubator.apache.org/tuscany/ - -Support -------- - -Any problem with this release can be reported to the Tuscany mailing list -or in the JIRA issue tracker. - -Mailing list subscription: - tuscany-dev-subscribe@ws.apache.org - -Jira: - http://issues.apache.org/jira/browse/Tuscany - - -Thank you for using Tuscany! - - -The Tuscany Team. - diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/MedicalTest.xsd b/branches/sdo-1.1.1-incubating/sample/src/main/resources/MedicalTest.xsd deleted file mode 100644 index 34ae528148..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/MedicalTest.xsd +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - --> -<schema xmlns="http://www.w3.org/2001/XMLSchema" - xmlns:people="www.example.org/people" xmlns:sdo="commonj.sdo" - xmlns:sdoxml="commonj.sdo/xml" - xmlns:tns="www.example.org/MedicalTest" - targetNamespace="www.example.org/MedicalTest"> - - <import namespace="www.example.org/people" - schemaLocation="People.xsd" /> - - <element name="test" type="tns:Test" /> - <element name="condition" type="tns:Condition" /> - - <complexType name="Test"> - <sequence> - <element name="referrals" type="people:PersonSet" /> - <element name="patients" type="people:PersonSet" /> - <element name="relatives" type="people:PersonSet" /> - </sequence> - </complexType> - - <complexType name="Condition"> - <sequence> - <element name="diagnosed" type="date" /> - </sequence> - <attribute name="name" type="tns:ConditionName" /> - </complexType> - - <simpleType name="ConditionName"> - <restriction base="string"> - <enumeration value="Rigellian fever" /> - <enumeration value="Vegan choriomeningitis" /> - <enumeration value="Scrofungulus" /> - <enumeration value="Panar Syndrome" /> - </restriction> - </simpleType> - - -</schema> diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/MedicalTest_CS.xsd b/branches/sdo-1.1.1-incubating/sample/src/main/resources/MedicalTest_CS.xsd deleted file mode 100644 index 668c023bc6..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/MedicalTest_CS.xsd +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - --> -<schema xmlns="http://www.w3.org/2001/XMLSchema" - xmlns:people="www.example.org/people" xmlns:sdo="commonj.sdo" - xmlns:sdoxml="commonj.sdo/xml" - xmlns:tns="www.example.org/MedicalTest" - targetNamespace="www.example.org/MedicalTest"> - - <import namespace="www.example.org/people" - schemaLocation="People.xsd" /> - - <element name="test" type="tns:Test" /> - <element name="condition" type="tns:Condition" /> - - <complexType name="Test"> - <sequence> - <element name="referrals" type="people:PersonSet" /> - <element name="patients" type="people:PersonSet" /> - <element name="relatives" type="people:PersonSet" /> - <element name="changes" type="sdo:ChangeSummaryType" /> - </sequence> - </complexType> - - <complexType name="Condition"> - <sequence> - <element name="diagnosed" type="date" /> - </sequence> - <attribute name="name" type="tns:ConditionName" /> - </complexType> - - <simpleType name="ConditionName"> - <restriction base="string"> - <enumeration value="Rigellian fever" /> - <enumeration value="Vegan choriomeningitis" /> - <enumeration value="Scrofungulus" /> - <enumeration value="Panar Syndrome" /> - </restriction> - </simpleType> - - -</schema> diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/People.xsd b/branches/sdo-1.1.1-incubating/sample/src/main/resources/People.xsd deleted file mode 100644 index b9e59701ae..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/People.xsd +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. - --> -<schema xmlns="http://www.w3.org/2001/XMLSchema" - targetNamespace="www.example.org/people" - xmlns:sdo="commonj.sdo" - xmlns:sdoxml="commonj.sdo/xml" - xmlns:tns="www.example.org/people"> - - <!-- <import namespace="commonj.sdo/xml" schemaLocation="sdoXML.xsd" /> --> - - <complexType name="Person"> - <sequence> - <element name="dob" type="date"/> - <element name="relative" maxOccurs="unbounded" type="tns:Relative"/> - <any namespace="##other" processContents="lax" maxOccurs="unbounded"/> - </sequence> - <attribute name="id" type="ID"/> - <attribute name="name" type="string"/> - <attribute name="gender" type = "tns:Gender"/> - </complexType> - - <!-- <complexType name="Parent"> - <attribute name="parent" type="IDREF" sdoxml:propertyType="tns:Person" use="required"/> - <attribute name="genetic" use="optional" type="boolean"/> - </complexType> --> - - <complexType name="Relative"> - <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person" use="required"/> - <attribute name="relationship" type="string" /> - <attribute name="genetic" use="optional" type="boolean"/> - </complexType> - - <!-- <complexType name="GeneticParent"> - <complexContent> - <extension base="tns:Parent"> - </extension> - </complexContent> - </complexType> --> - - <complexType name="PersonSet"> - <sequence> - <element name="person" type="tns:Person" maxOccurs="unbounded"/> - </sequence> - </complexType> - - <simpleType name="Gender"> - <restriction base="string"> - <enumeration value="male" /> - <enumeration value="female" /> - </restriction> - </simpleType> - -</schema> diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/company.xsd b/branches/sdo-1.1.1-incubating/sample/src/main/resources/company.xsd deleted file mode 100644 index c699f89e31..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/company.xsd +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> - - <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> diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyCompleteDataGraph.xml b/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyCompleteDataGraph.xml deleted file mode 100644 index f636f2131e..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyCompleteDataGraph.xml +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> -<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> diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyDataGraph.xml b/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyDataGraph.xml deleted file mode 100644 index 7114b98fdf..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyDataGraph.xml +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> - -<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> - diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyDataGraphGenerated.xml b/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyDataGraphGenerated.xml deleted file mode 100644 index a99e71bbaa..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyDataGraphGenerated.xml +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> - -<sdo:datagraph xmlns:company="company.xsd" xmlns:sdo="commonj.sdo"> - <company:company 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:company> -</sdo:datagraph> diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyGenerated.xml b/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyGenerated.xml deleted file mode 100644 index 0108e67a4b..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/companyGenerated.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> -<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 diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/doc-files/cmdPrompt.GIF b/branches/sdo-1.1.1-incubating/sample/src/main/resources/doc-files/cmdPrompt.GIF Binary files differdeleted file mode 100644 index ad2fbbf46f..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/doc-files/cmdPrompt.GIF +++ /dev/null diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/letter.xml b/branches/sdo-1.1.1-incubating/sample/src/main/resources/letter.xml deleted file mode 100644 index 85e0bd42b8..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/letter.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> - -<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 diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/letter.xsd b/branches/sdo-1.1.1-incubating/sample/src/main/resources/letter.xsd deleted file mode 100644 index e6e077ff75..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/letter.xsd +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> - -<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> - diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/po.xml b/branches/sdo-1.1.1-incubating/sample/src/main/resources/po.xml deleted file mode 100644 index e44cb07720..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/po.xml +++ /dev/null @@ -1,57 +0,0 @@ -<?xml version="1.0" encoding="ASCII"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> - -<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 diff --git a/branches/sdo-1.1.1-incubating/sample/src/main/resources/po.xsd b/branches/sdo-1.1.1-incubating/sample/src/main/resources/po.xsd deleted file mode 100644 index 8929775d49..0000000000 --- a/branches/sdo-1.1.1-incubating/sample/src/main/resources/po.xsd +++ /dev/null @@ -1,81 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - --> -<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 |