org.apache.tuscany.samples.sdo.otherSources
Class PurchaseOrderControl

java.lang.Object
  extended by org.apache.tuscany.samples.sdo.otherSources.PurchaseOrderControl

public class PurchaseOrderControl
extends java.lang.Object

Provides operational API for purchase order sample for SDO. It is used by PurchaseOrderCmdLine for an interactive sample. Often relies upon methods that are located within the org.apache.tuscany.samples.sdo.otherSources package.

See Also:
PurchaseOrderCmdLine

Field Summary
static int SET_DECIMAL_PROPERTY_VIA_SET
           
static int SET_DECIMAL_PROPERTY_VIA_SET_DOUBLE
           
static int SET_DECIMAL_PROPERTY_VIA_SET_STRING
           
 
Constructor Summary
PurchaseOrderControl()
          Uses resources files included in jar file to define types (using xsd), and populate DataObjects (xml)
PurchaseOrderControl(java.lang.String xsdFileName, java.lang.String xmlFileName)
          Uses files on the file system to define types (using xsd), and populate DataObjects (xml)
 
Method Summary
 void addItem(java.lang.String partNumber, java.lang.String productName, double price, int quantity, java.lang.String comment)
          Adds an additional item to the items list of the item property on purchase order DataObject
 void appendComment(java.lang.String newComment)
          Appends new comment to comment property of purchase order Accesses comment property by name
 commonj.sdo.ChangeSummary getChangeSummary()
          Currently this does not work
 int getDecimalPropertyMethod()
          Gets the mechanism used to zip decimal property for the zip code of an address
 commonj.sdo.DataObject getDeepCopyPurchaseOrder()
           
 commonj.sdo.DataObject getPurchaseOrder()
           
 commonj.sdo.DataObject getShallowCopyPurchaseOrder()
           
 commonj.sdo.helper.XMLDocument getXMLDocuement()
           
 java.lang.String getXMLString()
           
 void modifyBillTo(java.lang.String name, java.lang.String street, java.lang.String city, java.lang.String state, java.lang.String zip)
          Modifies complex address type for billTo.
 void modifyShipTo(java.lang.String name, java.lang.String street, java.lang.String city, java.lang.String state, java.lang.String zip)
          Modifies complex address type for shipTo.
 void printBillTo()
          Prints properties of shipTo
 void printChangeSummary()
          Prints purchase order summary to System.out
 void printPurchaseOrderProperties()
          Uses simple sample PrintPropertiesOfDataObject
 void printPurchaseOrderSummary()
          Accesses key properties via name and prints to System.out
 void printShipTo()
          Prints properties of billTo
 void readPurchaseOrderXml()
          Reads in xml and populates DataGraph.
 void removeItem(int index)
          Removes a particular item from the items list.
 void save()
          Saves modified purchase order DataObject to original xml used to populate it If resource packaged within jar is used will create a new file on file system
 void saveAs(java.lang.String fileName)
          Saves modified purchaseOrder DataObject to file
 void setComment(java.lang.String comment)
          Sets comment property on purchase order by accessing property by name
 void setDecimalPropertyMethod(int i)
          Sets the mechanism to set decimal property for zip code Decimals can be set in a number of ways.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SET_DECIMAL_PROPERTY_VIA_SET

public static final int SET_DECIMAL_PROPERTY_VIA_SET
See Also:
Constant Field Values

SET_DECIMAL_PROPERTY_VIA_SET_STRING

public static final int SET_DECIMAL_PROPERTY_VIA_SET_STRING
See Also:
Constant Field Values

SET_DECIMAL_PROPERTY_VIA_SET_DOUBLE

public static final int SET_DECIMAL_PROPERTY_VIA_SET_DOUBLE
See Also:
Constant Field Values
Constructor Detail

PurchaseOrderControl

public PurchaseOrderControl()
                     throws java.lang.Exception
Uses resources files included in jar file to define types (using xsd), and populate DataObjects (xml)

Throws:
java.lang.Exception

PurchaseOrderControl

public PurchaseOrderControl(java.lang.String xsdFileName,
                            java.lang.String xmlFileName)
                     throws java.lang.Exception
