You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ke...@apache.org on 2007/07/19 17:34:21 UTC
svn commit: r557658 - in
/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo:
basic/ intermediate/
Author: kelvingoodson
Date: Thu Jul 19 08:34:16 2007
New Revision: 557658
URL: http://svn.apache.org/viewvc?view=rev&rev=557658
Log:
attend to FIXMEs in samples
Modified:
incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java
incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessingTheContentsOfASequence.java
incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateDataObjectFromXmlString.java
incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java
Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java?view=diff&rev=557658&r1=557657&r2=557658
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessDataObjectPropertiesByName.java Thu Jul 19 08:34:16 2007
@@ -67,28 +67,31 @@
DataObject purchaseOrder = getDataObjectFromFile(scope, SampleInfrastructure.PO_XML_RESOURCE);
- // FIXME still converting this sample
-
- System.out.println("Accessing properties by name");
+ System.out.println("Accessing properties of purchaseOrder by name");
System.out.println("Purchase Order: ");
- System.out.println(" Order date: " + purchaseOrder.get("orderDate"));
- System.out.println(" Comment: " + purchaseOrder.get("comment"));
+ 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(" Ship to name: " + shipTo.get("name"));
+ 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(" Bill to name: " + billTo.get("name"));
+ 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(" Part num: " + item.get("partNum"));
- System.out.println(" Product name: " + item.get("productName"));
+ System.out.println(" item[" + i + "]");
+ System.out.println(" item.get(\"partNum\"): " + item.get("partNum"));
+ System.out.println(" item.get(\"productName\"): " + item.get("productName"));
}
}
Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessingTheContentsOfASequence.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessingTheContentsOfASequence.java?view=diff&rev=557658&r1=557657&r2=557658
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessingTheContentsOfASequence.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/AccessingTheContentsOfASequence.java Thu Jul 19 08:34:16 2007
@@ -85,49 +85,31 @@
DataObject letter = getDataObjectFromFile(scope, LETTER_XML);
// print letter sequence
- commentary("We've loaded a documet from an XML file that contains mixed content.\n" +
+ 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"));
-
-
- System.out.println("\nThe Type for the letter DataObject is mixed: " + scope.getXSDHelper().isMixed(letter.getType()));
+ 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();
-// FIXME -- sort out how this should be -- i think it is confusing
-
- System.out.println("Unstructured text:");
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("\t(" + text + ")");
+ System.out.println("Unstructured text (" + text + ")");
+ } else {
+ System.out.println("Property: " + prop.getName() + " Value : " + letterSequence.getValue(i));
}
}
- // Verify that the lastName property of the DataObject has the same
- // value as the lastName property for the Sequence.
- String dataObjectLastName = letter.getString("lastName");
- for (int i = 0; i < letterSequence.size(); i++) {
-
- /*
- * The following line has been corrected from the 2.0 specification
- * According to the SDO API sequence.getProperty will return null if the content is mixed.
- * We want to check that the content is not mixed, and then check that it it is the property which
- * we are looking for
- */
- Property property = letterSequence.getProperty(i);
-
- if ( (property != null) && ("lastName".equals(property.getName()))) {
- String sequenceLastName = (String) letterSequence.getValue(i);
- if (dataObjectLastName == sequenceLastName)
- System.out.println("Last Name property matches");
- break;
- }
- }
-
+ 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 untructured\n" +
+ "text and see the ordering of the instance document");
}
-
}
Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateDataObjectFromXmlString.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateDataObjectFromXmlString.java?view=diff&rev=557658&r1=557657&r2=557658
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateDataObjectFromXmlString.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/CreateDataObjectFromXmlString.java Thu Jul 19 08:34:16 2007
@@ -88,18 +88,14 @@
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");
+ "the document\n\n" +
+ "purchaseOrder.getType().isOpen returns true\n" +
+ "purchaseOrder.getType().getProperty(\"shipTo\") returns null and\n" +
+ "purchaseOrder.getInstanceProperty(\"shipTo\") returns a Property");
-
- // FIXME I'm not sure how to explain why the top level data object is of type AnyTypeDataObject
- // and the shipTo Property's type is DataObject
- // FIXME show that this is open and isDataType = false
- System.out.println("The type of the DataObject is " + purchaseOrder.getType().getName() +
- " and has " + purchaseOrder.getType().getProperties().size() + " Properties");
- System.out.println("The type of the DataObject is " + purchaseOrder.getInstanceProperty("shipTo").getType().getName());
- System.out.println("The DataObject itself has " + purchaseOrder.getInstanceProperties().size() + " Properties\n");
- Property p0 = (Property)purchaseOrder.getInstanceProperties().get(0);
- System.out.println("The first of these instance Properties is " + p0.getName() + " and is of type " + p0.getType().getName());
+ System.out.println("DataObject's type is open?: " + purchaseOrder.getType().isOpen());
+ System.out.println("Data Object's type has a propery shipTo?: " + (purchaseOrder.getType().getProperty("shipTo") != null));
+ System.out.println("Data Object instance has a propery shipTo?: " + (purchaseOrder.getInstanceProperty("shipTo") != null));
commentary(
"Without a Type definition accessing a DataObject is slightly\n"+
Modified: incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java?view=diff&rev=557658&r1=557657&r2=557658
==============================================================================
--- incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java (original)
+++ incubator/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/intermediate/SerializingDeserializingADataObject.java Thu Jul 19 08:34:16 2007
@@ -40,7 +40,6 @@
* sample.
*/
public class SerializingDeserializingADataObject extends SampleBase {
-// TODO reference central build instructions
HelperContext scope;
public SerializingDeserializingADataObject(Integer userLevel) {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org