Class ProDataGraph

java.lang.Object
com.progress.open4gl.ProDataGraph
All Implemented Interfaces:
commonj.sdo.DataGraph, Externalizable, Serializable, org.eclipse.emf.common.notify.Adapter

public class ProDataGraph extends Object implements commonj.sdo.DataGraph, org.eclipse.emf.common.notify.Adapter, Externalizable
Maps to either a 4GL DataSet, DataSet-Handle, Temp-Table, or Table-Handle parameter in a Java client. It implements the Java SDO DataGraph interface. We made a number of changes to the ProDataGraph class to enable java serialization. 1) Previously, this class extended DataGraphImpl. However, because of the way java serialization is implemented in DataGraphImpl, it is not intended to be used as a base class. Rather than extending DataGraphImpl, we instead implement the DataGraph interfaces and have an instance of DataGraphImpl as a member that we delegate to. This allows successful serialization of the DataGraphImpl as it has not been extended. 2) We now provide implementations of readObject() and writeObject() to control the java serialization of this class. 3) Serialization of the ProDataGraphMetaData is done separately from the serialization of the DataGraphImpl. This is because the type information from the metadata is needed to be able to deserialize the DataGraphImpl. As a result, on deserialization, the metadata information is read first, then creation of the types is done with the method createTypesFromMetadata(), and finally the datagraph can be recreated.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getProChangeSummary

      public ProChangeSummary getProChangeSummary()
      Returns:
      ProChangeSummary object associated with this ProDataGraph.
    • getProDataGraphName

      public String getProDataGraphName()
      Returns:
      Name of ProDataGraph
    • getNumTables

      public int getNumTables()
      Returns:
      The number of ProDataObject collections (temp-tables) in this ProDataGraph object.
    • getMetaData

      public ProDataGraphMetaData getMetaData()
      Returns:
      The ProDataGraphMetaData object
    • acceptChanges

      public void acceptChanges()
      Clears out the change list in the ProChangeSummary. Same behavior as the ChangeSummary.beginLogging().
    • hasError

      public boolean hasError()
      Returns:
      True if AppServer returned error message for ProDataGraph, else False - returned from AppServer.
    • createProDataObject

      public ProDataObject createProDataObject(String tableName) throws Open4GLException
      Returns a new ProDataObject
      Parameters:
      tableName - Specified table within the ProDataGraph
      Returns:
      Newly created ProDataObject instance (row) for tableName.
      Throws:
      Open4GLException
    • addProDataObject

      public void addProDataObject(ProDataObject dataObj) throws Open4GLException
      Adds ProDataObject instance to end of its ProDataObject collection within ProDataGraph.
      Parameters:
      dataObj - ProDataObject to add
      Throws:
      Open4GLException
    • addProDataObject

      public void addProDataObject(int index, ProDataObject dataObj) throws Open4GLException
      Adds ProDataObject instance at specified index in its ProDataObject collection within ProDataGraph.
      Parameters:
      index - 0-based location
      dataObj - ProDataObject to add
      Throws:
      Open4GLException
    • getProDataObjects

      public List<ProDataObject> getProDataObjects(int tableIdx) throws Exception
      Get the list of rows in a table
      Parameters:
      tableIdx - 0-based table index within ProDataGraph
      Returns:
      List of ProDataObject objects (instance data) for the specified tableIdx
      Throws:
      Exception
    • getProDataObjects

      public List<ProDataObject> getProDataObjects(String tableName) throws Exception, Open4GLException
      Get the list of rows in a table
      Parameters:
      tableName -
      Returns:
      List of ProDataObject objects (instance data) for specified tableName
      Throws:
      Exception
      Open4GLException
    • getTableIndex

      public int getTableIndex(String tableName) throws Open4GLException
      Parameters:
      tableName -
      Returns:
      Throws:
      Open4GLException
    • getTableNames

      public String[] getTableNames()
      Returns:
      String array of the table names of the ProDataObject collections in this ProDataGraph object.
    • setChildTableReferences

      public void setChildTableReferences() throws Exception
      Use this to build ProDataGraph object with data relations. It creates all the references (or relationship info) for each ProDataRelationMetaData. Once done, ProDataObject methods getChildRows() and getParentRow() can be used.
      Throws:
      Exception
    • setChildTableReferences

      public void setChildTableReferences(String tableName) throws Open4GLException, Exception
      Use this to build ProDataGraph object with data relations. It creates all the references (or relationship info) for each ProDataRelationMetaData where tableName is parent table. Once done, ProDataObject methods getChildRows() and getParentRow() can be used.
      Parameters:
      tableName - the parent's table name
      Throws:
      Open4GLException
      Exception
    • setChildTableReferences

      public void setChildTableReferences(int parentIx) throws Open4GLException, Exception
      Use this to build ProDataGraph object with data relations. It creates all the references (or relationship info) for each ProDataRelationMetaData where the specified table is parent table. Once this is done, ProDataObject methods getChildRows() and getParentRow() can be used.
      Parameters:
      parentIx - 0-based parent table index
      Throws:
      Open4GLException
      Exception
    • getDataGraph

      public commonj.sdo.DataGraph getDataGraph()
      Returns:
    • getResourceSet

      public org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
      Returns:
    • setResourceSet

      public void setResourceSet(org.eclipse.emf.ecore.resource.ResourceSet newResourceSet)
      Parameters:
      newResourceSet -
    • getDataGraphResource

      public org.eclipse.emf.ecore.resource.Resource getDataGraphResource()
      Returns:
    • getTarget

      public org.eclipse.emf.common.notify.Notifier getTarget()
      Specified by:
      getTarget in interface org.eclipse.emf.common.notify.Adapter
    • isAdapterForType

      public boolean isAdapterForType(Object type)
      Specified by:
      isAdapterForType in interface org.eclipse.emf.common.notify.Adapter
    • notifyChanged

      public void notifyChanged(org.eclipse.emf.common.notify.Notification message)
      Specified by:
      notifyChanged in interface org.eclipse.emf.common.notify.Adapter
    • setTarget

      public void setTarget(org.eclipse.emf.common.notify.Notifier target)
      Specified by:
      setTarget in interface org.eclipse.emf.common.notify.Adapter
    • createRootObject

      public commonj.sdo.DataObject createRootObject(commonj.sdo.Type type)
      Specified by:
      createRootObject in interface commonj.sdo.DataGraph
    • createRootObject

      public commonj.sdo.DataObject createRootObject(String namespaceURI, String typeName)
      Specified by:
      createRootObject in interface commonj.sdo.DataGraph
    • getChangeSummary

      public commonj.sdo.ChangeSummary getChangeSummary()
      Specified by:
      getChangeSummary in interface commonj.sdo.DataGraph
    • getType

      public commonj.sdo.Type getType(String namespaceURI, String typeName)
      Specified by:
      getType in interface commonj.sdo.DataGraph
    • getRootObject

      public commonj.sdo.DataObject getRootObject()
      Specified by:
      getRootObject in interface commonj.sdo.DataGraph
    • writeXML

      public void writeXML(String fileName) throws ProDataException, IOException
      Serialize a ProDataGraph in XML
      Parameters:
      fileName -
      Throws:
      IOException - Writes the ProDataGraph's data into a temp file. Then creates the file specified by fileName and merges into it the contents of the temp file along with the schema
      ProDataException
    • writeXML

      public void writeXML(StringBuilder builder) throws ProDataException, IOException
      Serialize a ProDataGraph into XML and sends output to StringBuilder.
      Throws:
      ProDataException
      IOException
    • readXMLUnsafe

      public void readXMLUnsafe(String fileName) throws FileNotFoundException, ProDataException, IOException
      readXMLUnsafe() copies data from file into a temp file. This is so that we can comment out the schema element after we read it. We do this because SDOUtil.loadDataGraph() throws an exception when it encounters the schema element. This perform an unsafe read of the XML document potentially exposing the user to exploits. This allows external DTD and external schema. Don't use this, this is here as a backdoor in case you absolutely are relying on external schema elements.
      Throws:
      FileNotFoundException
      ProDataException
      IOException
    • readXML

      public void readXML(String fileName) throws FileNotFoundException, ProDataException, IOException
      readXML() copies data from file into a temp file. This is so that we can comment out the schema element after we read it. We do this because SDOUtil.loadDataGraph() throws an exception when it encounters the schema element.
      Throws:
      FileNotFoundException
      ProDataException
      IOException
    • readExternal

      public void readExternal(ObjectInput in) throws IOException
      Deserialize a ProDataGraph
      Specified by:
      readExternal in interface Externalizable
      Parameters:
      in -
      Throws:
      IOException
    • readFromStream

      public void readFromStream(InputStream stream) throws IOException
      Populate a datagraph from a stream This method is used by BPM
      Parameters:
      stream -
      Throws:
      IOException
    • writeExternal

      public void writeExternal(ObjectOutput out) throws IOException
      Serialize a ProDataGraph
      Specified by:
      writeExternal in interface Externalizable
      Parameters:
      out -
      Throws:
      IOException
    • writeToStream

      public void writeToStream(OutputStream stream) throws IOException
      Write a representation of the dataset to a stream This method is used by BPM
      Parameters:
      stream -
      Throws:
      IOException