Uses files on the file system to define types (using xsd), and populate DataObjects (xml)

Parameters:
xsdFileName - location of po.xsd
xmlFileName - location of xml to populate DataObject (for example po.xml)
Throws:
java.lang.Exception
Method Detail

readPurchaseOrderXml

public void readPurchaseOrderXml()
                          throws java.lang.Exception,
                                 java.io.FileNotFoundException
Reads in xml and populates DataGraph. Will set the purchaseOrder to the root object Uses either fileName used to construct this class or will use resource ( po.xml ) included within jar file

Throws:
java.lang.Exception
java.io.FileNotFoundException

appendComment

public void appendComment(java.lang.String newComment)
Appends new comment to comment property of purchase order Accesses comment property by name

Parameters:
newComment -

setComment

public void setComment(java.lang.String comment)
Sets comment property on purchase order by accessing property by name

Parameters:
comment -

modifyBillTo

public void modifyBillTo(java.lang.String name,
                         java.lang.String street,
                         java.lang.String city,
                         java.lang.String state,
                         java.lang.String zip)
Modifies complex address type for billTo. If any parameter is null it will not be modified

Parameters:
name -
street -
city -
state -
zip -

modifyShipTo

public void modifyShipTo(java.lang.String name,
                         java.lang.String street,
                         java.lang.String city,
                         java.lang.String state,
                         java.lang.String zip)
Modifies complex address type for shipTo. If any parameter is null it will not be modified

Parameters:
name -
street -
city -
state -
zip -

addItem

public void addItem(java.lang.String partNumber,
                    java.lang.String productName,
                    double price,
                    int quantity,
                    java.lang.String comment)
Adds an additional item to the items list of the item property on purchase order DataObject

Parameters:
partNumber -
productName -
price -
quantity -
comment -

removeItem

public void removeItem(int index)
Removes a particular item from the items list. Obtains the List associated with the item property and removes by index

Parameters:
index -

save

public void save()
          throws java.io.IOException
Saves modified purchase order DataObject to original xml used to populate it If resource packaged within jar is used will create a new file on file system

Throws:
java.io.IOException

saveAs

public void saveAs(java.lang.String fileName)
            throws java.io.IOException
Saves modified purchaseOrder DataObject to file

Parameters:
fileName. - Location to save file to save DataObject to
Throws:
java.io.IOException

printChangeSummary

public void printChangeSummary()
Prints purchase order summary to System.out


printPurchaseOrderProperties

public void printPurchaseOrderProperties()
                                  throws java.lang.Exception
Uses simple sample PrintPropertiesOfDataObject

Throws:
java.lang.Exception

printPurchaseOrderSummary

public void printPurchaseOrderSummary()
Accesses key properties via name and prints to System.out


printBillTo

public void printBillTo()
Prints properties of shipTo


printShipTo

public void printShipTo()
Prints properties of billTo


setDecimalPropertyMethod

public void setDecimalPropertyMethod(int i)
Sets the mechanism to set decimal property for zip code Decimals can be set in a number of ways. This scenario controls how this class will set the zip code when modifying address


getDecimalPropertyMethod

public int getDecimalPropertyMethod()
Gets the mechanism used to zip decimal property for the zip code of an address

Returns:

getPurchaseOrder

public commonj.sdo.DataObject getPurchaseOrder()
Returns:
purchaseOrder DataObject

getDeepCopyPurchaseOrder

public commonj.sdo.DataObject getDeepCopyPurchaseOrder()
Returns:
deep copy of the purchase order DataObject

getShallowCopyPurchaseOrder

public commonj.sdo.DataObject getShallowCopyPurchaseOrder()
Returns:
shallow copy of the purchase order DataObject

getChangeSummary

public commonj.sdo.ChangeSummary getChangeSummary()
Currently this does not work

Returns:
Change summary for purchaseOrder

getXMLDocuement

public commonj.sdo.helper.XMLDocument getXMLDocuement()
Returns:
XMLDocument that represents current purchase order DataObject

getXMLString

public java.lang.String getXMLString()
Returns:
String xml representation of current purcahse order DataObject


Copyright © 2007 Apache Software Foundation. All Rights Reserved.